All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code
@ 2023-08-07 13:48 Xiongfeng Wang
  2023-08-07 13:48 ` [PATCH 1/3] PCI: apple: use " Xiongfeng Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Xiongfeng Wang @ 2023-08-07 13:48 UTC (permalink / raw)
  To: alyssa, maz, lpieralisi, kw, robh, bhelgaas, mahesh, oohall
  Cc: lukas, linux-pci, yangyingliang, wangxiongfeng2

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 and make the code more readable.

Xiongfeng Wang (3):
  PCI: apple: use pci_dev_id() to simplify the code
  PCI/AER: Use pci_dev_id() to simplify the code
  PCI/IOV: Use pci_dev_id() to simplify the code

 drivers/pci/controller/pcie-apple.c | 4 ++--
 drivers/pci/iov.c                   | 3 +--
 drivers/pci/pcie/aer.c              | 4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.20.1


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

* [PATCH 1/3] PCI: apple: use pci_dev_id() to simplify the code
  2023-08-07 13:48 [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code Xiongfeng Wang
@ 2023-08-07 13:48 ` Xiongfeng Wang
  2023-08-07 13:48 ` [PATCH 2/3] PCI/AER: Use " Xiongfeng Wang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Xiongfeng Wang @ 2023-08-07 13:48 UTC (permalink / raw)
  To: alyssa, maz, lpieralisi, kw, robh, bhelgaas, mahesh, oohall
  Cc: lukas, linux-pci, yangyingliang, wangxiongfeng2

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

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/pci/controller/pcie-apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 66f37e403a09..2abca318e22a 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -670,7 +670,7 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
 static int apple_pcie_add_device(struct apple_pcie_port *port,
 				 struct pci_dev *pdev)
 {
-	u32 sid, rid = PCI_DEVID(pdev->bus->number, pdev->devfn);
+	u32 sid, rid = pci_dev_id(pdev);
 	int idx, err;
 
 	dev_dbg(&pdev->dev, "added to bus %s, index %d\n",
@@ -701,7 +701,7 @@ static int apple_pcie_add_device(struct apple_pcie_port *port,
 static void apple_pcie_release_device(struct apple_pcie_port *port,
 				      struct pci_dev *pdev)
 {
-	u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn);
+	u32 rid = pci_dev_id(pdev);
 	int idx;
 
 	mutex_lock(&port->pcie->lock);
-- 
2.20.1


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

* [PATCH 2/3] PCI/AER: Use pci_dev_id() to simplify the code
  2023-08-07 13:48 [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code Xiongfeng Wang
  2023-08-07 13:48 ` [PATCH 1/3] PCI: apple: use " Xiongfeng Wang
@ 2023-08-07 13:48 ` Xiongfeng Wang
  2023-08-07 13:48 ` [PATCH 3/3] PCI/IOV: " Xiongfeng Wang
  2023-08-07 21:16 ` [PATCH 0/3] PCI: " Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Xiongfeng Wang @ 2023-08-07 13:48 UTC (permalink / raw)
  To: alyssa, maz, lpieralisi, kw, robh, bhelgaas, mahesh, oohall
  Cc: lukas, linux-pci, yangyingliang, wangxiongfeng2

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/pci/pcie/aer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index f6c24ded134c..2bc03937452b 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -712,7 +712,7 @@ static void __aer_print_error(struct pci_dev *dev,
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 {
 	int layer, agent;
-	int id = ((dev->bus->number << 8) | dev->devfn);
+	int id = pci_dev_id(dev);
 	const char *level;
 
 	if (!info->status) {
@@ -847,7 +847,7 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
 	if ((PCI_BUS_NUM(e_info->id) != 0) &&
 	    !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
 		/* Device ID match? */
-		if (e_info->id == ((dev->bus->number << 8) | dev->devfn))
+		if (e_info->id == pci_dev_id(dev))
 			return true;
 
 		/* Continue id comparing if there is no multiple error */
-- 
2.20.1


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

* [PATCH 3/3] PCI/IOV: Use pci_dev_id() to simplify the code
  2023-08-07 13:48 [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code Xiongfeng Wang
  2023-08-07 13:48 ` [PATCH 1/3] PCI: apple: use " Xiongfeng Wang
  2023-08-07 13:48 ` [PATCH 2/3] PCI/AER: Use " Xiongfeng Wang
@ 2023-08-07 13:48 ` Xiongfeng Wang
  2023-08-07 21:16 ` [PATCH 0/3] PCI: " Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Xiongfeng Wang @ 2023-08-07 13:48 UTC (permalink / raw)
  To: alyssa, maz, lpieralisi, kw, robh, bhelgaas, mahesh, oohall
  Cc: lukas, linux-pci, yangyingliang, wangxiongfeng2

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/pci/iov.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index b2e8322755c1..25dbe85c4217 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -41,8 +41,7 @@ int pci_iov_vf_id(struct pci_dev *dev)
 		return -EINVAL;
 
 	pf = pci_physfn(dev);
-	return (((dev->bus->number << 8) + dev->devfn) -
-		((pf->bus->number << 8) + pf->devfn + pf->sriov->offset)) /
+	return (pci_dev_id(dev) - (pci_dev_id(pf) + pf->sriov->offset)) /
 	       pf->sriov->stride;
 }
 EXPORT_SYMBOL_GPL(pci_iov_vf_id);
-- 
2.20.1


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

* Re: [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code
  2023-08-07 13:48 [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code Xiongfeng Wang
                   ` (2 preceding siblings ...)
  2023-08-07 13:48 ` [PATCH 3/3] PCI/IOV: " Xiongfeng Wang
@ 2023-08-07 21:16 ` Bjorn Helgaas
  2023-08-08  1:12   ` Xiongfeng Wang
  3 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2023-08-07 21:16 UTC (permalink / raw)
  To: Xiongfeng Wang
  Cc: alyssa, maz, lpieralisi, kw, robh, bhelgaas, mahesh, oohall,
	lukas, linux-pci, yangyingliang

On Mon, Aug 07, 2023 at 09:48:55PM +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
> simplify the code and make the code more readable.
> 
> Xiongfeng Wang (3):
>   PCI: apple: use pci_dev_id() to simplify the code
>   PCI/AER: Use pci_dev_id() to simplify the code
>   PCI/IOV: Use pci_dev_id() to simplify the code
> 
>  drivers/pci/controller/pcie-apple.c | 4 ++--
>  drivers/pci/iov.c                   | 3 +--
>  drivers/pci/pcie/aer.c              | 4 ++--
>  3 files changed, 5 insertions(+), 6 deletions(-)

Applied to pci/misc for v6.6, thanks!

There are several similar cases outside drivers/pci/ that it would be
nice to clean up as well.

Bjorn

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

* Re: [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code
  2023-08-07 21:16 ` [PATCH 0/3] PCI: " Bjorn Helgaas
@ 2023-08-08  1:12   ` Xiongfeng Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Xiongfeng Wang @ 2023-08-08  1:12 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: alyssa, maz, lpieralisi, kw, robh, bhelgaas, mahesh, oohall,
	lukas, linux-pci, yangyingliang



On 2023/8/8 5:16, Bjorn Helgaas wrote:
> On Mon, Aug 07, 2023 at 09:48:55PM +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
>> simplify the code and make the code more readable.
>>
>> Xiongfeng Wang (3):
>>   PCI: apple: use pci_dev_id() to simplify the code
>>   PCI/AER: Use pci_dev_id() to simplify the code
>>   PCI/IOV: Use pci_dev_id() to simplify the code
>>
>>  drivers/pci/controller/pcie-apple.c | 4 ++--
>>  drivers/pci/iov.c                   | 3 +--
>>  drivers/pci/pcie/aer.c              | 4 ++--
>>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> Applied to pci/misc for v6.6, thanks!
> 
> There are several similar cases outside drivers/pci/ that it would be
> nice to clean up as well.

Sure, I will do that. Thanks !

Thanks,
Xiongfeng

> 
> Bjorn
> .
> 

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

end of thread, other threads:[~2023-08-08  1:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 13:48 [PATCH 0/3] PCI: Use pci_dev_id() to simplify the code Xiongfeng Wang
2023-08-07 13:48 ` [PATCH 1/3] PCI: apple: use " Xiongfeng Wang
2023-08-07 13:48 ` [PATCH 2/3] PCI/AER: Use " Xiongfeng Wang
2023-08-07 13:48 ` [PATCH 3/3] PCI/IOV: " Xiongfeng Wang
2023-08-07 21:16 ` [PATCH 0/3] PCI: " Bjorn Helgaas
2023-08-08  1:12   ` Xiongfeng Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.