mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] Add subsys_i2c_driver() helpers and convert MFD I2C drivers
@ 2026-12-01  9:45 Peng Fan
  2026-12-01  9:45 ` [PATCH 1/2] i2c: add subsys_i2c_driver() macro Peng Fan
  2026-12-01  9:45 ` [PATCH 2/2] mfd: Convert to subsys_i2c_driver() Peng Fan
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2026-12-01  9:45 UTC (permalink / raw)
  To: Andi Shyti, Lee Jones, Support Opensource, Charles Keepax,
	Richard Fitzgerald, Chanwoo Choi, Krzysztof Kozlowski,
	Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
	Tony Lindgren, Matti Vaittinen, Wolfram Sang
  Cc: linux-i2c, mfd, patches, linux-kernel, linux-omap, Peng Fan

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
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,
-- 
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] i2c: add subsys_i2c_driver() macro
  2026-12-01  9:45 [PATCH 0/2] Add subsys_i2c_driver() helpers and convert MFD I2C drivers Peng Fan
@ 2026-12-01  9:45 ` Peng Fan
  2026-12-01  9:45 ` [PATCH 2/2] mfd: Convert to subsys_i2c_driver() Peng Fan
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2026-12-01  9:45 UTC (permalink / raw)
  To: Andi Shyti, Lee Jones, Support Opensource, Charles Keepax,
	Richard Fitzgerald, Chanwoo Choi, Krzysztof Kozlowski,
	Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
	Tony Lindgren, Matti Vaittinen, Wolfram Sang
  Cc: linux-i2c, mfd, patches, linux-kernel, linux-omap, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 include/linux/i2c.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 6a847fc88d25..f26bb2e0ba0d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -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;

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] mfd: Convert to subsys_i2c_driver()
  2026-12-01  9:45 [PATCH 0/2] Add subsys_i2c_driver() helpers and convert MFD I2C drivers Peng Fan
  2026-12-01  9:45 ` [PATCH 1/2] i2c: add subsys_i2c_driver() macro Peng Fan
@ 2026-12-01  9:45 ` Peng Fan
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2026-12-01  9:45 UTC (permalink / raw)
  To: Andi Shyti, Lee Jones, Support Opensource, Charles Keepax,
	Richard Fitzgerald, Chanwoo Choi, Krzysztof Kozlowski,
	Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
	Tony Lindgren, Matti Vaittinen, Wolfram Sang
  Cc: linux-i2c, mfd, patches, linux-kernel, linux-omap, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 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(-)

diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
index 98f1ebe38f71..6e661c3e28a7 100644
--- a/drivers/mfd/88pm800.c
+++ b/drivers/mfd/88pm800.c
@@ -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 <zhouqiao@marvell.com>");
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c
index f5d6663172ee..7e7ec4afac83 100644
--- a/drivers/mfd/88pm805.c
+++ b/drivers/mfd/88pm805.c
@@ -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 <zhouqiao@marvell.com>");
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index c64a13e677a7..cbba9350c7d0 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -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 <haojian.zhuang@marvell.com>");
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index 5d43fd1da96e..8610eb09b390 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -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);
diff --git a/drivers/mfd/act8945a.c b/drivers/mfd/act8945a.c
index cafefb4451cb..f1635c23b514 100644
--- a/drivers/mfd/act8945a.c
+++ b/drivers/mfd/act8945a.c
@@ -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 <wenyou.yang@atmel.com>");
diff --git a/drivers/mfd/as3711.c b/drivers/mfd/as3711.c
index b123195d911c..ef5ceaa2fb07 100644
--- a/drivers/mfd/as3711.c
+++ b/drivers/mfd/as3711.c
@@ -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);
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index 43c85d8ebee3..95aaf0ecd43c 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -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 <eric.miao@marvell.com>");
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index 612f202ce02a..31b7cf49f6f3 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -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 <dchen@diasemi.com>");
 MODULE_DESCRIPTION("I2C driver for Dialog DA9052 PMIC");
diff --git a/drivers/mfd/da9055-i2c.c b/drivers/mfd/da9055-i2c.c
index b9fde5e5a102..e803ffebd8df 100644
--- a/drivers/mfd/da9055-i2c.c
+++ b/drivers/mfd/da9055-i2c.c
@@ -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 <dchen@diasemi.com>");
 MODULE_DESCRIPTION("I2C driver for Dialog DA9055 PMIC");
diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 4ab83be8beba..0ec2a4ae8ef4 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -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 <jhovold@gmail.com>");
 MODULE_DESCRIPTION("LM3533 Core");
