Skip to contentSkip to conversation

irqchip: make non-modular code explicitly non-modular

PATCH In review Paul Gortmaker 2 participants 5 messages Oct 11, 2015 – Oct 14, 2015 irqchip drivers

lore
Share & tools
lore
#0 lore raw

cover irqchip: make non-modular code explicitly non-modular

In a previous merge window, we made changes to allow better delineation between modular and non-modular code in commit 0fd972a7d91d6e15393c449492a04d94c0b89351 ("module: relocate module_init from init.h to module.h"). This allows us to now ensure module code looks modular and non-modular code does not accidentally look modular just to avoid suffering build breakage.

Here we target code that is, by nature of their Makefile and/or Kconfig settings, only available to be built-in, but implicitly presenting itself as being possibly modular by way of using modular headers, macros, and functions.

The goal here is to remove that illusion of modularity from these files, but in a way that leaves the actual runtime unchanged. In doing so, we remove code that has never been tested and adds no value to the tree. And we continue the process of expecting a level of consistency between the Kconfig/Makefile of code and the code in use itself.

Fortuntately the irqchip subsystem has just two instances. For comparison there are over 300 instances tree wide, resulting in a possible net removal of on the order of 5000 lines of unused code.

Build tested on the latest linux-next, on ARM.

Paul.
--

Cc Jason Cooper <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>

Paul Gortmaker (2):
drivers/irqchip: make irq-renesas-intc-irqpin.c explicitly non-modular drivers/irqchip: make irq-renesas-irqc.c explicitly non-modular

 drivers/irqchip/irq-renesas-intc-irqpin.c | 24 +-----------------------
 drivers/irqchip/irq-renesas-irqc.c        | 30 +-----------------------------
 2 files changed, 2 insertions(+), 52 deletions(-)
Signature · 1 line
2.6.1
#1 lore raw

PATCH 1/2 drivers/irqchip: make irq-renesas-intc-irqpin.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

drivers/irqchip/Kconfig:config RENESAS_INTC_IRQPIN
drivers/irqchip/Kconfig: bool

...meaning that it currently is not being built as a module by anyone.

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

While at it, since this is core infrastructural code for the platform, lets prohibit any unbind actions that would have called the .remove function, if anyone was unwise enough to try that.

Since module_init was not in use by this code, the init ordering remains unchanged with this commit.

We don't replace module.h with init.h since the file already has that.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

Cc Magnus Damm <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 drivers/irqchip/irq-renesas-intc-irqpin.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/irqchip/irq-renesas-intc-irqpin.c +1 -23
index c325806561be..2fc5d425c5a0 100644
@@ -29,7 +29,6 @@
 #include <linux/irqdomain.h>
 #include <linux/err.h>
 #include <linux/slab.h>
-#include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/platform_data/irq-renesas-intc-irqpin.h>
 #include <linux/pm_runtime.h>
@@ -373,7 +372,6 @@ static const struct of_device_id intc_irqpin_dt_ids[] = {
 	  .data = &intc_irqpin_irlm_r8a777x },
 	{},
 };
-MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
 
 static int intc_irqpin_probe(struct platform_device *pdev)
 {
@@ -589,21 +587,11 @@ err0:
 	return ret;
 }
 
-static int intc_irqpin_remove(struct platform_device *pdev)
-{
-	struct intc_irqpin_priv *p = platform_get_drvdata(pdev);
-
-	irq_domain_remove(p->irq_domain);
-	pm_runtime_put(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
-	return 0;
-}
-
 static struct platform_driver intc_irqpin_device_driver = {
 	.probe		= intc_irqpin_probe,
-	.remove		= intc_irqpin_remove,
 	.driver		= {
 		.name	= "renesas_intc_irqpin",
+		.suppress_bind_attrs = true,
 		.of_match_table = intc_irqpin_dt_ids,
 	}
 };
@@ -613,13 +601,3 @@ static int __init intc_irqpin_init(void)
 	return platform_driver_register(&intc_irqpin_device_driver);
 }
 postcore_initcall(intc_irqpin_init);
-
-static void __exit intc_irqpin_exit(void)
-{
-	platform_driver_unregister(&intc_irqpin_device_driver);
-}
-module_exit(intc_irqpin_exit);
-
-MODULE_AUTHOR("Magnus Damm");
-MODULE_DESCRIPTION("Renesas INTC External IRQ Pin Driver");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.6.1
#2 lore raw

PATCH 2/2 drivers/irqchip: make irq-renesas-irqc.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/irqchip/Kconfig:config RENESAS_IRQC
drivers/irqchip/Kconfig: bool

...meaning that it currently is not being built as a module by anyone.

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

While at it, since this is core infrastructural code for the platform, lets prohibit any unbind actions that would have called the .remove function, if anyone was unwise enough to try that.

Since module_init was not in use by this code, the init ordering remains unchanged with this commit.

We don't replace module.h with init.h since the file already has that.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

Cc Magnus Damm <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 drivers/irqchip/irq-renesas-irqc.c | 30 +-----------------------------
 1 file changed, 1 insertion(+), 29 deletions(-)
drivers/irqchip/irq-renesas-irqc.c +1 -29
index 52304b139aa4..a05b1012fce7 100644
@@ -28,7 +28,6 @@
 #include <linux/irqdomain.h>
 #include <linux/err.h>
 #include <linux/slab.h>
-#include <linux/module.h>
 #include <linux/pm_runtime.h>
 
 #define IRQC_IRQ_MAX	32	/* maximum 32 interrupts per driver instance */
@@ -260,33 +259,16 @@ err0:
 	return ret;
 }
 
-static int irqc_remove(struct platform_device *pdev)
-{
-	struct irqc_priv *p = platform_get_drvdata(pdev);
-	int k;
-
-	for (k = 0; k < p->number_of_irqs; k++)
-		free_irq(p->irq[k].requested_irq, &p->irq[k]);
-
-	irq_domain_remove(p->irq_domain);
-	iounmap(p->iomem);
-	pm_runtime_put(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
-	kfree(p);
-	return 0;
-}
-
 static const struct of_device_id irqc_dt_ids[] = {
 	{ .compatible = "renesas,irqc", },
 	{},
 };
-MODULE_DEVICE_TABLE(of, irqc_dt_ids);
 
 static struct platform_driver irqc_device_driver = {
 	.probe		= irqc_probe,
-	.remove		= irqc_remove,
 	.driver		= {
 		.name	= "renesas_irqc",
+		.suppress_bind_attrs = true,
 		.of_match_table	= irqc_dt_ids,
 	}
 };
@@ -296,13 +278,3 @@ static int __init irqc_init(void)
 	return platform_driver_register(&irqc_device_driver);
 }
 postcore_initcall(irqc_init);
-
-static void __exit irqc_exit(void)
-{
-	platform_driver_unregister(&irqc_device_driver);
-}
-module_exit(irqc_exit);
-
-MODULE_AUTHOR("Magnus Damm");
-MODULE_DESCRIPTION("Renesas IRQC Driver");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.6.1
#3 lore raw
In reply to Paul Gortmaker

Hi Paul,

Quoted 33 lines · Paul Gortmaker

In a previous merge window, we made changes to allow better delineation between modular and non-modular code in commit 0fd972a7d91d6e15393c449492a04d94c0b89351 ("module: relocate module_init from init.h to module.h"). This allows us to now ensure module code looks modular and non-modular code does not accidentally look modular just to avoid suffering build breakage.

Here we target code that is, by nature of their Makefile and/or Kconfig settings, only available to be built-in, but implicitly presenting itself as being possibly modular by way of using modular headers, macros, and functions.

The goal here is to remove that illusion of modularity from these files, but in a way that leaves the actual runtime unchanged. In doing so, we remove code that has never been tested and adds no value to the tree. And we continue the process of expecting a level of consistency between the Kconfig/Makefile of code and the code in use itself.

Fortuntately the irqchip subsystem has just two instances. For comparison there are over 300 instances tree wide, resulting in a possible net removal of on the order of 5000 lines of unused code.

Build tested on the latest linux-next, on ARM.

Paul.
--

Cc Jason Cooper <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>
Quoted 7 lines

Paul Gortmaker (2):
drivers/irqchip: make irq-renesas-intc-irqpin.c explicitly non-modular drivers/irqchip: make irq-renesas-irqc.c explicitly non-modular

 drivers/irqchip/irq-renesas-intc-irqpin.c | 24 +-----------------------
 drivers/irqchip/irq-renesas-irqc.c        | 30 +-----------------------------
 2 files changed, 2 insertions(+), 52 deletions(-)

Both of these are "external interrupt controllers", meaning that on some boards they are used to handle only interrupts from external devices (e.g. Ethernet), which is optional.

Hence IMHO the bool should be changed to tristate instead.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#4 lore raw
Quoted 4 lines · [Re: [PATCH 0/2] irqchip: make non-modular code explicitly non-modular] On…

Hi Paul,

On Mon, Oct 12, 2015 at 1:05 AM, Paul Gortmaker
<[email protected]> wrote:

[...]

Quoted 8 lines
Quoted 7 lines

Paul Gortmaker (2):
drivers/irqchip: make irq-renesas-intc-irqpin.c explicitly non-modular drivers/irqchip: make irq-renesas-irqc.c explicitly non-modular

 drivers/irqchip/irq-renesas-intc-irqpin.c | 24 +-----------------------
 drivers/irqchip/irq-renesas-irqc.c        | 30 +-----------------------------
 2 files changed, 2 insertions(+), 52 deletions(-)
Quoted 5 lines

Both of these are "external interrupt controllers", meaning that on some boards they are used to handle only interrupts from external devices (e.g. Ethernet), which is optional.

Hence IMHO the bool should be changed to tristate instead.

So, at the risk of repeating myself -- changing to tristate widens the scope on build coverage and everything else. When I did this for a staging driver, I got caught in symbols that were not exported. Not critically complex, but it does show that allowing a new config option can make things break. Hence keeping the support matrix the same is table stakes to allow me to make this tree wide update in a way that scales.

As the changes I propose do not change the runtime, I think that the verification of the extension of functionality lies on those who think moving these drivers from bool to tristate is a genuine value add.

If for no other reason, it at least does keep a bisect honest in showing where existing functionality broke vs. added functionality brought in new breakage.

Paul.
--

Quoted 11 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds