From patchwork Wed Mar 18 15:00:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11445433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0260C92A for ; Wed, 18 Mar 2020 15:01:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4E9820776 for ; Wed, 18 Mar 2020 15:01:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gYjCqt5t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4E9820776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZRwua1FelcVR9WBsZtw3g+D2qdChx/5LlS09pmwwKvo=; b=gYjCqt5tL6ru/R q8FBUNZJPLgcAQRiV6jUsHoAMMPeYslEHrMANNQQviw3FEF4mqfPedOSpBim4RN0+2GgsqVZp/PW2 3NmwgQqqvXzMKkdYvxxcjorubQIZN5+CuBKnCd3HwdJDCQrJ1NVmfORdn5kc4pcP5qCxq9QQLUFM0 alxeS8eMuOhMhdowiraE5+RUKdH43Q1kqpt6pLKFVd4lFNZXW961aiGXSXHVLyVEzvP/i8ExoChcp TKBh3D/VhECTPGOvcQPiy4DhtuHtvZv5OoWE1FsIK6NGtb7Z+44d1S0kWG1b1Nqephomzbg84P6qY SCS7NArQEAg11g2bJiEQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaCE-0001UV-Fd; Wed, 18 Mar 2020 15:01:26 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaBx-0000WW-9B for linux-i3c@lists.infradead.org; Wed, 18 Mar 2020 15:01:10 +0000 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id 42CA82C2E6F; Wed, 18 Mar 2020 16:01:05 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH v2 1/6] i2c: use DEFINE for the dummy driver name Date: Wed, 18 Mar 2020 16:00:54 +0100 Message-Id: <20200318150059.21714-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> References: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200318_080109_465562_A8220E26 X-CRM114-Status: GOOD ( 10.57 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [88.99.104.3 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Geert Uytterhoeven , Wolfram Sang , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Luca Ceresoli , linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org We use it in multiple places, so make sure it is consistent whenever we need to change it. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven Reviewed-by: Kieran Bingham --- drivers/i2c/i2c-core-base.c | 8 ++++---- drivers/i2c/i2c-core.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index cefad0881942..3d7b8a00a7d9 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -853,7 +853,7 @@ EXPORT_SYMBOL_GPL(i2c_unregister_device); static const struct i2c_device_id dummy_id[] = { - { "dummy", 0 }, + { I2C_DUMMY_DRV_NAME, 0 }, { }, }; @@ -869,7 +869,7 @@ static int dummy_remove(struct i2c_client *client) } static struct i2c_driver dummy_driver = { - .driver.name = "dummy", + .driver.name = I2C_DUMMY_DRV_NAME, .probe = dummy_probe, .remove = dummy_remove, .id_table = dummy_id, @@ -896,7 +896,7 @@ static struct i2c_driver dummy_driver = { struct i2c_client *i2c_new_dummy_device(struct i2c_adapter *adapter, u16 address) { struct i2c_board_info info = { - I2C_BOARD_INFO("dummy", address), + I2C_BOARD_INFO(I2C_DUMMY_DRV_NAME, address), }; return i2c_new_client_device(adapter, &info); @@ -1487,7 +1487,7 @@ static void i2c_do_del_adapter(struct i2c_driver *driver, static int __unregister_client(struct device *dev, void *dummy) { struct i2c_client *client = i2c_verify_client(dev); - if (client && strcmp(client->name, "dummy")) + if (client && strcmp(client->name, I2C_DUMMY_DRV_NAME)) i2c_unregister_device(client); return 0; } diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 517d98be68d2..fb89fabf84d3 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -22,6 +22,8 @@ int i2c_check_7bit_addr_validity_strict(unsigned short addr); int i2c_dev_irq_from_resources(const struct resource *resources, unsigned int num_resources); +#define I2C_DUMMY_DRV_NAME "dummy" + /* * We only allow atomic transfers for very late communication, e.g. to send * the powerdown command to a PMIC. Atomic transfers are a corner case and not From patchwork Wed Mar 18 15:00:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11445437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1442C1874 for ; Wed, 18 Mar 2020 15:01:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E73F22077D for ; Wed, 18 Mar 2020 15:01:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Zn1FSjsp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E73F22077D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WPQKPA8x8t8++QchXzGeJFu1YDS+ULBafWAJ/TLr/OU=; b=Zn1FSjspkjrksy 9NLv389R/kASkEHhJMagri9EGU8LrI9LWCx9cVvOTZ+/GCcSBtS1UhcenXVgAzvKUowb6bpAvGoAv MN8qI5+dacliPvvrAyePXxnsVdYirX+4RAEwjP4xRKxhwC97DAGJHJIWXQjGQs+3r9AIwNLN6gb+s p29Bym4dwzC6eMJ7OCTHPTQB3DeCVWOS5NI/25rCmia0GOF9F2fppqp0tJT+ZXFoehEkda8kXNfOI G9rk4Pnl2nYjXvVqxUF2kNjI9G3s+NWZwcp50PU3DHffpdfcZ1y9v2z1mGtT0RzzEiZgKTNaxG2ps //S4G4L0Bs9GPEHq/RJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaCE-0001Up-In; Wed, 18 Mar 2020 15:01:26 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaBw-0000Wx-Kg for linux-i3c@lists.infradead.org; Wed, 18 Mar 2020 15:01:10 +0000 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id B29E42C2E79; Wed, 18 Mar 2020 16:01:05 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH v2 2/6] i2c: allow DT nodes without 'compatible' Date: Wed, 18 Mar 2020 16:00:55 +0100 Message-Id: <20200318150059.21714-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> References: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200318_080108_977694_C10A876D X-CRM114-Status: GOOD ( 13.01 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [88.99.104.3 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Geert Uytterhoeven , Wolfram Sang , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Luca Ceresoli , linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Sometimes, we have unknown devices in a system and still want to block their address. For that, we allow DT nodes with only a 'reg' property. These devices will be bound to the "dummy" driver but with the name "reserved". That way, we can distinguish them and even hand them over to the "dummy" driver later when they are really requested using i2c_new_ancillary_device(). Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven Acked-by: Rob Herring Reviewed-by: Luca Ceresoli Reviewed-by: Kieran Bingham --- Documentation/devicetree/bindings/i2c/i2c-ocores.txt | 2 -- Documentation/devicetree/bindings/i2c/i2c.txt | 4 +++- drivers/i2c/i2c-core-base.c | 1 + drivers/i2c/i2c-core-of.c | 8 +++----- drivers/i2c/i2c-core.h | 1 + 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt index 6b25a80ae8d3..fc8ea27934b3 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt @@ -50,7 +50,6 @@ Examples: reg-io-width = <1>; /* 8 bit read/write */ dummy@60 { - compatible = "dummy"; reg = <0x60>; }; }; @@ -68,7 +67,6 @@ or reg-io-width = <1>; /* 8 bit read/write */ dummy@60 { - compatible = "dummy"; reg = <0x60>; }; }; diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt index 9a53df4243c6..989b315e09dc 100644 --- a/Documentation/devicetree/bindings/i2c/i2c.txt +++ b/Documentation/devicetree/bindings/i2c/i2c.txt @@ -21,7 +21,9 @@ flags can be attached to the address. I2C_TEN_BIT_ADDRESS is used to mark a 10 bit address. It is needed to avoid the ambiguity between e.g. a 7 bit address of 0x50 and a 10 bit address of 0x050 which, in theory, can be on the same bus. Another flag is I2C_OWN_SLAVE_ADDRESS to mark addresses on which we listen to -be devices ourselves. +be devices ourselves. The 'reg' property of a child is required. The +'compatible' property is not. Empty 'compatible' child entries can be used to +describe unknown devices or addresses which shall be blocked for other reasons. Optional properties ------------------- diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 3d7b8a00a7d9..84464e439df5 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -854,6 +854,7 @@ EXPORT_SYMBOL_GPL(i2c_unregister_device); static const struct i2c_device_id dummy_id[] = { { I2C_DUMMY_DRV_NAME, 0 }, + { I2C_RESERVED_DRV_NAME, 0 }, { }, }; diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 6787c1f71483..d8d111ad6c85 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -27,17 +27,15 @@ int of_i2c_get_board_info(struct device *dev, struct device_node *node, memset(info, 0, sizeof(*info)); - if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) { - dev_err(dev, "of_i2c: modalias failure on %pOF\n", node); - return -EINVAL; - } - ret = of_property_read_u32(node, "reg", &addr); if (ret) { dev_err(dev, "of_i2c: invalid reg on %pOF\n", node); return ret; } + if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) + strlcpy(info->type, I2C_RESERVED_DRV_NAME, sizeof(I2C_RESERVED_DRV_NAME)); + if (addr & I2C_TEN_BIT_ADDRESS) { addr &= ~I2C_TEN_BIT_ADDRESS; info->flags |= I2C_CLIENT_TEN; diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index fb89fabf84d3..77b3a925ed95 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -23,6 +23,7 @@ int i2c_dev_irq_from_resources(const struct resource *resources, unsigned int num_resources); #define I2C_DUMMY_DRV_NAME "dummy" +#define I2C_RESERVED_DRV_NAME "reserved" /* * We only allow atomic transfers for very late communication, e.g. to send From patchwork Wed Mar 18 15:00:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11445441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8810A92A for ; Wed, 18 Mar 2020 15:01:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6663C2077A for ; Wed, 18 Mar 2020 15:01:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nOh0shgX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6663C2077A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mufbPVontC5NJBbNjfSbU2h69vHnNBFxRe01DFVNpnc=; b=nOh0shgXvc8u10 IYknuLnWxoNeBjQpET2jcYnMz2dYsX4bM0PSPl8SjdqnMSz1odUPCZ+owCcpk6ibbj0ecDxP+mAU3 P+PGV4Q0Xl67YofdTwcjmYE00nPKW9xbqdrBp7tVVGBbftHLn7T0EObW6RsAhNlS/DoiuJlt6jzHl kFzmb3cGyGZz6cIk6b3gfSRj6CnW/+cjaJutyGVeDmjM7WxGrLQkJNHjxxojfhSjrzbBIZ5ncreoo X/f5f3hHCmFSCbUeb7MxMad96j1c00WyebLz6vk6soERxGBc1+7Q75pC1H8qulOvdm6Drf0KGWvkd N69K7s3aNcScBCtYem1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaCE-0001Vf-Ox; Wed, 18 Mar 2020 15:01:26 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaBx-0000Xt-TG for linux-i3c@lists.infradead.org; Wed, 18 Mar 2020 15:01:12 +0000 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id 2A5E62C2E7D; Wed, 18 Mar 2020 16:01:06 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH v2 3/6] i2c: of: remove superfluous parameter from exported function Date: Wed, 18 Mar 2020 16:00:56 +0100 Message-Id: <20200318150059.21714-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> References: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200318_080110_086372_D63511BD X-CRM114-Status: UNSURE ( 9.30 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [88.99.104.3 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Geert Uytterhoeven , Wolfram Sang , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Luca Ceresoli , linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org 'dev' is only used for printing an error message. However, that information is not needed because '%pOF' fully describes the location of the error. Drop the 'dev' and remove the superfluous parameter. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven Reviewed-by: Luca Ceresoli Reviewed-by: Boris Brezillon Reviewed-by: Kieran Bingham --- drivers/i2c/i2c-core-of.c | 7 +++---- drivers/i3c/master.c | 2 +- include/linux/i2c.h | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index d8d111ad6c85..710704cd583e 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -19,8 +19,7 @@ #include "i2c-core.h" -int of_i2c_get_board_info(struct device *dev, struct device_node *node, - struct i2c_board_info *info) +int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info) { u32 addr; int ret; @@ -29,7 +28,7 @@ int of_i2c_get_board_info(struct device *dev, struct device_node *node, ret = of_property_read_u32(node, "reg", &addr); if (ret) { - dev_err(dev, "of_i2c: invalid reg on %pOF\n", node); + pr_err("of_i2c: invalid reg on %pOF\n", node); return ret; } @@ -69,7 +68,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node); - ret = of_i2c_get_board_info(&adap->dev, node, &info); + ret = of_i2c_get_board_info(node, &info); if (ret) return ERR_PTR(ret); diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 7f8f896fa0c3..cc0549a9fc64 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1943,7 +1943,7 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master, if (!boardinfo) return -ENOMEM; - ret = of_i2c_get_board_info(dev, node, &boardinfo->base); + ret = of_i2c_get_board_info(node, &boardinfo->base); if (ret) return ret; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index f834687989f7..d84aaf0d83d5 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -942,8 +942,7 @@ const struct of_device_id *i2c_of_match_device(const struct of_device_id *matches, struct i2c_client *client); -int of_i2c_get_board_info(struct device *dev, struct device_node *node, - struct i2c_board_info *info); +int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info); #else @@ -969,8 +968,7 @@ static inline const struct of_device_id return NULL; } -static inline int of_i2c_get_board_info(struct device *dev, - struct device_node *node, +static inline int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info) { return -ENOTSUPP; From patchwork Wed Mar 18 15:00:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11445439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1713C13B1 for ; Wed, 18 Mar 2020 15:01:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E69802077A for ; Wed, 18 Mar 2020 15:01:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PCvknFLX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E69802077A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FVn/I8g1Kn+T5cBAhg2DKweqaibGu/8uGCu6q1r2Kio=; b=PCvknFLXXHiuSo xx9wLED43xT73d3uZmLSWL+kMbQ2CVDvGwxv+tYfYADtFLfeLNOBr3DJpgA0r5zlb7icJWtWSLnjz ferM/rhXOez1mW52ImuhdqPTlVaR6GP1M4Zs5+Gcz60NK7PWCCABxTCJw17IzyNp1wM/ZI9M6Pc7S R6o5/QNskzDpdsCA4BQCcDMR2KRMfLA8wRFahKqkQJQCpjTnAEuXXXJe4DdwC0UnSs9iXOuDypmxG vtXzN8f8+vmWSQZI2+Xtu00g3h+zzrzCb+4pNFw6tsIMDhqs9wsGkpDkKdwtwEeE9lNtp0g+3LhZX qk1h/e5yTQFxFxAPet6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaCE-0001VG-MA; Wed, 18 Mar 2020 15:01:26 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaBx-0000ZM-Ma for linux-i3c@lists.infradead.org; Wed, 18 Mar 2020 15:01:12 +0000 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id 960812C2E7F; Wed, 18 Mar 2020 16:01:06 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH v2 4/6] i2c: of: error message unification Date: Wed, 18 Mar 2020 16:00:57 +0100 Message-Id: <20200318150059.21714-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> References: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200318_080109_881760_793E0F5D X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [88.99.104.3 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Geert Uytterhoeven , Wolfram Sang , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Luca Ceresoli , linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org - don't prefix the device if %pOF is provided. That information is enough. - move the prefix to pr_fmt - change prefix from "of_i2c" to "i2c_of" because the code was moved out of the of-domain long ago - drop error string for callers of of_i2c_register_device because it already reports enough (thanks to Tang Bin for the report!) Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven Reviewed-by: Luca Ceresoli Reviewed-by: Kieran Bingham --- drivers/i2c/i2c-core-of.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 710704cd583e..f2d09ea0d336 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -8,6 +8,8 @@ * Copyright (C) 2013, 2018 Wolfram Sang */ +#define pr_fmt(fmt) "i2c_of: " fmt + #include #include #include @@ -28,7 +30,7 @@ int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info) ret = of_property_read_u32(node, "reg", &addr); if (ret) { - pr_err("of_i2c: invalid reg on %pOF\n", node); + pr_err("invalid reg on %pOF\n", node); return ret; } @@ -66,7 +68,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, struct i2c_board_info info; int ret; - dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node); + pr_debug("register %pOF\n", node); ret = of_i2c_get_board_info(node, &info); if (ret) @@ -74,7 +76,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, client = i2c_new_client_device(adap, &info); if (IS_ERR(client)) - dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node); + pr_err("failure registering %pOF (%ld)\n", node, PTR_ERR(client)); return client; } @@ -88,7 +90,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap) if (!adap->dev.of_node) return; - dev_dbg(&adap->dev, "of_i2c: walking child nodes\n"); + dev_dbg(&adap->dev, "walking child nodes\n"); bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus"); if (!bus) @@ -99,12 +101,8 @@ void of_i2c_register_devices(struct i2c_adapter *adap) continue; client = of_i2c_register_device(adap, node); - if (IS_ERR(client)) { - dev_err(&adap->dev, - "Failed to create I2C device for %pOF\n", - node); + if (IS_ERR(client)) of_node_clear_flag(node, OF_POPULATED); - } } of_node_put(bus); @@ -243,8 +241,6 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, client = of_i2c_register_device(adap, rd->dn); if (IS_ERR(client)) { - dev_err(&adap->dev, "failed to create client for '%pOF'\n", - rd->dn); put_device(&adap->dev); of_node_clear_flag(rd->dn, OF_POPULATED); return notifier_from_errno(PTR_ERR(client)); From patchwork Wed Mar 18 15:00:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11445435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A10690 for ; Wed, 18 Mar 2020 15:01:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC2B920777 for ; Wed, 18 Mar 2020 15:01:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FYBGJnyZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC2B920777 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LgyjBU8RTLGo96dfMA5XxeqIag3DFCf00zNSLquqVeQ=; b=FYBGJnyZMfSnAX uBkySo83DSx23QaxeOy2RaH1J2BbEcY/9ZZwMiCRnHDyG1hV3i/H5WsLZzBEpaWHhZMO8eUiiBp0i 6x61FLZjToBhnKg3umB7+uBy9+b0evF59oSHE4ucp3hMT+Iw7hBtvh6VvhRHYt13asAVu/KGdojXn sCrxR9pnKsN+Ydq7Fr/KIrPIJLP7E1yhhHPlqKtwbIwvW9mN3HPuYAwyhqHruxqapwDjKf2zRCN6q JEpubbDarekcYgPUw2NAsui2rdbth3Rc3r1Q+8ypUbI/NKA2snIE+e22K1JtZ4UnBzJOFOJi6YA2a 71OniuDjoOaTlkBIBzkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaCF-0001XK-5E; Wed, 18 Mar 2020 15:01:27 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaBz-0000me-AW for linux-i3c@lists.infradead.org; Wed, 18 Mar 2020 15:01:13 +0000 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id 0D00C2C2E83; Wed, 18 Mar 2020 16:01:07 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH v2 5/6] i2c: of: mark a whole array of regs as reserved Date: Wed, 18 Mar 2020 16:00:58 +0100 Message-Id: <20200318150059.21714-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> References: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200318_080111_671186_4B88746D X-CRM114-Status: GOOD ( 12.45 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [88.99.104.3 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Luca Ceresoli , linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Back then, 'reg' properties in I2C DT bindings only contained one address and this address was assigned a device and, thus, blocked. Meanwhile, chips using multiple addresses are common and the 'reg' property can be an array described by 'reg-names'. This code enhances I2C DT parsing, so it will reserve all addresses described in an array. They will be bound to the 'dummy' driver as 'reserved' iff the first address can be assigned successfully. If that is not the case, the array is not further considered. If one later address of the array can not be assigned, it will be reported but we don't bail out. The driver has to decide if that address is critical or not. Signed-off-by: Wolfram Sang Reviewed-by: Luca Ceresoli --- drivers/i2c/i2c-core-of.c | 70 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index f2d09ea0d336..67eb2cd305cf 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -16,25 +16,18 @@ #include #include #include +#include #include #include #include "i2c-core.h" -int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info) +static void of_i2c_decode_board_info(struct device_node *node, u32 addr, + bool first_addr, struct i2c_board_info *info) { - u32 addr; - int ret; - memset(info, 0, sizeof(*info)); - ret = of_property_read_u32(node, "reg", &addr); - if (ret) { - pr_err("invalid reg on %pOF\n", node); - return ret; - } - - if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) + if (!first_addr || of_modalias_node(node, info->type, sizeof(info->type)) < 0) strlcpy(info->type, I2C_RESERVED_DRV_NAME, sizeof(I2C_RESERVED_DRV_NAME)); if (addr & I2C_TEN_BIT_ADDRESS) { @@ -51,11 +44,27 @@ int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info) info->of_node = node; info->fwnode = of_fwnode_handle(node); - if (of_property_read_bool(node, "host-notify")) - info->flags |= I2C_CLIENT_HOST_NOTIFY; + if (first_addr) { + if (of_property_read_bool(node, "host-notify")) + info->flags |= I2C_CLIENT_HOST_NOTIFY; + + if (of_get_property(node, "wakeup-source", NULL)) + info->flags |= I2C_CLIENT_WAKE; + } +} + +int of_i2c_get_board_info(struct device_node *node, struct i2c_board_info *info) +{ + u32 addr; + int ret; + + ret = of_property_read_u32(node, "reg", &addr); + if (ret) { + pr_err("invalid reg on %pOF\n", node); + return ret; + } - if (of_get_property(node, "wakeup-source", NULL)) - info->flags |= I2C_CLIENT_WAKE; + of_i2c_decode_board_info(node, addr, true, info); return 0; } @@ -64,21 +73,34 @@ EXPORT_SYMBOL_GPL(of_i2c_get_board_info); static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, struct device_node *node) { - struct i2c_client *client; + struct i2c_client *client, *first_client = ERR_PTR(-ENOENT); struct i2c_board_info info; - int ret; + bool first_reg = true; + unsigned int i = 0; + const __be32 *prop; + u16 reg; pr_debug("register %pOF\n", node); - ret = of_i2c_get_board_info(node, &info); - if (ret) - return ERR_PTR(ret); + while ((prop = of_get_address(node, i++, NULL, NULL))) { + reg = of_read_number(prop, 1); + of_i2c_decode_board_info(node, reg, first_reg, &info); + + client = i2c_new_client_device(adap, &info); + if (IS_ERR(client)) { + pr_err("failure registering addr 0x%02x for %pOF (%ld)\n", + reg, node, PTR_ERR(client)); + if (first_reg) + return client; + } - client = i2c_new_client_device(adap, &info); - if (IS_ERR(client)) - pr_err("failure registering %pOF (%ld)\n", node, PTR_ERR(client)); + if (first_reg) { + first_client = client; + first_reg = false; + } + } - return client; + return first_client; } void of_i2c_register_devices(struct i2c_adapter *adap) From patchwork Wed Mar 18 15:00:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11445431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20DD292A for ; Wed, 18 Mar 2020 15:01:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F328A20757 for ; Wed, 18 Mar 2020 15:01:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="c77FTwas" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F328A20757 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D8eCn6sMiHeFt0bCUW2N/T5+vIf81w90p5hTrE8uW1M=; b=c77FTwaskZ+FHq gr4fkEroJ7hXBwDN3ATbO78XzdM1Kn9++BPx7MFoFIJ/CEUJJsGk3HstVCXbfstHtUFXay0j7nIuF yF129yirgV7VnJL6i45EBnnsd8EzMNprxoo2YBX5GyFDSungQwXGUn8cY0ZXo1gJ33dWU1HVzXwZp uyjieacc5sp02iANSCPMWi3G6ms3apBPxhdd01G5snKWZDxA7OHg/nxYQkOeO7d72VknU1p04vo0H YXh3oVlvG/RVCMYV+jFyU0nnl5N7Ldb5YLQuIQjmAsbXsD+USviIwnqpOKwjuWYnNRPgPfsXhi6Qk vpp2QDOCZ7Pu+hot3piw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaCE-0001WT-Vk; Wed, 18 Mar 2020 15:01:26 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEaBz-0000md-AJ for linux-i3c@lists.infradead.org; Wed, 18 Mar 2020 15:01:12 +0000 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id 79B7A2C2E85; Wed, 18 Mar 2020 16:01:07 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH v2 6/6] i2c: core: hand over reserved devices when requesting ancillary addresses Date: Wed, 18 Mar 2020 16:00:59 +0100 Message-Id: <20200318150059.21714-7-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> References: <20200318150059.21714-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200318_080111_503129_6D0764B6 X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [88.99.104.3 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 FORGED_SPF_HELO No description available. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Luca Ceresoli , linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org With i2c_new_ancillary_address, we can check if the intended driver is requesting a reserved address. Update the function to do these checks. If the check passes, the "reserved" device will become a regular "dummy" device. Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-core-base.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 84464e439df5..81fb320de28d 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -974,7 +974,9 @@ struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, const char *name, u16 default_addr) { - struct device_node *np = client->dev.of_node; + struct device_node *reserved_np, *np = client->dev.of_node; + struct device *reserved_dev, *adapter_dev = &client->adapter->dev; + struct i2c_client *reserved_client = NULL; u32 addr = default_addr; int i; @@ -984,7 +986,25 @@ struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, of_property_read_u32_index(np, "reg", i, &addr); } - dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr); + dev_info(adapter_dev, "Address for %s : 0x%x\n", name, addr); + + /* No need to scan muxes, siblings must sit on the same adapter */ + reserved_dev = device_find_child(adapter_dev, &addr, __i2c_check_addr_busy); + if (reserved_dev) { + reserved_np = reserved_dev->of_node; + reserved_client = i2c_verify_client(reserved_dev); + put_device(reserved_dev); + } + + if (reserved_client) { + if (reserved_np != np || + strcmp(reserved_client->name, I2C_RESERVED_DRV_NAME) != 0) + return ERR_PTR(-EBUSY); + + strlcpy(reserved_client->name, I2C_DUMMY_DRV_NAME, sizeof(client->name)); + return reserved_client; + } + return i2c_new_dummy_device(client->adapter, addr); } EXPORT_SYMBOL_GPL(i2c_new_ancillary_device);