PCI: Use header type defines in pci_setup_device()
PATCH 1/3 PCI: Use header type defines in pci_setup_device()
Replace literals with PCI_HEADER_TYPE_* defines in pci_setup_device().
--- drivers/pci/probe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/probe.c +2 -2
@@ -1985,8 +1985,8 @@ int pci_setup_device(struct pci_dev *dev) dev->sysdata = dev->bus->sysdata; dev->dev.parent = dev->bus->bridge; dev->dev.bus = &pci_bus_type; - dev->hdr_type = hdr_type &0x7f ; - dev->multifunction = !!(hdr_type &0x80 ); + dev->hdr_type =FIELD_GET (PCI_HEADER_TYPE_MASK , hdr_type); + dev->multifunction =FIELD_GET (PCI_HEADER_TYPE_MFD , hdr_type); dev->error_state = pci_channel_io_normal;set_pcie_port_type (dev);
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
Signature · 1 line
2.39.5
PATCH 2/3 PCI: Cleanup early_dump_pci_device()
Convert 256 to PCI_CFG_SPACE_SIZE and 4 to sizeof(u32) and avoid i / 4 construct by changing the iteration.
--- drivers/pci/probe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/pci/probe.c +5 -4
@@ -3,6 +3,7 @@* PCI detection and setup code */ +#include <linux/array_size.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/init.h>
@@ -1912,16 +1913,16 @@ static int pci_intx_mask_broken(struct pci_dev *dev)static void early_dump_pci_device (struct pci_dev *pdev) { -u32 value[256 /4 ]; +u32 value[PCI_CFG_SPACE_SIZE /sizeof (u32)];int i;pci_info (pdev,"config space:\n" ); -for (i =0 ; i <256 ; i +=4 ) -pci_read_config_dword (pdev, i, &value[i /4 ]); +for (i =0 ; i <ARRAY_SIZE (value); i++) +pci_read_config_dword (pdev, i *sizeof (u32), &value[i]);print_hex_dump (KERN_INFO ,"" ,DUMP_PREFIX_OFFSET ,16 ,1 , - value,256 , false); + value,ARRAY_SIZE (value) *sizeof (u32), false); }static const char *pci_type_str (struct pci_dev *dev)
Signature · 1 line
2.39.5
Re: [PATCH 2/3] PCI: Cleanup early_dump_pci_device()
Quoted 5 lines · Ilpo Järvinen
Convert 256 to
PCI_CFG_SPACE_SIZEand 4 to sizeof(u32) and avoid i / 4 construct by changing the iteration.Signed-off-by Ilpo Järvinen <[email protected]>---
Quoted 36 lines
drivers/pci/probe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/pci/probe.c +5
-4@@ -3,6 +3,7 @@* PCI detection and setup code */ +#include <linux/array_size.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/init.h> @@ -1912,16 +1913,16 @@ static int pci_intx_mask_broken(struct pci_dev *dev)static void early_dump_pci_device (struct pci_dev *pdev) { -u32 value[256 /4 ]; +u32 value[PCI_CFG_SPACE_SIZE /sizeof (u32)];int i;pci_info (pdev,"config space:\n" ); -for (i =0 ; i <256 ; i +=4 ) -pci_read_config_dword (pdev, i, &value[i /4 ]); +for (i =0 ; i <ARRAY_SIZE (value); i++) +pci_read_config_dword (pdev, i *sizeof (u32), &value[i]);print_hex_dump (KERN_INFO ,"" ,DUMP_PREFIX_OFFSET ,16 ,1 , - value,256 , false); + value,ARRAY_SIZE (value) *sizeof (u32), false); }static const char *pci_type_str (struct pci_dev *dev)
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
PATCH 3/3 PCI: Cleanup pci_scan_child_bus_extend() loop
In reply to Ilpo Järvinenpci_scan_child_bus_extend() open-codes device number iteration in the for loop. Convert to use PCI_DEVFN() and add PCI_MAX_NR_DEVS (there seems to be no pre-existing defines for this purpose).
--- drivers/pci/pci.h | 1 + drivers/pci/probe.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/pci/pci.h +1 -0
@@ -8,6 +8,7 @@ struct pcie_tlp_log;/* Number of possible devfns: 0.0 to 1f.7 inclusive */ #define MAX_NR_DEVFNS 256 +#define PCI_MAX_NR_DEVS 32#define MAX_NR_LANES 16
drivers/pci/probe.c +3 -3
@@ -3029,14 +3029,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, {unsigned int used_buses, normal_bridges =0 , hotplug_bridges =0 ;unsigned int start = bus->busn_res.start; -unsigned int devfn, cmax, max = start; +unsigned int devnr, cmax, max = start;struct pci_dev *dev;dev_dbg (&bus->dev,"scanning bus\n" );/* Go find them, Rover! */ -for (devfn =0 ; devfn <256 ; devfn +=8 ) -pci_scan_slot (bus, devfn); +for (devnr =0 ; devnr <PCI_MAX_NR_DEVS ; devnr++) +pci_scan_slot (bus,PCI_DEVFN (devnr,0 ));/* Reserve buses for SR-IOV capability */ used_buses =pci_iov_bus_range (bus);
Signature · 1 line
2.39.5
Re: [PATCH 3/3] PCI: Cleanup pci_scan_child_bus_extend() loop
Quoted 6 lines · Ilpo Järvinen
pci_scan_child_bus_extend()open-codes device number iteration in the for loop. Convert to usePCI_DEVFN()and addPCI_MAX_NR_DEVS(there seems to be no pre-existing defines for this purpose).Signed-off-by Ilpo Järvinen <[email protected]>---
Quoted 38 lines
drivers/pci/pci.h | 1 + drivers/pci/probe.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)drivers/pci/pci.h +1
-0@@ -8,6 +8,7 @@ struct pcie_tlp_log;/* Number of possible devfns: 0.0 to 1f.7 inclusive */ #define MAX_NR_DEVFNS 256 +#define PCI_MAX_NR_DEVS 32#define MAX_NR_LANES 16drivers/pci/probe.c +3
-3@@ -3029,14 +3029,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, {unsigned int used_buses, normal_bridges =0 , hotplug_bridges =0 ;unsigned int start = bus->busn_res.start; -unsigned int devfn, cmax, max = start; +unsigned int devnr, cmax, max = start;struct pci_dev *dev;dev_dbg (&bus->dev,"scanning bus\n" );/* Go find them, Rover! */ -for (devfn =0 ; devfn <256 ; devfn +=8 ) -pci_scan_slot (bus, devfn); +for (devnr =0 ; devnr <PCI_MAX_NR_DEVS ; devnr++) +pci_scan_slot (bus,PCI_DEVFN (devnr,0 ));/* Reserve buses for SR-IOV capability */ used_buses =pci_iov_bus_range (bus);
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Quoted 4 lines · Ilpo Järvinen
Replace literals with PCI_HEADER_TYPE_* defines in
pci_setup_device().Signed-off-by Ilpo Järvinen <[email protected]>---
Quoted 20 lines
drivers/pci/probe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/probe.c +2
-2@@ -1985,8 +1985,8 @@ int pci_setup_device(struct pci_dev *dev) dev->sysdata = dev->bus->sysdata; dev->dev.parent = dev->bus->bridge; dev->dev.bus = &pci_bus_type; - dev->hdr_type = hdr_type &0x7f ; - dev->multifunction = !!(hdr_type &0x80 ); + dev->hdr_type =FIELD_GET (PCI_HEADER_TYPE_MASK , hdr_type); + dev->multifunction =FIELD_GET (PCI_HEADER_TYPE_MFD , hdr_type); dev->error_state = pci_channel_io_normal;set_pcie_port_type (dev);base-commit:
19272b37aa4f83ca52bdf9c16d5d81bdd1354494
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Quoted 3 lines · Ilpo Järvinen
Replace literals with PCI_HEADER_TYPE_* defines in
pci_setup_device().Signed-off-by Ilpo Järvinen <[email protected]>
All three applied to pci/enumeration for v6.18, thanks!
Quoted 24 lines
--- drivers/pci/probe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/probe.c +2
-2@@ -1985,8 +1985,8 @@ int pci_setup_device(struct pci_dev *dev) dev->sysdata = dev->bus->sysdata; dev->dev.parent = dev->bus->bridge; dev->dev.bus = &pci_bus_type; - dev->hdr_type = hdr_type &0x7f ; - dev->multifunction = !!(hdr_type &0x80 ); + dev->hdr_type =FIELD_GET (PCI_HEADER_TYPE_MASK , hdr_type); + dev->multifunction =FIELD_GET (PCI_HEADER_TYPE_MFD , hdr_type); dev->error_state = pci_channel_io_normal;set_pcie_port_type (dev);base-commit:
19272b37aa4f83ca52bdf9c16d5d81bdd1354494Signature · 1 line
2.39.5