From patchwork Wed Jul 1 09:40:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6702011 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2509A9F2F0 for ; Wed, 1 Jul 2015 09:42:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5241420458 for ; Wed, 1 Jul 2015 09:42:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E42E0202E5 for ; Wed, 1 Jul 2015 09:42:55 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0F6B42606BC; Wed, 1 Jul 2015 11:42:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1151726065A; Wed, 1 Jul 2015 11:42:44 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id AD63D260654; Wed, 1 Jul 2015 11:42:42 +0200 (CEST) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by alsa0.perex.cz (Postfix) with ESMTP id 4917D260627 for ; Wed, 1 Jul 2015 11:42:36 +0200 (CEST) Received: by wiwl6 with SMTP id l6so159011445wiw.0 for ; Wed, 01 Jul 2015 02:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jWL0LpCirlo+C8PPm8MolQrXIxjULHGkv/FhaE+jPaU=; b=QmA9LKX8CdVPHcbYq7l6yr7EC4gjwxOWNCPxlNQ/KAhzhAZ7LVOyPD0njJI0Hnvpk1 4jVkISuy1/giR/fAC0kfiOuEl94ifwy/YlW+qe3vwTl3RllPX+dusW8oyNzgaCPOdYdx vLhqBwSqq+IipybSLHgp+9B12Qol3wyzWknVZ8cJIZXJf98T1gN+MLdSfuNO/JmG9VVh zihiqruf/R2+X4bLjxTK0PEF9kxkBel1Nq6n3ggfFU7zmCIWkfJWJC2eiqFmVWd4K+Fh SMHREF613DOm/Pmb5+oVGMHWvtUDW5lzuqd9RlcYlkX42F82CCj7IH2fL7omtS87G1Yn TpRA== X-Received: by 10.194.178.201 with SMTP id da9mr4457309wjc.139.1435743756081; Wed, 01 Jul 2015 02:42:36 -0700 (PDT) Received: from cizrna.lan ([109.72.12.160]) by mx.google.com with ESMTPSA id x10sm1992663wjr.25.2015.07.01.02.42.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2015 02:42:34 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Date: Wed, 1 Jul 2015 11:40:59 +0200 Message-Id: <1435743667-11987-5-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1435743667-11987-1-git-send-email-tomeu.vizoso@collabora.com> References: <1435743667-11987-1-git-send-email-tomeu.vizoso@collabora.com> Cc: devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, Tomeu Vizoso , linux-gpio@vger.kernel.org, Linus Walleij , "Rafael J. Wysocki" , alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, Mark Brown , linux-pwm@vger.kernel.org, Alexandre Courbot Subject: [alsa-devel] [PATCH v2 04/12] gpio: register dependency parser for firmware nodes X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP So the GPIO subsystem can be queried about the dependencies of nodes that consume GPIOs, as specified in bindings/gpio/gpio.txt. Signed-off-by: Tomeu Vizoso --- Changes in v2: None drivers/gpio/gpiolib.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bf4bd1d..6a3e83f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2388,4 +2388,58 @@ static int __init gpiolib_debugfs_init(void) } subsys_initcall(gpiolib_debugfs_init); +static void gpio_get_dependencies(struct fwnode_handle *fwnode, + struct list_head *deps) +{ + struct device_node *np; + struct property *pp; + struct of_phandle_args pspec; + int count, i, ret; + + np = to_of_node(fwnode); + if (!np) + return; + + for_each_property_of_node(np, pp) { + if (strcmp(pp->name, "gpio") && + strcmp(pp->name, "gpios") && + !strends(pp->name, "-gpios") && + !strends(pp->name, "-gpio")) + continue; + + count = of_count_phandle_with_args(np, pp->name, + "#gpio-cells"); + for (i = 0; i < count; i++) { + ret = of_parse_phandle_with_args(np, pp->name, + "#gpio-cells", i, + &pspec); + if (ret || !pspec.np) + continue; + + fwnode_add_dependency(&pspec.np->fwnode, deps); + + of_node_put(pspec.np); + } + } + + for (i = 0;; i++) { + ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, + i, &pspec); + if (ret) + break; + + fwnode_add_dependency(&pspec.np->fwnode, deps); + + of_node_put(pspec.np); + } +} + +static int __init gpiolib_init(void) +{ + fwnode_add_dependency_parser(gpio_get_dependencies); + + return 0; +} +device_initcall(gpiolib_init); + #endif /* DEBUG_FS */