[PATCH v2 7/8] iio: core: Move initcalls closer to the respective calls

Andy Shevchenko posted 8 patches 2 years, 6 months ago
There is a newer version of this series
[PATCH v2 7/8] iio: core: Move initcalls closer to the respective calls
Posted by Andy Shevchenko 2 years, 6 months ago
Move subsys_initcall() and module_exit() closer to the respective calls.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/industrialio-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a9b9804097ab..5c9c68d69fc6 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -354,6 +354,7 @@ static int __init iio_init(void)
 error_nothing:
 	return ret;
 }
+subsys_initcall(iio_init);
 
 static void __exit iio_exit(void)
 {
@@ -362,6 +363,7 @@ static void __exit iio_exit(void)
 	bus_unregister(&iio_bus_type);
 	debugfs_remove(iio_debugfs_dentry);
 }
+module_exit(iio_exit);
 
 #if defined(CONFIG_DEBUG_FS)
 static ssize_t iio_debugfs_read_reg(struct file *file, char __user *userbuf,
@@ -2118,9 +2120,6 @@ int iio_device_get_current_mode(struct iio_dev *indio_dev)
 }
 EXPORT_SYMBOL_GPL(iio_device_get_current_mode);
 
-subsys_initcall(iio_init);
-module_exit(iio_exit);
-
 MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
 MODULE_DESCRIPTION("Industrial I/O core");
 MODULE_LICENSE("GPL");
-- 
2.40.0.1.gaa8946217a0b
Re: [PATCH v2 7/8] iio: core: Move initcalls closer to the respective calls
Posted by Jonathan Cameron 2 years, 6 months ago
On Fri, 21 Jul 2023 20:00:21 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Move subsys_initcall() and module_exit() closer to the respective calls.

Why? For this particular set of macros I can see advantages to them being
near the code and to them being in a fairly predictable location (end of
file).

I think the patch description should make the why argument. 

Jonathan


> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> ---
>  drivers/iio/industrialio-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index a9b9804097ab..5c9c68d69fc6 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -354,6 +354,7 @@ static int __init iio_init(void)
>  error_nothing:
>  	return ret;
>  }
> +subsys_initcall(iio_init);
>  
>  static void __exit iio_exit(void)
>  {
> @@ -362,6 +363,7 @@ static void __exit iio_exit(void)
>  	bus_unregister(&iio_bus_type);
>  	debugfs_remove(iio_debugfs_dentry);
>  }
> +module_exit(iio_exit);
>  
>  #if defined(CONFIG_DEBUG_FS)
>  static ssize_t iio_debugfs_read_reg(struct file *file, char __user *userbuf,
> @@ -2118,9 +2120,6 @@ int iio_device_get_current_mode(struct iio_dev *indio_dev)
>  }
>  EXPORT_SYMBOL_GPL(iio_device_get_current_mode);
>  
> -subsys_initcall(iio_init);
> -module_exit(iio_exit);
> -
>  MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
>  MODULE_DESCRIPTION("Industrial I/O core");
>  MODULE_LICENSE("GPL");
Re: [PATCH v2 7/8] iio: core: Move initcalls closer to the respective calls
Posted by Andy Shevchenko 2 years, 6 months ago
On Sun, Jul 23, 2023 at 10:23:35AM +0100, Jonathan Cameron wrote:
> On Fri, 21 Jul 2023 20:00:21 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
> > Move subsys_initcall() and module_exit() closer to the respective calls.
> 
> Why? For this particular set of macros I can see advantages to them being
> near the code and to them being in a fairly predictable location (end of
> file).
> 
> I think the patch description should make the why argument. 

The documented case is about exported symbols.
Now I looked for the module_*() stuff and there is no consensus
between subsystems. Both styles are being documented and used.

I think I may drop this. Someone also can investigate the trends,
but I won't spend my time on this.

Thank you for the review.

-- 
With Best Regards,
Andy Shevchenko