mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 14:21:47 +00:00
net: remove single-byte netdev->dev_addr writes
Make the drivers which use single-byte netdev addresses (netdev->addr_len == 1) use the appropriate address setting helpers. arcnet copies from int variables and io reads a lot, so add a helper for arcnet drivers to use. Similar helper could be reused for phonet and appletalk but there isn't any good central location where we could put it, and netdevice.h is already very crowded. Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for HSI Link: https://lore.kernel.org/r/20211012142757.4124842-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
400f17d330
commit
13b5ffa0e2
@ -1055,14 +1055,16 @@ static const struct net_device_ops ssip_pn_ops = {
|
||||
|
||||
static void ssip_pn_setup(struct net_device *dev)
|
||||
{
|
||||
static const u8 addr = PN_MEDIA_SOS;
|
||||
|
||||
dev->features = 0;
|
||||
dev->netdev_ops = &ssip_pn_ops;
|
||||
dev->type = ARPHRD_PHONET;
|
||||
dev->flags = IFF_POINTOPOINT | IFF_NOARP;
|
||||
dev->mtu = SSIP_DEFAULT_MTU;
|
||||
dev->hard_header_len = 1;
|
||||
dev->dev_addr[0] = PN_MEDIA_SOS;
|
||||
dev->addr_len = 1;
|
||||
dev_addr_set(dev, &addr);
|
||||
dev->tx_queue_len = SSIP_TXQUEUE_LEN;
|
||||
|
||||
dev->needs_free_netdev = true;
|
||||
|
@ -945,8 +945,8 @@ static int cops_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||
dev->broadcast[0] = 0xFF;
|
||||
|
||||
/* Set hardware address. */
|
||||
dev->dev_addr[0] = aa->s_node;
|
||||
dev->addr_len = 1;
|
||||
dev_addr_set(dev, &aa->s_node);
|
||||
return 0;
|
||||
|
||||
case SIOCGIFADDR:
|
||||
|
@ -846,9 +846,8 @@ static int ltpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||
set_30 (dev,ltflags);
|
||||
|
||||
dev->broadcast[0] = 0xFF;
|
||||
dev->dev_addr[0] = aa->s_node;
|
||||
|
||||
dev->addr_len=1;
|
||||
dev_addr_set(dev, &aa->s_node);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -207,7 +207,8 @@ static int __init arcrimi_found(struct net_device *dev)
|
||||
}
|
||||
|
||||
/* get and check the station ID from offset 1 in shmem */
|
||||
dev->dev_addr[0] = arcnet_readb(lp->mem_start, COM9026_REG_R_STATION);
|
||||
arcnet_set_addr(dev, arcnet_readb(lp->mem_start,
|
||||
COM9026_REG_R_STATION));
|
||||
|
||||
arc_printk(D_NORMAL, dev, "ARCnet RIM I: station %02Xh found at IRQ %d, ShMem %lXh (%ld*%d bytes)\n",
|
||||
dev->dev_addr[0],
|
||||
@ -324,7 +325,7 @@ static int __init arc_rimi_init(void)
|
||||
return -ENOMEM;
|
||||
|
||||
if (node && node != 0xff)
|
||||
dev->dev_addr[0] = node;
|
||||
arcnet_set_addr(dev, node);
|
||||
|
||||
dev->mem_start = io;
|
||||
dev->irq = irq;
|
||||
|
@ -364,6 +364,11 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
|
||||
struct net_device *dev);
|
||||
void arcnet_timeout(struct net_device *dev, unsigned int txqueue);
|
||||
|
||||
static inline void arcnet_set_addr(struct net_device *dev, u8 addr)
|
||||
{
|
||||
dev_addr_set(dev, &addr);
|
||||
}
|
||||
|
||||
/* I/O equivalents */
|
||||
|
||||
#ifdef CONFIG_SA1100_CT6001
|
||||
|
@ -151,7 +151,7 @@ static int __init com20020_init(void)
|
||||
return -ENOMEM;
|
||||
|
||||
if (node && node != 0xff)
|
||||
dev->dev_addr[0] = node;
|
||||
arcnet_set_addr(dev, node);
|
||||
|
||||
dev->netdev_ops = &com20020_netdev_ops;
|
||||
|
||||
|
@ -194,7 +194,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
|
||||
|
||||
SET_NETDEV_DEV(dev, &pdev->dev);
|
||||
dev->base_addr = ioaddr;
|
||||
dev->dev_addr[0] = node;
|
||||
arcnet_set_addr(dev, node);
|
||||
dev->sysfs_groups[0] = &com20020_state_group;
|
||||
dev->irq = pdev->irq;
|
||||
lp->card_name = "PCI COM20020";
|
||||
|
@ -157,7 +157,7 @@ static int com20020_set_hwaddr(struct net_device *dev, void *addr)
|
||||
struct arcnet_local *lp = netdev_priv(dev);
|
||||
struct sockaddr *hwaddr = addr;
|
||||
|
||||
memcpy(dev->dev_addr, hwaddr->sa_data, 1);
|
||||
dev_addr_set(dev, hwaddr->sa_data);
|
||||
com20020_set_subaddress(lp, ioaddr, SUB_NODE);
|
||||
arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
|
||||
|
||||
@ -220,7 +220,7 @@ int com20020_found(struct net_device *dev, int shared)
|
||||
|
||||
/* FIXME: do this some other way! */
|
||||
if (!dev->dev_addr[0])
|
||||
dev->dev_addr[0] = arcnet_inb(ioaddr, 8);
|
||||
arcnet_set_addr(dev, arcnet_inb(ioaddr, 8));
|
||||
|
||||
com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
|
||||
arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
|
||||
|
@ -133,7 +133,7 @@ static int com20020_probe(struct pcmcia_device *p_dev)
|
||||
lp->hw.owner = THIS_MODULE;
|
||||
|
||||
/* fill in our module parameters as defaults */
|
||||
dev->dev_addr[0] = node;
|
||||
arcnet_set_addr(dev, node);
|
||||
|
||||
p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
|
||||
p_dev->resource[0]->end = 16;
|
||||
|
@ -252,7 +252,7 @@ static int __init com90io_found(struct net_device *dev)
|
||||
|
||||
/* get and check the station ID from offset 1 in shmem */
|
||||
|
||||
dev->dev_addr[0] = get_buffer_byte(dev, 1);
|
||||
arcnet_set_addr(dev, get_buffer_byte(dev, 1));
|
||||
|
||||
err = register_netdev(dev);
|
||||
if (err) {
|
||||
|
@ -531,7 +531,8 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem,
|
||||
}
|
||||
|
||||
/* get and check the station ID from offset 1 in shmem */
|
||||
dev->dev_addr[0] = arcnet_readb(lp->mem_start, COM9026_REG_R_STATION);
|
||||
arcnet_set_addr(dev, arcnet_readb(lp->mem_start,
|
||||
COM9026_REG_R_STATION));
|
||||
|
||||
dev->base_addr = ioaddr;
|
||||
|
||||
|
@ -275,6 +275,8 @@ static const struct net_device_ops usbpn_ops = {
|
||||
|
||||
static void usbpn_setup(struct net_device *dev)
|
||||
{
|
||||
const u8 addr = PN_MEDIA_USB;
|
||||
|
||||
dev->features = 0;
|
||||
dev->netdev_ops = &usbpn_ops;
|
||||
dev->header_ops = &phonet_header_ops;
|
||||
@ -284,8 +286,8 @@ static void usbpn_setup(struct net_device *dev)
|
||||
dev->min_mtu = PHONET_MIN_MTU;
|
||||
dev->max_mtu = PHONET_MAX_MTU;
|
||||
dev->hard_header_len = 1;
|
||||
dev->dev_addr[0] = PN_MEDIA_USB;
|
||||
dev->addr_len = 1;
|
||||
dev_addr_set(dev, &addr);
|
||||
dev->tx_queue_len = 3;
|
||||
|
||||
dev->needs_free_netdev = true;
|
||||
|
@ -267,6 +267,8 @@ static const struct net_device_ops pn_netdev_ops = {
|
||||
|
||||
static void pn_net_setup(struct net_device *dev)
|
||||
{
|
||||
const u8 addr = PN_MEDIA_USB;
|
||||
|
||||
dev->features = 0;
|
||||
dev->type = ARPHRD_PHONET;
|
||||
dev->flags = IFF_POINTOPOINT | IFF_NOARP;
|
||||
@ -274,8 +276,9 @@ static void pn_net_setup(struct net_device *dev)
|
||||
dev->min_mtu = PHONET_MIN_MTU;
|
||||
dev->max_mtu = PHONET_MAX_MTU;
|
||||
dev->hard_header_len = 1;
|
||||
dev->dev_addr[0] = PN_MEDIA_USB;
|
||||
dev->addr_len = 1;
|
||||
dev_addr_set(dev, &addr);
|
||||
|
||||
dev->tx_queue_len = 1;
|
||||
|
||||
dev->netdev_ops = &pn_netdev_ops;
|
||||
|
Loading…
Reference in New Issue
Block a user