Skip to contentSkip to conversation

Fix drivers/scsi/fdomain.c CONFIG_PCI=n warnings

PATCH NAK [email protected] 2 participants 4 messages Aug 10, 2007 – Aug 15, 2007 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 12/30 Fix drivers/scsi/fdomain.c CONFIG_PCI=n warnings

From: Gabriel C <[email protected]>

I get this warnings on current git when CONFIG_PCI is not set :

drivers/scsi/fdomain.c:390: warning: 'PCI_dev' defined but not used drivers/scsi/fdomain.c:1768: warning: 'fdomain_pci_tbl' defined but not used

---

 drivers/scsi/fdomain.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/fdomain.c renamed from drivers/scsi/fdomain.c~fix-drivers-scsi-fdomainc-config_pci=n-warnings +4 -1
diff -puN drivers/scsi/fdomain.c~fix-drivers-scsi-fdomainc-config_pci=n-warnings drivers/scsi/fdomain.c
@@ -387,7 +387,9 @@ static void __iomem *    bios_mem;
 static int               bios_major;
 static int               bios_minor;
 static int               PCI_bus;
+#ifdef CONFIG_PCI
 static struct pci_dev	*PCI_dev;
+#endif
 static int               Quantum;	/* Quantum board variant */
 static int               interrupt_level;
 static volatile int      in_command;
@@ -1764,6 +1766,7 @@ struct scsi_host_template fdomain_driver
 };
 
 #ifndef PCMCIA
+#ifdef CONFIG_PCI
 
 static struct pci_device_id fdomain_pci_tbl[] __devinitdata = {
 	{ PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70,
@@ -1771,7 +1774,7 @@ static struct pci_device_id fdomain_pci_
 	{ }
 };
 MODULE_DEVICE_TABLE(pci, fdomain_pci_tbl);
-
+#endif
 #define driver_template fdomain_driver_template
 #include "scsi_module.c"
 

_

#1 lore raw
Quoted 9 lines · On Fri, 2007-08-10 at 14:50 -0700, [email protected] wrote:

From: Gabriel C <[email protected]>

I get this warnings on current git when CONFIG_PCI is not set :

drivers/scsi/fdomain.c:390: warning: 'PCI_dev' defined but not used drivers/scsi/fdomain.c:1768: warning: 'fdomain_pci_tbl' defined but not used

This function looks decidedly dangerous since it references a non-existent variable when CONFIG_PCI isn't set. It seems to work because pci_dev_put() is defined to a null macro, but it's not safe:

static int fdomain_16x0_release(struct Scsi_Host *shpnt)

{
	if (shpnt->irq)
		free_irq(shpnt->irq, shpnt);
	if (shpnt->io_port && shpnt->n_io_port)
		release_region(shpnt->io_port, shpnt->n_io_port);
	if (PCI_bus)
		pci_dev_put(PCI_dev);
	return 0;
}

James

#2 lore raw
Quoted 16 lines · On Wed, 15 Aug 2007 11:35:49 -0500 James Bottomley…
Quoted 9 lines · On Fri, 2007-08-10 at 14:50 -0700, [email protected] wrote:

From: Gabriel C <[email protected]>

I get this warnings on current git when CONFIG_PCI is not set :

drivers/scsi/fdomain.c:390: warning: 'PCI_dev' defined but not used drivers/scsi/fdomain.c:1768: warning: 'fdomain_pci_tbl' defined but not used

This function looks decidedly dangerous since it references a non-existent variable when CONFIG_PCI isn't set. It seems to work because pci_dev_put() is defined to a null macro, but it's not safe:

static int fdomain_16x0_release(struct Scsi_Host *shpnt)

Quoted 10 lines
{
	if (shpnt->irq)
		free_irq(shpnt->irq, shpnt);
	if (shpnt->io_port && shpnt->n_io_port)
		release_region(shpnt->io_port, shpnt->n_io_port);
	if (PCI_bus)
		pci_dev_put(PCI_dev);
	return 0;
}

I expect that's why pci_dev_put() is still implemented as a macro.

#3 lore raw
Quoted 29 lines · Andrew Morton
Quoted 16 lines · On Wed, 15 Aug 2007 11:35:49 -0500 James Bottomley…
Quoted 9 lines · On Fri, 2007-08-10 at 14:50 -0700, [email protected] wrote:

From: Gabriel C <[email protected]>

I get this warnings on current git when CONFIG_PCI is not set :

drivers/scsi/fdomain.c:390: warning: 'PCI_dev' defined but not used drivers/scsi/fdomain.c:1768: warning: 'fdomain_pci_tbl' defined but not used

This function looks decidedly dangerous since it references a non-existent variable when CONFIG_PCI isn't set. It seems to work because pci_dev_put() is defined to a null macro, but it's not safe:

static int fdomain_16x0_release(struct Scsi_Host *shpnt)

Quoted 10 lines
{
	if (shpnt->irq)
		free_irq(shpnt->irq, shpnt);
	if (shpnt->io_port && shpnt->n_io_port)
		release_region(shpnt->io_port, shpnt->n_io_port);
	if (PCI_bus)
		pci_dev_put(PCI_dev);
	return 0;
}
Quoted 1 line

I expect that's why pci_dev_put() is still implemented as a macro.

It's not in my best practices book to refer to a non-existent variable in the hope that the referring routine is an empty define ... at the very least it will cause a bit of head scratching for anyone looking over this driver in future. Not to say this driver will break if someone ever substitutes the #define for a static inline ...

James