Skip to contentSkip to conversation

PCI/IOV: fix building without CONFIG_PCI_IOV

PATCH In review Arnd Bergmann 3 participants 3 messages Sep 28 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/IOV: fix building without CONFIG_PCI_IOV

From: Arnd Bergmann <[email protected]>

The newly added code dealing with virtual functions causes a harmless build warning:

drivers/pci/probe.c: In function 'pci_class':
drivers/pci/probe.c:1902:12: error: unused variable 'rev' [-Werror=unused-variable]

Move the unused variable into the #ifdef block that uses it.

Fixes 8a2a9fa37b81 ("PCI/IOV: Read VF config values that need not match PF")
---
 drivers/pci/probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/probe.c +1 -1
index 833ce364f880..1ff07c592857 100644
@@ -1899,9 +1899,9 @@ int pci_cfg_space_size(struct pci_dev *dev)
 static u32 pci_class(struct pci_dev *dev)
 {
 	u32 class;
+#ifdef CONFIG_PCI_IOV
 	u8 rev;
 
-#ifdef CONFIG_PCI_IOV
 	if (dev->is_virtfn) {
 		if (pci_read_config_byte(dev, PCI_REVISION_ID, &rev))
 			rev = 0;
Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

From: Arnd Bergmann <[email protected]>

The newly added code dealing with virtual functions causes a harmless build warning:

Quoted 7 lines

drivers/pci/probe.c: In function 'pci_class':
drivers/pci/probe.c:1902:12: error: unused variable 'rev' [-Werror=unused-variable]

Move the unused variable into the #ifdef block that uses it.

Fixes 8a2a9fa37b81 ("PCI/IOV: Read VF config values that need not match PF")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly added code dealing with virtual functions causes a harmless build warning:

Quoted 7 lines

drivers/pci/probe.c: In function 'pci_class':
drivers/pci/probe.c:1902:12: error: unused variable 'rev' [-Werror=unused-variable]

Move the unused variable into the #ifdef block that uses it.

Fixes 8a2a9fa37b81 ("PCI/IOV: Read VF config values that need not match PF")

Thanks, I fixed this similarly:

https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=virtualization

   #ifdef CONFIG_PCI_IOV
  -	if (dev->is_virtfn)
  -		return dev->physfn->sriov->class;
  +	if (dev->is_virtfn) {
  +		u8 rev;
  +
  +		if (pci_read_config_byte(dev, PCI_REVISION_ID, &rev))
  +			rev = 0;
  +		return (dev->physfn->class << 8) | rev;
  +	}
   #endif
Quoted 22 lines
---
 drivers/pci/probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/probe.c +1 -1
index 833ce364f880..1ff07c592857 100644
@@ -1899,9 +1899,9 @@ int pci_cfg_space_size(struct pci_dev *dev)
 static u32 pci_class(struct pci_dev *dev)
 {
 	u32 class;
+#ifdef CONFIG_PCI_IOV
 	u8 rev;
 
-#ifdef CONFIG_PCI_IOV
 	if (dev->is_virtfn) {
 		if (pci_read_config_byte(dev, PCI_REVISION_ID, &rev))
 			rev = 0;
Signature · 1 line
2.53.0