From patchwork Thu Feb 20 17:23: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: 11394767 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 747CE13A4 for ; Thu, 20 Feb 2020 17:26: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 4CD5924673 for ; Thu, 20 Feb 2020 17:26: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="r8zbSo2W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CD5924673 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=vjAa2CH5BCzLFvt5XWrpVwXORDZeXPC9bptlbIGI9no=; b=r8zbSo2WLQlytG ylza2j3cVXQ2SloQMQ+YsRTamSJ0G0XxcYiQW860QBi74o/VWNfm6YXnffrBM34AvtjCd8PDxR55L yNSLnzWjdryHIkYzxuTnkScpPvbKJdJY5jEd1JgunvP2H+MYSf48Z3j0TyrWvh8Z78qXJg+gUuZLF 9CbjgZ4wZtjRkIvkuF6EhpZKffs1/z0rXc0TA3wp5Z9Ymu2HtK0NLTaHswiul47SyDkISljTlhv32 3gi/grAr6a/CGfAf8RXWb7MzrKj7KzB+bcXEIaXbB4NHSz+48V86eLf0Av4J86uQNTNL/QhMhnRw7 2y3GOSjRpFwNBAfzIHpw==; 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 1j4pal-0007pi-M1; Thu, 20 Feb 2020 17:26: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 1j4paG-0007Ek-MI for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:01 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id D7BF52C1EBA; Thu, 20 Feb 2020 18:25:50 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 1/7] i2c: add sanity check for parameter of i2c_verify_client() Date: Thu, 20 Feb 2020 18:23:57 +0100 Message-Id: <20200220172403.26062-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092556_910235_C5DF8A95 X-CRM114-Status: UNSURE ( 8.62 ) 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: devicetree@vger.kernel.org, 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 We export this function, so we should check the paramter to make it NULL-compatible. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index cefad0881942..8f46d1bb8c62 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(i2c_client_type); */ struct i2c_client *i2c_verify_client(struct device *dev) { - return (dev->type == &i2c_client_type) + return (dev && dev->type == &i2c_client_type) ? to_i2c_client(dev) : NULL; } From patchwork Thu Feb 20 17:23: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: 11394777 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 51B6513A4 for ; Thu, 20 Feb 2020 17:26: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 30F142468F for ; Thu, 20 Feb 2020 17:26: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="bjHZtHqh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30F142468F 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=+r4pWOkF1Wgb0J31iqnN8HUmNjVfA1Yo9kJSuJl2k50=; b=bjHZtHqhzVfOH4 peBfFxa2A8vkje7E+QRQFkmJO1R12gRR1rv0oUkiTY/QFr+G6BDE5SmG7HTXkMlh5gUWf/uGt6VyX ftT8yO/YjaevRLYp/fzZLzu5mcub59MJ5rhtMFO4fe0EB4bXQNaZ8ws9y1D/Yp0lYwJFfXuwowyLB /FYaMiwLj4E0rtcvtjE3LEOfPKIipPQfpy8DuycSS1QF7Xv6VJ7exVmM+ADtUnWsBTkCIcCJxLcT+ Ns2+/w7g69AMgChRiay5OQrfPD9Elk7/bnMQddeDR0PIlg5+t2aS5rCZX2OfcwXnHF8eAQjVJoGSO 2QWc4wP5+K9H4epVkZZw==; 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 1j4pan-0007rT-Rq; Thu, 20 Feb 2020 17:26:29 +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 1j4paG-0007F2-8E for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:01 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id 80B0D2C1EBB; Thu, 20 Feb 2020 18:25:51 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 2/7] i2c: use DEFINE for the dummy driver name Date: Thu, 20 Feb 2020 18:23:58 +0100 Message-Id: <20200220172403.26062-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092556_542246_65CF66B1 X-CRM114-Status: GOOD ( 10.97 ) 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: devicetree@vger.kernel.org, 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 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 --- 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 8f46d1bb8c62..8df2fa10c48a 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 Thu Feb 20 17:23: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: 11394773 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 BA82F17F0 for ; Thu, 20 Feb 2020 17:26: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 8D19824673 for ; Thu, 20 Feb 2020 17:26: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="GZe+5QZZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D19824673 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=7i6QdlATm/qtvMFRy09wJygxke9DKmSpOAqILnVVgUo=; b=GZe+5QZZZMmBaM IUDH6XftZTRruTp/MZGNVih0lPTJqiP7BBcQ5g1zgV97tWeBUS1NS1nvRnAOvusjV5UhAgI2xlb9N aW4mTQIbPRKujnCa3jkHB75MiGckfx0dQoDkwNM5fJ4Ewd8GZgdIIHWCbLCKzuKsQb0ck8tZ3jyjZ piBKMIYMTV5SYHpZlLMrc+cusZQTGtRblv+d7ocJUCg2/EKsXWM/bJPZEsNN17iWX+NvsQN8OIVNc 5imVGTrQYBIOJWTF6LrTPylaFHHkL90qCsmk1S09TkqyIry7KXG2XyhmgNOruUBxOe9Vhhjjuxodg Z2wFQUmRd9E/W02/np3w==; 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 1j4pal-0007pv-S1; Thu, 20 Feb 2020 17:26: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 1j4paG-0007FO-NY for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:01 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id 1ED662C1EBE; Thu, 20 Feb 2020 18:25:52 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 3/7] i2c: allow DT nodes without 'compatible' Date: Thu, 20 Feb 2020 18:23:59 +0100 Message-Id: <20200220172403.26062-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092557_094324_F2E2D3C0 X-CRM114-Status: GOOD ( 12.82 ) 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: devicetree@vger.kernel.org, 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 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 --- Documentation/devicetree/bindings/i2c/i2c-ocores.txt | 1 - 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(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt index 6b25a80ae8d3..2762effdd270 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>; }; }; 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 8df2fa10c48a..4000a4384306 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 Thu Feb 20 17:24:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11394769 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 B74B51892 for ; Thu, 20 Feb 2020 17:26: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 74D222467A for ; Thu, 20 Feb 2020 17:26: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="F3e71lJb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74D222467A 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=cHjYItFpEgSwPqtR+8iZBXSo8s7XsyeZkkXp0cPxUdw=; b=F3e71lJbR5viQG 7C81cYXkzXJPyv4/7mZovX1r4Xw5fWRNxJqGvyH2wDiEsMnLNuABvrMEAfyCpZxsSTFtLbPlO1nSn 5G7nrjAjVKA+n+UFUdBHqlbCvkMz02KwdiZckOqwJPdhUH2xkNANHXbrUi2GYTdfYzI98zxZasVJa 7JbOkIm4g10q91DGrIkVEMdYBF+ZuenE3Je5ObaXqnw3AbOUzf9ZrQTzr7hpktHh68foB+ct7dm2G 9p2kYH9tJ3VcUZN2zK7vrK8XYIsvfVAxB9WfjYTn9IRJps0L/Q/kksV0DFcIpeXzupxxInoSkcchQ 7cnlVKpdOuTVySBbXS8Q==; 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 1j4pal-0007pW-HM; Thu, 20 Feb 2020 17:26: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 1j4paH-0007Fi-JC for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:01 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id A6F8A2C1EBF; Thu, 20 Feb 2020 18:25:52 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 4/7] i2c: of: remove superfluous parameter from exported function Date: Thu, 20 Feb 2020 18:24:00 +0100 Message-Id: <20200220172403.26062-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092557_798938_7B437BC9 X-CRM114-Status: UNSURE ( 9.62 ) 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: devicetree@vger.kernel.org, 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 '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 --- 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 Thu Feb 20 17:24:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11394775 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 25F74109A for ; Thu, 20 Feb 2020 17:26: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 0390A2468F for ; Thu, 20 Feb 2020 17:26:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="itWkpneK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0390A2468F 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=CNODXUQNxhVMyNHyHzIkazTPvKuMu3+uUO1vp/+rLkg=; b=itWkpneKYGmk8T o1jMo2qeL+4P98cHa0zjNLumRqtx3QneCXUOK43CDRZkXtk1zfn6EWKlF6KUgA3HQaO3XXeqbcTcZ pbHbAWVIO5HnlrCNZ5kEOpE8qAk0f53lGbM31PzsA5S9i6Hol+FSXHp7WrJB6L4/5CVx5wwNG0bVk PAk4CpguhjOgucGwswX3hyWBq9GaYeP/QGf2LuaPqCx8Zj3/Oe9ty1GassWSgAzEdKI3hYVeyuFlp wVhfdWLCnpdLiN5z+i3P9RrY/wkiHlvOr/tz8u8szze5iRzhjgYc8bjTaMRU+AY/+V8Sc7piK1LOt UxJpBUcyuIDVqvI3nxGg==; 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 1j4pan-0007qx-6A; Thu, 20 Feb 2020 17:26:29 +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 1j4paK-0007NX-4x for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:02 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id 4E2892C1EC1; Thu, 20 Feb 2020 18:25:53 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 5/7] i2c: of: error message unification Date: Thu, 20 Feb 2020 18:24:01 +0100 Message-Id: <20200220172403.26062-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092600_372549_1E18866D X-CRM114-Status: GOOD ( 10.13 ) 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: devicetree@vger.kernel.org, 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 - 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 Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/i2c/i2c-core-of.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 710704cd583e..74b9f3fbb5ef 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\n", node); 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) @@ -100,9 +102,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap) client = of_i2c_register_device(adap, node); if (IS_ERR(client)) { - dev_err(&adap->dev, - "Failed to create I2C device for %pOF\n", - node); + pr_err("failed to create I2C device for %pOF\n", node); of_node_clear_flag(node, OF_POPULATED); } } @@ -243,8 +243,7 @@ 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); + pr_err("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 Thu Feb 20 17:24:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11394779 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 9DB591892 for ; Thu, 20 Feb 2020 17:26: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 7CB962467A for ; Thu, 20 Feb 2020 17:26: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="BNnMTUmH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CB962467A 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=HGf9nSVS/wyaUcXTfdvRdMfOPdzez0mB9W+avFeXrCg=; b=BNnMTUmHSemrgN HlCMVVMKhLxRWOBp5uvGWOqpRz+qu6Pd16tqltQ0Hv7qzZH2mVYIrDGmXC50n2Tx4d20gJo8Q6Bki K2URljjv5OXFy6mleUxx7zMKuQFzG0ZjSMKD5g61UwMfg8oKoO3Po6lLCtHHeJA9geuAIrYbH+A8C DtoadIyFKQ6Kaf7sDrybspqTToQaopumQDvGB3lOun884773FQQonzir5YrXcwSXRV9jDOdmRlmLW lpSbdlarFX9nJkqSZto0ReTx7Ajbf4EHzdObt1P8C35nDyFLINilDQ72rD5qHA9R699R9V7zJr3Ph wwPTLIsIulfgA7JRu12A==; 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 1j4pao-0007sA-Gc; Thu, 20 Feb 2020 17:26:30 +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 1j4paK-0007NR-36 for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:02 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id E09212C1EC3; Thu, 20 Feb 2020 18:25:53 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 6/7] i2c: of: mark a whole array of regs as reserved Date: Thu, 20 Feb 2020 18:24:02 +0100 Message-Id: <20200220172403.26062-7-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092600_443327_8B2D8F80 X-CRM114-Status: GOOD ( 12.05 ) 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: devicetree@vger.kernel.org, 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: Geert Uytterhoeven Reviewed-by: Luca Ceresoli --- drivers/i2c/i2c-core-of.c | 68 +++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 74b9f3fbb5ef..316db0c3b3c8 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -21,20 +21,12 @@ #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 +43,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 +72,33 @@ 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; + struct property *prop; + const __be32 *cur; + u32 reg; pr_debug("register %pOF\n", node); - ret = of_i2c_get_board_info(node, &info); - if (ret) - return ERR_PTR(ret); + of_property_for_each_u32(node, "reg", prop, cur, reg) { + 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\n", + reg, node); + if (first_reg) + return client; + } - client = i2c_new_client_device(adap, &info); - if (IS_ERR(client)) - pr_err("failure registering %pOF\n", node); + 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 Thu Feb 20 17:24:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11394781 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 D7B5F109A for ; Thu, 20 Feb 2020 17:26: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 B6D8C2467A for ; Thu, 20 Feb 2020 17:26: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="tlT88Hcs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6D8C2467A 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=CIXPSQ8q+MArir0P68Q7OY78POStPgeekt3BL22oqTw=; b=tlT88Hcsr07YQ8 jtlfhGAKDDMBxR/DJ83KCpidwCtmVePGNWkRRx+7eC/v6E8kOiSSU88/Ax+4HdKa07ROBw69YgaLU /531sPiicAr0N1hd7ILq0J57UACzUyFp63eKy1nE0A1bszplDfJvhZ0itBf+VHHVaZExuQrCmS0nf ObNVu4lvGwhly/7IB7MIX2db+y0u0hk+k+4CfvvAQqUqaIodUnCfMr4g2xS9BukVMFDWx+psKJD34 VbbODgWnMkB1IbA4hHmsVrNxtVjDkx1H/1rU4OdrJbY6VgYxdK712AivtD8KDSdYYQjtU23GJBclA hmsnTTokPAPJUmxpm7ZA==; 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 1j4pap-0007sq-2b; Thu, 20 Feb 2020 17:26:31 +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 1j4paL-0007PJ-R6 for linux-i3c@lists.infradead.org; Thu, 20 Feb 2020 17:26:03 +0000 Received: from localhost (p5486CC48.dip0.t-ipconnect.de [84.134.204.72]) by pokefinder.org (Postfix) with ESMTPSA id 721632C1EC5; Thu, 20 Feb 2020 18:25:54 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 7/7] i2c: core: hand over reserved devices when requesting ancillary addresses Date: Thu, 20 Feb 2020 18:24:03 +0100 Message-Id: <20200220172403.26062-8-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> References: <20200220172403.26062-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-20200220_092602_077758_A9B8DD68 X-CRM114-Status: UNSURE ( 9.43 ) 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: devicetree@vger.kernel.org, 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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 4000a4384306..ba325f8107a3 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -975,6 +975,8 @@ struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, u16 default_addr) { struct device_node *np = client->dev.of_node; + struct device *reserved_dev, *adapter_dev = &client->adapter->dev; + struct i2c_client *reserved_client; u32 addr = default_addr; int i; @@ -984,7 +986,21 @@ 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); + reserved_client = i2c_verify_client(reserved_dev); + + if (reserved_client) { + if (reserved_client->dev.of_node != 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);