From patchwork Thu Mar 12 16:17:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 5997131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43DC5BF90F for ; Thu, 12 Mar 2015 16:21:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 721DA2035D for ; Thu, 12 Mar 2015 16:21:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84C7B2035B for ; Thu, 12 Mar 2015 16:21:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YW5pL-0006y0-Cm; Thu, 12 Mar 2015 16:19:15 +0000 Received: from sauhun.de ([89.238.76.85] helo=pokefinder.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YW5ow-0006mg-Pr for linux-arm-kernel@lists.infradead.org; Thu, 12 Mar 2015 16:18:52 +0000 Received: from p4fe24c69.dip0.t-ipconnect.de ([79.226.76.105]:46379 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YW5of-0003YA-AM; Thu, 12 Mar 2015 17:18:33 +0100 From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [PATCH 2/2] i2c: busses with dynamic ids should start after fixed ids for DT Date: Thu, 12 Mar 2015 17:17:59 +0100 Message-Id: <1426177093-26820-3-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426177093-26820-1-git-send-email-wsa@the-dreams.de> References: <1426177093-26820-1-git-send-email-wsa@the-dreams.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150312_091851_070683_EF97767B X-CRM114-Status: GOOD ( 10.20 ) X-Spam-Score: -0.0 (/) Cc: devicetree@vger.kernel.org, Wolfram Sang , Bob Feretich , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jean Delvare X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure dynamic ids do not interfere with fixed ones and let them start after the highest fixed id. This patch might cause different bus-numbers for dynamic ids, however it fixes a bug. Assume: - fixed id0 defers probe - fixed id1 succeeds and registers a muxed bus with dynamic id - muxed bus gets id0 - fixed id0 wants to probe again, but its fixed id is gone now - fixed id0 probe fails With this patch, the fixed ids are always reserved in the DT case. For legacy board init, we already have a mechanism like this in i2c_register_board_info(). Reported-by: Bob Feretich Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 210cf4874cb7ea..4dda9a529f4464 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1878,6 +1878,14 @@ static int __init i2c_init(void) { int retval; + retval = of_alias_get_highest_id("i2c"); + + down_write(&__i2c_board_lock); + if (retval >= __i2c_first_dynamic_bus_num) { + __i2c_first_dynamic_bus_num = retval + 1; + } + up_write(&__i2c_board_lock); + retval = bus_register(&i2c_bus_type); if (retval) return retval;