diff --git a/drivers/mfd/lochnagar-i2c.c b/drivers/mfd/lochnagar-i2c.c
index 33551c82414d..b774240b92b2 100644
--- a/drivers/mfd/lochnagar-i2c.c
+++ b/drivers/mfd/lochnagar-i2c.c
@@ -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);
diff --git a/drivers/mfd/lp8788.c b/drivers/mfd/lp8788.c
index 79028e06a665..9f9e403cf42e 100644
--- a/drivers/mfd/lp8788.c
+++ b/drivers/mfd/lp8788.c
@@ -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");
diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
index d38f1da5e080..52d2a0fa330f 100644
--- a/drivers/mfd/max77843.c
+++ b/drivers/mfd/max77843.c
@@ -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);
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c
index 88d2448ae3a3..20390de65d58 100644
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -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 <jack.yoo@maxim-ic.com>");
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 00aff8949cad..89be9c493475 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -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);
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 3a1216ea20a7..888ac5e668b5 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -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);
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index ec9fa4487f01..3b462d9d8768 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -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);
diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
index b5e0aa6f3ec7..d7abb76c7bd6 100644
--- a/drivers/mfd/mc13xxx-i2c.c
+++ b/drivers/mfd/mc13xxx-i2c.c
@@ -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 <marc@cpdesign.com.au");
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 00332bd4f1c6..61ae8c13d0c5 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -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 <gg@slimlogic.co.uk>");
 MODULE_DESCRIPTION("Palmas chip family multi-function driver");
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c
index 431ee5deec00..768acba99baa 100644
--- a/drivers/mfd/rc5t583.c
+++ b/drivers/mfd/rc5t583.c
@@ -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);
diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c
index bd087004dde8..d8851f4499ec 100644
--- a/drivers/mfd/rohm-bd718x7.c
+++ b/drivers/mfd/rohm-bd718x7.c
@@ -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 <matti.vaittinen@fi.rohmeurope.com>");
 MODULE_DESCRIPTION("ROHM BD71837/BD71847 Power Management IC driver");
diff --git a/drivers/mfd/rohm-bd96801.c b/drivers/mfd/rohm-bd96801.c
index 3dad82db01c3..2e3fa2f7253f 100644
--- a/drivers/mfd/rohm-bd96801.c
+++ b/drivers/mfd/rohm-bd96801.c
@@ -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 <matti.vaittinen@fi.rohmeurope.com>");
 MODULE_DESCRIPTION("ROHM BD9680X Power Management IC driver");
diff --git a/drivers/mfd/rsmu_i2c.c b/drivers/mfd/rsmu_i2c.c
index 771631fdb350..c33f3373a0df 100644
--- a/drivers/mfd/rsmu_i2c.c
+++ b/drivers/mfd/rsmu_i2c.c
@@ -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");
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index ca506c157bde..75aa07c9125c 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -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");
diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
index d87d5216d2c6..3ba74688b1d9 100644
--- a/drivers/mfd/tps6105x.c
+++ b/drivers/mfd/tps6105x.c
@@ -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");
diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c
index 17137697158a..a0294a8a5262 100644
--- a/drivers/mfd/tps65010.c
+++ b/drivers/mfd/tps65010.c
@@ -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);
 
diff --git a/drivers/mfd/tps6507x.c b/drivers/mfd/tps6507x.c
index f75d088257fd..cfa02b0de11a 100644
--- a/drivers/mfd/tps6507x.c
+++ b/drivers/mfd/tps6507x.c
@@ -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");
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index 8bc5f4acc7a3..359e0d1f418f 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -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);
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index f087883dd5c8..809c4a9090d5 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -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 <anilkumar@ti.com>");
 MODULE_DESCRIPTION("TPS65217 chip family multi-function driver");
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index f524bbdc8f3b..b03d7757c8f4 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -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 <mike@compulab.co.il>");
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 07348ff28ab2..303e323d013e 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -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);
diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c
index 7fbeae088b24..3049406684ad 100644
--- a/drivers/mfd/wm831x-i2c.c
+++ b/drivers/mfd/wm831x-i2c.c
@@ -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);
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 35d2a8c7817e..00fe7bcf9ff8 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -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);
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 4ef57b70172a..821f994ddf40 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -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);

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01  9:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  9:45 [PATCH 0/2] Add subsys_i2c_driver() helpers and convert MFD I2C drivers Peng Fan
2026-12-01  9:45 ` [PATCH 1/2] i2c: add subsys_i2c_driver() macro Peng Fan
2026-12-01  9:45 ` [PATCH 2/2] mfd: Convert to subsys_i2c_driver() Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®