From patchwork Sun Feb 3 10:15:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 2086131 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 9545D3FCA4 for ; Sun, 3 Feb 2013 10:21:17 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U1wf1-0005oi-8o; Sun, 03 Feb 2013 10:18:55 +0000 Received: from mail-da0-f45.google.com ([209.85.210.45]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U1weL-0005DB-NS for linux-arm-kernel@lists.infradead.org; Sun, 03 Feb 2013 10:18:14 +0000 Received: by mail-da0-f45.google.com with SMTP id w4so2266800dam.4 for ; Sun, 03 Feb 2013 02:18:12 -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=BVMxPTYnBUbMV5wd5izVaOHXMwAIBrSRZn5qhVnSpBc=; b=kiyQLtrL+gRKjMbN030ZEg0d4xiNO5DdhnkHaM5YOuwG/y+qDxCWExRhlmT6Cwx43m 5PSb1iIn9ompuBB0auB15SfDubDG2gaEfET8VE8d8iT2uHndnW9rjvdgt0BmEGzmsSps yajIbMm+nl0p2IP6qg0irnm1RLoMTEnlTGwW8qMN+V1hl0BOlxkyHNzZR1lo1Q23jIUb qkAqPzF/lZVy6WpF41Ez3SLj9QW43nFrU4PmXtNDQPkMFWRfGNbrpJs9+1IQTM3urg2w gBkHrK3bkARNE9j6eyt0ruHXlVPeBc05OOXKpVTHky9U4cX280+fQuPQ6NRT3se3Q5SJ eMbg== X-Received: by 10.68.233.99 with SMTP id tv3mr46125679pbc.64.1359886692836; Sun, 03 Feb 2013 02:18:12 -0800 (PST) Received: from haojian-E6230.domain ([67.198.145.34]) by mx.google.com with ESMTPS id ov4sm14344348pbb.45.2013.02.03.02.18.01 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 03 Feb 2013 02:18:12 -0800 (PST) From: Haojian Zhuang To: linux@arm.linux.org.uk, marek.vasut@gmail.com, robert.jarzmik@free.fr, daniel@caiaq.de, linux-arm-kernel@lists.infradead.org, linus.walleij@linaro.org, grant.likely@secretlab.ca, cxie4@marvell.com, grinberg@compulab.co.il Subject: [PATCH v2 08/10] gpio: pxa: move gpio properties into child node Date: Sun, 3 Feb 2013 18:15:49 +0800 Message-Id: <1359886551-20950-9-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359886551-20950-1-git-send-email-haojian.zhuang@linaro.org> References: <1359886551-20950-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQmPEUe5+24wXnVXxsQ9QSTo2bdayFapIZoDdkyaYpQ2fJEEZbm6ZnKNzx/eObx2XLbM23Mp X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130203_051813_868745_BEBBB9CF X-CRM114-Status: GOOD ( 13.30 ) 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.210.45 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 --- drivers/gpio/gpio-pxa.c | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 8130e3b..5c39db3 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -63,10 +63,6 @@ int pxa_last_gpio; -#ifdef CONFIG_OF -static struct device_node *pxa_gpio_of_node; -#endif - struct pxa_gpio_chip { struct gpio_chip chip; void __iomem *regbase; @@ -404,9 +400,9 @@ static struct of_device_id pxa_gpio_dt_ids[] = { 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); @@ -430,25 +426,7 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) /* set the platform data */ pdev->dev.platform_data = pdata; - 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); - return 0; -err: - iounmap(gpio_reg_base); - return ret; } #else #define pxa_gpio_probe_dt(pdev) (-1) @@ -459,6 +437,7 @@ 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 device_node *next = NULL, *np = NULL; chips = devm_kzalloc(&pdev->dev, nbanks * sizeof(*chips), GFP_KERNEL); if (chips == NULL) { @@ -466,6 +445,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].chip; @@ -492,13 +476,18 @@ 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 gpiochip_add(gc); } + of_node_put(next); pxa_gpio_chips = chips; return 0; }