public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct
@ 2025-12-23 10:04 Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 01/12] i2c: allow setting the " Bartosz Golaszewski
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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/.

[1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@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       | 4 ++--
 drivers/i2c/busses/i2c-st.c         | 4 ++--
 drivers/i2c/i2c-core-base.c         | 5 +++++
 include/linux/i2c.h                 | 4 ++++
 13 files changed, 28 insertions(+), 19 deletions(-)
---
base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
change-id: 20251223-i2c-adap-dev-config-9403ab811795

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



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

* [PATCH 01/12] i2c: allow setting the parent device and OF node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 02/12] i2c: qcom-geni: set device parent and of_node " Bartosz Golaszewski
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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 ae7e9c8b65a65c415f5a42f0eb0e7a4ff3e86dce..732828e63730bb773b77ab59362bad8697a1ebde 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] 18+ messages in thread

* [PATCH 02/12] i2c: qcom-geni: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 01/12] i2c: allow setting the " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 03/12] i2c: bcm-kona: " Bartosz Golaszewski
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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 3a04016db2c3222cc6c91386f8904921014a3f90..389fa49f0ba7e657d97a94d9e27f5d916d1ffcf1 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -1038,8 +1038,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] 18+ messages in thread

* [PATCH 03/12] i2c: bcm-kona: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 01/12] i2c: allow setting the " Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 02/12] i2c: qcom-geni: set device parent and of_node " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 04/12] i2c: keba: " Bartosz Golaszewski
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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] 18+ messages in thread

* [PATCH 04/12] i2c: keba: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 03/12] i2c: bcm-kona: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 05/12] i2c: omap: " Bartosz Golaszewski
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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] 18+ messages in thread

* [PATCH 05/12] i2c: omap: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 04/12] i2c: keba: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-29 14:54   ` Andreas Kemnade
  2025-12-23 10:04 ` [PATCH 06/12] i2c: rcar: " Bartosz Golaszewski
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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-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] 18+ messages in thread

* [PATCH 06/12] i2c: rcar: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 05/12] i2c: omap: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2026-01-06  9:13   ` Geert Uytterhoeven
  2025-12-23 10:04 ` [PATCH 07/12] i2c: st: " Bartosz Golaszewski
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 5ce8f8e4856fb2bb21c9cd731ddbbd8f3622ca26..86826502533bf866ca81cb86ddd10b2a2be3c798 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -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] 18+ messages in thread

* [PATCH 07/12] i2c: st: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 06/12] i2c: rcar: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2026-01-05  7:26   ` Patrice CHOTARD
  2025-12-23 10:04 ` [PATCH 08/12] i2c: mxs: " Bartosz Golaszewski
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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-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 97d70e66722706f242cd97153387c3a865abc12d..b50be2c39eaa4b9b95a71b038a4d63f3c5fd7c4b 100644
--- a/drivers/i2c/busses/i2c-st.c
+++ b/drivers/i2c/busses/i2c-st.c
@@ -849,8 +849,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] 18+ messages in thread

* [PATCH 08/12] i2c: mxs: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 07/12] i2c: st: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 09/12] i2c: highlander: " Bartosz Golaszewski
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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] 18+ messages in thread

* [PATCH 09/12] i2c: highlander: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 08/12] i2c: mxs: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 10/12] i2c: gpio: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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 78c5845e0877ae3e2ad1dcef052cdef021372e12..8aa2baf96c266edeb67d1da123e314e57831e0f8 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] 18+ messages in thread

* [PATCH 10/12] i2c: gpio: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 09/12] i2c: highlander: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 11/12] i2c: nomadik: " Bartosz Golaszewski
  2025-12-23 10:04 ` [PATCH 12/12] i2c: bcm2835: " Bartosz Golaszewski
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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] 18+ messages in thread

* [PATCH 11/12] i2c: nomadik: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 10/12] i2c: gpio: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  2026-01-03 19:04   ` Linus Walleij
  2025-12-23 10:04 ` [PATCH 12/12] i2c: bcm2835: " Bartosz Golaszewski
  11 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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-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 19b648fc094d9748a0cce4e35f350da35ee25505..133ce90941ed596ba2e6dc2d9b368cebe7ace3a3 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -1147,8 +1147,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] 18+ messages in thread

* [PATCH 12/12] i2c: bcm2835: set device parent and of_node through the adapter struct
  2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2025-12-23 10:04 ` [PATCH 11/12] i2c: nomadik: " Bartosz Golaszewski
@ 2025-12-23 10:04 ` Bartosz Golaszewski
  11 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2025-12-23 10:04 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
  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] 18+ messages in thread

* Re: [PATCH 05/12] i2c: omap: set device parent and of_node through the adapter struct
  2025-12-23 10:04 ` [PATCH 05/12] i2c: omap: " Bartosz Golaszewski
@ 2025-12-29 14:54   ` Andreas Kemnade
  0 siblings, 0 replies; 18+ messages in thread
From: Andreas Kemnade @ 2025-12-29 14:54 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, 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 Tue, 23 Dec 2025 11:04:43 +0100
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>

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>


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

* Re: [PATCH 11/12] i2c: nomadik: set device parent and of_node through the adapter struct
  2025-12-23 10:04 ` [PATCH 11/12] i2c: nomadik: " Bartosz Golaszewski
@ 2026-01-03 19:04   ` Linus Walleij
  0 siblings, 0 replies; 18+ messages in thread
From: Linus Walleij @ 2026-01-03 19:04 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,
	Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel

On Tue, Dec 23, 2025 at 11:05 AM 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>

Provided the overall concept is deemed sound:
Acked-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij


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

* Re: [PATCH 07/12] i2c: st: set device parent and of_node through the adapter struct
  2025-12-23 10:04 ` [PATCH 07/12] i2c: st: " Bartosz Golaszewski
@ 2026-01-05  7:26   ` Patrice CHOTARD
  0 siblings, 0 replies; 18+ messages in thread
From: Patrice CHOTARD @ 2026-01-05  7:26 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,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Linus Walleij
  Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
	linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
	linux-rpi-kernel



On 12/23/25 11:04, 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>
> ---
>  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 97d70e66722706f242cd97153387c3a865abc12d..b50be2c39eaa4b9b95a71b038a4d63f3c5fd7c4b 100644
> --- a/drivers/i2c/busses/i2c-st.c
> +++ b/drivers/i2c/busses/i2c-st.c
> @@ -849,8 +849,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);
>  
> 
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice


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

* Re: [PATCH 06/12] i2c: rcar: set device parent and of_node through the adapter struct
  2025-12-23 10:04 ` [PATCH 06/12] i2c: rcar: " Bartosz Golaszewski
@ 2026-01-06  9:13   ` Geert Uytterhoeven
  2026-01-06 14:17     ` Bartosz Golaszewski
  0 siblings, 1 reply; 18+ messages in thread
From: Geert Uytterhoeven @ 2026-01-06  9:13 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

Hi Bartosz,

On Tue, 23 Dec 2025 at 11:05, 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>

Thanks for your patch!

> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -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);

    [....]
    ret = rcar_i2c_clock_calculate(priv);
    [...]
    ret = i2c_add_numbered_adapter(adap);

As rcar_i2c_clock_calculate() uses rcar_i2c_priv_to_dev(priv):

    #define rcar_i2c_priv_to_dev(p)         ((p)->adap.dev.parent)

I believe this will deference dev.parent before it is initialized by
the newly added code in i2c_register_adapter().

Let's check...

    Unable to handle kernel NULL pointer dereference at virtual
