From patchwork Thu Jul 26 19:55:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1244891 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 029B2DFFCE for ; Thu, 26 Jul 2012 20:19:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuURg-0007aF-B6; Thu, 26 Jul 2012 20:14:04 +0000 Received: from moutng.kundenserver.de ([212.227.17.9]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuUAQ-00045S-HE for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2012 19:56:15 +0000 Received: from mailbox.adnet.avionic-design.de (mailbox.avionic-design.de [109.75.18.3]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LaYSx-1Tftun1Uwp-00mCtU; Thu, 26 Jul 2012 21:55:22 +0200 Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id C27D72A282EA; Thu, 26 Jul 2012 21:55:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c7vV8Dtsvhbe; Thu, 26 Jul 2012 21:55:20 +0200 (CEST) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) (Authenticated sender: thierry.reding) by mailbox.adnet.avionic-design.de (Postfix) with ESMTPA id D1F642A282E4; Thu, 26 Jul 2012 21:55:19 +0200 (CEST) From: Thierry Reding To: linux-tegra@vger.kernel.org Subject: [PATCH v3 08/10] of/address: Handle #address-cells > 2 specially Date: Thu, 26 Jul 2012 21:55:10 +0200 Message-Id: <1343332512-28762-9-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1343332512-28762-1-git-send-email-thierry.reding@avionic-design.de> References: <1343332512-28762-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:fdAK+mKQ8QSoxsSMie02tqQ3ztvsLnkKDgJef7PEnGQ 7RuyseRibZBuQUEoiBofR4POAh8ShNqYbw89V2ZMqrau0QIKdw TQZ0d1wDS8zo1tCKPPZIY7GfLnyOb+IWzbSM2YfL0GYvNKtVWi XJRBb4mkltQGhcbLfEHBnmIbua5EnYGSv3KOYP0D5wDu5K1uo7 JT5oazso+U3NsTy8YSpevBDGFnIb4CVEHsgxE4vc8B5gA2HxWI t2k5KesX+DWZjcR66cshkraM4vRc8pinG1vJ32GqyW21lFukrD RVzET2o/rrRY/FdxBSk/A6XvvypGfw/WDnc8R8twI/5YBMvuzS 6wY0Fo+s8fSLfuvt2JFlsSAoZzV4rOdamkIyULGgGWWgkRJG+p 2dS2h7MbUptolK1gxbypd08FmxjlWCURmPmh3jnCSCNIpoPIzQ 2E4YF X-Spam-Note: CRM114 invocation failed X-Spam-Note: SpamAssassin invocation failed Cc: Mitch Bradley , Russell King , Arnd Bergmann , Stephen Warren , linux-pci@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Rob Herring , Grant Likely , Olof Johansson , Colin Cross , Bjorn Helgaas , 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 a bus specifies #address-cells > 2, of_bus_default_map() now assumes that the mapping isn't for a physical address but rather an identifier that needs to match exactly. This is required by bindings that use multiple cells to translate a resource to the parent bus (device index, type, ...). See here for the discussion: https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html Originally-by: Arnd Bergmann Signed-off-by: Thierry Reding Acked-by: Rob Herring --- Changes in v3: - new patch drivers/of/address.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 7e262a6..2776119 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -69,6 +69,14 @@ static u64 of_bus_default_map(u32 *addr, const __be32 *range, (unsigned long long)cp, (unsigned long long)s, (unsigned long long)da); + /* + * If the number of address cells is larger than 2 we assume the + * mapping doesn't specify a physical address. Rather, the address + * specifies an identifier that must match exactly. + */ + if (na > 2 && memcmp(range, addr, na * 4) != 0) + return OF_BAD_ADDR; + if (da < cp || da >= (cp + s)) return OF_BAD_ADDR; return da - cp;