Skip to contentSkip to conversation

net: Use pci_dev_id() to simplify the code

PATCH Applied Zheng Zengkai 3 participants 8 messages Aug 11, 2023 – Aug 13, 2023

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover net: Use pci_dev_id() to simplify the code

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. Use the API to simplify the code.

Zheng Zengkai (5):
et131x: Use pci_dev_id() to simplify the code
tg3: Use pci_dev_id() to simplify the code
net: smsc: Use pci_dev_id() to simplify the code
net: tc35815: Use pci_dev_id() to simplify the code
net: ngbe: use pci_dev_id() to simplify the code

 drivers/net/ethernet/agere/et131x.c           | 3 +--
 drivers/net/ethernet/broadcom/tg3.c           | 3 +--
 drivers/net/ethernet/smsc/smsc9420.c          | 3 +--
 drivers/net/ethernet/toshiba/tc35815.c        | 3 +--
 drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/5 et131x: Use pci_dev_id() to simplify the code

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. We don't need to compose it manually. Use pci_dev_id() to simplify the code a little bit.

---
 drivers/net/ethernet/agere/et131x.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/agere/et131x.c +1 -2
index 5fab589b3ddf..3d9220f9c9fe 100644
@@ -3982,8 +3982,7 @@ static int et131x_pci_setup(struct pci_dev *pdev,
 	}
 
 	adapter->mii_bus->name = "et131x_eth_mii";
-	snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x",
-		 (adapter->pdev->bus->number << 8) | adapter->pdev->devfn);
+	snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x", pci_dev_id(adapter->pdev));
 	adapter->mii_bus->priv = netdev;
 	adapter->mii_bus->read = et131x_mdio_read;
 	adapter->mii_bus->write = et131x_mdio_write;
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/5 tg3: Use pci_dev_id() to simplify the code

In reply to Zheng Zengkai

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. We don't need to compose it manually. Use pci_dev_id() to simplify the code a little bit.

---
 drivers/net/ethernet/broadcom/tg3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +1 -2
index 5ef073a79ce9..7f956cf36337 100644
@@ -1539,8 +1539,7 @@ static int tg3_mdio_init(struct tg3 *tp)
 		return -ENOMEM;
 
 	tp->mdio_bus->name     = "tg3 mdio bus";
-	snprintf(tp->mdio_bus->id, MII_BUS_ID_SIZE, "%x",
-		 (tp->pdev->bus->number << 8) | tp->pdev->devfn);
+	snprintf(tp->mdio_bus->id, MII_BUS_ID_SIZE, "%x", pci_dev_id(tp->pdev));
 	tp->mdio_bus->priv     = tp;
 	tp->mdio_bus->parent   = &tp->pdev->dev;
 	tp->mdio_bus->read     = &tg3_mdio_read;
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/5 net: smsc: Use pci_dev_id() to simplify the code

In reply to Zheng Zengkai

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. We don't need to compose it manually. Use pci_dev_id() to simplify the code a little bit.

---
 drivers/net/ethernet/smsc/smsc9420.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/smsc/smsc9420.c +1 -2
index 71fbb358bb7d..350becc0c6ec 100644
@@ -1144,8 +1144,7 @@ static int smsc9420_mii_init(struct net_device *dev)
 		goto err_out_1;
 	}
 	pd->mii_bus->name = DRV_MDIONAME;
-	snprintf(pd->mii_bus->id, MII_BUS_ID_SIZE, "%x",
-		(pd->pdev->bus->number << 8) | pd->pdev->devfn);
+	snprintf(pd->mii_bus->id, MII_BUS_ID_SIZE, "%x", pci_dev_id(pd->pdev));
 	pd->mii_bus->priv = pd;
 	pd->mii_bus->read = smsc9420_mii_read;
 	pd->mii_bus->write = smsc9420_mii_write;
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/5 net: tc35815: Use pci_dev_id() to simplify the code

In reply to Zheng Zengkai

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. We don't need to compose it manually. Use pci_dev_id() to simplify the code a little bit.

---
 drivers/net/ethernet/toshiba/tc35815.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/toshiba/tc35815.c +1 -2