address 0000024c when read
    [0000024c] *pgd=80000040004003, *pmd=00000000
    Internal error: Oops: 206 [#1] SMP ARM
    Modules linked in:
    CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
6.19.0-rc3-koelsch-04401-g9e22366a23cd #2288 NONE
    Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
    PC is at device_property_read_u32_array+0x0/0x14
    LR is at i2c_parse_timing+0x14/0x30
    [...]
    Call trace:
     device_property_read_u32_array from i2c_parse_timing+0x14/0x30
     i2c_parse_timing from i2c_parse_fw_timings+0x28/0x12c
     i2c_parse_fw_timings from rcar_i2c_probe+0x1cc/0x534
     rcar_i2c_probe from platform_probe+0x58/0x90

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] 18+ messages in thread

* Re: [PATCH 06/12] i2c: rcar: set device parent and of_node through the adapter struct
  2026-01-06  9:13   ` Geert Uytterhoeven
@ 2026-01-06 14:17     ` Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2026-01-06 14:17 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, linux-i2c, linux-kernel,
	linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel,
	imx, linux-rpi-kernel

On Tue, Jan 6, 2026 at 10:14 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Bartosz,
>
> On Tue, 23 Dec 2025 at 11:05, 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>
>
> Thanks for your patch!
>
> > --- a/drivers/i2c/busses/i2c-rcar.c
> > +++ b/drivers/i2c/busses/i2c-rcar.c
> > @@ -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);
>
>     [....]
>     ret = rcar_i2c_clock_calculate(priv);
>     [...]
>     ret = i2c_add_numbered_adapter(adap);
>
> As rcar_i2c_clock_calculate() uses rcar_i2c_priv_to_dev(priv):
>
>     #define rcar_i2c_priv_to_dev(p)         ((p)->adap.dev.parent)
>
> I believe this will deference dev.parent before it is initialized by
> the newly added code in i2c_register_adapter().
>
> Let's check...
>
>     Unable to handle kernel NULL pointer dereference at virtual
> address 0000024c when read
>     [0000024c] *pgd=80000040004003, *pmd=00000000
>     Internal error: Oops: 206 [#1] SMP ARM
>     Modules linked in:
>     CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> 6.19.0-rc3-koelsch-04401-g9e22366a23cd #2288 NONE
>     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
>     PC is at device_property_read_u32_array+0x0/0x14
>     LR is at i2c_parse_timing+0x14/0x30
>     [...]
>     Call trace:
>      device_property_read_u32_array from i2c_parse_timing+0x14/0x30
>      i2c_parse_timing from i2c_parse_fw_timings+0x28/0x12c
>      i2c_parse_fw_timings from rcar_i2c_probe+0x1cc/0x534
>      rcar_i2c_probe from platform_probe+0x58/0x90
>

Thanks for the heads-up. I'm still waiting for Wolfram to decide if
these changes will be accepted or not before sending a v2.

Bartosz


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

end of thread, other threads:[~2026-01-06 14:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 10:04 [PATCH 00/12] i2c: configure parent device and OF node through the adapter struct Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 01/12] i2c: allow setting the " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 02/12] i2c: qcom-geni: set device parent and of_node " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 03/12] i2c: bcm-kona: " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 04/12] i2c: keba: " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 05/12] i2c: omap: " Bartosz Golaszewski
2025-12-29 14:54   ` Andreas Kemnade
2025-12-23 10:04 ` [PATCH 06/12] i2c: rcar: " Bartosz Golaszewski
2026-01-06  9:13   ` Geert Uytterhoeven
2026-01-06 14:17     ` Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 07/12] i2c: st: " Bartosz Golaszewski
2026-01-05  7:26   ` Patrice CHOTARD
2025-12-23 10:04 ` [PATCH 08/12] i2c: mxs: " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 09/12] i2c: highlander: " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 10/12] i2c: gpio: " Bartosz Golaszewski
2025-12-23 10:04 ` [PATCH 11/12] i2c: nomadik: " Bartosz Golaszewski
2026-01-03 19:04   ` Linus Walleij
2025-12-23 10:04 ` [PATCH 12/12] i2c: bcm2835: " Bartosz Golaszewski

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