From patchwork Fri Jan 30 18:49:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44050 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C044420CA8 for ; Fri, 30 Jan 2015 18:51:55 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf3399132wiv.2 for ; Fri, 30 Jan 2015 10:51:54 -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=giVCS91S1XHuavjgNXZ1ZkagKjY5gHOhUl+FszIdZME=; b=eMrmqwGDJr/5kKaMFvlLMTJ3RKg6SXgQdcOQ8lpekwF54hoe5EIH6Ja0L/VMsPmK2t UBV5QYbH23Sv1l1G0+TwNzCo40GaOc65y0xMcAKKYTM15WksBvZ2Vxt3rR/3RX+AjwxD JeZvPx39SIKOhwYdeZ8ZcanaPUo77B7rUc5FebS+kUTbzr8psX7UUpM2/ifJ4/m6kW+t 7Qc+u/u5fWNMsHmwh2a/IaoqAarjcbetLWD4HlB+gGH/MXczKDjGf2L9eShlLsZ7FiTN W3PzI8NbYUkV8pw+JpgCNVnhLVg4ANYA3nu9XOQH5/G18vVWy/cSTLyPlc0veL9UQ9OP AqVQ== X-Gm-Message-State: ALoCoQlydrjZKGGxIJ4M8FGa0SpgHv1/8Xn/23ZkyOz8DbLLm91dzFG2wY4yziI1QGHFMrKHSbII X-Received: by 10.194.239.41 with SMTP id vp9mr91801wjc.5.1422643914862; Fri, 30 Jan 2015 10:51:54 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.232 with SMTP id t8ls457059laj.100.gmail; Fri, 30 Jan 2015 10:51:54 -0800 (PST) X-Received: by 10.152.45.4 with SMTP id i4mr8085262lam.74.1422643914541; Fri, 30 Jan 2015 10:51:54 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id po1si10735931lbb.87.2015.01.30.10.51.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:51:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id hs14so25213354lab.9 for ; Fri, 30 Jan 2015 10:51:54 -0800 (PST) X-Received: by 10.152.8.1 with SMTP id n1mr7750085laa.47.1422643914396; Fri, 30 Jan 2015 10:51:54 -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.35.133 with SMTP id h5csp377669lbj; Fri, 30 Jan 2015 10:51:53 -0800 (PST) X-Received: by 10.224.129.134 with SMTP id o6mr15326964qas.51.1422643911283; Fri, 30 Jan 2015 10:51:51 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id j3si2176344qgf.57.2015.01.30.10.51.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:51:51 -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 1YHGdr-0007By-Ua; Fri, 30 Jan 2015 18:50:07 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YHGdr-0007Bf-3p for xen-devel@lists.xenproject.org; Fri, 30 Jan 2015 18:50:07 +0000 Received: from [193.109.254.147] by server-15.bemta-14.messagelabs.com id 1B/48-02770-E52DBC45; Fri, 30 Jan 2015 18:50:06 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-27.messagelabs.com!1422643805!11845382!1 X-Originating-IP: [74.125.82.177] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19423 invoked from network); 30 Jan 2015 18:50:05 -0000 Received: from mail-we0-f177.google.com (HELO mail-we0-f177.google.com) (74.125.82.177) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jan 2015 18:50:05 -0000 Received: by mail-we0-f177.google.com with SMTP id l61so28714084wev.8 for ; Fri, 30 Jan 2015 10:50:05 -0800 (PST) X-Received: by 10.194.63.172 with SMTP id h12mr15024407wjs.32.1422643803891; Fri, 30 Jan 2015 10:50:03 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id n1sm169040wib.11.2015.01.30.10.50.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jan 2015 10:50:02 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 30 Jan 2015 18:49:18 +0000 Message-Id: <1422643768-23614-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> References: <1422643768-23614-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 v3 03/13] 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.50 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. For this purpose, add a new field in the dt_device_match to store the data. Also modify the return type of dt_match_node to return the matching structure. Signed-off-by: Julien Grall --- Changes in v3: - Make clear in the commit message that we add a new field... --- 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