PCI: Use pci_dev_id() to simplify the code
Subsystems (4)
cover PCI: 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 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(-)
Signature · 1 line
2.20.1
PATCH 1/3 PCI: apple: 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 mannually using PCI_DEVID(). Use pci_dev_id() to simplify the code a little bit.
--- drivers/pci/controller/pcie-apple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-apple.c +2 -2
@@ -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);
Signature · 1 line
2.20.1
PATCH 2/3 PCI/AER: Use pci_dev_id() to simplify the code
In reply to Xiongfeng WangPCI 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.
--- drivers/pci/pcie/aer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pcie/aer.c +2 -2
@@ -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 */
Signature · 1 line
2.20.1
PATCH 3/3 PCI/IOV: Use pci_dev_id() to simplify the code
In reply to Xiongfeng WangPCI 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.
--- drivers/pci/iov.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/iov.c +1 -2
@@ -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);
Signature · 1 line
2.20.1
Bjorn Helgaas
AppliedQuoted 9 lines · Xiongfeng Wang
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. Usepci_dev_id()to simplify the code and make the code more readable.Xiongfeng Wang (3):
PCI: apple: usepci_dev_id()to simplify the code PCI/AER: Usepci_dev_id()to simplify the code PCI/IOV: Usepci_dev_id()to simplify the code
Quoted 4 lines
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
Quoted 15 lines · Bjorn Helgaas
Quoted 9 lines · Xiongfeng Wang
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. Usepci_dev_id()to simplify the code and make the code more readable.Xiongfeng Wang (3):
PCI: apple: usepci_dev_id()to simplify the code PCI/AER: Usepci_dev_id()to simplify the code PCI/IOV: Usepci_dev_id()to simplify the codeQuoted 4 lines
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(-)
Quoted 4 lines
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
Quoted 4 lines
Bjorn
.