index b50be67b398b..14cf6ecf6d0d 100644
@@ -667,8 +667,7 @@ static int tc_mii_init(struct net_device *dev)
 	lp->mii_bus->name = "tc35815_mii_bus";
 	lp->mii_bus->read = tc_mdio_read;
 	lp->mii_bus->write = tc_mdio_write;
-	snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%x",
-		 (lp->pci_dev->bus->number << 8) | lp->pci_dev->devfn);
+	snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%x", pci_dev_id(lp->pci_dev));
 	lp->mii_bus->priv = dev;
 	lp->mii_bus->parent = &lp->pci_dev->dev;
 	err = mdiobus_register(lp->mii_bus);
Signature · 1 line
2.20.1
#5 lore raw

PATCH 5/5 net: ngbe: use pci_dev_id() to simplify the code

In reply to Zheng Zengkai

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. We don't need to compose it manually. Use pci_dev_id() to simplify the code a little bit.

---
 drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c +1 -2
index c9ddbbc3fa4f..f35e5d6e4272 100644
@@ -265,8 +265,7 @@ int ngbe_mdio_init(struct wx *wx)
 		mii_bus->write_c45 = ngbe_phy_write_reg_mdi_c45;
 	}
 
-	snprintf(mii_bus->id, MII_BUS_ID_SIZE, "ngbe-%x",
-		 (pdev->bus->number << 8) | pdev->devfn);
+	snprintf(mii_bus->id, MII_BUS_ID_SIZE, "ngbe-%x", pci_dev_id(pdev));
 	ret = devm_mdiobus_register(&pdev->dev, mii_bus);
 	if (ret)
 		return ret;
Signature · 1 line
2.20.1
#6 lore raw
In reply to Zheng Zengkai
Quoted 10 lines · Zheng Zengkai

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. Use the API to simplify the code.

Zheng Zengkai (5):
et131x: Use pci_dev_id() to simplify the code
tg3: Use pci_dev_id() to simplify the code
net: smsc: Use pci_dev_id() to simplify the code
net: tc35815: Use pci_dev_id() to simplify the code
net: ngbe: use pci_dev_id() to simplify the code

Quoted 7 lines
  drivers/net/ethernet/agere/et131x.c           | 3 +--
  drivers/net/ethernet/broadcom/tg3.c           | 3 +--
  drivers/net/ethernet/smsc/smsc9420.c          | 3 +--
  drivers/net/ethernet/toshiba/tc35815.c        | 3 +--
  drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c | 3 +--
  5 files changed, 5 insertions(+), 10 deletions(-)

code looks fine,
I wonder if it would be better to have just one patch here?

#7 lore raw
In reply to Zheng Zengkai
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 11 lines · On Fri, 11 Aug 2023 19:06:57 +0800 you wrote:

PCI core API pci_dev_id() can be used to get the BDF number for a pci device. Use the API to simplify the code.

Zheng Zengkai (5):
et131x: Use pci_dev_id() to simplify the code
tg3: Use pci_dev_id() to simplify the code
net: smsc: Use pci_dev_id() to simplify the code
net: tc35815: Use pci_dev_id() to simplify the code
net: ngbe: use pci_dev_id() to simplify the code

[...]

Here is the summary with links:
- [net-next,1/5] et131x: Use pci_dev_id() to simplify the code

    https://git.kernel.org/netdev/net-next/c/fcbb797458e1
  - [net-next,2/5] tg3: Use pci_dev_id() to simplify the code
    https://git.kernel.org/netdev/net-next/c/6ecb2ced346f
  - [net-next,3/5] net: smsc: Use pci_dev_id() to simplify the code
    https://git.kernel.org/netdev/net-next/c/adc4d18538ec
  - [net-next,4/5] net: tc35815: Use pci_dev_id() to simplify the code
    https://git.kernel.org/netdev/net-next/c/ca51d1356071
  - [net-next,5/5] net: ngbe: use pci_dev_id() to simplify the code
    https://git.kernel.org/netdev/net-next/c/cf9b107f5fdd

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html