[Intel-wired-lan] [PATCH v2] netdevice: use ifmap instead of plain fields
Vincenzo Palazzo
vincenzopalazzodev at gmail.com
Fri Mar 3 18:09:26 UTC 2023
clean the code by using the ifmap instead of plain fields,
and avoid code duplication.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev at gmail.com>
---
drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++--
include/linux/netdevice.h | 8 +-------
net/core/dev_ioctl.c | 12 ++++++------
net/core/rtnetlink.c | 6 +++---
4 files changed, 12 insertions(+), 18 deletions(-)
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/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
More information about the Intel-wired-lan
mailing list