public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct
@ 2026-02-23  9:05 Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
                   ` (13 more replies)
  0 siblings, 14 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.

Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.

This series addresses the usage of adap->dev in probe() callbacks where
drivers assign the parent device address and the associated OF-node
directly to the struct device embedded in i2c_adapter. We extend the
latter struct to accept the parent struct device and of_node directly
and make it assign it to its internal struct device inside
i2c_register_adapter(). For now just 12 patches but I'll keep on doing it
if these get accepted. Once these get upstream for v6.20/7.0, we'll be
able to also start converting i2c drivers outside of drivers/i2c/.

Link: https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- fix a NULL-pointer dereference in gpio-rcar (Geert)
- rebase on top of v7.0-rc1
- collect tags
- Link to v1: https://lore.kernel.org/r/20251223-i2c-adap-dev-config-v1-0-4829b1cf0834@oss.qualcomm.com

---
Bartosz Golaszewski (12):
      i2c: allow setting the parent device and OF node through the adapter struct
      i2c: qcom-geni: set device parent and of_node through the adapter struct
      i2c: bcm-kona: set device parent and of_node through the adapter struct
      i2c: keba: set device parent and of_node through the adapter struct
      i2c: omap: set device parent and of_node through the adapter struct
      i2c: rcar: set device parent and of_node through the adapter struct
      i2c: st: set device parent and of_node through the adapter struct
      i2c: mxs: set device parent and of_node through the adapter struct
      i2c: highlander: set device parent and of_node through the adapter struct
      i2c: gpio: set device parent and of_node through the adapter struct
      i2c: nomadik: set device parent and of_node through the adapter struct
      i2c: bcm2835: set device parent and of_node through the adapter struct

 drivers/i2c/busses/i2c-bcm-kona.c   | 4 ++--
 drivers/i2c/busses/i2c-bcm2835.c    | 4 ++--
 drivers/i2c/busses/i2c-gpio.c       | 2 +-
 drivers/i2c/busses/i2c-highlander.c | 2 +-
 drivers/i2c/busses/i2c-keba.c       | 2 +-
 drivers/i2c/busses/i2c-mxs.c        | 4 ++--
 drivers/i2c/busses/i2c-nomadik.c    | 4 ++--
 drivers/i2c/busses/i2c-omap.c       | 4 ++--
 drivers/i2c/busses/i2c-qcom-geni.c  | 4 ++--
 drivers/i2c/busses/i2c-rcar.c       | 6 +++---
 drivers/i2c/busses/i2c-st.c         | 4 ++--
 drivers/i2c/i2c-core-base.c         | 5 +++++
 include/linux/i2c.h                 | 4 ++++
 13 files changed, 29 insertions(+), 20 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251223-i2c-adap-dev-config-9403ab811795

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


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

* [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-03-02  7:47   ` Kalle Niemi
  2026-02-23  9:05 ` [PATCH v2 02/12] i2c: qcom-geni: set device parent and of_node " Bartosz Golaszewski
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

In order to stop i2c bus drivers from dereferencing the struct device
embedded in struct i2c_adapter, let's allow configuring the parent
device and OF-node of the adapter directly through dedicated fields.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/i2c-core-base.c | 5 +++++
 include/linux/i2c.h         | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 9c46147e3506d15d53b9b7d6b592709de56e41b9..dd8cec9b04c64b8340d20e018ab5ba28f1f7f5c9 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1561,6 +1561,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
 	adap->dev.type = &i2c_adapter_type;
 	device_initialize(&adap->dev);
 
+	if (!adap->dev.parent)
+		adap->dev.parent = adap->parent;
+	if (!adap->dev.of_node)
+		adap->dev.of_node = adap->of_node;
+
 	/*
 	 * This adapter can be used as a parent immediately after device_add(),
 	 * setup runtime-pm (especially ignore-children) before hand.
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 20fd41b51d5c85ee1665395c07345faafd8e2fca..72677f29aff161530bc3c497d1e07144a44eb9e4 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -761,6 +761,10 @@ struct i2c_adapter {
 	struct irq_domain *host_notify_domain;
 	struct regulator *bus_regulator;
 
+	/* Device configuration. */
+	struct device *parent;
+	struct device_node *of_node;
+
 	struct dentry *debugfs;
 
 	/* 7bit address space */

-- 
2.47.3


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

* [PATCH v2 02/12] i2c: qcom-geni: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 03/12] i2c: bcm-kona: " Bartosz Golaszewski
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-qcom-geni.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index a4acb78fafb669f49e71f739764b9779617f0cb5..d930d198518718aa107819cfebadb9e32a1da377 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -1039,8 +1039,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 				     "Request_irq failed: %d\n", gi2c->irq);
 
 	i2c_set_adapdata(&gi2c->adap, gi2c);
-	gi2c->adap.dev.parent = dev;
-	gi2c->adap.dev.of_node = dev->of_node;
+	gi2c->adap.parent = dev;
+	gi2c->adap.of_node = dev->of_node;
 	strscpy(gi2c->adap.name, "Geni-I2C", sizeof(gi2c->adap.name));
 
 	ret = geni_icc_get(&gi2c->se, desc ? desc->icc_ddr : "qup-memory");

-- 
2.47.3


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

* [PATCH v2 03/12] i2c: bcm-kona: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 02/12] i2c: qcom-geni: set device parent and of_node " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23 17:30   ` Florian Fainelli
  2026-02-23  9:05 ` [PATCH v2 04/12] i2c: keba: " Bartosz Golaszewski
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-bcm-kona.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c
index 9d8838bbd938bf6c43d9553d9f54acac1282f7e8..edd79689f40f451fc216455c9da5704bdc73c62f 100644
--- a/drivers/i2c/busses/i2c-bcm-kona.c
+++ b/drivers/i2c/busses/i2c-bcm-kona.c
@@ -840,8 +840,8 @@ static int bcm_kona_i2c_probe(struct platform_device *pdev)
 	adap->owner = THIS_MODULE;
 	strscpy(adap->name, "Broadcom I2C adapter", sizeof(adap->name));
 	adap->algo = &bcm_algo;
-	adap->dev.parent = &pdev->dev;
-	adap->dev.of_node = pdev->dev.of_node;
+	adap->parent = &pdev->dev;
+	adap->of_node = pdev->dev.of_node;
 
 	rc = i2c_add_adapter(adap);
 	if (rc)

-- 
2.47.3


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

* [PATCH v2 04/12] i2c: keba: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 03/12] i2c: bcm-kona: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 05/12] i2c: omap: " Bartosz Golaszewski
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device using the dedicated field in struct
i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-keba.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-keba.c b/drivers/i2c/busses/i2c-keba.c
index 9420c8b342b573da435eeef5a05efde35d61434d..01aa5dd9638dac38dd92500cc8890feb8020754c 100644
--- a/drivers/i2c/busses/i2c-keba.c
+++ b/drivers/i2c/busses/i2c-keba.c
@@ -532,7 +532,7 @@ static int ki2c_probe(struct auxiliary_device *auxdev,
 	adap->owner = THIS_MODULE;
 	adap->class = I2C_CLASS_HWMON;
 	adap->algo = &ki2c_algo;
-	adap->dev.parent = dev;
+	adap->parent = dev;
 
 	i2c_set_adapdata(adap, ki2c);
 

-- 
2.47.3


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

* [PATCH v2 05/12] i2c: omap: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 04/12] i2c: keba: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 06/12] i2c: rcar: " Bartosz Golaszewski
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-omap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d9f590f0c384340dd31308bdf9ed0cb1a1a2ba8b..f95f31c521314e1d67f3d5b34bb44fcef557624f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1496,8 +1496,8 @@ omap_i2c_probe(struct platform_device *pdev)
 	strscpy(adap->name, "OMAP I2C adapter", sizeof(adap->name));
 	adap->algo = &omap_i2c_algo;
 	adap->quirks = &omap_i2c_quirks;
-	adap->dev.parent = &pdev->dev;
-	adap->dev.of_node = pdev->dev.of_node;
+	adap->parent = &pdev->dev;
+	adap->of_node = pdev->dev.of_node;
 	adap->bus_recovery_info = &omap_i2c_bus_recovery_info;
 
 	/* i2c device drivers may be active on return from add_adapter() */

-- 
2.47.3


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

* [PATCH v2 06/12] i2c: rcar: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 05/12] i2c: omap: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 07/12] i2c: st: " Bartosz Golaszewski
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-rcar.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 5ce8f8e4856fb2bb21c9cd731ddbbd8f3622ca26..af96892718fe04c5c428c82d3a47ad23aa08ee9c 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -171,7 +171,7 @@ struct rcar_i2c_priv {
 	u8 slave_flags;
 };
 
-#define rcar_i2c_priv_to_dev(p)		((p)->adap.dev.parent)
+#define rcar_i2c_priv_to_dev(p)		((p)->adap.parent)
 #define rcar_i2c_is_recv(p)		((p)->msg->flags & I2C_M_RD)
 
 static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val)
@@ -1149,8 +1149,8 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	adap->algo = &rcar_i2c_algo;
 	adap->class = I2C_CLASS_DEPRECATED;
 	adap->retries = 3;
-	adap->dev.parent = dev;
-	adap->dev.of_node = dev->of_node;
+	adap->parent = dev;
+	adap->of_node = dev->of_node;
 	adap->bus_recovery_info = &rcar_i2c_bri;
 	adap->quirks = &rcar_i2c_quirks;
 	i2c_set_adapdata(adap, priv);

-- 
2.47.3


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

* [PATCH v2 07/12] i2c: st: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 06/12] i2c: rcar: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 08/12] i2c: mxs: " Bartosz Golaszewski
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-st.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
index 751ea421caaf388bc2337026e0860707823546d7..88ee5dfb55e469b64537694224a0fe39008a80c2 100644
--- a/drivers/i2c/busses/i2c-st.c
+++ b/drivers/i2c/busses/i2c-st.c
@@ -850,8 +850,8 @@ static int st_i2c_probe(struct platform_device *pdev)
 	adap->retries = 0;
 	adap->algo = &st_i2c_algo;
 	adap->bus_recovery_info = &st_i2c_recovery_info;
-	adap->dev.parent = &pdev->dev;
-	adap->dev.of_node = pdev->dev.of_node;
+	adap->parent = &pdev->dev;
+	adap->of_node = pdev->dev.of_node;
 
 	init_completion(&i2c_dev->complete);
 

-- 
2.47.3


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

* [PATCH v2 08/12] i2c: mxs: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 07/12] i2c: st: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23 17:19   ` Frank Li
  2026-02-23  9:05 ` [PATCH v2 09/12] i2c: highlander: " Bartosz Golaszewski
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-mxs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 08c9091a1e35151bac8d4adb80abdbd29a62b95a..bfbd96ee2f483cd1dd872c3448eaa6a17940d70f 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -849,9 +849,9 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	adap->owner = THIS_MODULE;
 	adap->algo = &mxs_i2c_algo;
 	adap->quirks = &mxs_i2c_quirks;
-	adap->dev.parent = dev;
+	adap->parent = dev;
 	adap->nr = pdev->id;
-	adap->dev.of_node = pdev->dev.of_node;
+	adap->of_node = pdev->dev.of_node;
 	i2c_set_adapdata(adap, i2c);
 	err = i2c_add_numbered_adapter(adap);
 	if (err) {

-- 
2.47.3


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

* [PATCH v2 09/12] i2c: highlander: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 08/12] i2c: mxs: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 10/12] i2c: gpio: " Bartosz Golaszewski
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device using the dedicated field in struct
i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-highlander.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
index a53b4bb7c3c0487ea028453cca6d09f6e4a993a3..ff30286efaf8df2895cd772fc554aabb85c5a998 100644
--- a/drivers/i2c/busses/i2c-highlander.c
+++ b/drivers/i2c/busses/i2c-highlander.c
@@ -404,7 +404,7 @@ static int highlander_i2c_probe(struct platform_device *pdev)
 	adap->class = I2C_CLASS_HWMON;
 	strscpy(adap->name, "HL FPGA I2C adapter", sizeof(adap->name));
 	adap->algo = &highlander_i2c_algo;
-	adap->dev.parent = &pdev->dev;
+	adap->parent = &pdev->dev;
 	adap->nr = pdev->id;
 
 	/*

-- 
2.47.3


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

* [PATCH v2 10/12] i2c: gpio: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 09/12] i2c: highlander: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 11/12] i2c: nomadik: " Bartosz Golaszewski
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device using the dedicated field in struct
i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index f4355b17bfbf15c402e71096ccbb99f5a35bb479..78f8bc2525be6d1fd9a7907df4c253f33bbec9f0 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -425,7 +425,7 @@ static int i2c_gpio_probe(struct platform_device *pdev)
 
 	adap->algo_data = bit_data;
 	adap->class = I2C_CLASS_HWMON;
-	adap->dev.parent = dev;
+	adap->parent = dev;
 	device_set_node(&adap->dev, fwnode);
 
 	adap->nr = pdev->id;

-- 
2.47.3


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

* [PATCH v2 11/12] i2c: nomadik: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 10/12] i2c: gpio: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23  9:05 ` [PATCH v2 12/12] i2c: bcm2835: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Acked-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-nomadik.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index b63ee51c1652080e414f4302bee16905914c1288..12b4f8750886d7f6f5b6027b00691240952a3694 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -1148,8 +1148,8 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 	init_hw(priv);
 
 	adap = &priv->adap;
