From patchwork Tue Feb 19 16:22:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 2163631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id E4937DF24C for ; Tue, 19 Feb 2013 16:28:19 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U7q0s-0005f1-P4; Tue, 19 Feb 2013 16:25:50 +0000 Received: from mail-pb0-f53.google.com ([209.85.160.53]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U7pyd-0004GC-78 for linux-arm-kernel@lists.infradead.org; Tue, 19 Feb 2013 16:23:32 +0000 Received: by mail-pb0-f53.google.com with SMTP id un1so2318464pbc.26 for ; Tue, 19 Feb 2013 08:23:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=WsWzUwmblRaSMvcixpcuV7s/Sqo9LpdcUmjqIgOq/5U=; b=ja0Htk1Nu0bP1F/HMPWXgY7ezfgXJVZ1WrTg+8xkS1Okp5snAb5mZwXf4GSjRGPjf+ TH+I8U1lHggrAHmw2rQUN/CxoygH3ZBzEMrYfjpkdRxQk0kbpDAquzrwuK+jdZlEYsB6 xuoIQFLVMy5+43m7oHXx0otJR7I6Mh/RpR8FMo1TlsXNkmjGcm34Gp4EReI4cUgm7XdT oodVCXIwu9iFi2HQLtya5DQVwBfghq61ehi66A91Lxuusc7UiWNvaMJ3sV3yR7lA5QWg ogSboJ9lYbcLH+rmGW62wT8t2bySph2n/kxNbfloR7TgeT8DMJaUmwe+suyPqidqu7ri jF2A== X-Received: by 10.66.73.165 with SMTP id m5mr46789916pav.78.1361291010243; Tue, 19 Feb 2013 08:23:30 -0800 (PST) Received: from localhost.localdomain ([27.115.121.39]) by mx.google.com with ESMTPS id rn14sm18472714pbb.33.2013.02.19.08.23.25 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 08:23:29 -0800 (PST) From: Haojian Zhuang To: grinberg@compulab.co.il, linus.walleij@linaro.org, linux@arm.linux.org.uk, marek.vasut@gmail.com, robert.jarzmik@free.fr, daniel@caiaq.de, linux-arm-kernel@lists.infradead.org, grant.likely@secretlab.ca, cxie4@marvell.com Subject: [PATCH v4 09/11] gpio: pxa: move gpio properties into child node Date: Wed, 20 Feb 2013 00:22:26 +0800 Message-Id: <1361290948-16669-10-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361290948-16669-1-git-send-email-haojian.zhuang@linaro.org> References: <1361290948-16669-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQlK5VbdssewxQSYcM2a/+QY5doUNztRMQeeClS4zupgV1UEA9RodkRFTZ+dykDEfyDTXbPz X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130219_112331_370046_2D91C4F6 X-CRM114-Status: GOOD ( 14.85 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.53 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Haojian Zhuang , patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Move gpio properties into child node. So pinctrl driver could binds to each gpio chip with gpio range. Signed-off-by: Haojian Zhuang Tested-by: Igor Grinberg --- drivers/gpio/gpio-pxa.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 983758f..0f3a350 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -65,7 +65,6 @@ static int irq_base; #ifdef CONFIG_OF static struct irq_domain *domain; -static struct device_node *pxa_gpio_of_node; #endif struct pxa_gpio_chip { @@ -233,8 +232,9 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc, static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end) { int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1; - struct pxa_gpio_chip *chips; struct pxa_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct pxa_gpio_chip *chips; + struct device_node *next = NULL, *np = NULL; chips = devm_kzalloc(&pdev->dev, nbanks * sizeof(*chips), GFP_KERNEL); if (!chips) { @@ -242,6 +242,11 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end) return -ENOMEM; } + np = pdev->dev.of_node; +#ifdef CONFIG_OF + if (np) + next = of_get_next_child(np, NULL); +#endif for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) { struct gpio_chip *gc = &chips[i].gc; @@ -258,16 +263,21 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end) gc->get = pxa_gpio_get; gc->set = pxa_gpio_set; gc->to_irq = pxa_gpio_to_irq; -#ifdef CONFIG_OF_GPIO - gc->of_node = pxa_gpio_of_node; - gc->of_xlate = pxa_gpio_of_xlate; - gc->of_gpio_n_cells = 2; +#ifdef CONFIG_OF + if (np) { + gc->of_node = next; + next = of_get_next_child(np, next); + + gc->of_xlate = pxa_gpio_of_xlate; + gc->of_gpio_n_cells = 2; + } #endif /* number of GPIOs on last bank may be less than 32 */ gc->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32; gpiochip_add(gc); } + of_node_put(next); pxa_gpio_chips = chips; return 0; } @@ -436,9 +446,9 @@ const struct irq_domain_ops pxa_irq_domain_ops = { static int pxa_gpio_probe_dt(struct platform_device *pdev) { - int ret, nr_banks; + int ret; struct pxa_gpio_platform_data *pdata; - struct device_node *prev, *next, *np = pdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(pxa_gpio_dt_ids, &pdev->dev); @@ -460,32 +470,16 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) return -ENOTSUPP; } - next = of_get_next_child(np, NULL); - prev = next; - if (!next) { - dev_err(&pdev->dev, "Failed to find child gpio node\n"); - ret = -EINVAL; - goto err; - } - for (nr_banks = 1; ; nr_banks++) { - next = of_get_next_child(np, prev); - if (!next) - break; - prev = next; - } - of_node_put(prev); - irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0); if (irq_base < 0) { dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); - goto err; + return -EINVAL; } pdata->irq_base = irq_base; /* set the platform data */ pdev->dev.platform_data = pdata; domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, &pxa_irq_domain_ops, NULL); - pxa_gpio_of_node = np; return 0; } #else