From patchwork Mon Dec 30 13:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 854331 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 5C3561A83E6; Mon, 30 Dec 2024 13:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564949; cv=none; b=fKs1vV2F6qDDvja4aTT2u5pHRJX8pp9Tqdfl+/OQcrtBfJmd04NBAjzQopCswLHOUtY56kGJPQxZUbjcPVrHKG7xv4vZKOWIlFu1qxXBcbyaN+edCJb7mx4l2WwO2PL0tmkJBDMHP8pKD57J3O0KQqw1xZQUDmEAyc/KHGMqlaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564949; c=relaxed/simple; bh=2wNb0ljvDCco91c2lkRWAVhQaQI+0RaU8HpQjf9yTU0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=odusWhUXVqMKs1dd09+rFWQpg6jclT50IeEglnr2B1hKqbEbhl0HdtKo4XPfnmH/6wHpdkEEkSyLjCmbM3cEmoEJ+ikdDq/KydkdWUSU7W9AaojWfPojqtD+y5M02JgobZOe41c49avnqJwBWru8ielqrRHGDw+9AhIUJ0m0ZWU= 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=M6CXjGnw; arc=none smtp.client-ip=217.70.183.194 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="M6CXjGnw" Received: by mail.gandi.net (Postfix) with ESMTPSA id E2FD740006; Mon, 30 Dec 2024 13:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735564938; 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=U5xciO/A0VbTKvNpAyu0K3ipQvV3vjm2jojCgoiIOXw=; b=M6CXjGnwwoUWQysQXj9TchxFHwdL5Uo01sFyuXR9F6pNWzcxVKl095OwGgT71QKkOKxNDT nvFLi9Uz1i06gXmSwAH0oVcMw9OAqedWSntJjUUVo9bMl3XDnGuWKbPlK8np2hXHBluHVW ZFyRe6WLbhHU63On+pYD+DwW3+TBs9hbyE0cEs/hvkEZ6nlE6+QPtZarmT4QxPIVvBlqZH xOe8JPyEychpcUkJ8azU/MlyKAuLHrAogLa2whoiK0G/e3rvvxRDEhzhvCEKmtuqPWB+xZ kuFdvamIvD/DFIX95xG4YZrJ2RErwzAj2EhOzpOr6iOzUdXqNSEinledZyJVxA== From: Romain Gantois Date: Mon, 30 Dec 2024 14:22:03 +0100 Subject: [PATCH v4 1/9] dt-bindings: misc: Describe TI FPC202 dual port controller Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-fpc202-v4-1-761b297dc697@bootlin.com> References: <20241230-fpc202-v4-0-761b297dc697@bootlin.com> In-Reply-To: <20241230-fpc202-v4-0-761b297dc697@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 FPC202 dual port controller serves as a low speed signal aggregator for common port types, notably SFP. It provides access to I2C and low-speed GPIO signals of a downstream device through a single upstream control interface. Up to two logical I2C addresses can be accessed on each of the FPC202's ports. The port controller acts as an I2C translator (ATR). It converts addresses of incoming and outgoing I2C transactions. One use case of this is accessing two SFP modules at logical address 0x50 from the same upstream I2C controller, using two different client aliases. Signed-off-by: Romain Gantois --- .../devicetree/bindings/misc/ti,fpc202.yaml | 94 ++++++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 100 insertions(+) diff --git a/Documentation/devicetree/bindings/misc/ti,fpc202.yaml b/Documentation/devicetree/bindings/misc/ti,fpc202.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bd1429c72d5efb62d2eeef1e74929fe0f80c86fc --- /dev/null +++ b/Documentation/devicetree/bindings/misc/ti,fpc202.yaml @@ -0,0 +1,94 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/ti,fpc202.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI FPC202 dual port controller with expanded IOs + +maintainers: + - Romain Gantois + +allOf: + - $ref: /schemas/i2c/i2c-atr.yaml# + +properties: + compatible: + const: ti,fpc202 + + reg: + maxItems: 1 + + gpio-controller: true + + "#gpio-cells": + const: 2 + + enable-gpios: + description: + Specifier for the GPIO connected to the EN pin. + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + +patternProperties: + "^i2c@[0-1]$": + $ref: /schemas/i2c/i2c-controller.yaml# + description: Downstream device ports 0 and 1 + + properties: + reg: + maxItems: 1 + description: + Downstream port ID + + required: + - "#address-cells" + - "#size-cells" + - reg + + unevaluatedProperties: false + +required: + - compatible + - gpio-controller + - "#gpio-cells" + - reg + - "#address-cells" + - "#size-cells" + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + i2c-atr@f { + compatible = "ti,fpc202"; + reg = <0xf>; + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + i2c@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + + i2c@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 1e930c7a58b13d8bbe6bf133ba7b36aa24c2b5e0..2ef5c0d395b3668167dddbd27237a2177f85571e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -23497,6 +23497,12 @@ F: drivers/misc/tifm* F: drivers/mmc/host/tifm_sd.c F: include/linux/tifm.h +TI FPC202 DUAL PORT CONTROLLER +M: Romain Gantois +L: linux-kernel@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/misc/ti,fpc202.yaml + TI FPD-LINK DRIVERS M: Tomi Valkeinen L: linux-media@vger.kernel.org From patchwork Mon Dec 30 13:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 854330 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 5EC341A83E9; Mon, 30 Dec 2024 13:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564949; cv=none; b=TdcZtKjkgbYXbinE5jcB1h0JUsOUlmjvTW5Les/2PEct3nPQYYKbE8N6RFPqh72hRaRAmzOb86rpjmZt+c+056cyhJmTmlHKt7R58YWMpLpV0F+YuozKyJE+9nO5y3j1zcIXyL/9/bpVbmtD+Cz8YHY0s7AxwZemp9iZumu+TMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564949; c=relaxed/simple; bh=Dle53yyRMtH5bYIX+Z/3srALAd6PgV0zPlo78ebz6yM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VtE8MmX5LjxKRp+kX4oyFxtH47biAXAv9zvHOGIn8su+mkpqAped1y7yx205RpeVv3aVi1l45dhsg2ckNxtxQGP/4GUs0aom7YdbAIL57tlWibPXXakYVsa7N/KnRKO4BTZm0Z7ilLsjQq3xlmLCwx4UJv501YEfrk3LP7FAWmY= 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=l8ueJI1F; arc=none smtp.client-ip=217.70.183.194 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="l8ueJI1F" Received: by mail.gandi.net (Postfix) with ESMTPSA id E543E40008; Mon, 30 Dec 2024 13:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735564939; 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=bejbN5LxZo1jDyfkaWI4AeUoOGlIeH8YG8Yw4adKU5Q=; b=l8ueJI1Fmav+dzMKGr3UaFjnxbGSK0lR9YwEY1xMkZyREJQ1mGr/mB9swKjo8uSlJW+Pqy NeU5hI3fZaZXSRPdVADbslexKYAGKFEvHtB6cLG9AX4/rzeKxCrH0WQBnrO/eGBP8OrLEy IS+YSr8ay17H+8EasokflnYkmVY5KA6ORiozLI1q5FJEJgR1S977XACaHUTEP4NB34wACg r8a+PHGipDBTY7LXBu21dAxJxw+fvGRUqisV2srGzFW/zyOdbAS+H29msvZkszKLwh3xm3 fiA7wp+VFJjugcQCU78KdN31PUmQzi0Vi4/YRIQAr+d2L2snMotCWGLJpGbBug== From: Romain Gantois Date: Mon, 30 Dec 2024 14:22:04 +0100 Subject: [PATCH v4 2/9] media: i2c: ds90ub960: Replace aliased clients list with address list Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-fpc202-v4-2-761b297dc697@bootlin.com> References: <20241230-fpc202-v4-0-761b297dc697@bootlin.com> In-Reply-To: <20241230-fpc202-v4-0-761b297dc697@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..7534ddf2079fef466d3a114f0be98599427639fa 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 < UB960_MAX_PORT_ALIASES; reg_idx++) { + if (!rxport->aliased_addrs[reg_idx]) break; } - if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) { + 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; + 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 < UB960_MAX_PORT_ALIASES; reg_idx++) { + if (rxport->aliased_addrs[reg_idx] == client->addr) break; } - 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; + rxport->aliased_addrs[reg_idx] = 0; ub960_rxport_write(priv, chan_id, UB960_RR_SLAVE_ALIAS(reg_idx), 0); From patchwork Mon Dec 30 13:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 854329 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 507E61A8402; Mon, 30 Dec 2024 13:22:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564951; cv=none; b=PnwSdB4tQELix2iSfZGp9bfO/Lsstuo8bOfnbz0x/qCKiD1ky8qVTDZQlNJ6bipI223DYimojrwh2IOrwTSp9PMPYfTrdhzFzoCAjsaVvLxfYJWsaZoJSbxxqDBQh+LOYoegJgPcxCb9xcvsIzW28vvB+QXi9sjpnLQ7z5MB2dA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564951; c=relaxed/simple; bh=Vf4cU8hGlN5CKeJUZ8FSEdnC2aYtMBXX+DP3iTawkkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G6xSDQgSuzeE3+ZrH4AdKsugr+XUG/u5iW6cc4+AqX0+517L0LF2KovMq0QLleW+ZULYFC9jpOHNdYUMXFVAv+XUmmZZ3W6jDmIo1Y9XKDxW0kML+iuCNORpYO1/J8sl8P0P1JXpkke3She++SEXFLVwR90Nn+hLmy9kBc8Go+g= 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=hjwFdsZf; arc=none smtp.client-ip=217.70.183.194 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="hjwFdsZf" Received: by mail.gandi.net (Postfix) with ESMTPSA id DE65C4000D; Mon, 30 Dec 2024 13:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735564940; 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=weXE6sdWg+2ApzA4KB1Gsr+ncUYzthpY4lVGqGGpBzo=; b=hjwFdsZfhrMFu9fZEdhwtY4FpbEAOF9yNAwp846Ed3fhfDaXCI+vqE+PX7gzgZbRR0ym3Z Q4DVR8fi5+S7NAg4ERQMrI01CULib15DSWk6SigWvIXD7bCmNi9Jww9BpcC5y3WCMVkdDS Yk2Jl7cfOyI0aluwe6b6jc5uY/3PnxqZO8NkeXprxuBLq+YklVwlL4XZSKrzQyNXTfKN9o AvoU7JPQEmVq0b7rolidnCqM08WqtmIcMZKN+Jg5cP3CmIBDW+adQhT3cEyuPovuVmXEDR PtEv7b04+RAcWhX/byNRInmDR5WvlaWDm6Z59ZkYwsPgJfZjlM47HggGtV8p5g== From: Romain Gantois Date: Mon, 30 Dec 2024 14:22:05 +0100 Subject: [PATCH v4 3/9] media: i2c: ds90ub960: Protect alias_use_mask with a mutex Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-fpc202-v4-3-761b297dc697@bootlin.com> References: <20241230-fpc202-v4-0-761b297dc697@bootlin.com> In-Reply-To: <20241230-fpc202-v4-0-761b297dc697@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 aliased_addrs list represents the occupation of an RX port's hardware alias table. This list and the underlying hardware table are only accessed in the attach/detach_client() callbacks. These functions are only called from a bus notifier handler in i2c-atr.c, which is always called with the notifier chain's semaphore held. This indirectly prevents concurrent access to the aliased_addrs list. However, more explicit and direct locking is preferable. Moreover, with the introduction of dynamic address translation in a future patch, the attach/detach_client() callbacks will be called from outside of the notifier chain's read section. Introduce a mutex to protect access to the aliased_addrs list and its underlying hardware table. Signed-off-by: Romain Gantois --- drivers/media/i2c/ds90ub960.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 7534ddf2079fef466d3a114f0be98599427639fa..0510427ac4e9214132bcdf3fa18873ec78c48a5e 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -467,6 +467,8 @@ struct ub960_rxport { }; } eq; + /* lock for aliased_addrs and associated registers */ + struct mutex aliased_addrs_lock; u16 aliased_addrs[UB960_MAX_PORT_ALIASES]; }; @@ -1030,6 +1032,9 @@ static int ub960_atr_attach_client(struct i2c_atr *atr, u32 chan_id, struct ub960_rxport *rxport = priv->rxports[chan_id]; struct device *dev = &priv->client->dev; unsigned int reg_idx; + int ret = 0; + + mutex_lock(&rxport->aliased_addrs_lock); for (reg_idx = 0; reg_idx < UB960_MAX_PORT_ALIASES; reg_idx++) { if (!rxport->aliased_addrs[reg_idx]) @@ -1038,7 +1043,8 @@ static int ub960_atr_attach_client(struct i2c_atr *atr, u32 chan_id, if (reg_idx == UB960_MAX_PORT_ALIASES) { dev_err(dev, "rx%u: alias pool exhausted\n", rxport->nport); - return -EADDRNOTAVAIL; + ret = -EADDRNOTAVAIL; + goto out_unlock; } rxport->aliased_addrs[reg_idx] = client->addr; @@ -1051,7 +1057,9 @@ static int ub960_atr_attach_client(struct i2c_atr *atr, u32 chan_id, dev_dbg(dev, "rx%u: client 0x%02x assigned alias 0x%02x at slot %u\n", rxport->nport, client->addr, alias, reg_idx); - return 0; +out_unlock: + mutex_unlock(&rxport->aliased_addrs_lock); + return ret; } static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id, @@ -1062,6 +1070,8 @@ static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id, struct device *dev = &priv->client->dev; unsigned int reg_idx; + mutex_lock(&rxport->aliased_addrs_lock); + for (reg_idx = 0; reg_idx < UB960_MAX_PORT_ALIASES; reg_idx++) { if (rxport->aliased_addrs[reg_idx] == client->addr) break; @@ -1070,7 +1080,7 @@ static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id, if (reg_idx == UB960_MAX_PORT_ALIASES) { dev_err(dev, "rx%u: client 0x%02x is not mapped!\n", rxport->nport, client->addr); - return; + goto out_unlock; } rxport->aliased_addrs[reg_idx] = 0; @@ -1079,6 +1089,9 @@ static void ub960_atr_detach_client(struct i2c_atr *atr, u32 chan_id, dev_dbg(dev, "rx%u: client 0x%02x released at slot %u\n", rxport->nport, client->addr, reg_idx); + +out_unlock: + mutex_unlock(&rxport->aliased_addrs_lock); } static const struct i2c_atr_ops ub960_atr_ops = { @@ -3181,6 +3194,8 @@ static void ub960_rxport_free_ports(struct ub960_data *priv) fwnode_handle_put(rxport->source.ep_fwnode); fwnode_handle_put(rxport->ser.fwnode); + mutex_destroy(&rxport->aliased_addrs_lock); + kfree(rxport); priv->rxports[nport] = NULL; } @@ -3401,6 +3416,8 @@ static int ub960_parse_dt_rxport(struct ub960_data *priv, unsigned int nport, if (ret) goto err_put_remote_fwnode; + mutex_init(&rxport->aliased_addrs_lock); + return 0; err_put_remote_fwnode: From patchwork Mon Dec 30 13:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 854328 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 63B821AAE33; Mon, 30 Dec 2024 13:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564953; cv=none; b=s9pGgGvcH6RB2Lv+ZZMvLxsPDuDwHlsCa9ER6wZmVGnB3faEvL0ZAfVxYzqU8B2yKOUptoChR3ZQOw7L/KF7pDjavh8SwyGIIHeoLRgWAAPKz+KPX83WSWsIppIDUJ0r4Wvqb5Zis4GPNj37k0fssVXZkBzsXeEIdAXmWdF0icQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564953; c=relaxed/simple; bh=VL8viaGxwdRCmczEsqK9PaOTz9dmS+n/w4JGlI5V4Xc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L6Pm0or3kTsibeNXg6Kh0dTKYZ0IOMEp9hOW8hBwonDaElyo6raCXG7lPkKdNiK/cjT8Mkr9ubtYgXRAoSG67QkRAaix/+J7o3PffwYaXvhrEv0bPzo9bPCB0gijWN5OYJyIueuQS+1w/xrTvMz42Nyw5uGXJ0ld7k+If3U7j30= 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=d4MfLn7G; arc=none smtp.client-ip=217.70.183.194 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="d4MfLn7G" Received: by mail.gandi.net (Postfix) with ESMTPSA id DF6634000F; Mon, 30 Dec 2024 13:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735564942; 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=qKubJbzkITuyg+usLsT1DkN2EjpfslQpQbRs8iiLYKs=; b=d4MfLn7G0vA8BXEcWn0JPgDalaGDl/PhqSpvvInCw6OOHhFAFNxJ9JR70SS0MLn1idI9Bd ixomXC5KPOGGYC+xQ31VyIso6Z6eolYAynUjzk4UCnrhVwZmBCOYbZbmEuMkHRpGIzEnZ1 YSZAu6H6o5kfDDAlQcMJPGV3F5lY7+bOJ8lsJz17c2ZzVFoMwPHwik2/i+GNH27oXb+XPa +gP40OTAz3dmsXVvpobmM4H03L9CBdUnZ+IPnN+YW+a1Va6755/b0qVASokKAvbLW0h1Kj oovsgLUcUPgVWpOeoFAZSqbAStbw0G5Q72bXNaM3rjvBPE68pouorku9KtpDfw== From: Romain Gantois Date: Mon, 30 Dec 2024 14:22:07 +0100 Subject: [PATCH v4 5/9] i2c: move ATR alias pool to a separate struct Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-fpc202-v4-5-761b297dc697@bootlin.com> References: <20241230-fpc202-v4-0-761b297dc697@bootlin.com> In-Reply-To: <20241230-fpc202-v4-0-761b297dc697@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 Each I2C address translator (ATR) has a pool of client aliases which can be used as translation targets. Some ATRs have a single alias pool shared by all downstream channels, while others have a separate alias pool for each channel. Currently, this alias pool is represented by the "aliases", "num_aliases", and "use_mask" fields of struct i2c_atr. In preparation for adding per-channel alias pool support, move the "aliases", "num_aliases", "use_mask" and associated lock to a new struct called "struct alias_pool". Signed-off-by: Romain Gantois --- drivers/i2c/i2c-atr.c | 172 +++++++++++++++++++++++++++++++------------------- 1 file changed, 107 insertions(+), 65 deletions(-) diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c index 894787246846b9965deb03a7ec7eb600b102ddad..ab759db56c546b2e26cd938dc9e0171df5473a8a 100644 --- a/drivers/i2c/i2c-atr.c +++ b/drivers/i2c/i2c-atr.c @@ -34,6 +34,23 @@ struct i2c_atr_alias_pair { u16 alias; }; +/** + * struct i2c_atr_alias_pool - Pool of client aliases available for an ATR. + * @size: Total number of aliases + * + * @lock: Lock protecting @aliases and @use_mask + * @aliases: Array of aliases, must hold exactly @size elements + * @use_mask: Mask of used aliases + */ +struct i2c_atr_alias_pool { + size_t size; + + /* Protects aliases and use_mask */ + spinlock_t lock; + u16 *aliases; + unsigned long *use_mask; +}; + /** * struct i2c_atr_chan - Data for a channel. * @adap: The &struct i2c_adapter for the channel @@ -67,10 +84,7 @@ struct i2c_atr_chan { * @algo: The &struct i2c_algorithm for adapters * @lock: Lock for the I2C bus segment (see &struct i2c_lock_operations) * @max_adapters: Maximum number of adapters this I2C ATR can have - * @num_aliases: Number of aliases in the aliases array - * @aliases: The aliases array - * @alias_mask_lock: Lock protecting alias_use_mask - * @alias_use_mask: Bitmask for used aliases in aliases array + * @alias_pool: Pool of available client aliases * @i2c_nb: Notifier for remote client add & del events * @adapter: Array of adapters */ @@ -86,17 +100,54 @@ struct i2c_atr { struct mutex lock; int max_adapters; - size_t num_aliases; - const u16 *aliases; - /* Protects alias_use_mask */ - spinlock_t alias_mask_lock; - unsigned long *alias_use_mask; + struct i2c_atr_alias_pool *alias_pool; struct notifier_block i2c_nb; struct i2c_adapter *adapter[] __counted_by(max_adapters); }; +static struct i2c_atr_alias_pool *i2c_atr_alloc_alias_pool(size_t num_aliases) +{ + struct i2c_atr_alias_pool *alias_pool; + int ret; + + alias_pool = kzalloc(sizeof(*alias_pool), GFP_KERNEL); + if (!alias_pool) + return ERR_PTR(-ENOMEM); + + alias_pool->size = num_aliases; + + alias_pool->aliases = kcalloc(num_aliases, sizeof(*alias_pool->aliases), GFP_KERNEL); + if (!alias_pool->aliases) { + ret = -ENOMEM; + goto err_free_alias_pool; + } + + alias_pool->use_mask = bitmap_zalloc(num_aliases, GFP_KERNEL); + if (!alias_pool->use_mask) { + ret = -ENOMEM; + goto err_free_aliases; + } + + spin_lock_init(&alias_pool->lock); + + return alias_pool; + +err_free_aliases: + kfree(alias_pool->aliases); +err_free_alias_pool: + kfree(alias_pool); + return ERR_PTR(ret); +} + +static void i2c_atr_free_alias_pool(struct i2c_atr_alias_pool *alias_pool) +{ + bitmap_free(alias_pool->use_mask); + kfree(alias_pool->aliases); + kfree(alias_pool); +} + static struct i2c_atr_alias_pair * i2c_atr_find_mapping_by_addr(const struct list_head *list, u16 phys_addr) { @@ -259,44 +310,42 @@ static const struct i2c_lock_operations i2c_atr_lock_ops = { .unlock_bus = i2c_atr_unlock_bus, }; -static int i2c_atr_reserve_alias(struct i2c_atr *atr) +static int i2c_atr_reserve_alias(struct i2c_atr_alias_pool *alias_pool) { unsigned long idx; + u16 alias; - spin_lock(&atr->alias_mask_lock); + spin_lock(&alias_pool->lock); - idx = find_first_zero_bit(atr->alias_use_mask, atr->num_aliases); - if (idx >= atr->num_aliases) { - spin_unlock(&atr->alias_mask_lock); - dev_err(atr->dev, "failed to find a free alias\n"); + idx = find_first_zero_bit(alias_pool->use_mask, alias_pool->size); + if (idx >= alias_pool->size) { + spin_unlock(&alias_pool->lock); return -EBUSY; } - set_bit(idx, atr->alias_use_mask); + set_bit(idx, alias_pool->use_mask); - spin_unlock(&atr->alias_mask_lock); + alias = alias_pool->aliases[idx]; - return atr->aliases[idx]; + spin_unlock(&alias_pool->lock); + return alias; } -static void i2c_atr_release_alias(struct i2c_atr *atr, u16 alias) +static void i2c_atr_release_alias(struct i2c_atr_alias_pool *alias_pool, u16 alias) { unsigned int idx; - spin_lock(&atr->alias_mask_lock); + spin_lock(&alias_pool->lock); - for (idx = 0; idx < atr->num_aliases; ++idx) { - if (atr->aliases[idx] == alias) { - clear_bit(idx, atr->alias_use_mask); - spin_unlock(&atr->alias_mask_lock); + for (idx = 0; idx < alias_pool->size; ++idx) { + if (alias_pool->aliases[idx] == alias) { + clear_bit(idx, alias_pool->use_mask); + spin_unlock(&alias_pool->lock); return; } } - spin_unlock(&atr->alias_mask_lock); - - /* This should never happen */ - dev_warn(atr->dev, "Unable to find mapped alias\n"); + spin_unlock(&alias_pool->lock); } static int i2c_atr_attach_addr(struct i2c_adapter *adapter, @@ -308,9 +357,11 @@ static int i2c_atr_attach_addr(struct i2c_adapter *adapter, u16 alias; int ret; - ret = i2c_atr_reserve_alias(atr); - if (ret < 0) + ret = i2c_atr_reserve_alias(atr->alias_pool); + if (ret < 0) { + dev_err(atr->dev, "failed to find a free alias\n"); return ret; + } alias = ret; @@ -336,7 +387,7 @@ static int i2c_atr_attach_addr(struct i2c_adapter *adapter, err_free: kfree(c2a); err_release_alias: - i2c_atr_release_alias(atr, alias); + i2c_atr_release_alias(atr->alias_pool, alias); return ret; } @@ -357,7 +408,7 @@ static void i2c_atr_detach_addr(struct i2c_adapter *adapter, return; } - i2c_atr_release_alias(atr, c2a->alias); + i2c_atr_release_alias(atr->alias_pool, c2a->alias); dev_dbg(atr->dev, "chan%u: addr 0x%02x unmapped from alias 0x%02x\n", @@ -411,12 +462,11 @@ static int i2c_atr_bus_notifier_call(struct notifier_block *nb, static int i2c_atr_parse_alias_pool(struct i2c_atr *atr) { + struct i2c_atr_alias_pool *alias_pool; struct device *dev = atr->dev; - unsigned long *alias_use_mask; size_t num_aliases; unsigned int i; u32 *aliases32; - u16 *aliases16; int ret; ret = fwnode_property_count_u32(dev_fwnode(dev), "i2c-alias-pool"); @@ -428,12 +478,23 @@ static int i2c_atr_parse_alias_pool(struct i2c_atr *atr) num_aliases = ret; - if (!num_aliases) + alias_pool = i2c_atr_alloc_alias_pool(num_aliases); + if (IS_ERR(alias_pool)) { + ret = PTR_ERR(alias_pool); + dev_err(dev, "Failed to allocate alias pool, err %d\n", ret); + return ret; + } + + atr->alias_pool = alias_pool; + + if (!alias_pool->size) return 0; aliases32 = kcalloc(num_aliases, sizeof(*aliases32), GFP_KERNEL); - if (!aliases32) - return -ENOMEM; + if (!aliases32) { + ret = -ENOMEM; + goto err_free_alias_pool; + } ret = fwnode_property_read_u32_array(dev_fwnode(dev), "i2c-alias-pool", aliases32, num_aliases); @@ -443,43 +504,27 @@ static int i2c_atr_parse_alias_pool(struct i2c_atr *atr) goto err_free_aliases32; } - aliases16 = kcalloc(num_aliases, sizeof(*aliases16), GFP_KERNEL); - if (!aliases16) { - ret = -ENOMEM; - goto err_free_aliases32; - } - for (i = 0; i < num_aliases; i++) { if (!(aliases32[i] & 0xffff0000)) { - aliases16[i] = aliases32[i]; + alias_pool->aliases[i] = aliases32[i]; continue; } dev_err(dev, "Failed to parse 'i2c-alias-pool' property: I2C flags are not supported\n"); ret = -EINVAL; - goto err_free_aliases16; - } - - alias_use_mask = bitmap_zalloc(num_aliases, GFP_KERNEL); - if (!alias_use_mask) { - ret = -ENOMEM; - goto err_free_aliases16; + goto err_free_aliases32; } kfree(aliases32); - atr->num_aliases = num_aliases; - atr->aliases = aliases16; - atr->alias_use_mask = alias_use_mask; - - dev_dbg(dev, "i2c-alias-pool has %zu aliases", atr->num_aliases); + dev_dbg(dev, "i2c-alias-pool has %zu aliases\n", alias_pool->size); return 0; -err_free_aliases16: - kfree(aliases16); err_free_aliases32: kfree(aliases32); +err_free_alias_pool: + i2c_atr_free_alias_pool(alias_pool); return ret; } @@ -500,7 +545,6 @@ struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev, return ERR_PTR(-ENOMEM); mutex_init(&atr->lock); - spin_lock_init(&atr->alias_mask_lock); atr->parent = parent; atr->dev = dev; @@ -520,13 +564,12 @@ struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev, atr->i2c_nb.notifier_call = i2c_atr_bus_notifier_call; ret = bus_register_notifier(&i2c_bus_type, &atr->i2c_nb); if (ret) - goto err_free_aliases; + goto err_free_alias_pool; return atr; -err_free_aliases: - bitmap_free(atr->alias_use_mask); - kfree(atr->aliases); +err_free_alias_pool: + i2c_atr_free_alias_pool(atr->alias_pool); err_destroy_mutex: mutex_destroy(&atr->lock); kfree(atr); @@ -543,8 +586,7 @@ void i2c_atr_delete(struct i2c_atr *atr) WARN_ON(atr->adapter[i]); bus_unregister_notifier(&i2c_bus_type, &atr->i2c_nb); - bitmap_free(atr->alias_use_mask); - kfree(atr->aliases); + i2c_atr_free_alias_pool(atr->alias_pool); mutex_destroy(&atr->lock); kfree(atr); } From patchwork Mon Dec 30 13:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 854332 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 813ADEAD0; Mon, 30 Dec 2024 13:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564948; cv=none; b=d1L6Dj5Nkaz8iVSmKuw58BZDbfpvLRDeT0ok9Vos7LWxKTn7+KbsSFCqmB8ScOcqJRKVdPE3es7jOpiQjlS3jFz+CXawP9cUa3N4E2cSkNmwGp9h9szN/Z94zrcA92hp5zurWKMrceF4PmPNNJGaAhoUvpIM5lHezNPddA2SRMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735564948; c=relaxed/simple; bh=7qjxaDb1n/cfOMOXwRC1Z14jSBnm4PHKXXck7whflZc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fHEv1koyAy1yano44dP+s+sCr5h4BjOxNXZAQKYNbS0C6tZAxGGgnYb9oBZA+CuJFe9MvWehFZVAWBtZjP/P1ae0NOUXBk9/4OWVX3IuvcQeX/VgNA24F0fL0j3v8cvAxGmAzrMUFzVFaeVZQ7rQKX3A6Er1ekDC7OmDq6fo4dk= 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=Fhqg5qnz; arc=none smtp.client-ip=217.70.183.194 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="Fhqg5qnz" Received: by mail.gandi.net (Postfix) with ESMTPSA id DB5FD40011; Mon, 30 Dec 2024 13:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735564943; 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=7w9qi7FvqEzP4F7I6TnPP8j1jGVlHkoBFUCaIMCoHaM=; b=Fhqg5qnzouWXrUuwi56MI2tkGUV3IxQOHgaa20Xd2zGvB5ZrcovsT4rps6+1YQkJWr/ort qvoNI3gmJNc32+qOvVdzovETW0Q5GtzRSTmFSszVp9jud6uwfTW8LkqSm/0/79sErDK1hq qTHPlISpDH55RI0vnTgMNts0P/JIesQNLa5AT5KoXsUoujhcE7LQ2mJNvUmvUZdXmXW7D3 GQzt1SvlyWUaLothrTqD0Droq2xs2vRrnGb8XYF7v2gFnPMPKGPJ6jYkxPfAkCMQ45GVWe 82P7lSu8aX8YXR279xN5EAZjrnCHUE+SwS22VOiS/QMi32N175/yzFPNuOaq7g== From: Romain Gantois Date: Mon, 30 Dec 2024 14:22:08 +0100 Subject: [PATCH v4 6/9] i2c: rename field 'alias_list' of struct i2c_atr_chan to 'alias_pairs' Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-fpc202-v4-6-761b297dc697@bootlin.com> References: <20241230-fpc202-v4-0-761b297dc697@bootlin.com> In-Reply-To: <20241230-fpc202-v4-0-761b297dc697@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 "alias_list" field of struct i2c_atr_chan describes translation table entries programmed in the ATR channel. This terminology will become more confusing when per-channel alias pool support is introduced, as struct i2c_atr_chan will gain a new field called "alias_pool", which will describe aliases which are available to the ATR channel. Rename the "alias_list" field to "alias_pairs" to clearly distinguish it from the future "alias_pool" field. No functional change is intended. Signed-off-by: Romain Gantois --- drivers/i2c/i2c-atr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c index ab759db56c546b2e26cd938dc9e0171df5473a8a..4652e9c2917ebdc817a5a661642e9f535e421c1a 100644 --- a/drivers/i2c/i2c-atr.c +++ b/drivers/i2c/i2c-atr.c @@ -56,7 +56,7 @@ struct i2c_atr_alias_pool { * @adap: The &struct i2c_adapter for the channel * @atr: The parent I2C ATR * @chan_id: The ID of this channel - * @alias_list: List of @struct i2c_atr_alias_pair containing the + * @alias_pairs: List of @struct i2c_atr_alias_pair containing the * assigned aliases * @orig_addrs_lock: Mutex protecting @orig_addrs * @orig_addrs: Buffer used to store the original addresses during transmit @@ -67,7 +67,7 @@ struct i2c_atr_chan { struct i2c_atr *atr; u32 chan_id; - struct list_head alias_list; + struct list_head alias_pairs; /* Lock orig_addrs during xfer */ struct mutex orig_addrs_lock; @@ -192,7 +192,7 @@ static int i2c_atr_map_msgs(struct i2c_atr_chan *chan, struct i2c_msg *msgs, for (i = 0; i < num; i++) { chan->orig_addrs[i] = msgs[i].addr; - c2a = i2c_atr_find_mapping_by_addr(&chan->alias_list, + c2a = i2c_atr_find_mapping_by_addr(&chan->alias_pairs, msgs[i].addr); if (!c2a) { dev_err(atr->dev, "client 0x%02x not mapped!\n", @@ -262,7 +262,7 @@ static int i2c_atr_smbus_xfer(struct i2c_adapter *adap, u16 addr, struct i2c_adapter *parent = atr->parent; struct i2c_atr_alias_pair *c2a; - c2a = i2c_atr_find_mapping_by_addr(&chan->alias_list, addr); + c2a = i2c_atr_find_mapping_by_addr(&chan->alias_pairs, addr); if (!c2a) { dev_err(atr->dev, "client 0x%02x not mapped!\n", addr); return -ENXIO; @@ -380,7 +380,7 @@ static int i2c_atr_attach_addr(struct i2c_adapter *adapter, c2a->addr = addr; c2a->alias = alias; - list_add(&c2a->node, &chan->alias_list); + list_add(&c2a->node, &chan->alias_pairs); return 0; @@ -401,7 +401,7 @@ static void i2c_atr_detach_addr(struct i2c_adapter *adapter, atr->ops->detach_addr(atr, chan->chan_id, addr); - c2a = i2c_atr_find_mapping_by_addr(&chan->alias_list, addr); + c2a = i2c_atr_find_mapping_by_addr(&chan->alias_pairs, addr); if (!c2a) { /* This should never happen */ dev_warn(atr->dev, "Unable to find address mapping\n"); @@ -621,7 +621,7 @@ int i2c_atr_add_adapter(struct i2c_atr *atr, u32 chan_id, chan->atr = atr; chan->chan_id = chan_id; - INIT_LIST_HEAD(&chan->alias_list); + INIT_LIST_HEAD(&chan->alias_pairs); mutex_init(&chan->orig_addrs_lock); snprintf(chan->adap.name, sizeof(chan->adap.name), "i2c-%d-atr-%d",