[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <81006407-cfbd-47b7-8050-3a455f9654dd@wanadoo.fr>
Date: Tue, 11 Jun 2024 20:01:59 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Farouk Bouabid <farouk.bouabid@...rry.de>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
Peter Rosin <peda@...ntia.se>, Andi Shyti <andi.shyti@...nel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>, Quentin Schulz
<quentin.schulz@...rry.de>, Heiko Stuebner <heiko@...ech.de>
Cc: linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org
Subject: Re: [PATCH v3 1/7] i2c: mux: add the ability to share mux address
with child nodes
Le 11/06/2024 à 13:43, Farouk Bouabid a écrit :
> Allow the mux (if it's an I2C device) to have the same address as a child
> device. This is useful when the mux can only use an I2C address that is
> used by a child device because no other addresses are free to use.
> eg. the mux can only use address 0x18 which is used by amc6821 connected
> to the mux.
>
> Signed-off-by: Farouk Bouabid <farouk.bouabid@...rry.de>
> ---
Hi,
2 nitpicks below.
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -334,7 +334,53 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
> priv->adap.dev.parent = &parent->dev;
> priv->adap.retries = parent->retries;
> priv->adap.timeout = parent->timeout;
> - priv->adap.quirks = parent->quirks;
> +
> + struct i2c_adapter_quirks *quirks;
Should this be at the beginning of the function?
> + /*
> + * When creating the adapter, the node devices are checked for I2C address
> + * match with other devices on the parent adapter, among which is the mux itself.
> + * If a match is found the node device is not probed successfully.
> + * Allow the mux to have the same address as a child device by skipping this check.
> + */
> + if (muxc->share_addr_with_children) {
> + struct i2c_client *client = to_i2c_client(muxc->dev);
> +
> + if (muxc->dev->type != &i2c_client_type)
> + dev_warn_once(muxc->dev, "Mux is not an I2C device\n");
> +
> + quirks = devm_kzalloc(muxc->dev, sizeof(*quirks), GFP_KERNEL);
> + if (!quirks)
> + return -ENOMEM;
> +
> + if (parent->quirks)
> + memcpy(quirks, parent->quirks, sizeof(*quirks));
> +
> + quirks->flags |= I2C_AQ_SKIP_ADDR_CHECK;
> + quirks->skip_addr_in_parent = client->addr;
> + priv->adap.quirks = quirks;
> +
> + } else if (parent->quirks &&
> + parent->quirks->flags & I2C_AQ_SKIP_ADDR_CHECK) {
> + /*
> + * Another I2C mux device can be a child of the Mule I2C mux.
> + * The former could probably not allow address conflict between
> + * its address and its own children addresses.
> + *
> + * For this purpose, do not propagate this flag unless
> + * share_addr_with_children is set.
> + */
> + quirks = devm_kzalloc(muxc->dev, sizeof(*quirks), GFP_KERNEL);
devm_kmemdup()? (not sure it is a win)
> + if (!quirks)
> + return -ENOMEM;
> +
> + memcpy(quirks, parent->quirks, sizeof(*quirks));
> + quirks->flags &= ~I2C_AQ_SKIP_ADDR_CHECK;
> + priv->adap.quirks = quirks;
> +
> + } else {
> + priv->adap.quirks = parent->quirks;
> + }
> +
> if (muxc->mux_locked)
> priv->adap.lock_ops = &i2c_mux_lock_ops;
> else
...
CJ
Powered by blists - more mailing lists