From patchwork Tue Apr 9 17:09:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 235145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 492BB2C00BB for ; Wed, 10 Apr 2013 03:10:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934726Ab3DIRJs (ORCPT ); Tue, 9 Apr 2013 13:09:48 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:52075 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759304Ab3DIRJr (ORCPT ); Tue, 9 Apr 2013 13:09:47 -0400 Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1UPc3F-0006ut-1A; Tue, 09 Apr 2013 19:09:45 +0200 From: Philipp Zabel To: linux-i2c@vger.kernel.org Cc: Ben Dooks , Wolfram Sang , Shawn Guo , Philipp Zabel Subject: [PATCH] i2c: imx: use of_alias_get_id to order i2c devices Date: Tue, 9 Apr 2013 19:09:39 +0200 Message-Id: <1365527379-17786-1-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 1.8.2.rc2 X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-i2c@vger.kernel.org Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This allows to order i2c character devices as they are numbered in the reference manual, instead of ordering them by register base address. Signed-off-by: Philipp Zabel --- drivers/i2c/busses/i2c-imx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 82f20c6..e5a3f08 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -488,6 +488,7 @@ static struct i2c_algorithm i2c_imx_algo = { static int __init i2c_imx_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids, &pdev->dev); struct imx_i2c_struct *i2c_imx; @@ -531,7 +532,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev) i2c_imx->adapter.owner = THIS_MODULE; i2c_imx->adapter.algo = &i2c_imx_algo; i2c_imx->adapter.dev.parent = &pdev->dev; - i2c_imx->adapter.nr = pdev->id; + i2c_imx->adapter.nr = (pdev->id < 0) ? of_alias_get_id(np, "i2c") : pdev->id; i2c_imx->adapter.dev.of_node = pdev->dev.of_node; i2c_imx->base = base;