Skip to content

Commit 666be28

Browse files
rgantoisWolfram Sang
authored andcommitted
media: i2c: ds90ub960: Replace aliased clients list with address list
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 <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 35c6e49 commit 666be28

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/media/i2c/ds90ub960.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ struct ub960_rxport {
478478
};
479479
} eq;
480480

481-
const struct i2c_client *aliased_clients[UB960_MAX_PORT_ALIASES];
481+
u16 aliased_addrs[UB960_MAX_PORT_ALIASES];
482482
};
483483

484484
struct ub960_asd {
@@ -1054,17 +1054,17 @@ static int ub960_atr_attach_client(struct i2c_atr *atr, u32 chan_id,
10541054
struct device *dev = &priv->client->dev;
10551055
unsigned int reg_idx;
10561056

1057-
for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) {
1058-
if (!rxport->aliased_clients[reg_idx])
1057+
for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
1058+
if (!rxport->aliased_addrs[reg_idx])
10591059
break;
10601060
}
10611061

1062-
if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
1062+
if (reg_idx == ARRAY_SIZE(rxport->aliased_addrs)) {
10631063
dev_err(dev, "rx%u: alias pool exhausted\n", rxport->nport);
10641064
return -EADDRNOTAVAIL;
10651065
}
10661066

1067-
rxport->aliased_clients[reg_idx] = client;
1067+
rxport->aliased_addrs[reg_idx] = client->addr;
10681068

10691069
ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ID(reg_idx),
10701070
client->addr << 1);
@@ -1085,18 +1085,18 @@ static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id,
10851085
struct device *dev = &priv->client->dev;
10861086
unsigned int reg_idx;
10871087

1088-
for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) {
1089-
if (rxport->aliased_clients[reg_idx] == client)
1088+
for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_addrs); reg_idx++) {
1089+
if (rxport->aliased_addrs[reg_idx] == client->addr)
10901090
break;
10911091
}
10921092

1093-
if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
1093+
if (reg_idx == ARRAY_SIZE(rxport->aliased_addrs)) {
10941094
dev_err(dev, "rx%u: client 0x%02x is not mapped!\n",
10951095
rxport->nport, client->addr);
10961096
return;
10971097
}
10981098

1099-
rxport->aliased_clients[reg_idx] = NULL;
1099+
rxport->aliased_addrs[reg_idx] = 0;
11001100

11011101
ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx), 0);
11021102

0 commit comments

Comments
 (0)