-	adap->dev.of_node = np;
-	adap->dev.parent = dev;
+	adap->of_node = np;
+	adap->parent = dev;
 	adap->owner = THIS_MODULE;
 	adap->class = I2C_CLASS_DEPRECATED;
 	adap->algo = &nmk_i2c_algo;

-- 
2.47.3


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

* [PATCH v2 12/12] i2c: bcm2835: set device parent and of_node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 11/12] i2c: nomadik: " Bartosz Golaszewski
@ 2026-02-23  9:05 ` Bartosz Golaszewski
  2026-02-23 11:32   ` Dave Stevenson
  2026-02-23 17:31   ` Florian Fainelli
  2026-02-23 14:08 ` [PATCH v2 00/12] i2c: configure parent device and OF node " Geert Uytterhoeven
  2026-02-26 20:24 ` Wolfram Sang
  13 siblings, 2 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23  9:05 UTC (permalink / raw)
  To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Bartosz Golaszewski

Configure the parent device and the OF-node using dedicated fields in
struct i2c_adapter and avoid dereferencing the internal struct device.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-bcm2835.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 0d7e2654a534e92a529f27fdc049812359678522..4f7e4a178b33fdd172657cc625a34018b18f88ca 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -474,8 +474,8 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	snprintf(adap->name, sizeof(adap->name), "bcm2835 (%s)",
 		 of_node_full_name(pdev->dev.of_node));
 	adap->algo = &bcm2835_i2c_algo;
-	adap->dev.parent = &pdev->dev;
-	adap->dev.of_node = pdev->dev.of_node;
+	adap->parent = &pdev->dev;
+	adap->of_node = pdev->dev.of_node;
 	adap->quirks = of_device_get_match_data(&pdev->dev);
 
 	/*

-- 
2.47.3


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

* Re: [PATCH v2 12/12] i2c: bcm2835: set device parent and of_node through the adapter struct
  2026-02-23  9:05 ` [PATCH v2 12/12] i2c: bcm2835: " Bartosz Golaszewski
