From patchwork Wed Jul 1 07:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1320299 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=jjGc2Fb5; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49xY9n74wZz9sTZ for ; Wed, 1 Jul 2020 17:43:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728327AbgGAHnF (ORCPT ); Wed, 1 Jul 2020 03:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727836AbgGAHnD (ORCPT ); Wed, 1 Jul 2020 03:43:03 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1F6C061755; Wed, 1 Jul 2020 00:43:03 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id s16so7565299lfp.12; Wed, 01 Jul 2020 00:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vhza9ZHeiMaCPs/6QRV0zm5dqFctu0tGjnrB9xohpRY=; b=jjGc2Fb5f5oGDiIof5sN1xI+8DKa0bOXujnT3GO1Br5PDOxSM+kEYWhbWtKT5KjtLH fnuP0+B6s6RWxdH8fetIqJQVdQszj3Kfa2RgnE8R4LUfey9OsKPmnZEFR3yWv2EieCT/ WOnNnkbm+BfX4PlRgD886yD+mYts7JB/RQ0IxOe+r5++BznYspBgwtwGsEZ22TwBjdGu SdrqTH8eYsF5uFcscqmUvLAtf/x6yRe/9JD2PV7HMfo8BM0dfcw0NyUG/E38vWaD30SE Ox5oDna49wLaCwhpIpI1Jchp6ghjDWUxnTB/ZA8SeKl37pnCrXRIOKqakZK/wm85GiNh YpIw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vhza9ZHeiMaCPs/6QRV0zm5dqFctu0tGjnrB9xohpRY=; b=G1DTASZS2wWi1PKuG6B57aTKAAty4zbOGyxqciyhBU7XQ+zjGUgNd3SfvGNc8K8C/z +jKVXQWp1B+KqCt037Abs+FOwYk8a3yFy4c7SqsY9UAdOM1OVoZU+K7lOYyUv0J5hWoy iUa8pDh/HbPJPQOonqSHxMgCl/77/Lq9UBHR4jHWzZvvaY6qIqdYFUwgVtsGp8n9ci3c n2JBf1cNwVxOeEhFgRyl2+NiD2UWiHmdLi1dUazbi+GBw0/qfqS0FBqVXKxB/AGzxN1E pbYCpZ6eRCGfViVqj3jj1v72ourVtVyeJlysqpyOdTF6qjKwQI/h5/k7uLFofucPStKq CADw== X-Gm-Message-State: AOAM531HcuCy+I0TXRwzWM9uwh4IJfrqe/P1Q04hKSXidtulkO3wBILb be4HTfFajWrQ822X/X4eHl4= X-Google-Smtp-Source: ABdhPJxzWdx03z6LDNSI0qZvHK4dIxS6mE6LKiwnMXFfZ5H2XLyjhSUJJvI3F4HorF2xTzpmLloM7g== X-Received: by 2002:ac2:44b2:: with SMTP id c18mr13714003lfm.99.1593589381631; Wed, 01 Jul 2020 00:43:01 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id e10sm1520881ljb.118.2020.07.01.00.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 00:43:00 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 1/2] of_graph: add of_graph_is_present() Date: Wed, 1 Jul 2020 10:42:31 +0300 Message-Id: <20200701074232.13632-2-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200701074232.13632-1-digetx@gmail.com> References: <20200701074232.13632-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org In some cases it's very useful to silently check whether port node exists at all in a device-tree before proceeding with parsing the graph. The DRM bridges code is one example of such case where absence of a graph in a device-tree is a legit condition. This patch adds of_graph_is_present() which returns true if given device-tree node contains OF graph port. Reviewed-by: Rob Herring Signed-off-by: Dmitry Osipenko Reviewed-by: Laurent Pinchart --- drivers/of/property.c | 23 +++++++++++++++++++++++ include/linux/of_graph.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index 6a5760f0d6cd..fed7229d9d9f 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -29,6 +29,29 @@ #include "of_private.h" +/** + * of_graph_is_present() - check graph's presence + * @node: pointer to device_node containing graph port + * + * Return: True if @node has a port or ports (with a port) sub-node, + * false otherwise. + */ +bool of_graph_is_present(const struct device_node *node) +{ + struct device_node *ports, *port; + + ports = of_get_child_by_name(node, "ports"); + if (ports) + node = ports; + + port = of_get_child_by_name(node, "port"); + of_node_put(ports); + of_node_put(port); + + return !!port; +} +EXPORT_SYMBOL(of_graph_is_present); + /** * of_property_count_elems_of_size - Count the number of elements in a property * diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index 01038a6aade0..4d7756087b6b 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -38,6 +38,7 @@ struct of_endpoint { child = of_graph_get_next_endpoint(parent, child)) #ifdef CONFIG_OF +bool of_graph_is_present(const struct device_node *node); int of_graph_parse_endpoint(const struct device_node *node, struct of_endpoint *endpoint); int of_graph_get_endpoint_count(const struct device_node *np); @@ -56,6 +57,11 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, u32 port, u32 endpoint); #else +static inline bool of_graph_is_present(const struct device_node *node) +{ + return false; +} + static inline int of_graph_parse_endpoint(const struct device_node *node, struct of_endpoint *endpoint) { From patchwork Wed Jul 1 07:42:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1320301 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=p2+CyBm3; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49xY9q2dQ1z9sTg for ; Wed, 1 Jul 2020 17:43:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728336AbgGAHnK (ORCPT ); Wed, 1 Jul 2020 03:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728322AbgGAHnF (ORCPT ); Wed, 1 Jul 2020 03:43:05 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58608C061755; Wed, 1 Jul 2020 00:43:04 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id t25so21186773lji.12; Wed, 01 Jul 2020 00:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vapTfDZ2f1tAvfpKmc+ZWDOZuBAyLK5G5gnKE1dsXng=; b=p2+CyBm3hryTHrZxURLXskWjQ/8tBPFEijkMuW7RW0ZeOWlUihpvWBa1f0/goGST4d /eeRaDMtMkY6I2Yx+CUMG1HaF9YPolELljK8KUxLZqnvpGxescuIgYoYrMsBENXKMnoN +DttfWVwAzh/o1j2XVIRrM8DxvRCnZAuO9a092SPAT4IztiLlF13xo+iHk1prupsrHi+ I2YLTgUM4mUfmsN+P66YuZb6qJc/dN7fZvl0DbCHQHJEq1RujEWdiZ+xRmn1/nbTGcco 8vdwMsb3m4SHR2tOaLylWAj9buhyOyS/jhoe7ZTXGZfFZ38GdmLpeWaZ4uiKw7RsqeyU BeMw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=vapTfDZ2f1tAvfpKmc+ZWDOZuBAyLK5G5gnKE1dsXng=; b=M1RgUuc1/xPaGXm6eVEsRa2BrYe/VmDjyew0U+uExWVyutbW7UerQ+OFx51CT5ztIw FYmRIFcCgZxFcJygnIUEbjDfLPdWwR1e1+LHipLhTKmeQE9sBNXw4SVglH75333BWSkJ ak/Ot+ToYVLBJFRDZYKBy5f/9wYa78M2yUqOTmSIKmgWmK89trAnEOQ1+sEMqkmYvjtE H2KAc75qf95M87o25NhQ3yPIVtgWcMjxIttXFOfwnkSMOaIaXga08ppdyOcZYZOBD/KJ z5+N++Pfb0PJyJnEB2ACelbYQ3tLafFzZ/fiqV/gYsGi53VmJygrG6mV2IbARMKvIhcR 8S7w== X-Gm-Message-State: AOAM530Qcy9H/ZhLjfDbfRIjzZOWJ2obf7FsFnxyMYnYw11WthmLBND1 ZJzVn5tQ2xrL4/LfMOrYBsg= X-Google-Smtp-Source: ABdhPJzQnoAy8VMG2guQ6rxw3JWQlodP3SToyfFNxeaRO3AZp9mee0BT7uQeSlEZTyyS++KM44v1lA== X-Received: by 2002:a05:651c:1057:: with SMTP id x23mr11651351ljm.116.1593589382903; Wed, 01 Jul 2020 00:43:02 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id e10sm1520881ljb.118.2020.07.01.00.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 00:43:02 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 2/2] drm/of: Make drm_of_find_panel_or_bridge() to check graph's presence Date: Wed, 1 Jul 2020 10:42:32 +0300 Message-Id: <20200701074232.13632-3-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200701074232.13632-1-digetx@gmail.com> References: <20200701074232.13632-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org When graph isn't defined in a device-tree, the of_graph_get_remote_node() prints a noisy error message, telling that port node is not found. This is undesirable behaviour in our case because absence of a panel/bridge graph is a valid case. Let's check the graph's presence in a device-tree before proceeding with parsing of the graph. Reviewed-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_of.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index b50b44e76279..fdb05fbf72a0 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -246,6 +246,15 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, if (panel) *panel = NULL; + /* + * of_graph_get_remote_node() produces a noisy error message if port + * node isn't found and the absence of the port is a legit case here, + * so at first we silently check whether graph presents in the + * device-tree node. + */ + if (!of_graph_is_present(np)) + return -ENODEV; + remote = of_graph_get_remote_node(np, port, endpoint); if (!remote) return -ENODEV;