From patchwork Fri Aug 16 21:05:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19263 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C5E4D248E6 for ; Fri, 16 Aug 2013 21:06:31 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id h10sf480398vbh.1 for ; Fri, 16 Aug 2013 14:06:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=wdOEq3H7MWvP5C63L+jxhCRfhv5dhfR/sT9H5jedx8o=; b=TGfGB6dJ2gZVKq0T3kEEM5bxXK27E7NnkaQVwNKFwtXNd3kN5Yj92YpzESVZP7wbO4 8twVfBAwEsX4GsBdRhIHV5dC/Dd2yuCs4R87fQUxUBGYz5GLoE8I20xvrDyarI+33lvz XJsCySILrrI49qD4L1xYRdbjZGqM8oPuV16XcUuKdBn79qbrlAv2BBsgyQOC1TJGwReU nRm6Hsfr2m9xF+4b3VqSPcW0xt3HqXZgLJ6mx4NJIpuXti/1S4F9pWQL7yKG9sTXgrj+ r4sXGcOqgz0sP842hYkpEHGIJIzIw/jgOIKCbfwC3vq6pr7yL2EgJxi5FRKq4Vu1/GYv WqSw== X-Received: by 10.236.56.70 with SMTP id l46mr1365020yhc.2.1376687191461; Fri, 16 Aug 2013 14:06:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.82.101 with SMTP id h5ls941546qey.91.gmail; Fri, 16 Aug 2013 14:06:31 -0700 (PDT) X-Received: by 10.220.173.134 with SMTP id p6mr18817vcz.36.1376687191350; Fri, 16 Aug 2013 14:06:31 -0700 (PDT) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id vf5si773097vdc.122.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Aug 2013 14:06:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id h10so1952354vbh.34 for ; Fri, 16 Aug 2013 14:06:31 -0700 (PDT) X-Gm-Message-State: ALoCoQloPVwoPxC2K1hAwJ2FLZBrGoN5Gt3vDSpvT7K+FfwNGnBBl6IdpmqiDJ0wOIS443f1eiRJ X-Received: by 10.58.137.167 with SMTP id qj7mr2838729veb.1.1376687191247; Fri, 16 Aug 2013 14:06:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp89461vcz; Fri, 16 Aug 2013 14:06:30 -0700 (PDT) X-Received: by 10.180.72.134 with SMTP id d6mr643910wiv.8.1376687190353; Fri, 16 Aug 2013 14:06:30 -0700 (PDT) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by mx.google.com with ESMTPS id h8si247400wiy.13.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Aug 2013 14:06:30 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.174 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.174; Received: by mail-we0-f174.google.com with SMTP id q54so7961wes.33 for ; Fri, 16 Aug 2013 14:06:30 -0700 (PDT) X-Received: by 10.180.85.133 with SMTP id h5mr675619wiz.1.1376687189936; Fri, 16 Aug 2013 14:06:29 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id b13sm797327wic.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Aug 2013 14:06:28 -0700 (PDT) From: Julien Grall To: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com Cc: patches@linaro.org, andre.przywara@linaro.org, xen-devel@lists.xen.org, Julien Grall Subject: [RFC 15/24] xen/arm: Use dt_device_match to avoid multiple if conditions Date: Fri, 16 Aug 2013 22:05:47 +0100 Message-Id: <1376687156-6737-16-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376687156-6737-1-git-send-email-julien.grall@linaro.org> References: <1376687156-6737-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There is some place in Xen ARM code where multiple if conditions is used check the presence of a node or find a node. These pieces of code can be replace by an array and using proper device tree helpers. Signed-off-by: Julien Grall --- xen/arch/arm/domain_build.c | 12 +++++++++--- xen/arch/arm/time.c | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a324c3b..604ec1c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -435,6 +435,14 @@ static int map_device(struct domain *d, const struct dt_device_node *dev) return 0; } +static const struct dt_device_match skip_matches[] __initconst = +{ + DT_MATCH_COMPATIBLE("xen,xen"), + DT_MATCH_TYPE("memory"), + DT_MATCH_PATH("/chosen"), + { /* sentinel */ }, +}; + static int handle_node(struct domain *d, const struct dt_device_node *np) { const struct dt_device_node *child; @@ -443,9 +451,7 @@ static int handle_node(struct domain *d, const struct dt_device_node *np) DPRINT("handle %s\n", dt_node_full_name(np)); /* Skip theses nodes and the sub-nodes */ - if ( dt_device_is_compatible(np, "xen,xen") || - dt_device_type_is_equal(np, "memory") || - !strcmp("/chosen", dt_node_full_name(np)) ) + if ( dt_match_node(skip_matches, np ) ) return 0; if ( dt_device_used_by(np) != DOMID_XEN ) diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index b5864ef..05e58ba 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -98,6 +98,13 @@ static uint32_t calibrate_timer(void) } */ +static const struct dt_device_match timer_ids[] __initdata = +{ + DT_MATCH_COMPATIBLE("arm,armv7-timer"), + DT_MATCH_COMPATIBLE("arm,armv8-timer"), + { /* sentinel */ }, +}; + /* Set up the timer on the boot CPU */ int __init init_xen_time(void) { @@ -105,9 +112,7 @@ int __init init_xen_time(void) int res; unsigned int i; - dev = dt_find_compatible_node(NULL, NULL, "arm,armv7-timer"); - if ( !dev ) - dev = dt_find_compatible_node(NULL, NULL, "arm,armv8-timer"); + dev = dt_find_matching_node(NULL, timer_ids); if ( !dev ) panic("Unable to find a compatible timer in the device tree\n");