From patchwork Thu Apr 19 03:14:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 133687 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp153824ljf; Wed, 18 Apr 2018 20:16:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx48sXaWsr1cZPA1IRpXV7iaDgZKhT99cKPYYulv46vqfmyCWgj1zbNhPDbDEVblzmOdaJPGu X-Received: by 10.80.179.202 with SMTP id t10mr6181003edd.14.1524107785140; Wed, 18 Apr 2018 20:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524107785; cv=none; d=google.com; s=arc-20160816; b=H8kNEiZhTY7Wiov1708HRYz0GTutrUeZasL5NeTL/+rQ9q6Wn4ElkXbNOGpYiVEcBH n50zK7crO6/mmTSA5HtnK29QzQfJ+WFW4qkLSpMQL45TM9qAGAVvRiPdjWsYUoilXupi 34qzB86EFYLXt7BvrFAAXjbsXOtnnEbR4Vp86OQRsmJ1VtTYho4lSuH/E067MS/DcpII dYfPn/n7lLMQuTnHD34N6ABBoU99hYgvaQC8Ni3teJvEhi13p9o1NWI0yptW8INvgRg9 BM2t7JpnmqUravo15EDQWTLPf/7uWy+v4E9Vrfy1XrKTyVcGsMX4gwqm4q5nZ0/pe9z7 doYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=ZAbxdheFQ6rCcOqcLEd/7xbgJ1tRV61bUn4l0q5OqvA=; b=pjFRCAgBm4j7Fdk/Ysm1yCu1Jzo+NA7n2sHcGUA7ik0o92BXwr0qIy6sbt8JnojSPH Mdcl/QUPbUadlJNyqrO6/p8VFCW34O31MCUXw4/hfZvlYe8YVq01Ez7f8H1+1+OfyZro fmDHUZ8LFVNdTaIw2yywVe3LgARS9xDyHHvClMWl3ALpY/LrcfgjdcKh0jpWdjxyRp7y 70lyveOfW8ISdkcQQEuLT7xeXx9Y9RMulLZmWeUgg/V/emKj7HSwrnH7FWlh+NxM/Tyt rVn120/GtE87QSfgxSEsjdmFnJWLASd1hM3jzNJjAhKYiplvYHn+XNSnKV5lZI3tqFrO Xrzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Ryoz38TG; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id p5si2622703eda.317.2018.04.18.20.16.24; Wed, 18 Apr 2018 20:16:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Ryoz38TG; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id BFDD3C21F21; Thu, 19 Apr 2018 03:16:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B0901C21EEF; Thu, 19 Apr 2018 03:16:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9AC88C21F16; Thu, 19 Apr 2018 03:15:33 +0000 (UTC) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by lists.denx.de (Postfix) with ESMTPS id 71928C21F21 for ; Thu, 19 Apr 2018 03:15:31 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id w3J3EwYr013098; Thu, 19 Apr 2018 12:15:01 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w3J3EwYr013098 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1524107701; bh=g2QoQSRTiOQ7vVa7DYsBTdwDPeep7CaFVmhF5KS6iXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ryoz38TGIizmWCtWAuMqx2S9e3tLAv19pihBgiVoPkyH30StIRhKtly6AoXPNfNit m77p/Mn1aE3Ndu4X3sPPvPuMylKKfq/zx/tMp59zYK3IyormD2se9TyK0q/LbgLMKf Du+HgP6yLGoNtUJpvdmt4B6xhTTA1hMNP2sIk9KW2sIW0S00yH9Nl4Tip4vG8eW0YU Tz4Zvzajf9lO76FpkadUguIvgnIOsLGTTJjUrPI9rq8X6NCdJNumPDzr1vvxtN5FZX G/zs4hM76IIKKVELDgD+NwDUOdSTiHj3aMySHnp97ZoJg5PXjDdmfw/d1c1zrYNcPa zf8aenwLdHNaA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 Apr 2018 12:14:02 +0900 Message-Id: <1524107644-28849-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524107644-28849-1-git-send-email-yamada.masahiro@socionext.com> References: <1524107644-28849-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini , Jassi Brar , Masami Hiramatsu Subject: [U-Boot] [PATCH v2 2/4] dm: ofnode: add ofnode_device_is_compatible() helper X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" device_is_compatible() takes udevice, but there is no such a helper that takes ofnode. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- Changes in v2: None drivers/core/device.c | 8 +------- drivers/core/ofnode.c | 11 +++++++++++ include/dm/ofnode.h | 11 +++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 940a153..8d95787 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -709,13 +709,7 @@ int device_set_name(struct udevice *dev, const char *name) bool device_is_compatible(struct udevice *dev, const char *compat) { - const void *fdt = gd->fdt_blob; - ofnode node = dev_ofnode(dev); - - if (ofnode_is_np(node)) - return of_device_is_compatible(ofnode_to_np(node), compat, NULL, NULL); - else - return !fdt_node_check_compatible(fdt, ofnode_to_offset(node), compat); + return ofnode_device_is_compatible(dev_ofnode(dev), compat); } bool of_machine_is_compatible(const char *compat) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 5909a25..ee2109b 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -687,3 +687,14 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr) else return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr); } + +int ofnode_device_is_compatible(ofnode node, const char *compat) +{ + if (ofnode_is_np(node)) + return of_device_is_compatible(ofnode_to_np(node), compat, + NULL, NULL); + else + return !fdt_node_check_compatible(gd->fdt_blob, + ofnode_to_offset(node), + compat); +} diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 0d00840..a2c6a50 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -681,4 +681,15 @@ int ofnode_read_resource_byname(ofnode node, const char *name, * @return the translated address; OF_BAD_ADDR on error */ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr); + +/** + * ofnode_device_is_compatible() - check if the node is compatible with compat + * + * This allows to check whether the node is comaptible with the compat. + * + * @node: Device tree node for which compatible needs to be verified. + * @compat: Compatible string which needs to verified in the given node. + * @return true if OK, false if the compatible is not found + */ +int ofnode_device_is_compatible(ofnode node, const char *compat); #endif