2016-03-27 17:01:14

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 0/2] scsi: remove orphaned modular code from non-modular drivers

In the ongoing audit/cleanup of non-modular code needlessly using modular
infrastructure, the SCSI subsystem fortunately only contains two instances
that I detected. Both are for legacy drivers that predate the git epoch,
so cleary there is no demand for converting these drivers to be tristate.

For anyone new to the underlying goal of this cleanup, we are trying to
not use module support for code that isn't buildable as a module since:

(1) it is easy to accidentally write unused module_exit and remove code
(2) it can be misleading when reading the source, thinking it can be
modular when the Makefile and/or Kconfig prohibit it
(3) it requires the include of the module.h header file which in turn
includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other code and spreads like weeds.

Build tested for mips (jazz) and m68k (sun3x) on 4.6-rc1 to ensure no
silly typos crept in.

---

Cc: Geert Uytterhoeven <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Paul Gortmaker (2):
drivers/scsi: make jazz_esp.c driver explicitly non-modular
drivers/scsi: make sun3x_esp.c driver explicitly non-modular

drivers/scsi/jazz_esp.c | 43 ++++++-------------------------------------
drivers/scsi/sun3x_esp.c | 44 +++++---------------------------------------
2 files changed, 11 insertions(+), 76 deletions(-)

--
2.6.1


2016-03-27 17:01:04

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 2/2] drivers/scsi: make sun3x_esp.c driver explicitly non-modular

The Kconfig for this driver is currently:

config SUN3X_ESP
bool "Sun3x ESP SCSI"

...meaning that it currently is not being built as a module by anyone,
and it has been this way since the beginning of git history (~2005).

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, and it allows us to drop the ".remove"
code for non-modular drivers.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

We also delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.

Cc: "James E.J. Bottomley" <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/scsi/sun3x_esp.c | 44 +++++---------------------------------------
1 file changed, 5 insertions(+), 39 deletions(-)

diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index d50c5ed8f428..55a02f4331e5 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -1,13 +1,14 @@
/* sun3x_esp.c: ESP front-end for Sun3x systems.
*
* Copyright (C) 2007,2008 Thomas Bogendoerfer ([email protected])
+ *
+ * License: GPL
*/

#include <linux/kernel.h>
#include <linux/gfp.h>
#include <linux/types.h>
#include <linux/delay.h>
-#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
@@ -268,33 +269,11 @@ fail:
return err;
}

-static int esp_sun3x_remove(struct platform_device *dev)
-{
- struct esp *esp = dev_get_drvdata(&dev->dev);
- unsigned int irq = esp->host->irq;
- u32 val;
-
- scsi_esp_unregister(esp);
-
- /* Disable interrupts. */
- val = dma_read32(DMA_CSR);
- dma_write32(val & ~DMA_INT_ENAB, DMA_CSR);
-
- free_irq(irq, esp);
- dma_free_coherent(esp->dev, 16,
- esp->command_block,
- esp->command_block_dma);
-
- scsi_host_put(esp->host);
-
- return 0;
-}
-
static struct platform_driver esp_sun3x_driver = {
.probe = esp_sun3x_probe,
- .remove = esp_sun3x_remove,
.driver = {
- .name = "sun3x_esp",
+ .name = "sun3x_esp",
+ .suppress_bind_attrs = true,
},
};

@@ -302,17 +281,4 @@ static int __init sun3x_esp_init(void)
{
return platform_driver_register(&esp_sun3x_driver);
}
-
-static void __exit sun3x_esp_exit(void)
-{
- platform_driver_unregister(&esp_sun3x_driver);
-}
-
-MODULE_DESCRIPTION("Sun3x ESP SCSI driver");
-MODULE_AUTHOR("Thomas Bogendoerfer ([email protected])");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(DRV_VERSION);
-
-module_init(sun3x_esp_init);
-module_exit(sun3x_esp_exit);
-MODULE_ALIAS("platform:sun3x_esp");
+device_initcall(sun3x_esp_init);
--
2.6.1

2016-03-27 17:01:36

by Paul Gortmaker

[permalink] [raw]
Subject: [PATCH 1/2] drivers/scsi: make jazz_esp.c driver explicitly non-modular

The Kconfig for this driver is currently:

config JAZZ_ESP
bool "MIPS JAZZ FAS216 SCSI support

...meaning that it currently is not being built as a module by anyone,
and it has been this way since the beginning of git history (~2005).

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, and it allows us to drop the ".remove"
code for non-modular drivers.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

We also delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.

Cc: "James E.J. Bottomley" <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/scsi/jazz_esp.c | 43 ++++++-------------------------------------
1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
index 9aaa74e349cc..4260a0f7e154 100644
--- a/drivers/scsi/jazz_esp.c
+++ b/drivers/scsi/jazz_esp.c
@@ -1,12 +1,13 @@
/* jazz_esp.c: ESP front-end for MIPS JAZZ systems.
*
- * Copyright (C) 2007 Thomas Bogendörfer ([email protected])
+ * Copyright (C) 2007 Thomas Bogendörfer ([email protected])
+ *
+ * License: GPL
*/

#include <linux/kernel.h>
#include <linux/gfp.h>
#include <linux/types.h>
-#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
@@ -201,31 +202,11 @@ fail:
return err;
}

-static int esp_jazz_remove(struct platform_device *dev)
-{
- struct esp *esp = dev_get_drvdata(&dev->dev);
- unsigned int irq = esp->host->irq;
-
- scsi_esp_unregister(esp);
-
- free_irq(irq, esp);
- dma_free_coherent(esp->dev, 16,
- esp->command_block,
- esp->command_block_dma);
-
- scsi_host_put(esp->host);
-
- return 0;
-}
-
-/* work with hotplug and coldplug */
-MODULE_ALIAS("platform:jazz_esp");
-
static struct platform_driver esp_jazz_driver = {
.probe = esp_jazz_probe,
- .remove = esp_jazz_remove,
.driver = {
- .name = "jazz_esp",
+ .name = "jazz_esp",
+ .suppress_bind_attrs = true,
},
};

@@ -233,16 +214,4 @@ static int __init jazz_esp_init(void)
{
return platform_driver_register(&esp_jazz_driver);
}
-
-static void __exit jazz_esp_exit(void)
-{
- platform_driver_unregister(&esp_jazz_driver);
-}
-
-MODULE_DESCRIPTION("JAZZ ESP SCSI driver");
-MODULE_AUTHOR("Thomas Bogendoerfer ([email protected])");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(DRV_VERSION);
-
-module_init(jazz_esp_init);
-module_exit(jazz_esp_exit);
+device_initcall(jazz_esp_init);
--
2.6.1

2016-03-28 05:33:17

by James Bottomley

[permalink] [raw]
Subject: Re: [PATCH 0/2] scsi: remove orphaned modular code from non-modular drivers

On Sun, 2016-03-27 at 13:00 -0400, Paul Gortmaker wrote:
> In the ongoing audit/cleanup of non-modular code needlessly using
> modular infrastructure, the SCSI subsystem fortunately only contains
> two instances that I detected. Both are for legacy drivers that
> predate the git epoch, so cleary there is no demand for converting
> these drivers to be tristate.
>
> For anyone new to the underlying goal of this cleanup, we are trying
> to not use module support for code that isn't buildable as a module
> since:
>
> (1) it is easy to accidentally write unused module_exit and remove
> code
> (2) it can be misleading when reading the source, thinking it can be
> modular when the Makefile and/or Kconfig prohibit it
> (3) it requires the include of the module.h header file which in
> turn
> includes nearly everything else, thus adding to CPP overhead.
> (4) it gets copied/replicated into other code and spreads like
> weeds.

I don't really buy any of these as being credible issues for the
ancient drivers, so there doesn't appear to be an real benefit to this
conversion; however, besides the danger of touching old stuff, there
are some down sides:

> -MODULE_DESCRIPTION("Sun3x ESP SCSI driver");
> -MODULE_AUTHOR("Thomas Bogendoerfer ([email protected])");
> -MODULE_LICENSE("GPL");
> -MODULE_VERSION(DRV_VERSION);

These tags are usefully greppable for drivers, regardless of whether
they generate actual kernel side information.

> We explicitly disallow a driver unbind, since that doesn't have a
> sensible use case anyway, and it allows us to drop the ".remove"
> code for non-modular drivers.

That's bogus. I use bind and unbind a lot for testing built in drivers
but the usual user use case is for resetting the devices.

> Build tested for mips (jazz) and m68k (sun3x) on 4.6-rc1 to ensure no
> silly typos crept in.

For trivial changes, build testing is not really sufficient: a
significant fraction of them break something that isn't spotted by the
reviewers. For the older drivers, this isn't discovered for months to
years and then someone has to go digging back through all the so called
trivial changes to find which one it was.

James

2016-03-28 15:10:40

by Paul Gortmaker

[permalink] [raw]
Subject: Re: [PATCH 0/2] scsi: remove orphaned modular code from non-modular drivers

[Re: [PATCH 0/2] scsi: remove orphaned modular code from non-modular drivers] On 27/03/2016 (Sun 22:31) James Bottomley wrote:

> On Sun, 2016-03-27 at 13:00 -0400, Paul Gortmaker wrote:
> > In the ongoing audit/cleanup of non-modular code needlessly using
> > modular infrastructure, the SCSI subsystem fortunately only contains
> > two instances that I detected. Both are for legacy drivers that
> > predate the git epoch, so cleary there is no demand for converting
> > these drivers to be tristate.
> >
> > For anyone new to the underlying goal of this cleanup, we are trying
> > to not use module support for code that isn't buildable as a module
> > since:
> >
> > (1) it is easy to accidentally write unused module_exit and remove
> > code
> > (2) it can be misleading when reading the source, thinking it can be
> > modular when the Makefile and/or Kconfig prohibit it
> > (3) it requires the include of the module.h header file which in
> > turn
> > includes nearly everything else, thus adding to CPP overhead.
> > (4) it gets copied/replicated into other code and spreads like
> > weeds.
>
> I don't really buy any of these as being credible issues for the
> ancient drivers, so there doesn't appear to be an real benefit to this
> conversion; however, besides the danger of touching old stuff, there
> are some down sides:

Thanks James for your review and always interesting/alternative
viewpoints. You seem pretty clear in your conviction here, so I won't
bother making counter points ; best we just agree to disagree, and I
won't bother you with these patches again.

Paul.
--

>
> > -MODULE_DESCRIPTION("Sun3x ESP SCSI driver");
> > -MODULE_AUTHOR("Thomas Bogendoerfer ([email protected])");
> > -MODULE_LICENSE("GPL");
> > -MODULE_VERSION(DRV_VERSION);
>
> These tags are usefully greppable for drivers, regardless of whether
> they generate actual kernel side information.
>
> > We explicitly disallow a driver unbind, since that doesn't have a
> > sensible use case anyway, and it allows us to drop the ".remove"
> > code for non-modular drivers.
>
> That's bogus. I use bind and unbind a lot for testing built in drivers
> but the usual user use case is for resetting the devices.
>
> > Build tested for mips (jazz) and m68k (sun3x) on 4.6-rc1 to ensure no
> > silly typos crept in.
>
> For trivial changes, build testing is not really sufficient: a
> significant fraction of them break something that isn't spotted by the
> reviewers. For the older drivers, this isn't discovered for months to
> years and then someone has to go digging back through all the so called
> trivial changes to find which one it was.
>
> James
>