netdevice: use ifmap instead of plain fields
Subsystems (6)
PATCH v4 1/1 netdevice: use ifmap instead of plain fields
clean the code by using the ifmap instead of plain fields, and avoid code duplication.
v4 with some build error that the 0 day bot found while compiling some drivers that I was not able to build on my machine.
--- drivers/net/arcnet/com20020_cs.c | 7 ++++--- drivers/net/ethernet/davicom/dm9000.c | 2 +- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- drivers/net/wan/pc300too.c | 4 ++-- drivers/net/wan/pci200syn.c | 4 ++-- include/linux/netdevice.h | 8 +------- net/core/dev_ioctl.c | 12 ++++++------ net/core/rtnetlink.c | 6 +++--- 8 files changed, 21 insertions(+), 26 deletions(-)
drivers/net/arcnet/com20020_cs.c +4 -3
@@ -229,7 +229,8 @@ static int com20020_config(struct pcmcia_device *link) goto failed; } - ioaddr = dev->base_addr = link->resource[0 ]->start; +/* FIXME: multiple assignments should be avoided */ + ioaddr = dev->dev_mapping.base_addr = link->resource[0 ]->start;dev_dbg (&link->dev,"got ioaddr %Xh\n" , ioaddr); dev_dbg(&link->dev, "request IRQ %d\n",
@@ -265,7 +266,7 @@ static int com20020_config(struct pcmcia_device *link) }netdev_dbg (dev,"port %#3lx, irq %d\n" , - dev->base_addr, dev->irq); + dev->dev_mapping.base_addr, dev->irq);return 0 ; failed:
@@ -297,7 +298,7 @@ static int com20020_resume(struct pcmcia_device *link)struct net_device *dev = info->dev;if (link->open) { -int ioaddr = dev->base_addr; +int ioaddr = dev->dev_mapping.base_addr;struct arcnet_local *lp =netdev_priv (dev);arcnet_outb (lp->config |0x80 , ioaddr,COM20020_REG_W_CONFIG );
drivers/net/ethernet/davicom/dm9000.c +1 -1
@@ -1569,7 +1569,7 @@ dm9000_probe(struct platform_device *pdev) }/* fill in parameters for net-dev structure */ - ndev->base_addr = (unsigned long )db->io_addr; + ndev->dev_mapping.base_addr = (unsigned long )db->io_addr;/* ensure at least we have a default set of IO routines */ dm9000_set_io (db, iosize);
drivers/net/ethernet/intel/e1000e/netdev.c +2 -2
@@ -7476,8 +7476,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)netif_napi_add (netdev, &adapter->napi, e1000e_poll);strscpy (netdev->name,pci_name (pdev),sizeof (netdev->name)); - netdev->mem_start = mmio_start; - netdev->mem_end = mmio_start + mmio_len; + netdev->dev_mapping.mem_start = mmio_start; + netdev->dev_mapping.mem_end = mmio_start + mmio_len; adapter->bd_number = cards_found++;
drivers/net/wan/pc300too.c +2 -2
@@ -434,8 +434,8 @@ static int pc300_pci_init_one(struct pci_dev *pdev,spin_lock_init (&port->lock); dev->irq = card->irq; - dev->mem_start = ramphys; - dev->mem_end = ramphys + ramsize -1 ; + dev->dev_mapping.mem_start = ramphys; + dev->dev_mapping.mem_end = ramphys + ramsize -1 ; dev->tx_queue_len =50 ; dev->netdev_ops = &pc300_ops; hdlc->attach = sca_attach;
drivers/net/wan/pci200syn.c +2 -2
@@ -373,8 +373,8 @@ static int pci200_pci_init_one(struct pci_dev *pdev,spin_lock_init (&port->lock); dev->irq = card->irq; - dev->mem_start = ramphys; - dev->mem_end = ramphys + ramsize -1 ; + dev->dev_mapping.mem_start = ramphys; + dev->dev_mapping.mem_end = ramphys + ramsize -1 ; dev->tx_queue_len =50 ; dev->netdev_ops = &pci200_ops; hdlc->attach = sca_attach;
include/linux/netdevice.h +1 -7
@@ -2031,13 +2031,7 @@ struct net_device {char name[IFNAMSIZ ];struct netdev_name_node *name_node;struct dev_ifalias __rcu *ifalias; -/* -* I/O specific fields -* FIXME: Merge these and struct ifmap into one -*/ -unsigned long mem_end; -unsigned long mem_start; -unsigned long base_addr; +struct ifmap dev_mapping;/* * Some hardware also needs these fields (state,dev_list,
net/core/dev_ioctl.c +6 -6
@@ -88,9 +88,9 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)if (in_compat_syscall ()) {struct compat_ifmap *cifmap = (struct compat_ifmap *)ifmap; - cifmap->mem_start = dev->mem_start; - cifmap->mem_end = dev->mem_end; - cifmap->base_addr = dev->base_addr; + cifmap->mem_start = dev->dev_mapping.mem_start; + cifmap->mem_end = dev->dev_mapping.mem_end; + cifmap->base_addr = dev->dev_mapping.base_addr; cifmap->irq = dev->irq; cifmap->dma = dev->dma; cifmap->port = dev->if_port;
@@ -98,9 +98,9 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)return 0 ; } - ifmap->mem_start = dev->mem_start; - ifmap->mem_end = dev->mem_end; - ifmap->base_addr = dev->base_addr; + ifmap->mem_start = dev->dev_mapping.mem_start; + ifmap->mem_end = dev->dev_mapping.mem_end; + ifmap->base_addr = dev->dev_mapping.base_addr; ifmap->irq = dev->irq; ifmap->dma = dev->dma; ifmap->port = dev->if_port;
net/core/rtnetlink.c +3 -3
@@ -1445,9 +1445,9 @@ static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)struct rtnl_link_ifmap map;memset (&map,0 ,sizeof (map)); - map.mem_start = dev->mem_start; - map.mem_end = dev->mem_end; - map.base_addr = dev->base_addr; + map.mem_start = dev->dev_mapping.mem_start; + map.mem_end = dev->dev_mapping.mem_end; + map.base_addr = dev->dev_mapping.base_addr; map.irq = dev->irq; map.dma = dev->dma; map.port = dev->if_port;
Signature · 1 line
2.39.2
Quoted 11 lines · On Sat, 4 Mar 2023 13:24:33 +0100 Vincenzo Palazzo…
clean the code by using the ifmap instead of plain fields, and avoid code duplication.
v4 with some build error that the 0 day bot found while compiling some drivers that I was not able to build on my machine.
Reported-by kernel test robot <[email protected]>Signed-off-by Vincenzo Palazzo <[email protected]>---
Patching cadaver drivers is not worth it.
Quoted 10 lines · Stephen Hemminger
Quoted 7 lines · On Sat, 4 Mar 2023 13:24:33 +0100 Vincenzo Palazzo…
clean the code by using the ifmap instead of plain fields, and avoid code duplication.
v4 with some build error that the 0 day bot found while compiling some drivers that I was not able to build on my machine.
Quoted 6 lines
Quoted 4 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Vincenzo Palazzo <[email protected]>---
Patching cadaver drivers is not worth it.
Mh, what is mean? they are drivers that are not longer mantained and/or used?
Cheers!
Vincent.