From: Romain Gantois <romain.gantois@bootlin.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Andi Shyti <andi.shyti@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Derek Kiernan <derek.kiernan@amd.com>,
Dragan Cvetic <dragan.cvetic@amd.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Kory Maincent <kory.maincent@bootlin.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-media@vger.kernel.org,
Romain Gantois <romain.gantois@bootlin.com>
Subject: [PATCH 2/9] media: i2c: ds90ub960: Replace aliased clients list with bitmap
Date: Fri, 08 Nov 2024 16:36:54 +0100 [thread overview]
Message-ID: <20241108-fpc202-v1-2-fe42c698bc92@bootlin.com> (raw)
In-Reply-To: <20241108-fpc202-v1-0-fe42c698bc92@bootlin.com>
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 if a specific alias slot is already
in use or not.
Convert the aliased_clients list to a bitmap named "alias_use_mask". This
will allow removing the "client" parameter from the i2c-atr callbacks in a
future patch.
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
drivers/media/i2c/ds90ub960.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
index ffe5f25f8647624be005da33a6412da2493413b4..f86028894c78187257efc8fd70812387000796f7 100644
--- a/drivers/media/i2c/ds90ub960.c
+++ b/drivers/media/i2c/ds90ub960.c
@@ -468,7 +468,7 @@ struct ub960_rxport {
};
} eq;
- const struct i2c_client *aliased_clients[UB960_MAX_PORT_ALIASES];
+ DECLARE_BITMAP(alias_use_mask, UB960_MAX_PORT_ALIASES);
};
struct ub960_asd {
@@ -1032,17 +1032,13 @@ 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])
- break;
- }
-
- if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) {
+ reg_idx = find_first_zero_bit(rxport->alias_use_mask, UB960_MAX_PORT_ALIASES);
+ 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;
+ set_bit(reg_idx, rxport->alias_use_mask);
ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ID(reg_idx),
client->addr << 1);
@@ -1063,18 +1059,15 @@ 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)
- break;
- }
+ reg_idx = find_first_zero_bit(rxport->alias_use_mask, UB960_MAX_PORT_ALIASES);
- 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;
+ clear_bit(reg_idx, rxport->alias_use_mask);
ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx), 0);
@@ -3404,6 +3397,8 @@ static int ub960_parse_dt_rxport(struct ub960_data *priv, unsigned int nport,
if (ret)
goto err_put_remote_fwnode;
+ bitmap_zero(rxport->alias_use_mask, UB960_MAX_PORT_ALIASES);
+
return 0;
err_put_remote_fwnode:
--
2.47.0
next prev parent reply other threads:[~2024-11-08 15:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 15:36 [PATCH 0/9] misc: Support TI FPC202 dual-port controller Romain Gantois
2024-11-08 15:36 ` [PATCH 1/9] dt-bindings: misc: Describe TI FPC202 dual port controller Romain Gantois
2024-11-08 18:23 ` Conor Dooley
2024-11-13 9:46 ` Romain Gantois
2024-11-08 15:36 ` Romain Gantois [this message]
2024-11-08 15:36 ` [PATCH 3/9] media: i2c: ds90ub960: Protect alias_use_mask with a mutex Romain Gantois
2024-11-08 15:36 ` [PATCH 4/9] i2c: use client addresses directly in ATR interface Romain Gantois
2024-11-08 15:36 ` [PATCH 5/9] i2c: move ATR alias pool to a separate struct Romain Gantois
2024-11-08 15:36 ` [PATCH 6/9] i2c: rename field 'alias_list' of struct i2c_atr_chan to 'alias_pairs' Romain Gantois
2024-11-08 15:36 ` [PATCH 7/9] i2c: support per-channel ATR alias pools Romain Gantois
2024-11-08 15:37 ` [PATCH 8/9] i2c: Support dynamic address translation Romain Gantois
2024-11-08 15:37 ` [PATCH 9/9] misc: add FPC202 dual port controller driver Romain Gantois
2024-11-09 20:19 ` kernel test robot
2024-11-11 8:56 ` Luca Ceresoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241108-fpc202-v1-2-fe42c698bc92@bootlin.com \
--to=romain.gantois@bootlin.com \
--cc=andi.shyti@kernel.org \
--cc=arnd@arndb.de \
--cc=conor+dt@kernel.org \
--cc=derek.kiernan@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=dragan.cvetic@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=kory.maincent@bootlin.com \
--cc=krzk+dt@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox