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: 173498 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 7BCFB2C0323 for ; Fri, 27 Jul 2012 05:55:49 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752704Ab2GZTzo (ORCPT ); Thu, 26 Jul 2012 15:55:44 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:58576 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642Ab2GZTzm (ORCPT ); Thu, 26 Jul 2012 15:55:42 -0400 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 Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, Grant Likely , Rob Herring , devicetree-discuss@lists.ozlabs.org, Russell King , linux-arm-kernel@lists.infradead.org, Colin Cross , Olof Johansson , Stephen Warren , Mitch Bradley , Arnd Bergmann 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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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;