[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7a6fd045-3513-4979-9210-8e30361022e3@ideasonboard.com>
Date: Mon, 6 Jan 2025 11:34:10 +0200
From: Tomi Valkeinen <tomi.valkeinen@...asonboard.com>
To: Romain Gantois <romain.gantois@...tlin.com>
Cc: Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Kory Maincent <kory.maincent@...tlin.com>, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
linux-media@...r.kernel.org, linux-gpio@...r.kernel.org,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
Luca Ceresoli <luca.ceresoli@...tlin.com>, Andi Shyti
<andi.shyti@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Derek Kiernan <derek.kiernan@....com>,
Dragan Cvetic <dragan.cvetic@....com>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>
Subject: Re: [PATCH v4 2/9] media: i2c: ds90ub960: Replace aliased clients
list with address list
Hi,
On 30/12/2024 15:22, Romain Gantois wrote:
> The ds90ub960 driver currently uses a list of i2c_client structs to keep
> track of used I2C address translator (ATR) alias slots for each RX port.
>
> Keeping these i2c_client structs in the alias slot list isn't actually
> needed, the driver only needs to know the client address for each slot.
>
> Convert the aliased_clients list to a list of aliased client addresses.
> This will allow removing the "client" parameter from the i2c-atr callbacks
> in a future patch.
>
> Signed-off-by: Romain Gantois <romain.gantois@...tlin.com>
> ---
> drivers/media/i2c/ds90ub960.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> index 33f362a008757578e4c96e6ea7bed2e590776d8d..7534ddf2079fef466d3a114f0be98599427639fa 100644
> --- a/drivers/media/i2c/ds90ub960.c
> +++ b/drivers/media/i2c/ds90ub960.c
> @@ -467,7 +467,7 @@ struct ub960_rxport {
> };
> } eq;
>
> - const struct i2c_client *aliased_clients[UB960_MAX_PORT_ALIASES];
> + u16 aliased_addrs[UB960_MAX_PORT_ALIASES];
> };
>
> struct ub960_asd {
> @@ -1031,17 +1031,17 @@ static int ub960_atr_attach_client(struct i2c_atr *atr, u32 chan_id,
> struct device *dev = &priv->client->dev;
> unsigned int reg_idx;
>
> - for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) {
> - if (!rxport->aliased_clients[reg_idx])
> + for (reg_idx = 0; reg_idx < UB960_MAX_PORT_ALIASES; reg_idx++) {
Any reason to drop the use of ARRAY_SIZE()? Usually when dealing with
fixed size arrays, it's nicer to use ARRAY_SIZE().
Tomi
> + if (!rxport->aliased_addrs[reg_idx])
> break;
> }
>
> - if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
> + if (reg_idx == UB960_MAX_PORT_ALIASES) {
> dev_err(dev, "rx%u: alias pool exhausted\n", rxport->nport);
> return -EADDRNOTAVAIL;
> }
>
> - rxport->aliased_clients[reg_idx] = client;
> + rxport->aliased_addrs[reg_idx] = client->addr;
>
> ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ID(reg_idx),
> client->addr << 1);
> @@ -1062,18 +1062,18 @@ static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id,
> struct device *dev = &priv->client->dev;
> unsigned int reg_idx;
>
> - for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) {
> - if (rxport->aliased_clients[reg_idx] == client)
> + for (reg_idx = 0; reg_idx < UB960_MAX_PORT_ALIASES; reg_idx++) {
> + if (rxport->aliased_addrs[reg_idx] == client->addr)
> break;
> }
>
> - if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
> + if (reg_idx == UB960_MAX_PORT_ALIASES) {
> dev_err(dev, "rx%u: client 0x%02x is not mapped!\n",
> rxport->nport, client->addr);
> return;
> }
>
> - rxport->aliased_clients[reg_idx] = NULL;
> + rxport->aliased_addrs[reg_idx] = 0;
>
> ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx), 0);
>
>
Powered by blists - more mailing lists