From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA9092D7DC6 for ; Sun, 23 Aug 2026 16:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787502887; cv=none; b=ZP5SKiZeCVTd5N3M3uuojlU/bMdZT1eHepFDP7UmzKMBCd1MJ/ouhXO132qfeYQia/peRLBU7yRV9AVpxoz1mYCukh/yY5VY0d+B0yrLa9vDFYYuiijWotZIH2XNG5+OqECukDtk1o+ir5nQ4HOIFgY82Pc4AeaYFK65SE7vSqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787502887; c=relaxed/simple; bh=HUYvrAXW6ktdAawFO9BGSNSafLNtS5sykuLnjS6hzPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eLH6WVoffmiWgQRPYWfBYh/9DjTtWQRTCd5xGrh1f8ThZKAE504jMMY4PcmRzzSnpnHE56GYnSRpfKOiFBJjDY1uZx6J79TZoUHMQaGBIAAUOCF3BKEdsUF3gfMr98o5ATJ7yGw+dYKKYoT79Erse0RE+nwGm/zipXiD+trMzTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A2zYf7qW; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A2zYf7qW" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-38e88b60121so1987022a91.3 for ; Sun, 23 Aug 2026 09:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787502884; x=1788107684; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GxGKUYSLhGHGkrvjs/JDyLU+7Ol+Ws3V83G2cQ2UfpU=; b=A2zYf7qWs9x/jOWQrxU+qooeXt95Y8s8kUJ87ciFHIDELzVyXfXxf/BMT/3aEoo43G E26BeXXC2Xps/X1SY0KrkFgGnCeUOUwCb8CED6aO/N1AxmxMwciOL5qFgwmON8xVSHJr OQtNgBQGG5pmtmrcG7N5EQWuPS8m8SbGkJCYrd/lkg25gdix4H0ShodpFL24rMD3uHqK jzrjz3KjGa1oUbu4IsjeIBcV7Ps/AI5GVybK4xcwn4QFqm/ewOA+hjzEcnT8b0G6GVhd cWu8snQkXj4QU46yIADWn9baGsYB3y/Um2OZvAGWnx8jZrw1P39S/yNnBwMY/mh7U6a0 MDeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787502884; x=1788107684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GxGKUYSLhGHGkrvjs/JDyLU+7Ol+Ws3V83G2cQ2UfpU=; b=VwFQngl4BoFolSpVubt0PQ9Se/cIsKB+DwywmvUOya+c9Mc7Br3XDXggk8/jFnokmJ cv3sHroBgJ7LGyGoIll0OZHFpIUrZMbnzQGzvp7xsMIi8+pv+a6UK+RZY0HVe6vQZDxv OEF9oZyLVOoiKu5bfY74jR1RNyJyikp9Q9Hm93LVJxoFtpv9Zt+Yfrf30HDP8N37I3uL zDwypvX6wxD7HZl/zaUdzx7KIAa2ylWa+lkljunFFPFRuT4Y1uVBm2Ji8KAIly1FV4mB z6N7YA/o1EuFk4KoV1YMiy/WzZbgFZCdzrp1XnsetHi2JmXOaEV/CtMDwKVP9gZddycs bv+Q== X-Forwarded-Encrypted: i=1; AHgh+RrrcmdsHT+fiKsJTDPCLO+PH613hZM9bnC+VgDT4TqHgwO88g57EK+oG5I5CepNHIRzqLQqdXfM24MRdZE=@vger.kernel.org X-Gm-Message-State: AFuF++n0kWcA1VkasknIrN9pyRbVsMTSVSO+Cbnjv7DvM/F1k1tLcXKB tBQ1pMy2Pw3Qqcmr1N25JAi1LlCj9PhXCK9xdYfe19cc5ltJ8gM7w4S1Venvug== X-Gm-Gg: AR+sD10qe5pea1AknvG7sYSGqoWm9D70vYPcENlXBA64SzIbWKQgmXqapIE1hg6kd0q gd1sp73noPqjOHuXO2/uwLOLUNZ/gECsPIpe1SOj66sBPKnsI2j0jbuHP8vp+5G418JoTL+kuRa ih6VVy1gctfuIMid8sBaoVjxHzoZdSr3ribtshShlLY0wgzsszwFNH7DTs4gosDssdQvQyAHF4E X82pekUSv/89Ie/89KueQCtdYuypgJZ1fxTnL643lousUQ3ZEjzqJO7VsRPrjIX4OZeN+Gy0M0D pgDRSa+jLIkZC+YOZk5nAfT1TdD3z2CRbE5n7hMrCD9m4vfoZJn7+W4cUIRvgGaJj9bDDl1TqQ0 0GKguJQoVB6YuIdIYdyElLNJTIHfflP5kLUjkqcSzRTgkjYxfQw82KxyyzxA5lo0KAWtfNhN3Lv Ns+pDuG5uTXOcMMcSKPPoHdM/34XGrpd53QdVQFN8mjKlVCpY3c82ORer6+zZU17s7KlRwFCzjG 9KTH0ykvkrbWDghdjwUx0IifEpRe8JJX3h6F/0JO3Uv1XnMMrsEk6m5vLDul4gp/USrnaUFHfKp jf1E371RLg2Zt5xSk/Gs X-Received: by 2002:a17:90b:5790:b0:38e:9045:babe with SMTP id 98e67ed59e1d1-395deecf08fmr24060528a91.7.1787502884014; Sun, 23 Aug 2026 09:34:44 -0700 (PDT) Received: from Mac.net (198-27-228-154.fiber.dynamic.sonic.net. [198.27.228.154]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-141860ef75esm17084319c88.7.2026.08.23.09.34.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 23 Aug 2026 09:34:43 -0700 (PDT) From: Ahmad Byagowi To: Andi Shyti Cc: Peter Rosin , Jakub Kicinski , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Ahmad Byagowi Subject: [PATCH v7 3/3] i2c: mux: Propagate software nodes to channel adapters Date: Sun, 23 Aug 2026 09:34:38 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Device Tree channel nodes are associated with the adapters created by i2c-mux, but equivalent software-node descriptions are not. Use generic firmware-node operations for the existing channel lookup and accept either an OF node or a software node. Associate the returned node with the adapter so child I2C devices can be instantiated from software-node properties. Save the adapter firmware node before adapter deletion and release the reference afterwards, following the lifetime pattern in i2c-atr. Signed-off-by: Ahmad Byagowi --- drivers/i2c/i2c-mux.c | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index a8b94b97a725..b37d36d3b121 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -264,40 +265,40 @@ static const struct i2c_lock_operations i2c_parent_lock_ops = { .unlock_bus = i2c_parent_unlock_bus, }; -static struct device_node * +static struct fwnode_handle * i2c_mux_get_channel_node(struct i2c_mux_core *muxc, u32 chan_id) { - struct device_node *dev_node = muxc->dev->of_node; - struct device_node *mux_node, *child = NULL; + struct fwnode_handle *dev_node = dev_fwnode(muxc->dev); + struct fwnode_handle *mux_node, *child = NULL; u32 reg; int ret; - if (!dev_node) + if (!is_of_node(dev_node) && !is_software_node(dev_node)) return NULL; if (muxc->arbitrator) - mux_node = of_get_child_by_name(dev_node, "i2c-arb"); + mux_node = fwnode_get_named_child_node(dev_node, "i2c-arb"); else if (muxc->gate) - mux_node = of_get_child_by_name(dev_node, "i2c-gate"); + mux_node = fwnode_get_named_child_node(dev_node, "i2c-gate"); else - mux_node = of_get_child_by_name(dev_node, "i2c-mux"); + mux_node = fwnode_get_named_child_node(dev_node, "i2c-mux"); if (mux_node) { - /* A "reg" property indicates an old-style DT entry */ - if (!of_property_read_u32(mux_node, "reg", ®)) { - of_node_put(mux_node); + /* A "reg" property indicates an old-style firmware entry. */ + if (!fwnode_property_read_u32(mux_node, "reg", ®)) { + fwnode_handle_put(mux_node); mux_node = NULL; } } if (!mux_node) - mux_node = of_node_get(dev_node); + mux_node = fwnode_handle_get(dev_node); else if (muxc->arbitrator || muxc->gate) - child = of_node_get(mux_node); + child = fwnode_handle_get(mux_node); if (!child) { - for_each_child_of_node(mux_node, child) { - ret = of_property_read_u32(child, "reg", ®); + fwnode_for_each_child_node(mux_node, child) { + ret = fwnode_property_read_u32(child, "reg", ®); if (ret) continue; if (chan_id == reg) @@ -305,7 +306,7 @@ i2c_mux_get_channel_node(struct i2c_mux_core *muxc, u32 chan_id) } } - of_node_put(mux_node); + fwnode_handle_put(mux_node); return child; } @@ -368,11 +369,9 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, else priv->adap.lock_ops = &i2c_parent_lock_ops; - /* - * Try to populate the mux adapter's of_node, expands to - * nothing if !CONFIG_OF. - */ - priv->adap.dev.of_node = i2c_mux_get_channel_node(muxc, chan_id); + /* Associate the mux adapter with its OF or software-node channel. */ + device_set_node(&priv->adap.dev, + i2c_mux_get_channel_node(muxc, chan_id)); /* * Associate the mux channel with an ACPI node. @@ -416,7 +415,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, return 0; err_free_priv: - of_node_put(priv->adap.dev.of_node); + fwnode_handle_put(dev_fwnode(&priv->adap.dev)); kfree(priv); return ret; } @@ -429,7 +428,7 @@ void i2c_mux_del_adapters(struct i2c_mux_core *muxc) while (muxc->num_adapters) { struct i2c_adapter *adap = muxc->adapter[--muxc->num_adapters]; struct i2c_mux_priv *priv = adap->algo_data; - struct device_node *np = adap->dev.of_node; + struct fwnode_handle *fwnode = dev_fwnode(&adap->dev); muxc->adapter[muxc->num_adapters] = NULL; @@ -439,7 +438,7 @@ void i2c_mux_del_adapters(struct i2c_mux_core *muxc) sysfs_remove_link(&priv->adap.dev.kobj, "mux_device"); i2c_del_adapter(adap); - of_node_put(np); + fwnode_handle_put(fwnode); kfree(priv); } } -- 2.50.1 (Apple Git-155)