@ 2026-02-23 11:32   ` Dave Stevenson
  2026-02-23 17:31   ` Florian Fainelli
  1 sibling, 0 replies; 22+ messages in thread
From: Dave Stevenson @ 2026-02-23 11:32 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li, Bartosz Golaszewski, linux-i2c,
	linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc,
	linux-arm-kernel, imx, linux-rpi-kernel

On Mon, 23 Feb 2026 at 09:07, Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> Configure the parent device and the OF-node using dedicated fields in
> struct i2c_adapter and avoid dereferencing the internal struct device.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

When used alongside [PATCH v2 01/12] i2c: allow setting the parent
device and OF node through the adapter struct:

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

> ---
>  drivers/i2c/busses/i2c-bcm2835.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
> index 0d7e2654a534e92a529f27fdc049812359678522..4f7e4a178b33fdd172657cc625a34018b18f88ca 100644
> --- a/drivers/i2c/busses/i2c-bcm2835.c
> +++ b/drivers/i2c/busses/i2c-bcm2835.c
> @@ -474,8 +474,8 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
>         snprintf(adap->name, sizeof(adap->name), "bcm2835 (%s)",
>                  of_node_full_name(pdev->dev.of_node));
>         adap->algo = &bcm2835_i2c_algo;
> -       adap->dev.parent = &pdev->dev;
> -       adap->dev.of_node = pdev->dev.of_node;
> +       adap->parent = &pdev->dev;
> +       adap->of_node = pdev->dev.of_node;
>         adap->quirks = of_device_get_match_data(&pdev->dev);
>
>         /*
>
> --
> 2.47.3
>
>

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

* Re: [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (11 preceding siblings ...)
  2026-02-23  9:05 ` [PATCH v2 12/12] i2c: bcm2835: " Bartosz Golaszewski
@ 2026-02-23 14:08 ` Geert Uytterhoeven
  2026-02-23 14:43   ` Bartosz Golaszewski
  2026-02-26 20:24 ` Wolfram Sang
  13 siblings, 1 reply; 22+ messages in thread
From: Geert Uytterhoeven @ 2026-02-23 14:08 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li, Bartosz Golaszewski, linux-i2c,
	linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc,
	linux-arm-kernel, imx, linux-rpi-kernel

Hi Bartosz,

On Mon, 23 Feb 2026 at 10:06, Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
> Changes in v2:
> - fix a NULL-pointer dereference in gpio-rcar (Geert)
                                      ^^^^
I guess that is bound to happen when a GPIO maintainer touches
the I2C subsystem? ;-)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct
  2026-02-23 14:08 ` [PATCH v2 00/12] i2c: configure parent device and OF node " Geert Uytterhoeven
@ 2026-02-23 14:43   ` Bartosz Golaszewski
  0 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23 14:43 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Wolfram Sang, Mukesh Kumar Savaliya,
	Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui,
	Scott Branden, Broadcom internal kernel review list, Vignesh R,
	Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade,
	Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm,
	Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel,
	linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel,
	imx, linux-rpi-kernel

On Mon, Feb 23, 2026 at 3:15 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Bartosz,
>
> On Mon, 23 Feb 2026 at 10:06, Bartosz Golaszewski
> <bartosz.golaszewski@oss.qualcomm.com> wrote:
> > Changes in v2:
> > - fix a NULL-pointer dereference in gpio-rcar (Geert)
>                                       ^^^^
> I guess that is bound to happen when a GPIO maintainer touches
> the I2C subsystem? ;-)
>

That or caffeine had not hit the system yet. :)

Bartosz

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

* Re: [PATCH v2 08/12] i2c: mxs: set device parent and of_node through the adapter struct
  2026-02-23  9:05 ` [PATCH v2 08/12] i2c: mxs: " Bartosz Golaszewski
@ 2026-02-23 17:19   ` Frank Li
  0 siblings, 0 replies; 22+ messages in thread
From: Frank Li @ 2026-02-23 17:19 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Bartosz Golaszewski, linux-i2c, linux-kernel,
	linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel,
	imx, linux-rpi-kernel

On Mon, Feb 23, 2026 at 10:05:54AM +0100, Bartosz Golaszewski wrote:
> Configure the parent device and the OF-node using dedicated fields in
> struct i2c_adapter and avoid dereferencing the internal struct device.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
>  drivers/i2c/busses/i2c-mxs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
> index 08c9091a1e35151bac8d4adb80abdbd29a62b95a..bfbd96ee2f483cd1dd872c3448eaa6a17940d70f 100644
> --- a/drivers/i2c/busses/i2c-mxs.c
> +++ b/drivers/i2c/busses/i2c-mxs.c
> @@ -849,9 +849,9 @@ static int mxs_i2c_probe(struct platform_device *pdev)
>  	adap->owner = THIS_MODULE;
>  	adap->algo = &mxs_i2c_algo;
>  	adap->quirks = &mxs_i2c_quirks;
> -	adap->dev.parent = dev;
> +	adap->parent = dev;
>  	adap->nr = pdev->id;
> -	adap->dev.of_node = pdev->dev.of_node;
> +	adap->of_node = pdev->dev.of_node;
>  	i2c_set_adapdata(adap, i2c);
>  	err = i2c_add_numbered_adapter(adap);
>  	if (err) {
>
> --
> 2.47.3
>

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

* Re: [PATCH v2 03/12] i2c: bcm-kona: set device parent and of_node through the adapter struct
  2026-02-23  9:05 ` [PATCH v2 03/12] i2c: bcm-kona: " Bartosz Golaszewski
@ 2026-02-23 17:30   ` Florian Fainelli
  0 siblings, 0 replies; 22+ messages in thread
From: Florian Fainelli @ 2026-02-23 17:30 UTC (permalink / raw)
  To: Bartosz Golaszewski, Wolfram Sang, Mukesh Kumar Savaliya,
	Viken Dadhaniya, Andi Shyti, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel

On 2/23/26 01:05, Bartosz Golaszewski wrote:
> Configure the parent device and the OF-node using dedicated fields in
> struct i2c_adapter and avoid dereferencing the internal struct device.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

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

* Re: [PATCH v2 12/12] i2c: bcm2835: set device parent and of_node through the adapter struct
  2026-02-23  9:05 ` [PATCH v2 12/12] i2c: bcm2835: " Bartosz Golaszewski
  2026-02-23 11:32   ` Dave Stevenson
@ 2026-02-23 17:31   ` Florian Fainelli
  1 sibling, 0 replies; 22+ messages in thread
From: Florian Fainelli @ 2026-02-23 17:31 UTC (permalink / raw)
  To: Bartosz Golaszewski, Wolfram Sang, Mukesh Kumar Savaliya,
	Viken Dadhaniya, Andi Shyti, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel

On 2/23/26 01:05, Bartosz Golaszewski wrote:
> Configure the parent device and the OF-node using dedicated fields in
> struct i2c_adapter and avoid dereferencing the internal struct device.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

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

* Re: [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct
  2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (12 preceding siblings ...)
  2026-02-23 14:08 ` [PATCH v2 00/12] i2c: configure parent device and OF node " Geert Uytterhoeven
@ 2026-02-26 20:24 ` Wolfram Sang
  13 siblings, 0 replies; 22+ messages in thread
From: Wolfram Sang @ 2026-02-26 20:24 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li, Bartosz Golaszewski, linux-i2c,
	linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc,
	linux-arm-kernel, imx, linux-rpi-kernel

On Mon, Feb 23, 2026 at 10:05:46AM +0100, Bartosz Golaszewski wrote:
> It's been another year of discussing the object life-time problems at
> conferences. I2C is one of the offenders and its problems are more
> complex than those of some other subsystems. It seems the revocable[1]
> API may make its way into the kernel this year but even with it in
> place, I2C won't be able to use it as there's currently nothing to
> *revoke*. The struct device is embedded within the i2c_adapter struct
> whose lifetime is tied to the provider device being bound to its driver.
> 
> Fixing this won't be fast and easy but nothing's going to happen if we
> don't start chipping away at it. The ultimate goal in order to be able
> to use an SRCU-based solution (revocable or otherwise) is to convert the
> embedded struct device in struct i2c_adapter into an __rcu pointer that
> can be *revoked*. To that end we need to hide all dereferences of
> adap->dev in drivers.
> 
> This series addresses the usage of adap->dev in probe() callbacks where
> drivers assign the parent device address and the associated OF-node
> directly to the struct device embedded in i2c_adapter. We extend the
> latter struct to accept the parent struct device and of_node directly
> and make it assign it to its internal struct device inside
> i2c_register_adapter(). For now just 12 patches but I'll keep on doing it
> if these get accepted. Once these get upstream for v6.20/7.0, we'll be
> able to also start converting i2c drivers outside of drivers/i2c/.
> 
> Link: https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Also applied (and squashed) to for-current. Tags are retained BTW.


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

* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct
  2026-02-23  9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
@ 2026-03-02  7:47   ` Kalle Niemi
  2026-03-02  8:55     ` Bartosz Golaszewski
  0 siblings, 1 reply; 22+ messages in thread
From: Kalle Niemi @ 2026-03-02  7:47 UTC (permalink / raw)
  To: Bartosz Golaszewski, Wolfram Sang, Mukesh Kumar Savaliya,
	Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui,
	Scott Branden, Broadcom internal kernel review list, Vignesh R,
	Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade,
	Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm,
	Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Linus Walleij, Frank Li
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Matti Vaittinen

On 2/23/26 11:05, Bartosz Golaszewski wrote:
> In order to stop i2c bus drivers from dereferencing the struct device
> embedded in struct i2c_adapter, let's allow configuring the parent
> device and OF-node of the adapter directly through dedicated fields.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
>   drivers/i2c/i2c-core-base.c | 5 +++++
>   include/linux/i2c.h         | 4 ++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 9c46147e3506d15d53b9b7d6b592709de56e41b9..dd8cec9b04c64b8340d20e018ab5ba28f1f7f5c9 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -1561,6 +1561,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>   	adap->dev.type = &i2c_adapter_type;
>   	device_initialize(&adap->dev);
>   
> +	if (!adap->dev.parent)
> +		adap->dev.parent = adap->parent;
> +	if (!adap->dev.of_node)
> +		adap->dev.of_node = adap->of_node;
> +
>   	/*
>   	 * This adapter can be used as a parent immediately after device_add(),
>   	 * setup runtime-pm (especially ignore-children) before hand.
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 20fd41b51d5c85ee1665395c07345faafd8e2fca..72677f29aff161530bc3c497d1e07144a44eb9e4 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -761,6 +761,10 @@ struct i2c_adapter {
>   	struct irq_domain *host_notify_domain;
>   	struct regulator *bus_regulator;
>   
> +	/* Device configuration. */
> +	struct device *parent;
> +	struct device_node *of_node;
> +
>   	struct dentry *debugfs;
>   
>   	/* 7bit address space */
> 

