drivers/mfd: make max drivers explicitly non-modular
cover drivers/mfd: make max drivers explicitly non-modular
For anyone new to the underlying goal of this cleanup, we are trying to make driver code consistent with the Makefiles/Kconfigs that control them.
This means not using modular functions/macros for drivers that can never be built as a module. Some of the other downfalls this leads to are:
(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 drivers and spreads like weeds.
There are quite a few in the mfd space, so rather than send a large series, I'll try and batch them up into reasonable sized queues. To that end, here we fix up all the maxim drivers as the 1st mfd batch.
As always, the option exists for someone with the hardware and the desire to extend the functionality to make any given driver tristate. But given the number of these tree wide and the fact that I can't test that new extended functionality in all cases, I just make the code consistent with the existing Kconfig/Makefile settings that restrict them to "bool".
Build tested on linux-next for arm, arm64 and x86-64 to ensure no typos or similar issues crept in.
Paul.
---
Paul Gortmaker (7):
drivers/mfd: make max8925-i2c.c explicitly non-modular drivers/mfd: make max8997.c explicitly non-modular drivers/mfd: make max8998.c explicitly non-modular drivers/mfd: make max14577.c explicitly non-modular drivers/mfd: make max77686.c explicitly non-modular drivers/mfd: make max77693.c explicitly non-modular drivers/mfd: make max77843.c explicitly non-modular
drivers/mfd/max14577.c | 13 +------------ drivers/mfd/max77686.c | 26 ++------------------------ drivers/mfd/max77693.c | 34 +++------------------------------- drivers/mfd/max77843.c | 24 ++---------------------- drivers/mfd/max8925-i2c.c | 14 +------------- drivers/mfd/max8997.c | 30 +++--------------------------- drivers/mfd/max8998.c | 27 +-------------------------- 7 files changed, 13 insertions(+), 155 deletions(-)
Signature · 1 line
2.8.0
PATCH 1/7 drivers/mfd: make max8925-i2c.c explicitly non-modular
The Kconfig currently controlling compilation of this code is:
drivers/mfd/Kconfig: config MFD_MAX8925drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX8925 PMIC Support"
...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 was not in use by this code, 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 is already contained at the top of the file in the comments.
--- drivers/mfd/max8925-i2c.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/mfd/max8925-i2c.c +1 -13
@@ -9,7 +9,7 @@* published by the Free Software Foundation. */ #include <linux/kernel.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/mfd/max8925.h>
@@ -133,7 +133,6 @@ static const struct i2c_device_id max8925_id_table[] = { { "max8925", 0 }, { }, }; -MODULE_DEVICE_TABLE (i2c, max8925_id_table);static int max8925_dt_init (struct device_node *np,struct device *dev,struct max8925_platform_data *pdata)
@@ -240,7 +239,6 @@ static const struct of_device_id max8925_dt_ids[] = { { .compatible = "maxim,max8925", }, {}, }; -MODULE_DEVICE_TABLE (of, max8925_dt_ids);static struct i2c_driver max8925_driver = { .driver = {
@@ -264,13 +262,3 @@ static int __init max8925_i2c_init(void)return ret; }subsys_initcall (max8925_i2c_init); - -static void __exit max8925_i2c_exit(void) -{ -i2c_del_driver (&max8925_driver); -} -module_exit (max8925_i2c_exit); - -MODULE_DESCRIPTION ("I2C Driver for Maxim 8925" ); -MODULE_AUTHOR ("Haojian Zhuang <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Signature · 1 line
2.8.0
PATCH 2/7 drivers/mfd: make max8997.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/mfd/Kconfig:config MFD_MAX8997drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX8997/8966 PMIC Support"
...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_init was not in use by this code, 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 is already contained at the top of the file in the comments.
--- drivers/mfd/max8997.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
drivers/mfd/max8997.c +3 -27
@@ -2,7 +2,7 @@* max8997.c - mfd core driver for the Maxim 8966 and 8997 * * Copyright (C) 2011 Samsung Electronics -* MyungJoo Ham <[email protected]> +* MyungJoo Ham <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@#include <linux/of_irq.h> #include <linux/interrupt.h> #include <linux/pm_runtime.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/mutex.h> #include <linux/mfd/core.h> #include <linux/mfd/max8997.h>
@@ -55,7 +55,6 @@ static const struct of_device_id max8997_pmic_dt_match[] = { { .compatible = "maxim,max8997-pmic", .data = (void *)TYPE_MAX8997 }, {}, }; -MODULE_DEVICE_TABLE (of, max8997_pmic_dt_match);#endif int max8997_read_reg (struct i2c_client *i2c,u8 reg,u8 *dest)
@@ -263,24 +262,11 @@ err_i2c_haptic:return ret; } -static int max8997_i2c_remove (struct i2c_client *i2c) -{ -struct max8997_dev *max8997 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max8997->dev); -i2c_unregister_device (max8997->muic); -i2c_unregister_device (max8997->haptic); -i2c_unregister_device (max8997->rtc); - -return 0 ; -} -static const struct i2c_device_id max8997_i2c_id[] = { {"max8997" ,TYPE_MAX8997 }, {"max8966" ,TYPE_MAX8966 }, { } }; -MODULE_DEVICE_TABLE (i2c, max8998_i2c_id);static u8 max8997_dumpaddr_pmic[] = {MAX8997_REG_INT1MSK ,
@@ -510,10 +496,10 @@ static struct i2c_driver max8997_i2c_driver = { .driver = { .name = "max8997", .pm = &max8997_pm, + .suppress_bind_attrs = true, .of_match_table = of_match_ptr(max8997_pmic_dt_match), }, .probe = max8997_i2c_probe, - .remove = max8997_i2c_remove, .id_table = max8997_i2c_id, };
@@ -523,13 +509,3 @@ static int __init max8997_i2c_init(void) }/* init early so consumer devices can complete system boot */ subsys_initcall (max8997_i2c_init); - -static void __exit max8997_i2c_exit(void) -{ -i2c_del_driver (&max8997_i2c_driver); -} -module_exit (max8997_i2c_exit); - -MODULE_DESCRIPTION ("MAXIM 8997 multi-function core driver" ); -MODULE_AUTHOR ("MyungJoo Ham <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Signature · 1 line
2.8.0
PATCH 3/7 drivers/mfd: make max8998.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
mfd/Kconfig:config MFD_MAX8998
mfd/Kconfig: bool "Maxim Semiconductor MAX8998/National LP3974 PMIC Support"
...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_init was not in use by this code, the init ordering remains unchanged with this commit.
We delete the include of module.h as well as an unused include of moduleparam.h too.
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.
--- drivers/mfd/max8998.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-)
drivers/mfd/max8998.c +1 -26
@@ -21,8 +21,6 @@*/ #include <linux/err.h> -#include <linux/module.h> -#include <linux/moduleparam.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h>
@@ -138,7 +136,6 @@ static const struct of_device_id max8998_dt_match[] = { { .compatible = "ti,lp3974", .data = (void *)TYPE_LP3974 }, {}, }; -MODULE_DEVICE_TABLE (of, max8998_dt_match);#endif /*
@@ -254,23 +251,11 @@ err:return ret; } -static int max8998_i2c_remove (struct i2c_client *i2c) -{ -struct max8998_dev *max8998 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max8998->dev); -max8998_irq_exit (max8998); -i2c_unregister_device (max8998->rtc); - -return 0 ; -} -static const struct i2c_device_id max8998_i2c_id[] = { {"max8998" ,TYPE_MAX8998 }, {"lp3974" ,TYPE_LP3974 }, { } }; -MODULE_DEVICE_TABLE (i2c, max8998_i2c_id);static int max8998_suspend (struct device *dev) {
@@ -378,10 +363,10 @@ static struct i2c_driver max8998_i2c_driver = { .driver = { .name = "max8998", .pm = &max8998_pm, + .suppress_bind_attrs = true, .of_match_table = of_match_ptr(max8998_dt_match), }, .probe = max8998_i2c_probe, - .remove = max8998_i2c_remove, .id_table = max8998_i2c_id, };
@@ -391,13 +376,3 @@ static int __init max8998_i2c_init(void) }/* init early so consumer devices can complete system boot */ subsys_initcall (max8998_i2c_init); - -static void __exit max8998_i2c_exit(void) -{ -i2c_del_driver (&max8998_i2c_driver); -} -module_exit (max8998_i2c_exit); - -MODULE_DESCRIPTION ("MAXIM 8998 multi-function core driver" ); -MODULE_AUTHOR ("Kyungmin Park <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Signature · 1 line
2.8.0
PATCH 4/7 drivers/mfd: make max14577.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
mfd/Kconfig:config MFD_MAX14577
mfd/Kconfig: bool "Maxim Semiconductor MAX14577/77836 MUIC + Charger Support"
...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 was not in use by this code, 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 is already contained at the top of the file in the comments.
--- drivers/mfd/max14577.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/mfd/max14577.c +1 -12
@@ -19,7 +19,7 @@*/ #include <linux/err.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/interrupt.h> #include <linux/of_device.h> #include <linux/mfd/core.h>
@@ -490,7 +490,6 @@ static const struct i2c_device_id max14577_i2c_id[] = { { "max77836", MAXIM_DEVICE_TYPE_MAX77836, }, { } }; -MODULE_DEVICE_TABLE (i2c, max14577_i2c_id);#ifdef CONFIG_PM_SLEEP static int max14577_suspend (struct device *dev)
@@ -562,13 +561,3 @@ static int __init max14577_i2c_init(void)return i2c_add_driver (&max14577_i2c_driver); }subsys_initcall (max14577_i2c_init); - -static void __exit max14577_i2c_exit(void) -{ -i2c_del_driver (&max14577_i2c_driver); -} -module_exit (max14577_i2c_exit); - -MODULE_AUTHOR ("Chanwoo Choi <[email protected]>, Krzysztof Kozlowski <[email protected]>" ); -MODULE_DESCRIPTION ("Maxim 14577/77836 multi-function core driver" ); -MODULE_LICENSE ("GPL" );
Signature · 1 line
2.8.0
Re: [PATCH 4/7] drivers/mfd: make max14577.c explicitly non-modular
Quoted 18 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:mfd/Kconfig:config
MFD_MAX14577
mfd/Kconfig: bool "Maxim Semiconductor MAX14577/77836 MUIC + Charger Support"...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_initwas not in use by this code, the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.
Quoted 8 lines
Cc Chanwoo Choi <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Lee Jones <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- drivers/mfd/max14577.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
+Cc Javier,
In general I agree with the patchset except maybe here because it conflicts with Javier's work to make it a module:
mfd: max14577: Use module_init() instead of subsys_initcall()
http://www.spinics.net/lists/kernel/msg2213747.html
Javier's patchset is however missing a tested-by tag so maybe this is why it was not merged.
Unfortunately I cannot provide testing because my current device with max14577/max77836 is dead and its recovery is not easy. Maybe I will get a proper device in a few weeks after going back to Poland.
My proposal would be to wait with this max14577 change a little bit.
Best regards,
Krzysztof
Re: [PATCH 4/7] drivers/mfd: make max14577.c explicitly non-modular
Quoted 7 lines · [Re: [PATCH 4/7] drivers/mfd: make max14577.c explicitly non-modular] On…
Quoted 6 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:mfd/Kconfig:config
MFD_MAX14577
mfd/Kconfig: bool "Maxim Semiconductor MAX14577/77836 MUIC + Charger Support"...meaning that it currently is not being built as a module by anyone.
[...]
Quoted 10 lines
Quoted 3 lines
--- drivers/mfd/max14577.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)+Cc Javier,
In general I agree with the patchset except maybe here because it conflicts with Javier's work to make it a module:
mfd: max14577: Usemodule_init()instead ofsubsys_initcall()
http://www.spinics.net/lists/kernel/msg2213747.html
No problem, I'll shelf this one as well and assume it is on the way to being tristate.
Thanks,
Paul.
--
Quoted 12 lines
Javier's patchset is however missing a tested-by tag so maybe this is why it was not merged.
Unfortunately I cannot provide testing because my current device with max14577/max77836 is dead and its recovery is not easy. Maybe I will get a proper device in a few weeks after going back to Poland.
My proposal would be to wait with this max14577 change a little bit.
Best regards,
Krzysztof
Re: [PATCH 4/7] drivers/mfd: make max14577.c explicitly non-modular
In reply to Krzysztof KozlowskiHello Krzysztof,
Quoted 35 lines · Krzysztof Kozlowski
Quoted 18 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:mfd/Kconfig:config
MFD_MAX14577
mfd/Kconfig: bool "Maxim Semiconductor MAX14577/77836 MUIC + Charger Support"...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_initwas not in use by this code, the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.Quoted 8 lines
Cc Chanwoo Choi <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Lee Jones <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- drivers/mfd/max14577.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)+Cc Javier,
In general I agree with the patchset except maybe here because it conflicts with Javier's work to make it a module:
mfd: max14577: Usemodule_init()instead ofsubsys_initcall()
http://www.spinics.net/lists/kernel/msg2213747.html
Quoted 9 lines
Javier's patchset is however missing a tested-by tag so maybe this is why it was not merged.
Unfortunately I cannot provide testing because my current device with max14577/max77836 is dead and its recovery is not easy. Maybe I will get a proper device in a few weeks after going back to Poland.
My proposal would be to wait with this max14577 change a little bit.
Chanwoo said he should be able to test: https://lkml.org/lkml/2016/3/18/78
So hopefully I should have some Tested-by tags for that series soon.
Quoted 3 lines
Best regards,
Krzysztof
Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America
PATCH 5/7 drivers/mfd: make max77686.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/mfd/Kconfig:config MFD_MAX77686drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77686/802 PMIC Support"
...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_init was not in use by this code, 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 is already contained at the top of the file in the comments.
--- drivers/mfd/max77686.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)
drivers/mfd/max77686.c +2 -24
@@ -28,7 +28,7 @@#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/pm_runtime.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/mfd/core.h> #include <linux/mfd/max77686.h> #include <linux/mfd/max77686-private.h>
@@ -253,23 +253,11 @@ err_del_irqc:return ret; } -static int max77686_i2c_remove (struct i2c_client *i2c) -{ -struct max77686_dev *max77686 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max77686->dev); - -regmap_del_irq_chip (max77686->irq, max77686->irq_data); - -return 0 ; -} -static const struct i2c_device_id max77686_i2c_id[] = { {"max77686" ,TYPE_MAX77686 }, {"max77802" ,TYPE_MAX77802 }, { } }; -MODULE_DEVICE_TABLE (i2c, max77686_i2c_id);#ifdef CONFIG_PM_SLEEP static int max77686_suspend (struct device *dev)
@@ -314,10 +302,10 @@ static struct i2c_driver max77686_i2c_driver = { .driver = { .name = "max77686", .pm = &max77686_pm, + .suppress_bind_attrs = true, .of_match_table = of_match_ptr(max77686_pmic_dt_match), }, .probe = max77686_i2c_probe, - .remove = max77686_i2c_remove, .id_table = max77686_i2c_id, };
@@ -327,13 +315,3 @@ static int __init max77686_i2c_init(void) }/* init early so consumer devices can complete system boot */ subsys_initcall (max77686_i2c_init); - -static void __exit max77686_i2c_exit(void) -{ -i2c_del_driver (&max77686_i2c_driver); -} -module_exit (max77686_i2c_exit); - -MODULE_DESCRIPTION ("MAXIM 77686/802 multi-function core driver" ); -MODULE_AUTHOR ("Chiwoong Byun <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Signature · 1 line
2.8.0
Re: [PATCH 5/7] drivers/mfd: make max77686.c explicitly non-modular
Quoted 22 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/mfd/Kconfig:config
MFD_MAX77686drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77686/802 PMIC Support"...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_initwas not in use by this code, the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.
Quoted 8 lines
Cc Chanwoo Choi <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Lee Jones <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- drivers/mfd/max77686.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)
+Cc Javier,
I think we want to proceed with Javier's work for max77686:
mfd: max77686: Allow the driver to be built as a module
http://lkml.iu.edu/hypermail/linux/kernel/1602.1/03921.html
Javier, what is the status of your patchset? What do you need?
Best regards,
Krzysztof
Re: [PATCH 5/7] drivers/mfd: make max77686.c explicitly non-modular
Quoted 8 lines · [Re: [PATCH 5/7] drivers/mfd: make max77686.c explicitly non-modular] On…
Quoted 7 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/mfd/Kconfig:config
MFD_MAX77686drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77686/802 PMIC Support"...meaning that it currently is not being built as a module by anyone.
[...]
Quoted 9 lines
Quoted 3 lines
--- drivers/mfd/max77686.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)+Cc Javier,
I think we want to proceed with Javier's work for max77686:
mfd: max77686: Allow the driver to be built as a module
http://lkml.iu.edu/hypermail/linux/kernel/1602.1/03921.html
Not a problem ; I'll shelf this patch and assume it will make the move to tristate. Thanks for the heads up on the conversion in progress.
Paul.
--
Quoted 5 lines
Javier, what is the status of your patchset? What do you need?
Best regards,
Krzysztof
Re: [PATCH 5/7] drivers/mfd: make max77686.c explicitly non-modular
In reply to Krzysztof KozlowskiHello Krzysztof,
Quoted 32 lines · Krzysztof Kozlowski
Quoted 22 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/mfd/Kconfig:config
MFD_MAX77686drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77686/802 PMIC Support"...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_initwas not in use by this code, the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.Quoted 8 lines
Cc Chanwoo Choi <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Lee Jones <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- drivers/mfd/max77686.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)
Quoted 8 lines
+Cc Javier,
I think we want to proceed with Javier's work for max77686:
mfd: max77686: Allow the driver to be built as a module
http://lkml.iu.edu/hypermail/linux/kernel/1602.1/03921.htmlJavier, what is the status of your patchset? What do you need?
All patches but the one getting rid of the subsys initcall were already picked by Lee.
I was waiting for the exynos thermal [0] patch that adds probe deferral support to land into mainline to resend that one. The patch is already in mainline so I'll do it today after testing.
Quoted 3 lines
Best regards,
Krzysztof
[0]: https://lkml.org/lkml/2016/2/18/592
Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America
PATCH 6/7 drivers/mfd: make max77693.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/mfd/Kconfig:config MFD_MAX77693drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77693 PMIC Support"
...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_init was not in use by this code, 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 contained at the top of the file in the comments.
--- drivers/mfd/max77693.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-)
drivers/mfd/max77693.c +3 -31
@@ -2,7 +2,7 @@* max77693.c - mfd core driver for the MAX 77693 * * Copyright (C) 2012 Samsung Electronics -* SangYoung Son <[email protected]> +* SangYoung Son <[email protected]> * * This program is not provided / owned by Maxim Integrated Products. *
@@ -23,7 +23,7 @@* This driver is based on max8997.c */ -#include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/err.h>
@@ -309,28 +309,10 @@ err_i2c_haptic:return ret; } -static int max77693_i2c_remove (struct i2c_client *i2c) -{ -struct max77693_dev *max77693 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max77693->dev); - -regmap_del_irq_chip (max77693->irq, max77693->irq_data_muic); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_chg); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_topsys); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_led); - -i2c_unregister_device (max77693->i2c_muic); -i2c_unregister_device (max77693->i2c_haptic); - -return 0 ; -} -static const struct i2c_device_id max77693_i2c_id[] = { {"max77693" ,TYPE_MAX77693 }, { } }; -MODULE_DEVICE_TABLE (i2c, max77693_i2c_id);static int max77693_suspend (struct device *dev) {
@@ -374,10 +356,10 @@ static struct i2c_driver max77693_i2c_driver = { .driver = { .name = "max77693", .pm = &max77693_pm, + .suppress_bind_attrs = true, .of_match_table = of_match_ptr(max77693_dt_match), }, .probe = max77693_i2c_probe, - .remove = max77693_i2c_remove, .id_table = max77693_i2c_id, };
@@ -387,13 +369,3 @@ static int __init max77693_i2c_init(void) }/* init early so consumer devices can complete system boot */ subsys_initcall (max77693_i2c_init); - -static void __exit max77693_i2c_exit(void) -{ -i2c_del_driver (&max77693_i2c_driver); -} -module_exit (max77693_i2c_exit); - -MODULE_DESCRIPTION ("MAXIM 77693 multi-function core driver" ); -MODULE_AUTHOR ("SangYoung, Son <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Signature · 1 line
2.8.0
Re: [PATCH 6/7] drivers/mfd: make max77693.c explicitly non-modular
Quoted 36 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/mfd/Kconfig:config
MFD_MAX77693drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77693 PMIC Support"...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_initwas not in use by this code, the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We also delete the
MODULE_LICENSEtag etc. since all that information was contained at the top of the file in the comments.Cc Chanwoo Choi <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Samuel Ortiz <[email protected]>Cc Lee Jones <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- drivers/mfd/max77693.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-)drivers/mfd/max77693.c +0
-0
drivers/mfd/max77693.c line 6
Quoted 6 lines
drivers/mfd/max77693.c +1
-1@@ -2,7 +2,7 @@* max77693.c - mfd core driver for the MAX 77693 * * Copyright (C) 2012 Samsung Electronics -* SangYoung Son <[email protected]> +* SangYoung Son <[email protected]> *
That's good change.
As for the rest, I think the driver can be switch to module. Consumer (phy-samsung-usb2) support deferred probing. I can prepare and test a patch for that.
Best regards,
Krzysztof
Quoted 67 lines
drivers/mfd/max77693.c +2
-30* This program is not provided / owned by Maxim Integrated Products. * @@ -23,7 +23,7 @@* This driver is based on max8997.c */ -#include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/err.h> @@ -309,28 +309,10 @@ err_i2c_haptic:return ret; } -static int max77693_i2c_remove (struct i2c_client *i2c) -{ -struct max77693_dev *max77693 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max77693->dev); - -regmap_del_irq_chip (max77693->irq, max77693->irq_data_muic); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_chg); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_topsys); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_led); - -i2c_unregister_device (max77693->i2c_muic); -i2c_unregister_device (max77693->i2c_haptic); - -return 0 ; -} -static const struct i2c_device_id max77693_i2c_id[] = { {"max77693" ,TYPE_MAX77693 }, { } }; -MODULE_DEVICE_TABLE (i2c, max77693_i2c_id);static int max77693_suspend (struct device *dev) {@@ -374,10 +356,10 @@ static struct i2c_driver max77693_i2c_driver = { .driver = { .name = "max77693", .pm = &max77693_pm, + .suppress_bind_attrs = true, .of_match_table = of_match_ptr(max77693_dt_match), }, .probe = max77693_i2c_probe, - .remove = max77693_i2c_remove, .id_table = max77693_i2c_id, };@@ -387,13 +369,3 @@ static int __init max77693_i2c_init(void) }/* init early so consumer devices can complete system boot */ subsys_initcall (max77693_i2c_init); - -static void __exit max77693_i2c_exit(void) -{ -i2c_del_driver (&max77693_i2c_driver); -} -module_exit (max77693_i2c_exit); - -MODULE_DESCRIPTION ("MAXIM 77693 multi-function core driver" ); -MODULE_AUTHOR ("SangYoung, Son <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Re: [PATCH 6/7] drivers/mfd: make max77693.c explicitly non-modular
Quoted 1 line · [Re: [PATCH 6/7] drivers/mfd: make max77693.c explicitly non-modular] On…
On 04.04.2016 06:24, Paul Gortmaker wrote:
[...]
Quoted 5 lines
Quoted 5 lines
drivers/mfd/max77693.c +0
-0@@ -2,7 +2,7 @@
Quoted 8 lines
drivers/mfd/max77693.c line 6
Quoted 6 lines
drivers/mfd/max77693.c +1
-1* max77693.c - mfd core driver for the MAX 77693 * * Copyright (C) 2012 Samsung Electronics -* SangYoung Son <[email protected]> +* SangYoung Son <[email protected]> * That's good change.
Do you wan't to simply fold the typo fix into your patch? I don't need to carry a trivial change like that as a separate patch, nor does it warrant a "Reported-by" or anything like that.
Paul.
--
Quoted 76 lines
As for the rest, I think the driver can be switch to module. Consumer (phy-samsung-usb2) support deferred probing. I can prepare and test a patch for that.
Best regards,
KrzysztofQuoted 67 lines
drivers/mfd/max77693.c +2
-30* This program is not provided / owned by Maxim Integrated Products. * @@ -23,7 +23,7 @@* This driver is based on max8997.c */ -#include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/err.h> @@ -309,28 +309,10 @@ err_i2c_haptic:return ret; } -static int max77693_i2c_remove (struct i2c_client *i2c) -{ -struct max77693_dev *max77693 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max77693->dev); - -regmap_del_irq_chip (max77693->irq, max77693->irq_data_muic); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_chg); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_topsys); -regmap_del_irq_chip (max77693->irq, max77693->irq_data_led); - -i2c_unregister_device (max77693->i2c_muic); -i2c_unregister_device (max77693->i2c_haptic); - -return 0 ; -} -static const struct i2c_device_id max77693_i2c_id[] = { {"max77693" ,TYPE_MAX77693 }, { } }; -MODULE_DEVICE_TABLE (i2c, max77693_i2c_id);static int max77693_suspend (struct device *dev) {@@ -374,10 +356,10 @@ static struct i2c_driver max77693_i2c_driver = { .driver = { .name = "max77693", .pm = &max77693_pm, + .suppress_bind_attrs = true, .of_match_table = of_match_ptr(max77693_dt_match), }, .probe = max77693_i2c_probe, - .remove = max77693_i2c_remove, .id_table = max77693_i2c_id, };@@ -387,13 +369,3 @@ static int __init max77693_i2c_init(void) }/* init early so consumer devices can complete system boot */ subsys_initcall (max77693_i2c_init); - -static void __exit max77693_i2c_exit(void) -{ -i2c_del_driver (&max77693_i2c_driver); -} -module_exit (max77693_i2c_exit); - -MODULE_DESCRIPTION ("MAXIM 77693 multi-function core driver" ); -MODULE_AUTHOR ("SangYoung, Son <[email protected]>" ); -MODULE_LICENSE ("GPL" );
Re: [PATCH 6/7] drivers/mfd: make max77693.c explicitly non-modular
Quoted 20 lines · Paul Gortmaker
Quoted 1 line · [Re: [PATCH 6/7] drivers/mfd: make max77693.c explicitly non-modular] On…
On 04.04.2016 06:24, Paul Gortmaker wrote:
[...]
Quoted 5 lines
Quoted 5 lines
drivers/mfd/max77693.c +0
-0@@ -2,7 +2,7 @@Quoted 8 lines
drivers/mfd/max77693.c line 6
Quoted 6 lines
drivers/mfd/max77693.c +1
-1* max77693.c - mfd core driver for the MAX 77693 * * Copyright (C) 2012 Samsung Electronics -* SangYoung Son <[email protected]> +* SangYoung Son <[email protected]> * That's good change.
Quoted 3 lines
Do you wan't to simply fold the typo fix into your patch? I don't need to carry a trivial change like that as a separate patch, nor does it warrant a "Reported-by" or anything like that.
Ok, I will handle this fix. Thanks!
Best regards,
Krzysztof
PATCH 7/7 drivers/mfd: make max77843.c explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/mfd/Kconfig:config MFD_MAX77843drivers/mfd/Kconfig: bool "Maxim Semiconductor MAX77843 PMIC Support"
...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_i2c_driver() uses the same init level priority as builtin_i2c_driver() the init ordering remains unchanged with this commit.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
--- drivers/mfd/max77843.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
drivers/mfd/max77843.c +2 -22
@@ -15,7 +15,7 @@#include <linux/i2c.h> #include <linux/init.h> #include <linux/interrupt.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/mfd/core.h> #include <linux/mfd/max77693-common.h> #include <linux/mfd/max77843-private.h>
@@ -171,19 +171,6 @@ err_pmic_id:return ret; } -static int max77843_remove (struct i2c_client *i2c) -{ -struct max77693_dev *max77843 =i2c_get_clientdata (i2c); - -mfd_remove_devices (max77843->dev); - -regmap_del_irq_chip (max77843->irq, max77843->irq_data_topsys); - -i2c_unregister_device (max77843->i2c_chg); - -return 0 ; -} -static const struct of_device_id max77843_dt_match[] = { { .compatible ="maxim,max77843" , }, { },
@@ -193,7 +180,6 @@ static const struct i2c_device_id max77843_id[] = { { "max77843", TYPE_MAX77843, }, { }, }; -MODULE_DEVICE_TABLE (i2c, max77843_id);static int __maybe_unused max77843_suspend (struct device *dev) {
@@ -226,9 +212,9 @@ static struct i2c_driver max77843_i2c_driver = { .name = "max77843", .pm = &max77843_pm, .of_match_table = max77843_dt_match, + .suppress_bind_attrs = true, }, .probe = max77843_probe, - .remove = max77843_remove, .id_table = max77843_id, };
@@ -237,9 +223,3 @@ static int __init max77843_i2c_init(void)return i2c_add_driver (&max77843_i2c_driver); }subsys_initcall (max77843_i2c_init); - -static void __exit max77843_i2c_exit(void) -{ -i2c_del_driver (&max77843_i2c_driver); -} -module_exit (max77843_i2c_exit);
Signature · 1 line
2.8.0
How did you come up with the subject lines for these patches?
Please do git log --oneline -- <subsystem>, as is normal when submitting to mainline.
Quoted 55 lines
For anyone new to the underlying goal of this cleanup, we are trying to make driver code consistent with the Makefiles/Kconfigs that control them.
This means not using modular functions/macros for drivers that can never be built as a module. Some of the other downfalls this leads to are:
(1) it is easy to accidentally write unused
module_exitand remove code
(2) it can be misleading when reading the source, thinking it can be modular when theMakefileand/orKconfigprohibit it
(3) it requires the include of themodule.hheader file which in turn includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other drivers and spreads like weeds.There are quite a few in the mfd space, so rather than send a large series, I'll try and batch them up into reasonable sized queues. To that end, here we fix up all the maxim drivers as the 1st mfd batch.
As always, the option exists for someone with the hardware and the desire to extend the functionality to make any given driver tristate. But given the number of these tree wide and the fact that I can't test that new extended functionality in all cases, I just make the code consistent with the existing Kconfig/Makefile settings that restrict them to "bool".
Build tested on linux-next for arm, arm64 and x86-64 to ensure no typos or similar issues crept in.
Paul.
---Cc Chanwoo Choi <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Kyungmin Park <[email protected]>Cc Lee Jones <[email protected]>Cc MyungJoo Ham <[email protected]>Cc Samuel Ortiz <[email protected]>Paul Gortmaker (7):
drivers/mfd: makemax8925-i2c.cexplicitly non-modulardrivers/mfd: makemax8997.cexplicitly non-modulardrivers/mfd: makemax8998.cexplicitly non-modulardrivers/mfd: makemax14577.cexplicitly non-modulardrivers/mfd: makemax77686.cexplicitly non-modulardrivers/mfd: makemax77693.cexplicitly non-modulardrivers/mfd: makemax77843.cexplicitly non-modulardrivers/mfd/max14577.c | 13 +------------ drivers/mfd/max77686.c | 26 ++------------------------ drivers/mfd/max77693.c | 34 +++------------------------------- drivers/mfd/max77843.c | 24 ++---------------------- drivers/mfd/max8925-i2c.c | 14 +------------- drivers/mfd/max8997.c | 30 +++--------------------------- drivers/mfd/max8998.c | 27 +-------------------------- 7 files changed, 13 insertions(+), 155 deletions(-)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 1 line · [Re: [PATCH 0/7] drivers/mfd: make max drivers explicitly non-modular] On…
How did you come up with the subject lines for these patches?
I just used the general default of:
<path_to_subsystem>: rest of subject
Quoted 3 lines
Please do
git log --oneline -- <subsystem>, as is normal when submitting to mainline.
Just to be clear, looking at other mfd history, you want me to just drop the "drivers/" prefix ; i.e. change from:
drivers/mfd: text text text driver.c text
...to:
mfd: text text text driver.c text
If so, that is no problem and I can do that for the next revision when I drop the patches pending tristate conversion that I wasn't aware of.
Thanks,
Paul.
--
Quoted 62 lines
Quoted 56 lines
For anyone new to the underlying goal of this cleanup, we are trying to make driver code consistent with the Makefiles/Kconfigs that control them.
This means not using modular functions/macros for drivers that can never be built as a module. Some of the other downfalls this leads to are:
(1) it is easy to accidentally write unused
module_exitand remove code
(2) it can be misleading when reading the source, thinking it can be modular when theMakefileand/orKconfigprohibit it
(3) it requires the include of themodule.hheader file which in turn includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other drivers and spreads like weeds.There are quite a few in the mfd space, so rather than send a large series, I'll try and batch them up into reasonable sized queues. To that end, here we fix up all the maxim drivers as the 1st mfd batch.
As always, the option exists for someone with the hardware and the desire to extend the functionality to make any given driver tristate. But given the number of these tree wide and the fact that I can't test that new extended functionality in all cases, I just make the code consistent with the existing Kconfig/Makefile settings that restrict them to "bool".
Build tested on linux-next for arm, arm64 and x86-64 to ensure no typos or similar issues crept in.
Paul.
---Cc Chanwoo Choi <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Kyungmin Park <[email protected]>Cc Lee Jones <[email protected]>Cc MyungJoo Ham <[email protected]>Cc Samuel Ortiz <[email protected]>Paul Gortmaker (7):
drivers/mfd: makemax8925-i2c.cexplicitly non-modulardrivers/mfd: makemax8997.cexplicitly non-modulardrivers/mfd: makemax8998.cexplicitly non-modulardrivers/mfd: makemax14577.cexplicitly non-modulardrivers/mfd: makemax77686.cexplicitly non-modulardrivers/mfd: makemax77693.cexplicitly non-modulardrivers/mfd: makemax77843.cexplicitly non-modulardrivers/mfd/max14577.c | 13 +------------ drivers/mfd/max77686.c | 26 ++------------------------ drivers/mfd/max77693.c | 34 +++------------------------------- drivers/mfd/max77843.c | 24 ++---------------------- drivers/mfd/max8925-i2c.c | 14 +------------- drivers/mfd/max8997.c | 30 +++--------------------------- drivers/mfd/max8998.c | 27 +-------------------------- 7 files changed, 13 insertions(+), 155 deletions(-)Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 14 lines · Paul Gortmaker
Quoted 1 line · [Re: [PATCH 0/7] drivers/mfd: make max drivers explicitly non-modular] On…
How did you come up with the subject lines for these patches?
I just used the general default of:
<path_to_subsystem>: rest of subjectQuoted 3 lines
Please do
git log --oneline -- <subsystem>, as is normal when submitting to mainline.Just to be clear, looking at other mfd history, you want me to just drop the "
drivers/" prefix ; i.e. change from:
Quoted 8 lines
drivers/mfd: text text textdriver.ctext...to:
mfd: text text text
driver.ctextIf so, that is no problem and I can do that for the next revision when I drop the patches pending tristate conversion that I wasn't aware of.
Current subsystem format is:
mfd: sub-driver-name: Thing you're doing
Sub-driver-name doesn't require file extensions and 'Think that you're doing" should start with an uppercase character.
(Royal-)We like straight lines and conformity. ;)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog