From patchwork Mon Feb 25 03:49:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 2180091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 5CDB23FCA4 for ; Mon, 25 Feb 2013 03:57:22 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U9p8z-0004vq-AY; Mon, 25 Feb 2013 03:54:25 +0000 Received: from mail-pa0-f47.google.com ([209.85.220.47]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U9p6Q-0003O9-SS for linux-arm-kernel@lists.infradead.org; Mon, 25 Feb 2013 03:51:48 +0000 Received: by mail-pa0-f47.google.com with SMTP id bj3so1490262pad.6 for ; Sun, 24 Feb 2013 19:51:45 -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=PQMaYluDSvRrEOhjXko5JCuXETB95dElQbgRSNheNbo=; b=YTKkeoULAwWf14A22VyZAfiS9DAC2dPf/mUYH24Kr/BZ/RaVhoSSnHf1rHu+y7u2AM pMVFpg6mFOzDgAVldIohsmlhGDXQ6MGKnF8fLA/A6yqHTisJxH1/oVh3KpyHOyOpplag xj9NC0HhyH+WSA+tc6ERdijglnpc63jHqQiDBK8b2zdciFub7l64+pTP9nBvgq/W+RWv J90vyD4i4sVbsMt2pD/ludN6YQawDg+YDh6oypzWhSkRBgFIPeEbi6O90TzHvdAI8hOn 6FZPy5nmE1K8I/TdkilXblYR9jF6stzUzibuYAycDVMerp2tYc56+fkIiKr3MTjMc/NR faUQ== X-Received: by 10.66.122.74 with SMTP id lq10mr16718427pab.189.1361764305327; Sun, 24 Feb 2013 19:51:45 -0800 (PST) Received: from localhost.localdomain ([67.198.145.34]) by mx.google.com with ESMTPS id b9sm11188695pba.6.2013.02.24.19.51.40 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Feb 2013 19:51:44 -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 v5 10/12] gpio: pxa: move gpio properties into child node Date: Mon, 25 Feb 2013 11:49:39 +0800 Message-Id: <1361764181-26647-11-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361764181-26647-1-git-send-email-haojian.zhuang@linaro.org> References: <1361764181-26647-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQmPTMcCcgfQsuZX3XN3BuzJcYBcVSzKOMmRgPETsYqOoMEyufKYhUuNBCmZxUMVrcrTikZb X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130224_225147_025960_20F85497 X-CRM114-Status: GOOD ( 15.75 ) 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.220.47 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 | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index f5f78ea..91f4881 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); @@ -458,20 +468,6 @@ 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"); - return -EINVAL; - } - 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, pdata->nr_gpios, 0); if (irq_base < 0) { dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); @@ -482,7 +478,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) pdev->dev.platform_data = pdata; domain = irq_domain_add_legacy(np, pdata->nr_gpios, irq_base, 0, &pxa_irq_domain_ops, NULL); - pxa_gpio_of_node = np; return 0; } #else