netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: txgbe: Use pci_dev_id() to simplify the code
@ 2023-08-08  2:49 Xiongfeng Wang
  2023-08-08  8:35 ` Yang Yingliang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xiongfeng Wang @ 2023-08-08  2:49 UTC (permalink / raw)
  To: jiawenwu, mengyuanlou, davem, edumazet, kuba, pabeni,
	maciej.fijalkowski, andrew, piotr.raczynski, wangxiongfeng2
  Cc: netdev, yangyingliang

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 mannually. Use pci_dev_id() to
simplify the code a little bit.

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
index 8779645a54be..819d1db34643 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
@@ -26,7 +26,7 @@ static int txgbe_swnodes_register(struct txgbe *txgbe)
 	struct software_node *swnodes;
 	u32 id;
 
-	id = (pdev->bus->number << 8) | pdev->devfn;
+	id = pci_dev_id(pdev);
 
 	snprintf(nodes->gpio_name, sizeof(nodes->gpio_name), "txgbe_gpio-%x", id);
 	snprintf(nodes->i2c_name, sizeof(nodes->i2c_name), "txgbe_i2c-%x", id);
@@ -140,7 +140,7 @@ static int txgbe_mdio_pcs_init(struct txgbe *txgbe)
 	mii_bus->phy_mask = ~0;
 	mii_bus->priv = wx;
 	snprintf(mii_bus->id, MII_BUS_ID_SIZE, "txgbe_pcs-%x",
-		 (pdev->bus->number << 8) | pdev->devfn);
+		 pci_dev_id(pdev));
 
 	ret = devm_mdiobus_register(&pdev->dev, mii_bus);
 	if (ret)
@@ -459,7 +459,7 @@ static int txgbe_gpio_init(struct txgbe *txgbe)
 		return -ENOMEM;
 
 	gc->label = devm_kasprintf(dev, GFP_KERNEL, "txgbe_gpio-%x",
-				   (wx->pdev->bus->number << 8) | wx->pdev->devfn);
+				   pci_dev_id(wx->pdev));
 	if (!gc->label)
 		return -ENOMEM;
 
@@ -503,7 +503,7 @@ static int txgbe_clock_register(struct txgbe *txgbe)
 	struct clk *clk;
 
 	snprintf(clk_name, sizeof(clk_name), "i2c_designware.%d",
-		 (pdev->bus->number << 8) | pdev->devfn);
+		 pci_dev_id(pdev));
 
 	clk = clk_register_fixed_rate(NULL, clk_name, NULL, 0, 156250000);
 	if (IS_ERR(clk))
@@ -566,7 +566,7 @@ static int txgbe_i2c_register(struct txgbe *txgbe)
 	info.parent = &pdev->dev;
 	info.fwnode = software_node_fwnode(txgbe->nodes.group[SWNODE_I2C]);
 	info.name = "i2c_designware";
-	info.id = (pdev->bus->number << 8) | pdev->devfn;
+	info.id = pci_dev_id(pdev);
 
 	info.res = &DEFINE_RES_IRQ(pdev->irq);
 	info.num_res = 1;
@@ -588,7 +588,7 @@ static int txgbe_sfp_register(struct txgbe *txgbe)
 	info.parent = &pdev->dev;
 	info.fwnode = software_node_fwnode(txgbe->nodes.group[SWNODE_SFP]);
 	info.name = "sfp";
-	info.id = (pdev->bus->number << 8) | pdev->devfn;
+	info.id = pci_dev_id(pdev);
 	sfp_dev = platform_device_register_full(&info);
 	if (IS_ERR(sfp_dev))
 		return PTR_ERR(sfp_dev);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: txgbe: Use pci_dev_id() to simplify the code
  2023-08-08  2:49 [PATCH] net: txgbe: Use pci_dev_id() to simplify the code Xiongfeng Wang
@ 2023-08-08  8:35 ` Yang Yingliang
  2023-08-09 12:38 ` Simon Horman
  2023-08-09 20:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2023-08-08  8:35 UTC (permalink / raw)
  To: Xiongfeng Wang, jiawenwu, mengyuanlou, davem, edumazet, kuba,
	pabeni, maciej.fijalkowski, andrew, piotr.raczynski
  Cc: netdev


On 2023/8/8 10:49, Xiongfeng Wang wrote:
> 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 mannually. Use pci_dev_id() to
> simplify the code a little bit.
>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: txgbe: Use pci_dev_id() to simplify the code
  2023-08-08  2:49 [PATCH] net: txgbe: Use pci_dev_id() to simplify the code Xiongfeng Wang
  2023-08-08  8:35 ` Yang Yingliang
@ 2023-08-09 12:38 ` Simon Horman
  2023-08-09 20:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-08-09 12:38 UTC (permalink / raw)
  To: Xiongfeng Wang
  Cc: jiawenwu, mengyuanlou, davem, edumazet, kuba, pabeni,
	maciej.fijalkowski, andrew, piotr.raczynski, netdev,
	yangyingliang

On Tue, Aug 08, 2023 at 10:49:31AM +0800, Xiongfeng Wang wrote:
> 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 mannually. Use pci_dev_id() to

nit: mannually -> manually

checkpatch.pl --codespell is your friend here.


> simplify the code a little bit.
> 
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>

Otherwise this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: txgbe: Use pci_dev_id() to simplify the code
  2023-08-08  2:49 [PATCH] net: txgbe: Use pci_dev_id() to simplify the code Xiongfeng Wang
  2023-08-08  8:35 ` Yang Yingliang
  2023-08-09 12:38 ` Simon Horman
@ 2023-08-09 20:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-09 20:10 UTC (permalink / raw)
  To: Xiongfeng Wang
  Cc: jiawenwu, mengyuanlou, davem, edumazet, kuba, pabeni,
	maciej.fijalkowski, andrew, piotr.raczynski, netdev,
	yangyingliang

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 8 Aug 2023 10:49:31 +0800 you wrote:
> 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 mannually. Use pci_dev_id() to
> simplify the code a little bit.
> 
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
> ---
>  drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Here is the summary with links:
  - net: txgbe: Use pci_dev_id() to simplify the code
    https://git.kernel.org/netdev/net-next/c/d8c21ef7b2b1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-09 20:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08  2:49 [PATCH] net: txgbe: Use pci_dev_id() to simplify the code Xiongfeng Wang
2023-08-08  8:35 ` Yang Yingliang
2023-08-09 12:38 ` Simon Horman
2023-08-09 20:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).