From patchwork Wed Apr 18 02:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 133594 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp5392008ljb; Tue, 17 Apr 2018 19:42:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/VibhQSdZX10lvHGNmO/IpChSzTHt2JwV4ylxNHADfSCaopwBfAJWgjy4Yp9t4D9VfciCG X-Received: by 10.80.163.144 with SMTP id s16mr755229edb.271.1524019343446; Tue, 17 Apr 2018 19:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524019343; cv=none; d=google.com; s=arc-20160816; b=XV9OnihqAvFr9tiHgVhAZ4+9130OoZLpbeQG3N2In8SOIZYXJi/uSP3kcoiES3/OQG tkKTy/Oi6Ig0dW8G+T1OlrFzZki/ZV53sF+xyWTyFdpKYkWXCIYschJ5mAJFXVkPDnOe s7dk/K7x01yWJnOII9VnuYTmnCB75NcTOMllwGTEoEfN4tYocEJsr4r0CLreTY/1jHNZ VaYCi4Om1FBzEPzIfMfy/6WnwvbFPKM5QZiuK/7frr0mXJdd0bWAQ92InxD8Uu1sht16 ZS/S1KEtyyf+3Fm5J1EJgX9U6WUrUD8BbJ1DJm8RKzfOVc+iuPFd0SMDH7Jbs8A4Mi5e Oa4g== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=kNTrLxu6rZ6kAz37ZAsICKa2FDYE0ocy+7wfCvi1lbw=; b=i68eUjda3ADTzF4xYcK1wMQWhawrn9Ll1ZWzxI/7jIm8oeUw7VMPrM7eBSf74/8s40 piu+5s3wUrcdWdIY/ENo0wZRcFQZpydUpmRRKOx/hwAaElPvwDmQLp6yBVYSjnVC6bvQ P3E/WO0/EmTiFh3F5NklvQkVeMSAQED0D0pYFPDZGpwxnEYvcdzWCH5Aye8FN/g69742 94eSYa422UDK8PiGa7yvdVxNr32MbFsyExb7HiCv5QDWMr+292MTVpWOaQKGYgLiZcBO jZuT17f2Om541xKSfP/wjW28ekWAUT16dlSJWflk+7yWY85/Md+GG6BxkvGcZ232k5VN EcVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=YVCPbxps; 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 a19si272421edb.453.2018.04.17.19.42.23; Tue, 17 Apr 2018 19:42:23 -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=YVCPbxps; 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 0BDC0C21E34; Wed, 18 Apr 2018 02:40:05 +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 ECD08C21E88; Wed, 18 Apr 2018 02:39:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B7579C21C29; Wed, 18 Apr 2018 02:39:24 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id C9FF7C21C2C for ; Wed, 18 Apr 2018 02:39:23 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w3I2culE028728; Wed, 18 Apr 2018 11:38:58 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w3I2culE028728 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1524019138; bh=IxrpUlyh1+x6LHtl4CLbBCJX2JB4A8iZ2BBMpoxwNs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YVCPbxps7FPoSqLUzEonz1M4/IYBE37Ed8Jvr0QEgOSxuslnSsFzPWDacGRWZGaUW 2GbA3a1S3nKOAyzGsq7s/LWPtAlysc1Ph7X6gmtj7sfhQVQr0FdTGLuiJ2Cc0vayNp KCV6oCmOzhKqR+FTKV0vYzjuBgbWmzpKGtq3TwwsdOIwtGtM8jOFw9CpcZtEWAvCdz srFIDFlwY3cQhGqjPsSAAQuxMCU/5f8cBPjhLAgDu6KPjCM+IFwIxOBcZ9BDHnfuFG 2Uf7TLiJG78+y7DJ0lpZMFRXG3gyZaKOWLvA9wCw+usp4WwNYEuRnt7I4jXfXPq6MR xFvx/Nv8tm3oQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 18 Apr 2018 11:38:43 +0900 Message-Id: <1524019125-26287-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524019125-26287-1-git-send-email-yamada.masahiro@socionext.com> References: <1524019125-26287-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 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 --- 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