mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-27 01:53:12 -04:00
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 <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>
This commit is contained in:
committed by
Wolfram Sang
parent
35c6e493bd
commit
666be28145
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user