staging: make non-modular code explicitly non-modular
Subsystems (2)
cover staging: make non-modular code explicitly non-modular
[resending; forgot to add lkml to Cc: -- sorry for those who get this 2x]
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.
There are two exceptions to unchanged runtime here: The first is in emxx_udc.c driver: one previously could use sysfs to unbind the driver which would try and use a .remove function that the linker should have dropped as it was __exit. We simply disable unbind/bind for this driver. The second is for Tegra ION memory manager; it clearly was intended to be tristate but the makefile did not allow it to be; that is now fixed.
Build tested on staging-testing from Sat, on ARM, since the majority of drivers here are Android related.
Paul.
--
Signature · 26 lines
2.6.1 Paul Gortmaker (7): drivers/staging: make android ashmem.c explicitly non-modular drivers/staging: make android ion_page_pool.c explicitly non-modular drivers/staging: make android tegra_ion.c properly tristate drivers/staging: make android sw_sync.c explicitly non-modular drivers/staging: make android lowmemorykiller.c explicitly non-modular drivers/staging: make android timed_output.c explicitly non-modular drivers/staging: make emxx_udc.c explicitly non-modular drivers/staging/android/ashmem.c | 20 +++------------- drivers/staging/android/ion/ion_page_pool.c | 10 ++------ drivers/staging/android/ion/tegra/Makefile | 2 +- drivers/staging/android/lowmemorykiller.c | 18 ++++++-------- drivers/staging/android/sw_sync.c | 11 ++------- drivers/staging/android/timed_output.c | 16 +++---------- drivers/staging/emxx_udc/emxx_udc.c | 37 ++++------------------------- 7 files changed, 22 insertions(+), 92 deletions(-) -- 2.6.1 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 1/7 drivers/staging: make android ashmem.c explicitly non-modular
The Kconfig currently controlling compilation of this code is:
drivers/staging/android/Kconfig:config ASHMEMdrivers/staging/android/Kconfig: bool "Enable the Anonymous Shared Memory Subsystem"
...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.
Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.
We replace module.h with init.h and export.h ; the latter since this file uses the global THIS_MODULE.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/staging/android/ashmem.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/staging/android/ashmem.c +3 -17
@@ -18,7 +18,8 @@#define pr_fmt (fmt) "ashmem: " fmt -#include <linux/module.h> +#include <linux/init.h> +#include <linux/export.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/falloc.h>
@@ -860,19 +861,4 @@ static int __init ashmem_init(void)return 0 ; } - -static void __exit ashmem_exit(void) -{ -unregister_shrinker (&ashmem_shrinker); - -misc_deregister (&ashmem_misc); -kmem_cache_destroy (ashmem_range_cachep); -kmem_cache_destroy (ashmem_area_cachep); - -pr_info ("unloaded\n" ); -} - -module_init (ashmem_init); -module_exit (ashmem_exit); - -MODULE_LICENSE ("GPL" ); +device_initcall (ashmem_init);
Signature · 1 line
2.6.1
PATCH 2/7 drivers/staging: make android ion_page_pool.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/staging/android/ion/Kconfig:menuconfig IONdrivers/staging/android/ion/Kconfig: bool "Ion Memory Manager"
...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.
Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.
--- drivers/staging/android/ion/ion_page_pool.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/staging/android/ion/ion_page_pool.c +2 -8
@@ -19,7 +19,7 @@#include <linux/err.h> #include <linux/fs.h> #include <linux/list.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/swap.h> #include "ion_priv.h"
@@ -174,10 +174,4 @@ static int __init ion_page_pool_init(void) {return 0 ; } - -static void __exit ion_page_pool_exit(void) -{ -} - -module_init (ion_page_pool_init); -module_exit (ion_page_pool_exit); +device_initcall (ion_page_pool_init);
Signature · 1 line
2.6.1
PATCH 3/7 drivers/staging: make android tegra_ion.c properly tristate
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/staging/android/ion/Kconfig:config ION_TEGRAdrivers/staging/android/ion/Kconfig: tristate "Ion for Tegra"
...which led me to incorrectly conclude this file was built modular earlier. However the above CONFIG is just used to enter the dir and once we do enter that dir, we see the build is unconditional:
drivers/staging/android/ion/Makefile:obj-$(CONFIG_ION_TEGRA) += tegra/ drivers/staging/android/ion/tegra/Makefile:obj-y += tegra_ion.o
...meaning that it currently is not being built as a module by anyone.
However, given that the Kconfig did explicitly choose tristate, and that the dummy ion driver is (functionally) tristate, I chose to make the Makefile do the right thing for it to build as a module.
After this change, on an ARM allmodconfig, we see:
CC [M] drivers/staging/android/ion/tegra/tegra_ion.o
so it does build OK as a module. I can't vouch for the modular functionality however, so consider this compile tested only.
--- drivers/staging/android/ion/tegra/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/android/ion/tegra/Makefile +1 -1
@@ -1 +1 @@ -obj-y += tegra_ion.o +obj-$(CONFIG_ION_TEGRA) += tegra_ion.o
Signature · 6 lines
2.6.1 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 4/7 drivers/staging: make android sw_sync.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
staging/android/Kconfig:config SW_SYNC
staging/android/Kconfig: bool "Software synchronization objects"
...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.
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 is already contained at the top of the file in the comments.
--- drivers/staging/android/sw_sync.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/staging/android/sw_sync.c +2 -9
@@ -15,11 +15,11 @@*/ #include <linux/kernel.h> +#include <linux/init.h> #include <linux/export.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/miscdevice.h> -#include <linux/module.h> #include <linux/syscalls.h> #include <linux/uaccess.h>
@@ -255,13 +255,6 @@ static int __init sw_sync_device_init(void) {return misc_register (&sw_sync_dev); } - -static void __exit sw_sync_device_remove(void) -{ -misc_deregister (&sw_sync_dev); -} - -module_init (sw_sync_device_init); -module_exit (sw_sync_device_remove); +device_initcall (sw_sync_device_init);#endif /* CONFIG_SW_SYNC_USER */
Signature · 1 line
2.6.1
PATCH 5/7 drivers/staging: make android lowmemorykiller.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/staging/android/Kconfig:config ANDROID_LOW_MEMORY_KILLERdrivers/staging/android/Kconfig: bool "Android Low Memory Killer"
...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.
Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.
We replace module.h with init.h and moduleparam.h ; the latter since this file was previously implicitly relying on getting that header.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/staging/android/lowmemorykiller.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/staging/android/lowmemorykiller.c +7 -11
@@ -32,7 +32,8 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#include <linux/module.h> +#include <linux/init.h> +#include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/oom.h>
@@ -190,12 +191,12 @@ static int __init lowmem_init(void)register_shrinker (&lowmem_shrinker);return 0 ; } +device_initcall (lowmem_init); -static void __exit lowmem_exit(void) -{ -unregister_shrinker (&lowmem_shrinker); -} - +/* +* not really modular, but the easiest way to keep compat with existing +* bootargs behaviour is to continue using module_param here. +*/ module_param_named (cost, lowmem_shrinker.seeks, int,S_IRUGO |S_IWUSR );module_param_array_named (adj, lowmem_adj, short, &lowmem_adj_size,S_IRUGO |S_IWUSR );
@@ -203,8 +204,3 @@ module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size, S_IRUGO | S_IWUSR);module_param_named (debug_level, lowmem_debug_level, uint,S_IRUGO |S_IWUSR ); -module_init (lowmem_init); -module_exit (lowmem_exit); - -MODULE_LICENSE ("GPL" ); -
Signature · 1 line
2.6.1
PATCH 6/7 drivers/staging: make android timed_output.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/staging/android/Kconfig:config ANDROID_TIMED_OUTPUTdrivers/staging/android/Kconfig: bool "Timed output class 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.
Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.
We replace module.h with init.h and export.h ; the latter since this file does actually export some symbols.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/staging/android/timed_output.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/staging/android/timed_output.c +3 -13
@@ -16,7 +16,8 @@#define pr_fmt (fmt) "timed_output: " fmt -#include <linux/module.h> +#include <linux/init.h> +#include <linux/export.h> #include <linux/types.h> #include <linux/device.h> #include <linux/fs.h>
@@ -106,15 +107,4 @@ static int __init timed_output_init(void) {return create_timed_output_class (); } - -static void __exit timed_output_exit(void) -{ -class_destroy (timed_output_class); -} - -module_init (timed_output_init); -module_exit (timed_output_exit); - -MODULE_AUTHOR ("Mike Lockwood <[email protected]>" ); -MODULE_DESCRIPTION ("timed output class driver" ); -MODULE_LICENSE ("GPL" ); +device_initcall (timed_output_init);
Signature · 1 line
2.6.1
PATCH 7/7 drivers/staging: make emxx_udc.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/staging/emxx_udc/Kconfig:config USB_EMXXdrivers/staging/emxx_udc/Kconfig: bool "EMXX USB Function Device Controller"
...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.
Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.
The .remove function was declared __exit, so it wouldn't have been available for a sysfs bind/unbind anyway, so lets be explicit here and use ".suppress_bind_attrs = true" to prevent root from doing something silly.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/staging/emxx_udc/emxx_udc.c | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +4 -33
@@ -15,7 +15,7 @@*/ #include <linux/kernel.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/ioport.h>
@@ -40,11 +40,9 @@#include "emxx_udc.h" -#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0)static const char driver_name[] ="emxx_udc" ; -static const char driver_desc[] =DRIVER_DESC ;/*===========================================================================*/ /* Prototype */
@@ -3321,28 +3319,6 @@ static void nbu2ss_drv_shutdown(struct platform_device *pdev) }/*-------------------------------------------------------------------------*/ -static int __exit nbu2ss_drv_remove(struct platform_device *pdev) -{ -struct nbu2ss_udc *udc; -struct nbu2ss_ep *ep; -int i; - - udc = &udc_controller; - -for (i =0 ; i <NUM_ENDPOINTS ; i++) { - ep = &udc->ep[i]; -if (ep->virt_buf) -dma_free_coherent (NULL ,PAGE_SIZE , - (void *)ep->virt_buf, ep->phys_buf); - } - -/* Interrupt Handler - Release */ -free_irq (INT_VBUS , udc); - -return 0 ; -} - -/*-------------------------------------------------------------------------*/ static int nbu2ss_drv_suspend (struct platform_device *pdev,pm_message_t state) {struct nbu2ss_udc *udc;
@@ -3394,17 +3370,12 @@ static int nbu2ss_drv_resume(struct platform_device *pdev)static struct platform_driver udc_driver = { .probe = nbu2ss_drv_probe, .shutdown = nbu2ss_drv_shutdown, - .remove =__exit_p (nbu2ss_drv_remove), .suspend = nbu2ss_drv_suspend, .resume = nbu2ss_drv_resume, .driver = { - .name = driver_name, + .name = driver_name, + .suppress_bind_attrs = true, }, }; -module_platform_driver (udc_driver); - -MODULE_DESCRIPTION (DRIVER_DESC ); -MODULE_AUTHOR ("Renesas Electronics Corporation" ); -MODULE_LICENSE ("GPL" ); - +builtin_platform_driver (udc_driver);
Signature · 1 line
2.6.1