[PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE

Alexey Gladkov posted 6 patches 6 months, 3 weeks ago
There is a newer version of this series
[PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE
Posted by Alexey Gladkov 6 months, 3 weeks ago
Since MODULE_DEVICE_TABLE no longer depends on whether the module is
built separately or compiled into the kernel, it now makes sense to
always define DEVICE_TABLE. In this case, even if the module is in the
kernel, correct module.builtin.modaliases will be generated.

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 8ce2ac9293a3..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},
@@ -3732,7 +3731,6 @@ static const struct pci_device_id blogic_pci_tbl[] = {
 	{0, },
 };
 MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
-#endif
 
 module_init(blogic_init);
 module_exit(blogic_exit);
-- 
2.49.0
Re: [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE
Posted by James Bottomley 6 months, 3 weeks ago
On Tue, 2025-05-27 at 15:15 +0200, Alexey Gladkov wrote:
> Since MODULE_DEVICE_TABLE no longer depends on whether the module is
> built separately or compiled into the kernel, it now makes sense to
> always define DEVICE_TABLE. In this case, even if the module is in
> the
> kernel, correct module.builtin.modaliases will be generated.
> 
> 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 8ce2ac9293a3..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},
> @@ -3732,7 +3731,6 @@ static const struct pci_device_id
> blogic_pci_tbl[] = {
>  	{0, },
>  };
>  MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
> -#endif

You don't need to do this in two steps.  The original problem of
defined but not used table stopped being a problem when the structure
was converted to static const over ten years ago (the compiler doesn't
warn about unused static consts).

Regards,

James
Re: [PATCH v3 7/6] scsi: Always define MODULE_DEVICE_TABLE
Posted by Alexey Gladkov 6 months, 3 weeks ago
On Tue, May 27, 2025 at 09:22:09AM -0400, James Bottomley wrote:
> On Tue, 2025-05-27 at 15:15 +0200, Alexey Gladkov wrote:
> > Since MODULE_DEVICE_TABLE no longer depends on whether the module is
> > built separately or compiled into the kernel, it now makes sense to
> > always define DEVICE_TABLE. In this case, even if the module is in
> > the
> > kernel, correct module.builtin.modaliases will be generated.
> > 
> > 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 8ce2ac9293a3..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},
> > @@ -3732,7 +3731,6 @@ static const struct pci_device_id
> > blogic_pci_tbl[] = {
> >  	{0, },
> >  };
> >  MODULE_DEVICE_TABLE(pci, blogic_pci_tbl);
> > -#endif
> 
> You don't need to do this in two steps.  The original problem of
> defined but not used table stopped being a problem when the structure
> was converted to static const over ten years ago (the compiler doesn't
> warn about unused static consts).

Ah. Ok, I will recreate this patch shortly.

Basically my original plan was to fix compilation errors as a first step,
and second step make MODULE_DEVICE_TABLE be used independently of MODULE.
Because there are a bunch of modules that also use MODULE_DEVICE_TABLE
only if MODULE is defined.

-- 
Rgrds, legion