From patchwork Wed Jan 8 16:14:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 855781 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 7F4761FECB3; Wed, 8 Jan 2025 16:14:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736352862; cv=none; b=lmFnIXJyMQXM/SIA3RohRenQJCEa+xZciG8Trux13ohedsbytnvrIkFhypmi3g8a1vzOuR7yCTr+XYfSED4gidndam069Oo83N29dRGU01y5shDZqcAZWK4IRCD0ZwbsdMQpenX9lznL7B9baAJoONYb6qMZA6DSI+ES/Bxagns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736352862; c=relaxed/simple; bh=/u6Z70HltpNm709SIsczeyre2BDQ22jOY7EfZq/dd/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AKFhSXcuYyhrQ72omtBdoxf3Ut/RhBvEHj51QL0iyXsJoVPX2oY4WssYEySlBaFGt3dx/2wtNywn/xWymr8gqkVXT8u4oEVHgYB+Xiu3fJNLqR3+SEKss0MT/fAjK0bacy1TlbqUBlU3gs7qALkmz2D4Mf16GOKOQf97a4lYNe4= 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=D9WHFQL3; arc=none smtp.client-ip=217.70.183.195 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="D9WHFQL3" Received: by mail.gandi.net (Postfix) with ESMTPSA id 1367D6000C; Wed, 8 Jan 2025 16:14:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736352852; 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=IdyqF/MNpk1AC1etMIMx4Zbfpq93DP6GrcctH+T5wdE=; b=D9WHFQL3FjZGx2jO2NCcD3zl4i8epPt+uGvISHb7xP41+fjvkVwq6d/+T/lrKGYhTXbXoN JjT6ZfXogo7Jw24gMef9bAghtfNudjGFjSUKqZwWwSe5ZTKRJSzz0obu3I0Az3Ota93Jcz EbtU/ZJA8e1PvSHmlGvtz0slvLVF7koN3wAZKz9BEaFHZFGLyiX4r77+cHniKKmJIKPQ8R lNd2vQR1CYNRc1oLvIVr3D1xTOn1E5AW5Ip/0pJr2zErRTSgpQBoQVlsf9vghJgPMLTRIq Hf1+vIEiXoHQEft/ILFDMnsj8kl57+lHV1xIq/llJNjfH+rVCMj7GhkrWKmmzQ== From: Romain Gantois Date: Wed, 08 Jan 2025 17:14:03 +0100 Subject: [PATCH v5 2/9] media: i2c: ds90ub960: Replace aliased clients list with address list Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-fpc202-v5-2-a439ab999d5a@bootlin.com> References: <20250108-fpc202-v5-0-a439ab999d5a@bootlin.com> In-Reply-To: <20250108-fpc202-v5-0-a439ab999d5a@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 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. Signed-off-by: Romain Gantois --- drivers/media/i2c/ds90ub960.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 33f362a008757578e4c96e6ea7bed2e590776d8d..13fb6020364d2b2d774400755f65da19365f220b 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -467,7 +467,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 { @@ -1031,17 +1031,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); @@ -1062,18 +1062,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);