Hello,

Automated driver test system bisected this commit to be the first bad 
commit, linux-next next-20260227 was tested. Failed tests include driver 
tests for ROHM PMIC and accelerometers, which are connected to 
BeagleBone Black.

The failed driver tests all fail to first i2cget and the tests stop 
there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or 
directory".

BR
Kalle Niemi


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

* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct
  2026-03-02  7:47   ` Kalle Niemi
@ 2026-03-02  8:55     ` Bartosz Golaszewski
  0 siblings, 0 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2026-03-02  8:55 UTC (permalink / raw)
  To: Kalle Niemi, Wolfram Sang
  Cc: Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya,
	Andi Shyti, Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
	Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel, Matti Vaittinen

On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote:
>
> On 2/23/26 11:05, Bartosz Golaszewski wrote:
> > In order to stop i2c bus drivers from dereferencing the struct device
> > embedded in struct i2c_adapter, let's allow configuring the parent
> > device and OF-node of the adapter directly through dedicated fields.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > ---
> >
>
> Hello,
>
> Automated driver test system bisected this commit to be the first bad
> commit, linux-next next-20260227 was tested. Failed tests include driver
> tests for ROHM PMIC and accelerometers, which are connected to
> BeagleBone Black.
>
> The failed driver tests all fail to first i2cget and the tests stop
> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or
> directory".
>

Wolfram: well, now it would actually be useful to know which commit
exactly is the culprit so maybe splitting the changes is not a bad
idea after all.

Kalle: which i2c bus driver fails here? Any errors in kernel log?

Bart

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

end of thread, other threads:[~2026-03-02  8:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23  9:05 [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
2026-03-02  7:47   ` Kalle Niemi
2026-03-02  8:55     ` Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 02/12] i2c: qcom-geni: set device parent and of_node " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 03/12] i2c: bcm-kona: " Bartosz Golaszewski
2026-02-23 17:30   ` Florian Fainelli
2026-02-23  9:05 ` [PATCH v2 04/12] i2c: keba: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 05/12] i2c: omap: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 06/12] i2c: rcar: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 07/12] i2c: st: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 08/12] i2c: mxs: " Bartosz Golaszewski
2026-02-23 17:19   ` Frank Li
2026-02-23  9:05 ` [PATCH v2 09/12] i2c: highlander: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 10/12] i2c: gpio: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 11/12] i2c: nomadik: " Bartosz Golaszewski
2026-02-23  9:05 ` [PATCH v2 12/12] i2c: bcm2835: " Bartosz Golaszewski
2026-02-23 11:32   ` Dave Stevenson
2026-02-23 17:31   ` Florian Fainelli
2026-02-23 14:08 ` [PATCH v2 00/12] i2c: configure parent device and OF node " Geert Uytterhoeven
2026-02-23 14:43   ` Bartosz Golaszewski
2026-02-26 20:24 ` Wolfram Sang

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