From: Julien Grall Subject: [PATCH v3 03/13] xen/dt: Extend dt_device_match to possibly store data Date: Fri, 30 Jan 2015 18:49:18 +0000 Message-ID: <1422643768-23614-4-git-send-email-julien.grall@linaro.org> References: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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: by mail-we0-f177.google.com with SMTP id l61so28714084wev.8 for ; Fri, 30 Jan 2015 10:50:05 -0800 (PST) In-Reply-To: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org 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 -- 2.1.4