Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com>,
	Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Vignesh R <vigneshr@ti.com>, Aaro Koskinen <aaro.koskinen@iki.fi>,
	Janusz Krzysztofik <jmkrzyszt@gmail.com>,
	Tony Lindgren <tony@atomide.com>,
	Andreas Kemnade <andreas@kemnade.info>,
	Kevin Hilman <khilman@baylibre.com>,
	Roger Quadros <rogerq@kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Linus Walleij <linusw@kernel.org>, Frank Li <Frank.Li@nxp.com>
Cc: Bartosz Golaszewski <brgl@kernel.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	linux-rpi-kernel@lists.infradead.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct
Date: Mon, 23 Feb 2026 10:05:47 +0100	[thread overview]
Message-ID: <20260223-i2c-adap-dev-config-v2-1-d78db0a6fcf7@oss.qualcomm.com> (raw)
In-Reply-To: <20260223-i2c-adap-dev-config-v2-0-d78db0a6fcf7@oss.qualcomm.com>

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


  reply	other threads:[~2026-02-23  9:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-03-02  7:47   ` [PATCH v2 01/12] i2c: allow setting the " 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
  -- strict thread matches above, loose matches on Subject: below --
2026-03-02 10:38 [PATCH v2 01/12] i2c: allow setting the " Kalle Niemi
2026-03-02 11:08 ` Bartosz Golaszewski
2026-03-02 15:59   ` Andreas Kemnade
2026-03-02 16:56     ` Andreas Kemnade
2026-03-02 15:09 ` Andreas Kemnade
2026-03-02 15:42   ` Bartosz Golaszewski
2026-03-02 16:14     ` Andreas Kemnade

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260223-i2c-adap-dev-config-v2-1-d78db0a6fcf7@oss.qualcomm.com \
    --to=bartosz.golaszewski@oss.qualcomm.com \
    --cc=Frank.Li@nxp.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=andi.shyti@kernel.org \
    --cc=andreas@kemnade.info \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=brgl@kernel.org \
    --cc=festevam@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=geert+renesas@glider.be \
    --cc=imx@lists.linux.dev \
    --cc=jmkrzyszt@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=khilman@baylibre.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=magnus.damm@gmail.com \
    --cc=mukesh.savaliya@oss.qualcomm.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=rjui@broadcom.com \
    --cc=rogerq@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sbranden@broadcom.com \
    --cc=shawnguo@kernel.org \
    --cc=tony@atomide.com \
    --cc=vigneshr@ti.com \
    --cc=viken.dadhaniya@oss.qualcomm.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox