From nobody Sun Nov 24 02:54:22 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FA2C19340E; Mon, 18 Nov 2024 10:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731924800; cv=none; b=KY09xUH0ocSbP8Svnh/iMneEmvI8SyTPznOYRdWcCoQ7FVe0cxIVN+rZ0ic0T1BHrXZ7UcyNKioG2oGm/uoWvYioLBQVX2DFmnSZRXYknEKxKz9GflmVP2cqmPaeCy7KUcHQiwrZcSLD+gx5JeDOSU9MOhAL0Nlcf6hLHgSZ/zA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731924800; c=relaxed/simple; bh=1ypPzc3wV+lBm0DYM/aNzTLOzfM+uS1LxxpyOA8V4G8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PjT694kROXDrVQS7BvXLlwEn7TkquOmZ6o/4hbSsrlYKbgvtBi/Tnvj0/E2xRX6gwYva+5GXDfcPz7cKEY0KHstkWBH1R670RRAvRhXPFfk+oU9S9smE6Zxr2aHCoZ0MY1QoZt/s59yCSNAwdvE8iWk9JxmRxQIbKvLBnzMN/Sc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=lKTVn7aN; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="lKTVn7aN" Received: by mail.gandi.net (Postfix) with ESMTPSA id 4643E1BF204; Mon, 18 Nov 2024 10:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731924791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sFZV/j2cdKSUUBE7wpD1K2bQ3OXCC6ZtMchgh75jPUI=; b=lKTVn7aNyzeWJCGW8t4isl8EESGUzHey2EReJeO+jTglw3vv7SJ8gqN2d/GAbD+jJ047HQ iNMEVAKENbzhiz7AeY3iGHEchbxsybOpNPEf6cjN3uvpQkS8TeZbdWZQyaDAW8OCuYavn3 dzdOw00Nyg8gp8pJkyxyphsxjJsoLX2nvj+YHAglx+feFxuKSl8XeeMxlJCmNUgazmLZl7 Lnn6Mt2DaIhR0HyqfWMs70plzitnedpgRsRF/iMF67QaaH3MEo3YStuEVafnfVPWf7ChnF F7JUKNCRfi78nfw/pAeGjYzykXFWsvab1/rspi5Nc9fPCEp3MaVE5X8/8AcJJw== From: Romain Gantois Date: Mon, 18 Nov 2024 11:13:01 +0100 Subject: [PATCH v2 2/9] media: i2c: ds90ub960: Replace aliased clients list with bitmap Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241118-fpc202-v2-2-744e4f192a2d@bootlin.com> References: <20241118-fpc202-v2-0-744e4f192a2d@bootlin.com> In-Reply-To: <20241118-fpc202-v2-0-744e4f192a2d@bootlin.com> To: Wolfram Sang , Tomi Valkeinen , Luca Ceresoli , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Mauro Carvalho Chehab , Linus Walleij , Bartosz Golaszewski Cc: Thomas Petazzoni , Kory Maincent , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, linux-gpio@vger.kernel.org, Romain Gantois X-Mailer: b4 0.14.2 X-GND-Sasl: romain.gantois@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 --- 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..f86028894c78187257efc8fd708= 12387000796f7 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -468,7 +468,7 @@ struct ub960_rxport { }; } eq; =20 - const struct i2c_client *aliased_clients[UB960_MAX_PORT_ALIASES]; + DECLARE_BITMAP(alias_use_mask, UB960_MAX_PORT_ALIASES); }; =20 struct ub960_asd { @@ -1032,17 +1032,13 @@ static int ub960_atr_attach_client(struct i2c_atr *= atr, u32 chan_id, struct device *dev =3D &priv->client->dev; unsigned int reg_idx; =20 - for (reg_idx =3D 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_id= x++) { - if (!rxport->aliased_clients[reg_idx]) - break; - } - - if (reg_idx =3D=3D ARRAY_SIZE(rxport->aliased_clients)) { + reg_idx =3D find_first_zero_bit(rxport->alias_use_mask, UB960_MAX_PORT_AL= IASES); + if (reg_idx >=3D UB960_MAX_PORT_ALIASES) { dev_err(dev, "rx%u: alias pool exhausted\n", rxport->nport); return -EADDRNOTAVAIL; } =20 - rxport->aliased_clients[reg_idx] =3D client; + set_bit(reg_idx, rxport->alias_use_mask); =20 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 =3D &priv->client->dev; unsigned int reg_idx; =20 - for (reg_idx =3D 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_id= x++) { - if (rxport->aliased_clients[reg_idx] =3D=3D client) - break; - } + reg_idx =3D find_first_zero_bit(rxport->alias_use_mask, UB960_MAX_PORT_AL= IASES); =20 - if (reg_idx =3D=3D ARRAY_SIZE(rxport->aliased_clients)) { + if (reg_idx >=3D UB960_MAX_PORT_ALIASES) { dev_err(dev, "rx%u: client 0x%02x is not mapped!\n", rxport->nport, client->addr); return; } =20 - rxport->aliased_clients[reg_idx] =3D NULL; + clear_bit(reg_idx, rxport->alias_use_mask); =20 ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx), 0); =20 @@ -3404,6 +3397,8 @@ static int ub960_parse_dt_rxport(struct ub960_data *p= riv, unsigned int nport, if (ret) goto err_put_remote_fwnode; =20 + bitmap_zero(rxport->alias_use_mask, UB960_MAX_PORT_ALIASES); + return 0; =20 err_put_remote_fwnode: --=20 2.47.0