From patchwork Mon Oct 7 16:29:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 2998291 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C80B0BF924 for ; Mon, 7 Oct 2013 17:13:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9980720207 for ; Mon, 7 Oct 2013 17:13:58 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3867B201F6 for ; Mon, 7 Oct 2013 17:13:57 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VTDjR-0001da-5x; Mon, 07 Oct 2013 16:32:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VTDir-0001Sc-3E; Mon, 07 Oct 2013 16:31:53 +0000 Received: from mail-gg0-f182.google.com ([209.85.161.182]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VTDiE-0001KJ-Ix for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2013 16:31:22 +0000 Received: by mail-gg0-f182.google.com with SMTP id h13so1142637ggd.27 for ; Mon, 07 Oct 2013 09:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=S2nUHD3UZqWps1cxDev8BBGOc6Hv2124iNo0BfwqLlI=; b=UaWA2n3GmecsHlM/H4jVNRd6N6WOIlj+6ynxbzkKmH/MR9Ry3bKNNpTS8VFuD0F1lN FwauO8VBUmjiJzqYWA6ZGN1yLxlDtgT4ugrgtck7rk2aCpsZfRy7c5dMRNj8BzObKHBJ iSKmTseZCdPPpKrPgL1DDdYpHS9myt9nAXp8R2WU64PfaDDxis7/iFZKjc3PGDt1MWP9 +7j8i1npkpGmZcY/4Dcu2SYBICqg2t9oDT6CT9h/mw2HCPBVm8S1n55LLTfMFjg6tUmS ooyR3HaX9cNve9GOWXhR5xen6nEcNMSap6ljjPtLVscbMfq3E2Qm19g4PMhcP1hjLTY9 /9tg== X-Received: by 10.236.194.15 with SMTP id l15mr14623318yhn.12.1381163438859; Mon, 07 Oct 2013 09:30:38 -0700 (PDT) Received: from rob-laptop.calxeda.com ([173.226.190.126]) by mx.google.com with ESMTPSA id d40sm44620829yhi.10.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Oct 2013 09:30:38 -0700 (PDT) From: Rob Herring To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 26/29] arm: use common of_flat_dt_match_machine Date: Mon, 7 Oct 2013 11:29:34 -0500 Message-Id: <1381163377-21044-27-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1381163377-21044-1-git-send-email-robherring2@gmail.com> References: <1381163377-21044-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131007_123114_737993_C9C6A477 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -2.5 (--) Cc: Grant Likely , Russell King , linux-arm-kernel@lists.infradead.org, Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Rob Herring Convert arm to use the common of_flat_dt_match_machine function. Signed-off-by: Rob Herring Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org --- arch/arm/kernel/devtree.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index e7ce175..0541f36 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -174,6 +174,19 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) return (phys_id & MPIDR_HWID_BITMASK) == cpu_logical_map(cpu); } +static const void * __init arch_get_next_mach(const char *const **match) +{ + static const struct machine_desc *mdesc = __arch_info_begin; + const struct machine_desc *m = mdesc; + + if (m >= __arch_info_end) + return NULL; + + mdesc++; + *match = m->dt_compat; + return m; +} + /** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt_phys: physical address of dt blob @@ -184,9 +197,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) { const struct machine_desc *mdesc, *mdesc_best = NULL; - unsigned int score, mdesc_score = ~1; - unsigned long dt_root; - const char *model; #ifdef CONFIG_ARCH_MULTIPLATFORM DT_MACHINE_START(GENERIC_DT, "Generic DT based system") @@ -198,23 +208,17 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) if (!dt_phys || !early_init_dt_scan(phys_to_virt(dt_phys))) return NULL; + mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); - /* Search the mdescs for the 'best' compatible value match */ - dt_root = of_get_flat_dt_root(); - for_each_machine_desc(mdesc) { - score = of_flat_dt_match(dt_root, mdesc->dt_compat); - if (score > 0 && score < mdesc_score) { - mdesc_best = mdesc; - mdesc_score = score; - } - } - if (!mdesc_best) { + if (!mdesc) { const char *prop; long size; + unsigned long dt_root; early_print("\nError: unrecognized/unsupported " "device tree compatible list:\n[ "); + dt_root = of_get_flat_dt_root(); prop = of_get_flat_dt_prop(dt_root, "compatible", &size); while (size > 0) { early_print("'%s' ", prop); @@ -225,16 +229,10 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) dump_machine_table(); /* does not return */ } - - model = of_get_flat_dt_prop(dt_root, "model", NULL); - if (!model) - model = of_get_flat_dt_prop(dt_root, "compatible", NULL); - if (!model) - model = ""; - pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); + early_print("matched mach %s\n", mdesc->name); /* Change machine number to match the mdesc we're using */ - __machine_arch_type = mdesc_best->nr; + __machine_arch_type = mdesc->nr; - return mdesc_best; + return mdesc; }