]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: i2c: ds90ub960: Replace aliased clients list with address list
authorRomain Gantois <romain.gantois@bootlin.com>
Thu, 6 Mar 2025 16:23:23 +0000 (17:23 +0100)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Fri, 18 Apr 2025 21:33:11 +0000 (23:33 +0200)
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.

Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
Acked-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/media/i2c/ds90ub960.c

index 5afdbbad9ff4faa32cb33c0a5bf5920192281041..fa06ce38e35f123277ad6cb356a3668bb0fc4820 100644 (file)
@@ -478,7 +478,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 {
@@ -1054,17 +1054,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 < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
+               if (!rxport->aliased_addrs[reg_idx])
                        break;
        }
 
-       if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
+       if (reg_idx == ARRAY_SIZE(rxport->aliased_addrs)) {
                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);
@@ -1085,18 +1085,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 < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
+               if (rxport->aliased_addrs[reg_idx] == client->addr)
                        break;
        }
 
-       if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
+       if (reg_idx == ARRAY_SIZE(rxport->aliased_addrs)) {
                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);