Define MODULE_DEVICE_TABLE only if a structure is defined for it.
drivers/scsi/BusLogic.c:3735:26: error: use of undeclared identifier 'blogic_pci_tbl'
3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
Fixes: 1079a2d251f2 ("[SCSI] BusLogic: stop using check_region")
Cc: Khalid Aziz <khalid@gonehiking.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
drivers/scsi/BusLogic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 1f100270cd38..8ce2ac9293a3 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3731,8 +3731,8 @@ static const struct pci_device_id blogic_pci_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)},
{0, },
};
-#endif
MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
+#endif
module_init(blogic_init);
module_exit(blogic_exit);
--
2.49.0
On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote: > Define MODULE_DEVICE_TABLE only if a structure is defined for it. > > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared identifier > 'blogic_pci_tbl' > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); Well, a) need to cc the scsi list and b) how is this possible when MODULE_DEVICE_TABLE() has an empty definition if MODULE isn't defined (so the guard you move should be over an empty statement)? Regards, James
On Tue, May 27, 2025 at 07:28:59AM -0400, James Bottomley wrote: > On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote: > > Define MODULE_DEVICE_TABLE only if a structure is defined for it. > > > > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared identifier > > 'blogic_pci_tbl' > > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); > > Well, a) need to cc the scsi list Sorry. I miss it. > and b) how is this possible when > MODULE_DEVICE_TABLE() has an empty definition if MODULE isn't defined > (so the guard you move should be over an empty statement)? In the next patch: [PATCH v3 4/6] modpost: Create modalias for builtin modules I remove this condition for the MODULE_DEVICE_TABLE macro and it will be always defined. I put the drivers/scsi/BusLogic.c change before these changes to avoid errors. Besides, even an empty macro uses a structure name that is not defined (if MODULE isn't defined). This seems wrong in any case. -- Rgrds, legion
On Tue, 2025-05-27 at 13:54 +0200, Alexey Gladkov wrote: > On Tue, May 27, 2025 at 07:28:59AM -0400, James Bottomley wrote: > > On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote: > > > Define MODULE_DEVICE_TABLE only if a structure is defined for it. > > > > > > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared > > > identifier > > > 'blogic_pci_tbl' > > > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); > > > > Well, a) need to cc the scsi list > > Sorry. I miss it. > > > and b) how is this possible when MODULE_DEVICE_TABLE() has an empty > > definition if MODULE isn't defined (so the guard you move should be > > over an empty statement)? > > In the next patch: > > [PATCH v3 4/6] modpost: Create modalias for builtin modules > > I remove this condition for the MODULE_DEVICE_TABLE macro and it will > be always defined. Well, why? If there's a reason for the table to always exist, wouldn't the best fix then be to remove the module guards from the PCI table in the buslogic ... they only really exist to prevent a defined but not used error which it sounds like you're getting rid of? Regards, James
On Tue, May 27, 2025 at 07:58:27AM -0400, James Bottomley wrote: > On Tue, 2025-05-27 at 13:54 +0200, Alexey Gladkov wrote: > > On Tue, May 27, 2025 at 07:28:59AM -0400, James Bottomley wrote: > > > On Tue, 2025-05-27 at 11:07 +0200, Alexey Gladkov wrote: > > > > Define MODULE_DEVICE_TABLE only if a structure is defined for it. > > > > > > > > drivers/scsi/BusLogic.c:3735:26: error: use of undeclared > > > > identifier > > > > 'blogic_pci_tbl' > > > > 3735 | MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); > > > > > > Well, a) need to cc the scsi list > > > > Sorry. I miss it. > > > > > and b) how is this possible when MODULE_DEVICE_TABLE() has an empty > > > definition if MODULE isn't defined (so the guard you move should be > > > over an empty statement)? > > > > In the next patch: > > > > [PATCH v3 4/6] modpost: Create modalias for builtin modules > > > > I remove this condition for the MODULE_DEVICE_TABLE macro and it will > > be always defined. > > Well, why? If there's a reason for the table to always exist, wouldn't > the best fix then be to remove the module guards from the PCI table in > the buslogic ... they only really exist to prevent a defined but not > used error which it sounds like you're getting rid of? I wanted to keep the original logic and remove the build error. Before my changes blogic_pci_tbl was only used when the module was built separately (MODULE case). But yes, you are right. In this case, it would be more appropriate to remove the MODULE condition at all since MODULE_DEVICE_TABLE always makes sense after my changes. -- Rgrds, legion
The blogic_pci_tbl structure is used by the MODULE_DEVICE_TABLE macro.
There is no longer a need to protect it with the MODULE condition, since
this no longer causes the compiler to warn about an unused variable.
Cc: Khalid Aziz <khalid@gonehiking.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
drivers/scsi/BusLogic.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 1f100270cd38..08e12a3d6703 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void)
__setup("BusLogic=", blogic_setup);
-#ifdef MODULE
/*static const struct pci_device_id blogic_pci_tbl[] = {
{ PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -3731,7 +3730,6 @@ static const struct pci_device_id blogic_pci_tbl[] = {
{PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)},
{0, },
};
-#endif
MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
module_init(blogic_init);
--
2.49.0
© 2016 - 2025 Red Hat, Inc.