Add subsys_i2c_driver() helpers and convert MFD I2C drivers
Subsystems (9)
cover Add subsys_i2c_driver() helpers and convert MFD I2C drivers
Many I2C drivers open-code their own init/exit functions because they need to be registered at the subsys_initcall() level when built in, which prevents them from using module_i2c_driver(). The recently added subsys_driver() and subsys_platform_driver() helpers address this for platform drivers; this series adds the I2C equivalents and converts the MFD users.
Patch 1 adds two macros in <linux/i2c.h>:
- subsys_i2c_driver() for drivers that need an unregister path. It replaces the subsys_initcall()/module_exit() pair.
- subsys_i2c_driver_probe() for drivers without an exit callback. It replaces a bare subsys_initcall().
Patch 2 converts 34 MFD driver files: some use subsys_i2c_driver() and some use subsys_i2c_driver_probe(). The error messages around i2c_add_driver() are dropped because registration failures are already reported by the driver core, and initcall_debug can be used to see initcall return values. No functional change is intended.
Because patch 2 depends on patch 1, I can resend the conversion after the helper is merged, or the MFD maintainer can take both patches through an immutable branch.
---
Peng Fan (2):
i2c: add subsys_i2c_driver() macro
mfd: Convert to subsys_i2c_driver()
drivers/mfd/88pm800.c | 13 +------------ drivers/mfd/88pm805.c | 13 +------------ drivers/mfd/88pm860x-core.c | 18 +----------------- drivers/mfd/aat2870-core.c | 7 +------ drivers/mfd/act8945a.c | 13 +------------ drivers/mfd/as3711.c | 7 +------ drivers/mfd/da903x.c | 13 +------------ drivers/mfd/da9052-i2c.c | 21 +-------------------- drivers/mfd/da9055-i2c.c | 21 +-------------------- drivers/mfd/lm3533-core.c | 13 +------------ drivers/mfd/lochnagar-i2c.c | 13 +------------ drivers/mfd/lp8788.c | 13 +------------ drivers/mfd/max77843.c | 7 +------ drivers/mfd/max8907.c | 19 +------------------ drivers/mfd/max8925-i2c.c | 13 +------------ drivers/mfd/max8997.c | 7 +------ drivers/mfd/max8998.c | 7 +------ drivers/mfd/mc13xxx-i2c.c | 13 +------------ drivers/mfd/palmas.c | 13 +------------ drivers/mfd/rc5t583.c | 7 +------ drivers/mfd/rohm-bd718x7.c | 13 +------------ drivers/mfd/rohm-bd96801.c | 14 +------------- drivers/mfd/rsmu_i2c.c | 13 +------------ drivers/mfd/tc3589x.c | 13 +------------ drivers/mfd/tps6105x.c | 13 +------------ drivers/mfd/tps65010.c | 15 +-------------- drivers/mfd/tps6507x.c | 13 +------------ drivers/mfd/tps65090.c | 7 +------ drivers/mfd/tps65217.c | 13 +------------ drivers/mfd/tps6586x.c | 13 +------------ drivers/mfd/tps65910.c | 7 +------ drivers/mfd/wm831x-i2c.c | 13 +------------ drivers/mfd/wm8350-i2c.c | 7 +------ drivers/mfd/wm8400-core.c | 15 +-------------- include/linux/i2c.h | 23 +++++++++++++++++++++++ 35 files changed, 57 insertions(+), 386 deletions(-)
---
base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d
change-id: 20261201-add-i2c-subsys-mfd-120cdb5f68a1
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
PATCH 1/2 i2c: add subsys_i2c_driver() macro
From: Peng Fan <[email protected]>
Add subsys_i2c_driver() and subsys_i2c_driver_probe() macros so that I2C drivers registered at the subsys_initcall() level can avoid the open-coded init/exit boilerplate.
subsys_i2c_driver() replaces subsys_initcall() plus module_exit() for drivers that need an unregister path. subsys_i2c_driver_probe() replaces subsys_initcall() for drivers without an exit callback.
--- include/linux/i2c.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
include/linux/i2c.h +23 -0
@@ -915,6 +915,29 @@ void i2c_del_driver(struct i2c_driver *driver);#define i2c_add_driver (driver) \ i2c_register_driver(THIS_MODULE, driver) +/* +* subsys_i2c_driver() - Helper macro for i2c drivers that don't do anything +* special in module init/exit but need to register earlier, at +* subsys_initcall level, when built in. This eliminates a lot of +* boilerplate. Each driver may only use this macro once, and calling it +* replaces subsys_initcall() and module_exit(). +*/ +#define subsys_i2c_driver (__i2c_driver) \ + subsys_driver(__i2c_driver, i2c_add_driver, i2c_del_driver) + +/* +* subsys_i2c_driver_probe() - Helper macro for drivers that don't do +* anything special in driver register and have no exit, but need to register +* earlier, at subsys_initcall level. This eliminates some boilerplate. Each +* driver may only use this macro once, and using it replaces subsys_initcall. +*/ +#define subsys_i2c_driver_probe (__i2c_driver) \ +static int __init __i2c_driver##_init(void) \ +{ \ + return i2c_add_driver(&__i2c_driver); \ +} \ +subsys_initcall(__i2c_driver##_init) +static inline bool i2c_client_has_driver (struct i2c_client *client) {return !IS_ERR_OR_NULL (client) && client->dev.driver;
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 1/2] i2c: add subsys_i2c_driver() macro
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] i2c: misnamed and redundant subsys_i2c_driver_probe() macro - [Low] i2c: inconsistent placement and…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] i2c: misnamed and redundant subsys_i2c_driver_probe() macro
- [Low] i2c: inconsistent placement and comment style for subsys_i2c_driver()
--
commit 740e2ad66bef9c533701a5564e85f3b5ba81bdf3
Author: Peng Fan <[email protected]>
i2c: add subsys_i2c_driver() macro
This commit adds the subsys_i2c_driver() and subsys_i2c_driver_probe() helper macros to register I2C drivers at the subsys_initcall() level.
Quoted 7 lines
include/linux/i2c.h +0
-0@@ -915,6 +915,29 @@ void i2c_del_driver(struct i2c_driver *driver);#define i2c_add_driver (driver) \ i2c_register_driver(THIS_MODULE, driver)
include/linux/i2c.h void i2c_del_driver(struct i2c_driver *driver); · line 926
Quoted 10 lines
include/linux/i2c.h +9
-0+/* +* subsys_i2c_driver() - Helper macro for i2c drivers that don't do anything +* special in module init/exit but need to register earlier, at +* subsys_initcall level, when built in. This eliminates a lot of +* boilerplate. Each driver may only use this macro once, and calling it +* replaces subsys_initcall() and module_exit(). +*/ +#define subsys_i2c_driver (__i2c_driver) \ + subsys_driver(__i2c_driver, i2c_add_driver, i2c_del_driver)
[Severity: Low]
This isn't a bug, but module_i2c_driver() and builtin_i2c_driver() are grouped together further down in include/linux/i2c.h with kernel-doc comments (including @__i2c_driver). Could subsys_i2c_driver() be placed alongside them using the same kernel-doc format?
include/linux/i2c.h void i2c_del_driver(struct i2c_driver *driver); · line 939
Quoted 13 lines
include/linux/i2c.h +13
-0+ +/* +* subsys_i2c_driver_probe() - Helper macro for drivers that don't do +* anything special in driver register and have no exit, but need to register +* earlier, at subsys_initcall level. This eliminates some boilerplate. Each +* driver may only use this macro once, and using it replaces subsys_initcall. +*/ +#define subsys_i2c_driver_probe (__i2c_driver) \ +static int __init __i2c_driver##_init(void) \ +{ \ + return i2c_add_driver(&__i2c_driver); \ +} \ +subsys_initcall(__i2c_driver##_init)
[Severity: Low]
Is subsys_i2c_driver_probe() needed in addition to subsys_i2c_driver()?
In platform_device.h, the _probe suffix in module_platform_driver_probe(), builtin_platform_driver_probe(), and subsys_platform_driver_probe() means the macro takes a separate probe function and calls platform_driver_probe(). I2C has no i2c_driver_probe() equivalent, and this macro takes a single struct i2c_driver argument and calls i2c_add_driver() just like subsys_i2c_driver().
For built-in drivers without an exit callback, subsys_i2c_driver() already works because the __exit function generated by subsys_driver() is discarded at link time and i2c_del_driver() does not require a .remove callback. For loadable modules, subsys_initcall() becomes module_init(), so using subsys_i2c_driver_probe() omits module_exit() and leaves the module permanently non-unloadable. Could subsys_i2c_driver_probe() be dropped in favor of subsys_i2c_driver()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/2] i2c: add subsys_i2c_driver() macro
In reply to Peng FanQuoted 11 lines · Peng Fan
From: Peng Fan <[email protected]>
Add
subsys_i2c_driver()andsubsys_i2c_driver_probe()macros so that I2C drivers registered at thesubsys_initcall()level can avoid the open-coded init/exit boilerplate.
subsys_i2c_driver()replacessubsys_initcall()plusmodule_exit()for drivers that need an unregister path.subsys_i2c_driver_probe()replacessubsys_initcall()for drivers without an exit callback.Signed-off-by Peng Fan <[email protected]>
Applied to my for-andi branch, thanks!
Re: [PATCH 1/2] i2c: add subsys_i2c_driver() macro
Hi Wolfram,
Quoted 11 lines · Wolfram Sang
Quoted 10 lines · Peng Fan
From: Peng Fan <[email protected]>
Add
subsys_i2c_driver()andsubsys_i2c_driver_probe()macros so that I2C drivers registered at thesubsys_initcall()level can avoid the open-coded init/exit boilerplate.
subsys_i2c_driver()replacessubsys_initcall()plusmodule_exit()for drivers that need an unregister path.subsys_i2c_driver_probe()replacessubsys_initcall()for drivers without an exit callback.
Quoted 5 lines
Quoted 1 line
Signed-off-by Peng Fan <[email protected]>Acked-by Wolfram Sang <[email protected]>Applied to my for-andi branch, thanks!
Thanks for applying.
Sashiko reported minor issue:
https://sashiko.dev/#/message/sashiko-outbox-243018%40kernel.org
I am thinking to use below simplied version, do you expect a V2 or the applied version is fine for you?
Thanks
Peng
------------------------------------------------------
Subject: [PATCH V2] i2c: add subsys_i2c_driver() macro
Add subsys_i2c_driver() so that I2C drivers registered at the subsys_initcall() level can avoid the open-coded init/exit boilerplate. It replaces subsys_initcall() plus module_exit() and is a parallel of module_i2c_driver() with the init call promoted to subsys_initcall() when built in.
--- include/linux/i2c.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/i2c.h +13 -0
@@ -1020,6 +1020,19 @@ int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr);#define builtin_i2c_driver (__i2c_driver) \ builtin_driver(__i2c_driver, i2c_add_driver) +/** +* subsys_i2c_driver() - Helper macro for registering an I2C driver +* @__i2c_driver: i2c_driver struct +* +* Helper macro for I2C drivers which do not do anything special in their +* init/exit and need to be registered earlier, at subsys_initcall() level, +* when built in. This eliminates a lot of boilerplate. Each driver may only +* use this macro once, and calling it replaces subsys_initcall() and +* module_exit(). +*/ +#define subsys_i2c_driver (__i2c_driver) \ + subsys_driver(__i2c_driver, i2c_add_driver, i2c_del_driver) +/* must call put_device() when done with returned i2c_client device */ struct i2c_client *i2c_find_device_by_fwnode (struct fwnode_handle *fwnode);
Signature · 1 line
2.56.0
Re: [PATCH 1/2] i2c: add subsys_i2c_driver() macro
Quoted 3 lines
Sashiko reported minor issue:
https://sashiko.dev/#/message/sashiko-outbox-243018%40kernel.org
Ah, I didn't get this mail.
Quoted 2 lines
I am thinking to use below simplied version, do you expect a V2 or the applied version is fine for you?
Please send a next version. My for-andi branch is not in -next, so can be rebased.
PATCH 2/2 mfd: Convert to subsys_i2c_driver()
In reply to Peng FanFrom: Peng Fan <[email protected]>
Replace the open-coded subsys_initcall()/module_exit() I2C driver registration with subsys_i2c_driver(). Drivers without an exit callback use subsys_i2c_driver_probe().
The error message on i2c_add_driver() failure is dropped as the driver core already reports registration failures.
No functional change.
--- drivers/mfd/88pm800.c | 13 +------------ drivers/mfd/88pm805.c | 13 +------------ drivers/mfd/88pm860x-core.c | 18 +----------------- drivers/mfd/aat2870-core.c | 7 +------ drivers/mfd/act8945a.c | 13 +------------ drivers/mfd/as3711.c | 7 +------ drivers/mfd/da903x.c | 13 +------------ drivers/mfd/da9052-i2c.c | 21 +-------------------- drivers/mfd/da9055-i2c.c | 21 +-------------------- drivers/mfd/lm3533-core.c | 13 +------------ drivers/mfd/lochnagar-i2c.c | 13 +------------ drivers/mfd/lp8788.c | 13 +------------ drivers/mfd/max77843.c | 7 +------ drivers/mfd/max8907.c | 19 +------------------ drivers/mfd/max8925-i2c.c | 13 +------------ drivers/mfd/max8997.c | 7 +------ drivers/mfd/max8998.c | 7 +------ drivers/mfd/mc13xxx-i2c.c | 13 +------------ drivers/mfd/palmas.c | 13 +------------ drivers/mfd/rc5t583.c | 7 +------ drivers/mfd/rohm-bd718x7.c | 13 +------------ drivers/mfd/rohm-bd96801.c | 14 +------------- drivers/mfd/rsmu_i2c.c | 13 +------------ drivers/mfd/tc3589x.c | 13 +------------ drivers/mfd/tps6105x.c | 13 +------------ drivers/mfd/tps65010.c | 15 +-------------- drivers/mfd/tps6507x.c | 13 +------------ drivers/mfd/tps65090.c | 7 +------ drivers/mfd/tps65217.c | 13 +------------ drivers/mfd/tps6586x.c | 13 +------------ drivers/mfd/tps65910.c | 7 +------ drivers/mfd/wm831x-i2c.c | 13 +------------ drivers/mfd/wm8350-i2c.c | 7 +------ drivers/mfd/wm8400-core.c | 15 +-------------- 34 files changed, 34 insertions(+), 386 deletions(-)
drivers/mfd/88pm800.c +1 -12
@@ -600,18 +600,7 @@ static struct i2c_driver pm800_driver = { .remove = pm800_remove, .id_table = pm80x_id_table, }; - -static int __init pm800_i2c_init (void ) -{ -return i2c_add_driver (&pm800_driver); -} -subsys_initcall (pm800_i2c_init); - -static void __exit pm800_i2c_exit(void) -{ -i2c_del_driver (&pm800_driver); -} -module_exit (pm800_i2c_exit); +subsys_i2c_driver (pm800_driver);MODULE_DESCRIPTION ("PMIC Driver for Marvell 88PM800" );MODULE_AUTHOR ("Qiao Zhou <[email protected]>" );
drivers/mfd/88pm805.c +1 -12
@@ -257,18 +257,7 @@ static struct i2c_driver pm805_driver = { .remove = pm805_remove, .id_table = pm80x_id_table, }; - -static int __init pm805_i2c_init (void ) -{ -return i2c_add_driver (&pm805_driver); -} -subsys_initcall (pm805_i2c_init); - -static void __exit pm805_i2c_exit(void) -{ -i2c_del_driver (&pm805_driver); -} -module_exit (pm805_i2c_exit); +subsys_i2c_driver (pm805_driver);MODULE_DESCRIPTION ("PMIC Driver for Marvell 88PM805" );MODULE_AUTHOR ("Qiao Zhou <[email protected]>" );
drivers/mfd/88pm860x-core.c +1 -17
@@ -1251,23 +1251,7 @@ static struct i2c_driver pm860x_driver = { .remove = pm860x_remove, .id_table = pm860x_id_table, }; - -static int __init pm860x_i2c_init (void ) -{ -int ret; - - ret =i2c_add_driver (&pm860x_driver); -if (ret !=0 ) -pr_err ("Failed to register 88PM860x I2C driver: %d\n" , ret); -return ret; -} -subsys_initcall (pm860x_i2c_init); - -static void __exit pm860x_i2c_exit(void) -{ -i2c_del_driver (&pm860x_driver); -} -module_exit (pm860x_i2c_exit); +subsys_i2c_driver (pm860x_driver);MODULE_DESCRIPTION ("PMIC Driver for Marvell 88PM860x" );MODULE_AUTHOR ("Haojian Zhuang <[email protected]>" );
drivers/mfd/aat2870-core.c +1 -6
@@ -449,9 +449,4 @@ static struct i2c_driver aat2870_i2c_driver = { .probe = aat2870_i2c_probe, .id_table = aat2870_i2c_id_table, }; - -static int __init aat2870_init (void ) -{ -return i2c_add_driver (&aat2870_i2c_driver); -} -subsys_initcall (aat2870_init); +subsys_i2c_driver_probe (aat2870_i2c_driver);
drivers/mfd/act8945a.c +1 -12
@@ -73,18 +73,7 @@ static struct i2c_driver act8945a_i2c_driver = { .probe = act8945a_i2c_probe, .id_table = act8945a_i2c_id, }; - -static int __init act8945a_i2c_init (void ) -{ -return i2c_add_driver (&act8945a_i2c_driver); -} -subsys_initcall (act8945a_i2c_init); - -static void __exit act8945a_i2c_exit(void) -{ -i2c_del_driver (&act8945a_i2c_driver); -} -module_exit (act8945a_i2c_exit); +subsys_i2c_driver (act8945a_i2c_driver);MODULE_DESCRIPTION ("ACT8945A PMIC multi-function driver" );MODULE_AUTHOR ("Wenyou Yang <[email protected]>" );
drivers/mfd/as3711.c +1 -6
@@ -203,10 +203,5 @@ static struct i2c_driver as3711_i2c_driver = { .probe = as3711_i2c_probe, .id_table = as3711_i2c_id, }; - -static int __init as3711_i2c_init (void ) -{ -return i2c_add_driver (&as3711_i2c_driver); -}/* Initialise early */ -subsys_initcall (as3711_i2c_init); +subsys_i2c_driver (as3711_i2c_driver);
drivers/mfd/da903x.c +1 -12
@@ -562,18 +562,7 @@ static struct i2c_driver da903x_driver = { .probe = da903x_probe, .id_table = da903x_id_table, }; - -static int __init da903x_init (void ) -{ -return i2c_add_driver (&da903x_driver); -} -subsys_initcall (da903x_init); - -static void __exit da903x_exit(void) -{ -i2c_del_driver (&da903x_driver); -} -module_exit (da903x_exit); +subsys_i2c_driver (da903x_driver);MODULE_DESCRIPTION ("PMIC Driver for Dialog Semiconductor DA9034" );MODULE_AUTHOR ("Eric Miao <[email protected]>" );
drivers/mfd/da9052-i2c.c +1 -20
@@ -183,26 +183,7 @@ static struct i2c_driver da9052_i2c_driver = {#endif }, }; - -static int __init da9052_i2c_init (void ) -{ -int ret; - - ret =i2c_add_driver (&da9052_i2c_driver); -if (ret !=0 ) { -pr_err ("DA9052 I2C registration failed %d\n" , ret); -return ret; - } - -return 0 ; -} -subsys_initcall (da9052_i2c_init); - -static void __exit da9052_i2c_exit(void) -{ -i2c_del_driver (&da9052_i2c_driver); -} -module_exit (da9052_i2c_exit); +subsys_i2c_driver (da9052_i2c_driver);MODULE_AUTHOR ("David Dajun Chen <[email protected]>" );MODULE_DESCRIPTION ("I2C driver for Dialog DA9052 PMIC" );
drivers/mfd/da9055-i2c.c +1 -20
@@ -73,26 +73,7 @@ static struct i2c_driver da9055_i2c_driver = { .of_match_table = da9055_of_match, }, }; - -static int __init da9055_i2c_init (void ) -{ -int ret; - - ret =i2c_add_driver (&da9055_i2c_driver); -if (ret !=0 ) { -pr_err ("DA9055 I2C registration failed %d\n" , ret); -return ret; - } - -return 0 ; -} -subsys_initcall (da9055_i2c_init); - -static void __exit da9055_i2c_exit(void) -{ -i2c_del_driver (&da9055_i2c_driver); -} -module_exit (da9055_i2c_exit); +subsys_i2c_driver (da9055_i2c_driver);MODULE_AUTHOR ("David Dajun Chen <[email protected]>" );MODULE_DESCRIPTION ("I2C driver for Dialog DA9055 PMIC" );
drivers/mfd/lm3533-core.c +1 -12
@@ -516,18 +516,7 @@ static struct i2c_driver lm3533_i2c_driver = { .probe = lm3533_i2c_probe, .remove = lm3533_i2c_remove, }; - -static int __init lm3533_i2c_init (void ) -{ -return i2c_add_driver (&lm3533_i2c_driver); -} -subsys_initcall (lm3533_i2c_init); - -static void __exit lm3533_i2c_exit(void) -{ -i2c_del_driver (&lm3533_i2c_driver); -} -module_exit (lm3533_i2c_exit); +subsys_i2c_driver (lm3533_i2c_driver);MODULE_AUTHOR ("Johan Hovold <[email protected]>" );MODULE_DESCRIPTION ("LM3533 Core" );
drivers/mfd/lochnagar-i2c.c +1 -12
@@ -378,15 +378,4 @@ static struct i2c_driver lochnagar_i2c_driver = { }, .probe = lochnagar_i2c_probe, }; - -static int __init lochnagar_i2c_init (void ) -{ -int ret; - - ret =i2c_add_driver (&lochnagar_i2c_driver); -if (ret) -pr_err ("Failed to register Lochnagar driver: %d\n" , ret); - -return ret; -} -subsys_initcall (lochnagar_i2c_init); +subsys_i2c_driver_probe (lochnagar_i2c_driver);
drivers/mfd/lp8788.c +1 -12
@@ -229,18 +229,7 @@ static struct i2c_driver lp8788_driver = { .remove = lp8788_remove, .id_table = lp8788_ids, }; - -static int __init lp8788_init (void ) -{ -return i2c_add_driver (&lp8788_driver); -} -subsys_initcall (lp8788_init); - -static void __exit lp8788_exit(void) -{ -i2c_del_driver (&lp8788_driver); -} -module_exit (lp8788_exit); +subsys_i2c_driver (lp8788_driver);MODULE_DESCRIPTION ("TI LP8788 MFD Driver" );MODULE_AUTHOR ("Milo Kim" );
drivers/mfd/max77843.c +1 -6
@@ -209,9 +209,4 @@ static struct i2c_driver max77843_i2c_driver = { .probe = max77843_probe, .id_table = max77843_id, }; - -static int __init max77843_i2c_init (void ) -{ -return i2c_add_driver (&max77843_i2c_driver); -} -subsys_initcall (max77843_i2c_init); +subsys_i2c_driver_probe (max77843_i2c_driver);
drivers/mfd/max8907.c +1 -18
@@ -329,24 +329,7 @@ static struct i2c_driver max8907_i2c_driver = { .remove = max8907_i2c_remove, .id_table = max8907_i2c_id, }; - -static int __init max8907_i2c_init (void ) -{ -int ret = -ENODEV ; - - ret =i2c_add_driver (&max8907_i2c_driver); -if (ret !=0 ) -pr_err ("Failed to register I2C driver: %d\n" , ret); - -return ret; -} -subsys_initcall (max8907_i2c_init); - -static void __exit max8907_i2c_exit(void) -{ -i2c_del_driver (&max8907_i2c_driver); -} -module_exit (max8907_i2c_exit); +subsys_i2c_driver (max8907_i2c_driver);MODULE_DESCRIPTION ("MAX8907 multi-function core driver" );MODULE_AUTHOR ("Gyungoh Yoo <[email protected]>" );
drivers/mfd/max8925-i2c.c +1 -12
@@ -242,15 +242,4 @@ static struct i2c_driver max8925_driver = { .remove = max8925_remove, .id_table = max8925_id_table, }; - -static int __init max8925_i2c_init (void ) -{ -int ret; - - ret =i2c_add_driver (&max8925_driver); -if (ret !=0 ) -pr_err ("Failed to register MAX8925 I2C driver: %d\n" , ret); - -return ret; -} -subsys_initcall (max8925_i2c_init); +subsys_i2c_driver_probe (max8925_driver);
drivers/mfd/max8997.c +1 -6
@@ -469,10 +469,5 @@ static struct i2c_driver max8997_i2c_driver = { .probe = max8997_i2c_probe, .id_table = max8997_i2c_id, }; - -static int __init max8997_i2c_init (void ) -{ -return i2c_add_driver (&max8997_i2c_driver); -}/* init early so consumer devices can complete system boot */ -subsys_initcall (max8997_i2c_init); +subsys_i2c_driver_probe (max8997_i2c_driver);
drivers/mfd/max8998.c +1 -6
@@ -339,10 +339,5 @@ static struct i2c_driver max8998_i2c_driver = { .probe = max8998_i2c_probe, .id_table = max8998_i2c_id, }; - -static int __init max8998_i2c_init (void ) -{ -return i2c_add_driver (&max8998_i2c_driver); -}/* init early so consumer devices can complete system boot */ -subsys_initcall (max8998_i2c_init); +subsys_i2c_driver_probe (max8998_i2c_driver);
drivers/mfd/mc13xxx-i2c.c +1 -12
@@ -91,18 +91,7 @@ static struct i2c_driver mc13xxx_i2c_driver = { .probe = mc13xxx_i2c_probe, .remove = mc13xxx_i2c_remove, }; - -static int __init mc13xxx_i2c_init (void ) -{ -return i2c_add_driver (&mc13xxx_i2c_driver); -} -subsys_initcall (mc13xxx_i2c_init); - -static void __exit mc13xxx_i2c_exit(void) -{ -i2c_del_driver (&mc13xxx_i2c_driver); -} -module_exit (mc13xxx_i2c_exit); +subsys_i2c_driver (mc13xxx_i2c_driver);MODULE_DESCRIPTION ("i2c driver for Freescale MC13XXX PMIC" );MODULE_AUTHOR ("Marc Reilly <[email protected]" );
drivers/mfd/palmas.c +1 -12
@@ -716,19 +716,8 @@ static struct i2c_driver palmas_i2c_driver = { .remove = palmas_i2c_remove, .id_table = palmas_i2c_id, }; - -static int __init palmas_i2c_init (void ) -{ -return i2c_add_driver (&palmas_i2c_driver); -}/* init early so consumer devices can complete system boot */ -subsys_initcall (palmas_i2c_init); - -static void __exit palmas_i2c_exit(void) -{ -i2c_del_driver (&palmas_i2c_driver); -} -module_exit (palmas_i2c_exit); +subsys_i2c_driver (palmas_i2c_driver);MODULE_AUTHOR ("Graeme Gregory <[email protected]>" );MODULE_DESCRIPTION ("Palmas chip family multi-function driver" );
drivers/mfd/rc5t583.c +1 -6
@@ -291,9 +291,4 @@ static struct i2c_driver rc5t583_i2c_driver = { .probe = rc5t583_i2c_probe, .id_table = rc5t583_i2c_id, }; - -static int __init rc5t583_i2c_init (void ) -{ -return i2c_add_driver (&rc5t583_i2c_driver); -} -subsys_initcall (rc5t583_i2c_init); +subsys_i2c_driver_probe (rc5t583_i2c_driver);
drivers/mfd/rohm-bd718x7.c +1 -12
@@ -191,19 +191,8 @@ static struct i2c_driver bd718xx_i2c_driver = { .probe = bd718xx_i2c_probe, }; -static int __init bd718xx_i2c_init (void ) -{ -return i2c_add_driver (&bd718xx_i2c_driver); -} -/* Initialise early so consumer devices can complete system boot */ -subsys_initcall (bd718xx_i2c_init); - -static void __exit bd718xx_i2c_exit(void) -{ -i2c_del_driver (&bd718xx_i2c_driver); -} -module_exit (bd718xx_i2c_exit); +subsys_i2c_driver (bd718xx_i2c_driver);MODULE_AUTHOR ("Matti Vaittinen <[email protected]>" );MODULE_DESCRIPTION ("ROHM BD71837/BD71847 Power Management IC driver" );
drivers/mfd/rohm-bd96801.c +1 -13
@@ -776,20 +776,8 @@ static struct i2c_driver bd96801_i2c_driver = { }, .probe = bd96801_i2c_probe, }; - -static int __init bd96801_i2c_init (void ) -{ -return i2c_add_driver (&bd96801_i2c_driver); -} -/* Initialise early so consumer devices can complete system boot */ -subsys_initcall (bd96801_i2c_init); - -static void __exit bd96801_i2c_exit(void) -{ -i2c_del_driver (&bd96801_i2c_driver); -} -module_exit (bd96801_i2c_exit); +subsys_i2c_driver (bd96801_i2c_driver);MODULE_AUTHOR ("Matti Vaittinen <[email protected]>" );MODULE_DESCRIPTION ("ROHM BD9680X Power Management IC driver" );
drivers/mfd/rsmu_i2c.c +1 -12
@@ -360,18 +360,7 @@ static struct i2c_driver rsmu_i2c_driver = { .remove = rsmu_i2c_remove, .id_table = rsmu_i2c_id, }; - -static int __init rsmu_i2c_init (void ) -{ -return i2c_add_driver (&rsmu_i2c_driver); -} -subsys_initcall (rsmu_i2c_init); - -static void __exit rsmu_i2c_exit(void) -{ -i2c_del_driver (&rsmu_i2c_driver); -} -module_exit (rsmu_i2c_exit); +subsys_i2c_driver (rsmu_i2c_driver);MODULE_DESCRIPTION ("Renesas SMU I2C driver" );MODULE_LICENSE ("GPL" );
drivers/mfd/tc3589x.c +1 -12
@@ -486,18 +486,7 @@ static struct i2c_driver tc3589x_driver = { .remove = tc3589x_remove, .id_table = tc3589x_id, }; - -static int __init tc3589x_init (void ) -{ -return i2c_add_driver (&tc3589x_driver); -} -subsys_initcall (tc3589x_init); - -static void __exit tc3589x_exit(void) -{ -i2c_del_driver (&tc3589x_driver); -} -module_exit (tc3589x_exit); +subsys_i2c_driver (tc3589x_driver);MODULE_DESCRIPTION ("TC3589x MFD core driver" );MODULE_AUTHOR ("Hanumath Prasad, Rabin Vincent" );
drivers/mfd/tps6105x.c +1 -12
@@ -213,18 +213,7 @@ static struct i2c_driver tps6105x_driver = { .remove = tps6105x_remove, .id_table = tps6105x_id, }; - -static int __init tps6105x_init (void ) -{ -return i2c_add_driver (&tps6105x_driver); -} -subsys_initcall (tps6105x_init); - -static void __exit tps6105x_exit(void) -{ -i2c_del_driver (&tps6105x_driver); -} -module_exit (tps6105x_exit); +subsys_i2c_driver (tps6105x_driver);MODULE_AUTHOR ("Linus Walleij" );MODULE_DESCRIPTION ("TPS6105x White LED Boost Converter Driver" );
drivers/mfd/tps65010.c +1 -14
@@ -1033,23 +1033,10 @@ int tps65013_set_low_pwr(unsigned mode)return status; }EXPORT_SYMBOL (tps65013_set_low_pwr); - -/*-------------------------------------------------------------------------*/ - -static int __init tps_init (void ) -{ -return i2c_add_driver (&tps65010_driver); -}/* NOTE: this MUST be initialized before the other parts of the system * that rely on it ... but after the i2c bus on which this relies. * That is, much earlier than on PC-type systems, which don't often use * I2C as a core system bus. */ -subsys_initcall (tps_init); - -static void __exit tps_exit(void) -{ -i2c_del_driver (&tps65010_driver); -} -module_exit (tps_exit); +subsys_i2c_driver (tps65010_driver);
drivers/mfd/tps6507x.c +1 -12
@@ -123,19 +123,8 @@ static struct i2c_driver tps6507x_i2c_driver = { .probe = tps6507x_i2c_probe, .id_table = tps6507x_i2c_id, }; - -static int __init tps6507x_i2c_init (void ) -{ -return i2c_add_driver (&tps6507x_i2c_driver); -}/* init early so consumer devices can complete system boot */ -subsys_initcall (tps6507x_i2c_init); - -static void __exit tps6507x_i2c_exit(void) -{ -i2c_del_driver (&tps6507x_i2c_driver); -} -module_exit (tps6507x_i2c_exit); +subsys_i2c_driver (tps6507x_i2c_driver);MODULE_DESCRIPTION ("TPS6507x chip family multi-function driver" );MODULE_LICENSE ("GPL" );
drivers/mfd/tps65090.c +1 -6
@@ -238,9 +238,4 @@ static struct i2c_driver tps65090_driver = { .probe = tps65090_i2c_probe, .id_table = tps65090_id_table, }; - -static int __init tps65090_init (void ) -{ -return i2c_add_driver (&tps65090_driver); -} -subsys_initcall (tps65090_init); +subsys_i2c_driver_probe (tps65090_driver);
drivers/mfd/tps65217.c +1 -12
@@ -431,18 +431,7 @@ static struct i2c_driver tps65217_driver = { .id_table = tps65217_id_table, .probe = tps65217_probe, }; - -static int __init tps65217_init (void ) -{ -return i2c_add_driver (&tps65217_driver); -} -subsys_initcall (tps65217_init); - -static void __exit tps65217_exit(void) -{ -i2c_del_driver (&tps65217_driver); -} -module_exit (tps65217_exit); +subsys_i2c_driver (tps65217_driver);MODULE_AUTHOR ("AnilKumar Ch <[email protected]>" );MODULE_DESCRIPTION ("TPS65217 chip family multi-function driver" );
drivers/mfd/tps6586x.c +1 -12
@@ -657,18 +657,7 @@ static struct i2c_driver tps6586x_driver = { .remove = tps6586x_i2c_remove, .id_table = tps6586x_id_table, }; - -static int __init tps6586x_init (void ) -{ -return i2c_add_driver (&tps6586x_driver); -} -subsys_initcall (tps6586x_init); - -static void __exit tps6586x_exit(void) -{ -i2c_del_driver (&tps6586x_driver); -} -module_exit (tps6586x_exit); +subsys_i2c_driver (tps6586x_driver);MODULE_DESCRIPTION ("TPS6586X core driver" );MODULE_AUTHOR ("Mike Rapoport <[email protected]>" );
drivers/mfd/tps65910.c +1 -6
@@ -564,10 +564,5 @@ static struct i2c_driver tps65910_i2c_driver = { .probe = tps65910_i2c_probe, .id_table = tps65910_i2c_id, }; - -static int __init tps65910_i2c_init (void ) -{ -return i2c_add_driver (&tps65910_i2c_driver); -}/* init early so consumer devices can complete system boot */ -subsys_initcall (tps65910_i2c_init); +subsys_i2c_driver_probe (tps65910_i2c_driver);
drivers/mfd/wm831x-i2c.c +1 -12
@@ -97,15 +97,4 @@ static struct i2c_driver wm831x_i2c_driver = { .probe = wm831x_i2c_probe, .id_table = wm831x_i2c_id, }; - -static int __init wm831x_i2c_init (void ) -{ -int ret; - - ret =i2c_add_driver (&wm831x_i2c_driver); -if (ret !=0 ) -pr_err ("Failed to register wm831x I2C driver: %d\n" , ret); - -return ret; -} -subsys_initcall (wm831x_i2c_init); +subsys_i2c_driver (wm831x_i2c_driver);
drivers/mfd/wm8350-i2c.c +1 -6
@@ -55,10 +55,5 @@ static struct i2c_driver wm8350_i2c_driver = { .probe = wm8350_i2c_probe, .id_table = wm8350_i2c_id, }; - -static int __init wm8350_i2c_init (void ) -{ -return i2c_add_driver (&wm8350_i2c_driver); -}/* init early so consumer devices can complete system boot */ -subsys_initcall (wm8350_i2c_init); +subsys_i2c_driver_probe (wm8350_i2c_driver);
drivers/mfd/wm8400-core.c +1 -14
@@ -146,18 +146,5 @@ static struct i2c_driver wm8400_i2c_driver = { .probe = wm8400_i2c_probe, .id_table = wm8400_i2c_id, }; +subsys_i2c_driver_probe (wm8400_i2c_driver);#endif - -static int __init wm8400_driver_init (void ) -{ -int ret = -ENODEV ; - -#if IS_ENABLED (CONFIG_I2C ) - ret =i2c_add_driver (&wm8400_i2c_driver); -if (ret !=0 ) -pr_err ("Failed to register I2C driver: %d\n" , ret); -#endif - -return ret; -} -subsys_initcall (wm8400_driver_init);
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 2/2] mfd: Convert to subsys_i2c_driver()
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] mfd: exit-less drivers converted to subsys_i2c_driver() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mfd: exit-less drivers converted to subsys_i2c_driver() --
commit 14a41c42fcfdc5229494b4b2ee13de3e1844671c
Author: Peng Fan <[email protected]>
mfd: Convert to subsys_i2c_driver()
This commit replaces open-coded subsys_initcall()/module_exit() I2C driver registrations in MFD drivers with subsys_i2c_driver() or subsys_i2c_driver_probe().
[ ... ]
Quoted 16 lines
drivers/mfd/as3711.c +1
-6@@ -203,10 +203,5 @@ static struct i2c_driver as3711_i2c_driver = { .probe = as3711_i2c_probe, .id_table = as3711_i2c_id, }; - -static int __init as3711_i2c_init (void ) -{ -return i2c_add_driver (&as3711_i2c_driver); -}/* Initialise early */ -subsys_initcall (as3711_i2c_init); +subsys_i2c_driver (as3711_i2c_driver);
[ ... ]
Quoted 11 lines
drivers/mfd/wm831x-i2c.c +0
-3@@ -97,15 +97,4 @@ static struct i2c_driver wm831x_i2c_driver = { .probe = wm831x_i2c_probe, .id_table = wm831x_i2c_id, }; - -static int __init wm831x_i2c_init (void ) -{
drivers/mfd/wm831x-i2c.c static struct i2c_driver wm831x_i2c_driver = { · line 100
Quoted 10 lines
drivers/mfd/wm831x-i2c.c +1
-9-int ret; - - ret =i2c_add_driver (&wm831x_i2c_driver); -if (ret !=0 ) -pr_err ("Failed to register wm831x I2C driver: %d\n" , ret); - -return ret; -} -subsys_initcall (wm831x_i2c_init); +subsys_i2c_driver (wm831x_i2c_driver);
[Severity: Low]
Should as3711_i2c_driver and wm831x_i2c_driver use subsys_i2c_driver_probe() instead of subsys_i2c_driver()?
Neither driver had a module_exit() callback prior to this patch (both are built-in only via bool Kconfig options), so converting them to subsys_i2c_driver() adds an unused module_exit() callback and differs from the other exit-less drivers in this patch.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Lee Jones
maintainerRe: [PATCH 2/2] mfd: Convert to subsys_i2c_driver()
Quoted 3 lines · On Tue, 01 Dec 2026, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mfd: exit-less drivers converted tosubsys_i2c_driver()
Please review, explain or fix the Sashiko review(s).
If this is a set, this request includes the other patches too.
Quoted 65 lines
--
commit
14a41c42fcfdc5229494b4b2ee13de3e1844671c
Author: Peng Fan <[email protected]>mfd: Convert to
subsys_i2c_driver()This commit replaces open-coded subsys_initcall()/module_exit() I2C driver registrations in MFD drivers with
subsys_i2c_driver()orsubsys_i2c_driver_probe().[ ... ]
Quoted 16 lines
drivers/mfd/as3711.c +1
-6@@ -203,10 +203,5 @@ static struct i2c_driver as3711_i2c_driver = { .probe = as3711_i2c_probe, .id_table = as3711_i2c_id, }; - -static int __init as3711_i2c_init (void ) -{ -return i2c_add_driver (&as3711_i2c_driver); -}/* Initialise early */ -subsys_initcall (as3711_i2c_init); +subsys_i2c_driver (as3711_i2c_driver);[ ... ]
Quoted 11 lines
drivers/mfd/wm831x-i2c.c +0
-3@@ -97,15 +97,4 @@ static struct i2c_driver wm831x_i2c_driver = { .probe = wm831x_i2c_probe, .id_table = wm831x_i2c_id, }; - -static int __init wm831x_i2c_init (void ) -{drivers/mfd/wm831x-i2c.c static struct i2c_driver wm831x_i2c_driver = { · line 100
Quoted 10 lines
drivers/mfd/wm831x-i2c.c +1
-9-int ret; - - ret =i2c_add_driver (&wm831x_i2c_driver); -if (ret !=0 ) -pr_err ("Failed to register wm831x I2C driver: %d\n" , ret); - -return ret; -} -subsys_initcall (wm831x_i2c_init); +subsys_i2c_driver (wm831x_i2c_driver);[Severity: Low]
Shouldas3711_i2c_driverandwm831x_i2c_driverusesubsys_i2c_driver_probe()instead ofsubsys_i2c_driver()?Neither driver had a
module_exit()callback prior to this patch (both are built-in only via boolKconfigoptions), so converting them tosubsys_i2c_driver()adds an unusedmodule_exit()callback and differs from the other exit-less drivers in this patch.Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Signature · 1 line
Lee Jones
Lee Jones
maintainerRe: [PATCH 2/2] mfd: Convert to subsys_i2c_driver()
Quoted 9 lines · Lee Jones
Quoted 3 lines · On Tue, 01 Dec 2026, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mfd: exit-less drivers converted tosubsys_i2c_driver()Please review, explain or fix the Sashiko review(s).
If this is a set, this request includes the other patches too.
Also, you should include the authors / heavy contributors as well.
Signature · 1 line
Lee Jones
Re: [PATCH 2/2] mfd: Convert to subsys_i2c_driver()
Quoted 8 lines · Lee Jones
Quoted 6 lines · Lee Jones
Quoted 3 lines · On Tue, 01 Dec 2026, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mfd: exit-less drivers converted tosubsys_i2c_driver()
Quoted 5 lines
Quoted 3 lines
Please review, explain or fix the Sashiko review(s).
If this is a set, this request includes the other patches too.
Also, you should include the authors / heavy contributors as well.
I use 'b4 prep --auto-to-cc' to collect the To and Cc list, so maintainers and reviewers listed in MAINTAINERS are already copied.
If need to Cc authors and heavy contributors. I need write a script to filter out patches to get heavy contributors (:
Thanks
Peng
Quoted 5 lines
Signature · 2 lines
-- Lee Jones
Lee Jones
maintainerRe: [PATCH 2/2] mfd: Convert to subsys_i2c_driver()
Quoted 13 lines · Peng Fan
Quoted 12 lines · Lee Jones
Quoted 9 lines · Lee Jones
Quoted 3 lines · On Tue, 01 Dec 2026, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mfd: exit-less drivers converted tosubsys_i2c_driver()Please review, explain or fix the Sashiko review(s).
If this is a set, this request includes the other patches too.
Quoted 7 lines
Quoted 1 line
Also, you should include the authors / heavy contributors as well.
I use 'b4 prep --auto-to-cc' to collect the To and Cc list, so maintainers and reviewers listed in
MAINTAINERSare already copied.If need to Cc authors and heavy contributors. I need write a script to filter out patches to get heavy contributors (:
No you don't. I use:
scripts/get_maintainer.pl --norolestats --file-emails --git --git-min-percent 75
Signature · 1 line
Lee Jones
Quoted 4 lines
Because patch 2 depends on patch 1, I can resend the conversion after the helper is merged, or the MFD maintainer can take both patches through an immutable branch.
I'd prefer resending conversions once the helper is upstream. Do you know other subsystems than MFD which could make use of this helper?
Quoted 6 lines · Wolfram Sang
Quoted 4 lines
Because patch 2 depends on patch 1, I can resend the conversion after the helper is merged, or the MFD maintainer can take both patches through an immutable branch.
I'd prefer resending conversions once the helper is upstream. Do you
I just dropped the mfd patch in V2. Will repost mfd and other subsystems to use this helper after this patch land in upstream.
Quoted 1 line
know other subsystems than MFD which could make use of this helper?
Yes. At least some gpio and regulator drivers could also use this helper.
Thanks
Peng