From patchwork Fri Jan 16 14:23:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43241 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D9510240D8 for ; Fri, 16 Jan 2015 14:26:09 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id k14sf11243356wgh.2 for ; Fri, 16 Jan 2015 06:26:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=8+0ksZw8WM7Pko0o9etFCTYcZzDzl5eul8rI8QWuL74=; b=B7yW0cEfQPAaA8ajazKAPA6Q8lXDzoRAiuXv1zpOJpwjcOy3ElcNQRZ+Bt/PDAO5Y9 /tvQbXaU8vHBAV2Ekqhi4cO51E5rYHA1ONq913QUTQfwLIiSqd+RiYZr8iaC+cy3eB+j R4v4GQkYAC/qACvw24WjBmDAmLEMcqzIi6/kmMTHUt5FuPGQxpELDNlaKAWb3K2KBXhQ 2WY94r0BkQZp7dYjTg+9KyHYZWOkhOBxrW+zO/2/Gxx92225IFBtyHmrax4aGTijdd6s BLZary79woUDgdWGhuy9/+ey6+hCYDY7F8CpOtHgA3buFvKAxSfKc5nt4Et99eYSg0NW Pn1A== X-Gm-Message-State: ALoCoQnpBG6j9T9b8VMo/RWH6jltn7Dz67Qj8Fm0kJkbsyXwMnKZiGrBculH1C2w7otB6tFAhCys X-Received: by 10.180.7.226 with SMTP id m2mr473355wia.5.1421418368849; Fri, 16 Jan 2015 06:26:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.200 with SMTP id d8ls301523lah.18.gmail; Fri, 16 Jan 2015 06:26:08 -0800 (PST) X-Received: by 10.152.170.194 with SMTP id ao2mr16275496lac.12.1421418368688; Fri, 16 Jan 2015 06:26:08 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id p15si3415203laa.34.2015.01.16.06.26.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 06:26:08 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gf13so19156208lab.7 for ; Fri, 16 Jan 2015 06:26:08 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr15658305lbc.23.1421418368549; Fri, 16 Jan 2015 06:26:08 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp325246lbb; Fri, 16 Jan 2015 06:26:07 -0800 (PST) X-Received: by 10.224.114.81 with SMTP id d17mr25235839qaq.27.1421418367051; Fri, 16 Jan 2015 06:26:07 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id e2si6144077qcg.39.2015.01.16.06.26.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Jan 2015 06:26:07 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YC7pa-0004Gs-Vb; Fri, 16 Jan 2015 14:24:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YC7pZ-0004GA-T4 for xen-devel@lists.xenproject.org; Fri, 16 Jan 2015 14:24:58 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id D7/36-14727-93F19B45; Fri, 16 Jan 2015 14:24:57 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-3.tower-206.messagelabs.com!1421418296!10889340!1 X-Originating-IP: [209.85.212.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13208 invoked from network); 16 Jan 2015 14:24:56 -0000 Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by server-3.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 16 Jan 2015 14:24:56 -0000 Received: by mail-wi0-f169.google.com with SMTP id bs8so4710911wib.0 for ; Fri, 16 Jan 2015 06:24:56 -0800 (PST) X-Received: by 10.194.143.12 with SMTP id sa12mr29619281wjb.101.1421418296279; Fri, 16 Jan 2015 06:24:56 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id x6sm6270862wjf.24.2015.01.16.06.24.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 06:24:50 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 16 Jan 2015 14:23:58 +0000 Message-Id: <1421418247-30068-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421418247-30068-1-git-send-email-julien.grall@linaro.org> References: <1421418247-30068-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v2 03/12] xen/dt: Extend dt_device_match to possibly store data X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Some drivers may want to configure differently the device depending on the compatible string. Also modify the return type of dt_match_node to return the matching structure. Signed-off-by: Julien Grall --- xen/arch/arm/platform.c | 2 +- xen/common/device_tree.c | 12 ++++++------ xen/include/xen/device_tree.h | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/platform.c b/xen/arch/arm/platform.c index cb4cda8..a79a098 100644 --- a/xen/arch/arm/platform.c +++ b/xen/arch/arm/platform.c @@ -157,7 +157,7 @@ bool_t platform_device_is_blacklisted(const struct dt_device_node *node) if ( platform && platform->blacklist_dev ) blacklist = platform->blacklist_dev; - return dt_match_node(blacklist, node); + return (dt_match_node(blacklist, node) != NULL); } unsigned int platform_dom0_evtchn_ppi(void) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index f72b2e9..34a1b9e 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -290,11 +290,12 @@ struct dt_device_node *dt_find_node_by_alias(const char *alias) return NULL; } -bool_t dt_match_node(const struct dt_device_match *matches, - const struct dt_device_node *node) +const struct dt_device_match * +dt_match_node(const struct dt_device_match *matches, + const struct dt_device_node *node) { if ( !matches ) - return 0; + return NULL; while ( matches->path || matches->type || matches->compatible || matches->not_available ) @@ -314,12 +315,11 @@ bool_t dt_match_node(const struct dt_device_match *matches, match &= !dt_device_is_available(node); if ( match ) - return match; - + return matches; matches++; } - return 0; + return NULL; } const struct dt_device_node *dt_get_parent(const struct dt_device_node *node) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 08db8bc..6502369 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -28,6 +28,7 @@ struct dt_device_match { const char *type; const char *compatible; const bool_t not_available; + const void *data; }; #define DT_MATCH_PATH(p) { .path = p } @@ -547,8 +548,9 @@ bool_t dt_device_is_available(const struct dt_device_node *device); * * Returns true if the device node match one of dt_device_match. */ -bool_t dt_match_node(const struct dt_device_match *matches, - const struct dt_device_node *node); +const struct dt_device_match * +dt_match_node(const struct dt_device_match *matches, + const struct dt_device_node *node); /** * dt_find_matching_node - Find a node based on an dt_device_match match table