[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230304115626.215026-1-vincenzopalazzodev@gmail.com>
Date: Sat, 4 Mar 2023 12:56:26 +0100
From: Vincenzo Palazzo <vincenzopalazzodev@...il.com>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, intel-wired-lan@...ts.osuosl.org,
jesse.brandeburg@...el.com, khc@...waw.pl,
Vincenzo Palazzo <vincenzopalazzodev@...il.com>,
kernel test robot <lkp@...el.com>
Subject: [PATCH v3] netdevice: use ifmap instead of plain fields
clean the code by using the ifmap instead of plain fields,
and avoid code duplication.
Reported-by: kernel test robot <lkp@...el.com>
Link: https://lore.kernel.org/oe-kbuild-all/202303041847.nRrrz1v9-lkp@intel.com/
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@...il.com>
---
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(-)
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index dc3253b318da..5e5e065acfb9 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -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);
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index b21e56de6167..5f87903fc516 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -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);
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index e1eb1de88bf9..059ff8bcdbbc 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -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++;
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c
index 4766446f0fa0..2fd9ce9825e0 100644
--- a/drivers/net/wan/pc300too.c
+++ b/drivers/net/wan/pc300too.c
@@ -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;
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index ea86c7035653..6cd2c40ef281 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -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;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6a14b7b11766..c5987e90a078 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -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,
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 5cdbfbf9a7dc..89469cb97e35 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -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;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 5d8eb57867a9..ff8fc1bbda31 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -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;
--
2.39.2
Powered by blists - more mailing lists