From patchwork Fri Aug 31 07:52:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Vaussard X-Patchwork-Id: 1391351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id D1E62DFABE for ; Fri, 31 Aug 2012 07:56:29 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T7M30-00069P-JK; Fri, 31 Aug 2012 07:53:46 +0000 Received: from smtp4.epfl.ch ([128.178.224.218]) by merlin.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1T7M2n-00068P-Ln for linux-arm-kernel@lists.infradead.org; Fri, 31 Aug 2012 07:53:35 +0000 Received: (qmail 22624 invoked by uid 107); 31 Aug 2012 07:53:25 -0000 X-Virus-Scanned: ClamAV Received: from lsro1pc340.epfl.ch (HELO lsro1pc340.epfl.ch) (128.178.145.154) (authenticated) by smtp4.epfl.ch (AngelmatoPhylax SMTP proxy) with ESMTPA; Fri, 31 Aug 2012 09:53:25 +0200 From: Florian Vaussard To: Tony Lindgren Subject: [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree Date: Fri, 31 Aug 2012 09:52:54 +0200 Message-Id: <1346399575-7285-2-git-send-email-florian.vaussard@epfl.ch> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1346399575-7285-1-git-send-email-florian.vaussard@epfl.ch> References: <1346399575-7285-1-git-send-email-florian.vaussard@epfl.ch> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.4 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [128.178.224.218 listed in list.dnswl.org] -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Benoit Cousson , Wolfram Sang , linux-i2c@vger.kernel.org, Ben Dooks , Florian Vaussard , =?UTF-8?q?Philippe=20R=C3=A9tornaz?= , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When booting from a device tree, the omap driver is using pdev->id, which is incorrect. The proposed patch uses aliases, as done in omap-serial. Signed-off-by: Florian Vaussard --- drivers/i2c/busses/i2c-omap.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 5d19a49..9445d1f 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1064,9 +1064,6 @@ omap_i2c_probe(struct platform_device *pdev) goto err_unuse_clocks; } - dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", pdev->id, - dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed); - adap = &dev->adapter; i2c_set_adapdata(adap, dev); adap->owner = THIS_MODULE; @@ -1076,8 +1073,22 @@ omap_i2c_probe(struct platform_device *pdev) adap->dev.parent = &pdev->dev; adap->dev.of_node = pdev->dev.of_node; + if (adap->dev.of_node) + adap->nr = of_alias_get_id(adap->dev.of_node, "i2c"); + else + adap->nr = pdev->id; + + if (adap->nr < 0) { + dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", + adap->nr); + r = -ENODEV; + goto err_free_irq; + } + + dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", adap->nr, + dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed); + /* i2c device drivers may be active on return from add_adapter() */ - adap->nr = pdev->id; r = i2c_add_numbered_adapter(adap); if (r) { dev_err(dev->dev, "failure adding adapter\n");