From patchwork Tue Nov 22 10:41:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 9440783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7040600BA for ; Tue, 22 Nov 2016 10:42:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B2ED284D5 for ; Tue, 22 Nov 2016 10:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FCE5284D9; Tue, 22 Nov 2016 10:42:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E874284D5 for ; Tue, 22 Nov 2016 10:42:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AAF536E2B3; Tue, 22 Nov 2016 10:42:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3F456E2AF for ; Tue, 22 Nov 2016 10:41:58 +0000 (UTC) Received: by mail-wm0-x236.google.com with SMTP id a197so17874201wmd.0 for ; Tue, 22 Nov 2016 02:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wZvjTy5CqD1+avP+y8uphKpTPmSfKih2rcPlbE6NUcA=; b=EPdbS+sCb5JStPZSEMcz/Ben7csw3QIY/+SnXz9lzUzKQWNrhrmbNGZeASRqNJ3EaD PpwLw3tmc7lcRUj2EnC4imuepDhF8bWwtAGvyE7CrOcIl+S9aPCXzpE4euVkZbaxxTP4 pGKFcfCewHRn+zDN/4u69zb2i7umNNcNF3g+9nyyxJXZ2lURMWL0kbHpiWsbP7vm0Iyf lcCFpqU3kbiTxvKl4VJ2ZL/y5JGzrwt/Fv8/0kajGLswcuKu1NiXT5VBpG35nCbzq0Q8 PzjIgrAgqwInuZW6eNdAqa0EsxxkzecL7wEkGv4Xrr/s/vGrqCv2sC+H0dw+RjXjxAeU fIAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wZvjTy5CqD1+avP+y8uphKpTPmSfKih2rcPlbE6NUcA=; b=DYrxzBYIHcDGM9RZdJBjPH38BntIkDqegVzzkQWSKNQTUTcKZB5raloJse6wsXKzRW GejGuyroiHJNBIoJ/xRIxP7mvNCsFwem3tpVHC8blUeEvMpEcK7uZ5wvbO6DI15EakYz wnoo7nv+VTBLSWOlLOcWvi9pvlnF1LM/oZgAd537K0e2SOHF2lHsgmxToUQbexawq5Pv ju6ceXM9GYMDQhsEYDv4Z2W28Txdmlv6dHHrKh6PhR6SfWOyw4P8/b/T4ns1orfd3Mh4 mlnfiDk56r4hAWEKYCnpprSBdLHxqsj3jGbRyWOCjs76OGrp2aFKLyyzeLFiso2pnzkI XGRQ== X-Gm-Message-State: AKaTC006+wD15p82ozqhc3qYpRgaVZGDQE9aOzUPAgHeMq8pyRFUOAqe7+BRrdfYf5aqpAoy X-Received: by 10.28.69.217 with SMTP id l86mr1611473wmi.129.1479811317299; Tue, 22 Nov 2016 02:41:57 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id u81sm2228926wmu.10.2016.11.22.02.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 02:41:56 -0800 (PST) From: Bartosz Golaszewski To: Kevin Hilman , Michael Turquette , Sekhar Nori , Rob Herring , Frank Rowand , Mark Rutland , Peter Ujfalusi , Russell King Subject: [PATCH 1/3] of: base: add support to get machine compatible string Date: Tue, 22 Nov 2016 11:41:49 +0100 Message-Id: <1479811311-3080-2-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1479811311-3080-1-git-send-email-bgolaszewski@baylibre.com> References: <1479811311-3080-1-git-send-email-bgolaszewski@baylibre.com> Cc: linux-devicetree , LKML , linux-drm , Bartosz Golaszewski , Tomi Valkeinen , Jyri Sarha , Sudeep Holla , Robin Murphy , arm-soc , Laurent Pinchart X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a function allowing to retrieve the compatible string of the root node of the device tree. Signed-off-by: Bartosz Golaszewski --- drivers/of/base.c | 22 ++++++++++++++++++++++ include/linux/of.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index a0bccb5..bbfe5e9 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -546,6 +546,28 @@ int of_machine_is_compatible(const char *compat) EXPORT_SYMBOL(of_machine_is_compatible); /** + * of_machine_get_compatible - Get the compatible property of the root node + * + * Returns a NULL-terminated string containing the compatible if it could + * be found, NULL otherwise. + */ +const char *of_machine_get_compatible(void) +{ + struct device_node *root; + const char *compatible; + int ret = -1; + + root = of_find_node_by_path("/"); + if (root) { + ret = of_property_read_string(root, "compatible", &compatible); + of_node_put(root); + } + + return ret ? NULL : compatible; +} +EXPORT_SYMBOL(of_machine_get_compatible); + +/** * __of_device_is_available - check if a device is available for use * * @device: Node to check for availability, with locks already held diff --git a/include/linux/of.h b/include/linux/of.h index 299aeb1..664b734 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -367,6 +367,7 @@ extern int of_alias_get_id(struct device_node *np, const char *stem); extern int of_alias_get_highest_id(const char *stem); extern int of_machine_is_compatible(const char *compat); +extern const char *of_machine_get_compatible(void); extern int of_add_property(struct device_node *np, struct property *prop); extern int of_remove_property(struct device_node *np, struct property *prop); @@ -788,6 +789,11 @@ static inline int of_machine_is_compatible(const char *compat) return 0; } +static inline const char *of_machine_get_compatible(void) +{ + return NULL; +} + static inline bool of_console_check(const struct device_node *dn, const char *name, int index) { return false;