* [PATCH v2 0/4] bus: remove unused modular code from non-modular drivers
@ 2016-07-03 17:30 Paul Gortmaker
[not found] ` <20160703173040.23612-1-paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Paul Gortmaker @ 2016-07-03 17:30 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Paul Gortmaker, Alexandre Courbot, Alison Chaiken, Brian Norris,
Florian Fainelli, Geert Uytterhoeven, Gregory Fong, Jon Hunter,
Kevin Hilman, Sascha Hauer, Shawn Guo, Simon Horman,
Stephen Warren, Thierry Reding, Wolfram Sang,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
The drivers/bus doesn't have a strict maintainer entry, but since
all the changes here are for ARM platforms, I'm Cc'ing arm-kernel
and hoping it makes sense to vector these few changes through the
arm-soc tree.
My ongoing audit looking for non-modular code that needlessly uses
modular macros (vs. built-in equivalents) and/or has dead code
relating to module unloading that can never be executed led to the
creation of these four commits.
Two are of the trivial kind, where we substitute in the non-modular
versions that CPP would have put in place anyway, resulting in no
actual changes, even at the binary output level.
Another is of the kind where there was a ".remove" function
registered into the driver struct. Being non-modular, these
functions will never be called via a normal module_exit path.
However, since it was possible (but largely pointless, and without
a real use case) to unbind these drivers via sysfs, we explicitly
disallow the unbind as part of the removal of the ".remove" itself.
Finally one is a conversion of a bool to a tristate; not something
I'd do myself by default, but in this case we had a desire from
the original author to have it that way.
For anyone new to the underlying goal of this cleanup, we are trying to
not use module support for code that can never be built 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 arm and arm64 on linux-next to ensure no silly typos
that would break compilation crept in.
---
[v2: drop arm-ccn patch; it is being made tristate elsewhere, convert
simple-pm to tristate, add new patch for new tegra-aconnect driver.]
[v1: https://lkml.kernel.org/r/1459113058-14340-1-git-send-email-paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org ]
Cc: Alexandre Courbot <gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Alison Chaiken <alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
Cc: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: Gregory Fong <gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Kevin Hilman <khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Simon Horman <horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Paul Gortmaker (4):
bus: brcmstb_gisb: make it explicitly non-modular
bus: imx-weim: make it explicitly non-modular
bus: tegra-aconnect: make it explicitly non-modular
bus: simple-pm-bus: convert bool SIMPLE_PM_BUS to tristate
drivers/bus/Kconfig | 2 +-
drivers/bus/brcmstb_gisb.c | 4 +---
drivers/bus/imx-weim.c | 9 ++-------
drivers/bus/tegra-aconnect.c | 22 +++++-----------------
4 files changed, 9 insertions(+), 28 deletions(-)
--
2.8.4
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <20160703173040.23612-1-paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>]
* [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular [not found] ` <20160703173040.23612-1-paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> @ 2016-07-03 17:30 ` Paul Gortmaker 2016-07-04 9:17 ` Jon Hunter 0 siblings, 1 reply; 5+ messages in thread From: Paul Gortmaker @ 2016-07-03 17:30 UTC (permalink / raw) To: linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Paul Gortmaker, Stephen Warren, Thierry Reding, Alexandre Courbot, Jon Hunter, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r The Kconfig currently controlling compilation of this code is: drivers/bus/Kconfig:config TEGRA_ACONNECT drivers/bus/Kconfig: bool "Tegra ACONNECT Bus Driver" ...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. 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_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit. 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 was (or is now) contained at the top of the file in the comments. Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Alexandre Courbot <gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Signed-off-by: Paul Gortmaker <paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> --- drivers/bus/tegra-aconnect.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/bus/tegra-aconnect.c b/drivers/bus/tegra-aconnect.c index 7e4104b74fa8..f3982946ab8a 100644 --- a/drivers/bus/tegra-aconnect.c +++ b/drivers/bus/tegra-aconnect.c @@ -1,6 +1,8 @@ /* * Tegra ACONNECT Bus Driver * + * Author: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> + * * Copyright (C) 2016, NVIDIA CORPORATION. All rights reserved. * * This file is subject to the terms and conditions of the GNU General Public @@ -9,7 +11,7 @@ */ #include <linux/clk.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/pm_clock.h> @@ -66,15 +68,6 @@ clk_destroy: return ret; } -static int tegra_aconnect_remove(struct platform_device *pdev) -{ - pm_runtime_disable(&pdev->dev); - - pm_clk_destroy(&pdev->dev); - - return 0; -} - static int tegra_aconnect_runtime_resume(struct device *dev) { return pm_clk_resume(dev); @@ -94,19 +87,14 @@ static const struct of_device_id tegra_aconnect_of_match[] = { { .compatible = "nvidia,tegra210-aconnect", }, { } }; -MODULE_DEVICE_TABLE(of, tegra_aconnect_of_match); static struct platform_driver tegra_aconnect_driver = { .probe = tegra_aconnect_probe, - .remove = tegra_aconnect_remove, .driver = { .name = "tegra-aconnect", + .suppress_bind_attrs = true, .of_match_table = tegra_aconnect_of_match, .pm = &tegra_aconnect_pm_ops, }, }; -module_platform_driver(tegra_aconnect_driver); - -MODULE_DESCRIPTION("NVIDIA Tegra ACONNECT Bus Driver"); -MODULE_AUTHOR("Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>"); -MODULE_LICENSE("GPL v2"); +builtin_platform_driver(tegra_aconnect_driver); -- 2.8.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular 2016-07-03 17:30 ` [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular Paul Gortmaker @ 2016-07-04 9:17 ` Jon Hunter 2016-07-04 13:41 ` Paul Gortmaker 0 siblings, 1 reply; 5+ messages in thread From: Jon Hunter @ 2016-07-04 9:17 UTC (permalink / raw) To: Paul Gortmaker, linux-kernel Cc: linux-tegra, Alexandre Courbot, Thierry Reding, linux-arm-kernel, Stephen Warren Hi Paul, On 03/07/16 18:30, Paul Gortmaker wrote: > The Kconfig currently controlling compilation of this code is: > > drivers/bus/Kconfig:config TEGRA_ACONNECT > drivers/bus/Kconfig: bool "Tegra ACONNECT Bus Driver" > > ...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. > > 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_platform_driver() uses the same init level priority as > builtin_platform_driver() the init ordering remains unchanged with > this commit. > > 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 > was (or is now) contained at the top of the file in the comments. In version 3 of the aconnect series [0] I had made this a tristate because we allowed it to be removed and you had submitted a patch to export the PM_CLK APIs. However, when discussing with Thierry he said that we were unable to merge with tristate because of the dependency on your patch. So he suggested we merge with bool for now and then change it back to tristate for v4.9. I understand that we should not do this, but we do plan to make this modular in the future. Cheers Jon [0] http://marc.info/?l=linux-tegra&m=146616753627760&w=2 -- nvpublic ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular 2016-07-04 9:17 ` Jon Hunter @ 2016-07-04 13:41 ` Paul Gortmaker [not found] ` <20160704134123.GV26134-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Paul Gortmaker @ 2016-07-04 13:41 UTC (permalink / raw) To: Jon Hunter Cc: linux-kernel, Stephen Warren, Thierry Reding, Alexandre Courbot, linux-tegra, linux-arm-kernel [Re: [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular] On 04/07/2016 (Mon 10:17) Jon Hunter wrote: > Hi Paul, > > On 03/07/16 18:30, Paul Gortmaker wrote: > > The Kconfig currently controlling compilation of this code is: > > > > drivers/bus/Kconfig:config TEGRA_ACONNECT > > drivers/bus/Kconfig: bool "Tegra ACONNECT Bus Driver" > > > > ...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. > > > > 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_platform_driver() uses the same init level priority as > > builtin_platform_driver() the init ordering remains unchanged with > > this commit. > > > > 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 > > was (or is now) contained at the top of the file in the comments. > > In version 3 of the aconnect series [0] I had made this a tristate > because we allowed it to be removed and you had submitted a patch to > export the PM_CLK APIs. However, when discussing with Thierry he said > that we were unable to merge with tristate because of the dependency on > your patch. So he suggested we merge with bool for now and then change > it back to tristate for v4.9. Oh I see. The exported clock syms were for the 210 DMA driver and it never crossed my mind that this driver needed the same syms in order for it to be tristate. Guess the exports proved useful afterall. :) > > I understand that we should not do this, but we do plan to make this > modular in the future. No problem ; I will drop this patch in favor of a one line Kconfig patch in my test queue so it doesn't trip the regular audit, just like I have for the 210 below -- not yet submitted for the same dependency reason. P. --- From fe5bdc6348828c157deb14e8d75c732abcc2ad2b Mon Sep 17 00:00:00 2001 From: Paul Gortmaker <paul.gortmaker@windriver.com> Date: Fri, 20 May 2016 14:30:43 -0400 Subject: [PATCH] dma: tegra210-adma: convert TEGRA210_ADMA from bool to tristate This driver currently uses modular infrastructure but is controlled by a bool Kconfig. There is a general consensus from the DMA reviewers and maintainers that "if it can be modular, it should be modular" in order to keep the bzImage size under control for multi platform kernels. Build tested only. Also needs some new pm_clk symbols exported before this commit is applied to tree in order to avoid modpost errors like: ERROR: "pm_clk_add_clk" [drivers/dma/tegra210-adma.ko] undefined! ERROR: "pm_clk_create" [drivers/dma/tegra210-adma.ko] undefined! ERROR: "pm_clk_destroy" [drivers/dma/tegra210-adma.ko] undefined! ERROR: "pm_clk_suspend" [drivers/dma/tegra210-adma.ko] undefined! ERROR: "pm_clk_resume" [drivers/dma/tegra210-adma.ko] undefined! Cc: Laxman Dewangan <ldewangan@nvidia.com> Cc: Jon Hunter <jonathanh@nvidia.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Vinod Koul <vinod.koul@intel.com> Cc: Stephen Warren <swarren@wwwdotorg.org> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Alexandre Courbot <gnurou@gmail.com> Cc: dmaengine@vger.kernel.org Cc: linux-tegra@vger.kernel.org Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> --- drivers/dma/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 8c98779a12b1..866068d84ca2 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -468,7 +468,7 @@ config TEGRA20_APB_DMA or vice versa. It does not support memory to memory data transfer. config TEGRA210_ADMA - bool "NVIDIA Tegra210 ADMA support" + tristate "NVIDIA Tegra210 ADMA support" depends on ARCH_TEGRA_210_SOC select DMA_ENGINE select DMA_VIRTUAL_CHANNELS -- 2.8.0 > > Cheers > Jon > > [0] http://marc.info/?l=linux-tegra&m=146616753627760&w=2 > > -- > nvpublic ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <20160704134123.GV26134-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>]
* Re: [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular [not found] ` <20160704134123.GV26134-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> @ 2016-07-04 13:47 ` Jon Hunter 0 siblings, 0 replies; 5+ messages in thread From: Jon Hunter @ 2016-07-04 13:47 UTC (permalink / raw) To: Paul Gortmaker Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stephen Warren, Thierry Reding, Alexandre Courbot, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On 04/07/16 14:41, Paul Gortmaker wrote: > [Re: [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular] On 04/07/2016 (Mon 10:17) Jon Hunter wrote: > >> Hi Paul, >> >> On 03/07/16 18:30, Paul Gortmaker wrote: >>> The Kconfig currently controlling compilation of this code is: >>> >>> drivers/bus/Kconfig:config TEGRA_ACONNECT >>> drivers/bus/Kconfig: bool "Tegra ACONNECT Bus Driver" >>> >>> ...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. >>> >>> 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_platform_driver() uses the same init level priority as >>> builtin_platform_driver() the init ordering remains unchanged with >>> this commit. >>> >>> 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 >>> was (or is now) contained at the top of the file in the comments. >> >> In version 3 of the aconnect series [0] I had made this a tristate >> because we allowed it to be removed and you had submitted a patch to >> export the PM_CLK APIs. However, when discussing with Thierry he said >> that we were unable to merge with tristate because of the dependency on >> your patch. So he suggested we merge with bool for now and then change >> it back to tristate for v4.9. > > Oh I see. The exported clock syms were for the 210 DMA driver and it > never crossed my mind that this driver needed the same syms in order for > it to be tristate. Guess the exports proved useful afterall. :) Yes indeed and I did learn my lesson after your previous catch for the ADMA ;-) >> >> I understand that we should not do this, but we do plan to make this >> modular in the future. > > No problem ; I will drop this patch in favor of a one line Kconfig patch > in my test queue so it doesn't trip the regular audit, just like I have > for the 210 below -- not yet submitted for the same dependency reason. > > P. > --- > > > From fe5bdc6348828c157deb14e8d75c732abcc2ad2b Mon Sep 17 00:00:00 2001 > From: Paul Gortmaker <paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> > Date: Fri, 20 May 2016 14:30:43 -0400 > Subject: [PATCH] dma: tegra210-adma: convert TEGRA210_ADMA from bool to > tristate > > This driver currently uses modular infrastructure but is controlled > by a bool Kconfig. > > There is a general consensus from the DMA reviewers and maintainers > that "if it can be modular, it should be modular" in order to keep > the bzImage size under control for multi platform kernels. > > Build tested only. Also needs some new pm_clk symbols exported > before this commit is applied to tree in order to avoid modpost > errors like: > > ERROR: "pm_clk_add_clk" [drivers/dma/tegra210-adma.ko] undefined! > ERROR: "pm_clk_create" [drivers/dma/tegra210-adma.ko] undefined! > ERROR: "pm_clk_destroy" [drivers/dma/tegra210-adma.ko] undefined! > ERROR: "pm_clk_suspend" [drivers/dma/tegra210-adma.ko] undefined! > ERROR: "pm_clk_resume" [drivers/dma/tegra210-adma.ko] undefined! > > Cc: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > Cc: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > Cc: Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> > Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Cc: Alexandre Courbot <gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Cc: dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Signed-off-by: Paul Gortmaker <paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> > --- > drivers/dma/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig > index 8c98779a12b1..866068d84ca2 100644 > --- a/drivers/dma/Kconfig > +++ b/drivers/dma/Kconfig > @@ -468,7 +468,7 @@ config TEGRA20_APB_DMA > or vice versa. It does not support memory to memory data transfer. > > config TEGRA210_ADMA > - bool "NVIDIA Tegra210 ADMA support" > + tristate "NVIDIA Tegra210 ADMA support" > depends on ARCH_TEGRA_210_SOC > select DMA_ENGINE > select DMA_VIRTUAL_CHANNELS Thanks! FWIW ... Acked-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Cheers Jon -- nvpublic ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-07-04 13:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-03 17:30 [PATCH v2 0/4] bus: remove unused modular code from non-modular drivers Paul Gortmaker
[not found] ` <20160703173040.23612-1-paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2016-07-03 17:30 ` [PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular Paul Gortmaker
2016-07-04 9:17 ` Jon Hunter
2016-07-04 13:41 ` Paul Gortmaker
[not found] ` <20160704134123.GV26134-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2016-07-04 13:47 ` Jon Hunter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).