From patchwork Thu Aug 30 18:52:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 145566 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp244141ljw; Thu, 30 Aug 2018 11:52:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY06r3tTtlRam6gY1krkct8GKU1uOIYqtNSEQNHNUf39zZaDZ24Kcb5pbga2WwAgEHM6Njk X-Received: by 2002:a17:902:4a:: with SMTP id 68-v6mr5124462pla.276.1535655152854; Thu, 30 Aug 2018 11:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535655152; cv=none; d=google.com; s=arc-20160816; b=NJKEc4EBXF4A0aNEHPUBuMqEwWFapSYAyi5qnd3gMo+HII3JoL8smFY7vupX9N3vba TvIHtbSvLuJ4pRdHrcOnxOBBrnI/n3hZwauybAYHTQ0yoLR+bNMYERrwgh+5NnMfZNSI pcVu2F3s/1Ljsxm3FX3ViOgKvbDJcY1beReDfgg7XTV1D0DsAY5S3YBduW4I0qraXCd3 awhRtsq+a+uwZstawODXKo8YqYsBHwPBQuUwBU7nJw5685iWTqifDqf7hvxN+PVJR7Gn 3ihWEbXMy/OUOtSscNCrQWpEtn6zifZxNwqUGgE2QvBQDq4M5Opq9Yt2H2d7+HgVO4jx uJKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1Kkp6VXQTWLNRTjIurqTu/b/ONg3G/htDfEkWKGxZmA=; b=w/cXYpLZNNMC6+DNLNpSO24N5RpeUY41pKc71eIZhcqPvcaNi70JfLIGX1iJNL+QgN BwsqAtMprJp80sNmK2qTEAXCZNjQkyZzv5nNalpQOYxnwiWbf0eBGW60STYQZyDKShBw By7ad+JEKEIH7a5IlSQeKfhEVgl7lTFn6/XD8ip5ZexBbQ3CgkMOP2GvHu9Icv81BdbT sSGIqfr5wypreG/dIsHfUxsn9E+3xaNX1czXyJ4ruIP1+JzLj8MvV3vTPrnYQ8/ortzu u5hyti6hRj0omGwzT/m8iasOhPAB3dOC59qyeeiHKIPIpPY/2eTXSBXkxS+Ourzl0dMq YyHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v126-v6si7105828pgv.10.2018.08.30.11.52.32; Thu, 30 Aug 2018 11:52:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727703AbeH3W4E (ORCPT + 6 others); Thu, 30 Aug 2018 18:56:04 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:39707 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727702AbeH3W4E (ORCPT ); Thu, 30 Aug 2018 18:56:04 -0400 Received: by mail-oi0-f67.google.com with SMTP id c190-v6so17307341oig.6; Thu, 30 Aug 2018 11:52:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1Kkp6VXQTWLNRTjIurqTu/b/ONg3G/htDfEkWKGxZmA=; b=kcEkKvgZ6LtOXBVkNq5jPo4vWo6u4busglTh5u4PEpC0FeiwLmG+fXT95rwKgVblNG q7buBAOWWbroeGglP3asVuANRnEB1LfbQ/z7He41Lbh3KNSHhEh0MEjcvNO4Fy9wLJqJ ApgIS68RMVN/F46q37T4y5hFG6UX8X3004cMSJdWgFVDcUQK7QQl9me700e7kajmH5HS 0BGuvBC+LdMqheGZnQgjsUU51cqoL1fYtMmClUw0Agw/xJbcdqHCeVi/QLmQz846FUja binbgAYTBTUCeQW9hMNH06nzgqMnFT/4lq4G4e/y8SO+5qbmkOivJ+wmMzKTxMvSQKlI xTkg== X-Gm-Message-State: APzg51BS634GtJ3AJgFVY53WhJ6pRQD2s5IiW/OYzYkOjfCNQ7QxWHVh xyrxeZMF1Zj4Ft5h3pYFrUEqo2I= X-Received: by 2002:aca:d9c5:: with SMTP id q188-v6mr3966425oig.239.1535655150823; Thu, 30 Aug 2018 11:52:30 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j125-v6sm5587426oih.53.2018.08.30.11.52.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:52:30 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Frank Rowand Subject: [PATCH] of: Add device_type access helper functions Date: Thu, 30 Aug 2018 13:52:29 -0500 Message-Id: <20180830185229.20393-1-robh@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In preparation to remove direct access to device_node.type, add of_node_is_type() and of_node_get_device_type() helpers to check and retrieve the device type. Cc: Frank Rowand Signed-off-by: Rob Herring --- include/linux/of.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.17.1 diff --git a/include/linux/of.h b/include/linux/of.h index a40f63a36afa..506beca9588d 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -980,6 +980,18 @@ static inline struct device_node *of_find_matching_node( return of_find_matching_node_and_match(from, matches, NULL); } +static inline const char *of_node_get_device_type(const struct device_node *np) +{ + return of_get_property(np, "type", NULL); +} + +static inline bool of_node_is_type(const struct device_node *np, const char *type) +{ + const char *match = of_node_get_device_type(np); + + return np && match && type && !of_prop_cmp(match, type); +} + /** * of_property_count_u8_elems - Count the number of u8 elements in a property *