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: 14441 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F17DE23F94 for ; Sun, 3 Feb 2013 10:18:14 +0000 (UTC) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9712AA19678 for ; Sun, 3 Feb 2013 10:18:14 +0000 (UTC) Received: by mail-vb0-f52.google.com with SMTP id fa15so3332163vbb.11 for ; Sun, 03 Feb 2013 02:18:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=BVMxPTYnBUbMV5wd5izVaOHXMwAIBrSRZn5qhVnSpBc=; b=PPpyYJjBkEJxeIa26CXcA9ATAIaOuuWf8CCyCcKsld3gaDZ9x3csfCifLuGOzcivOI KJikPnG8BufQV22RpulxtE0Yeu2r1DuOhpr9Y7EC3xpFIMKrE/Zyr3T4swz1johjLMJe ys6HxdyFDoTjWpYxFOvR/FO2bIvflGcdFmsT3S2c3DzSnc9oqWkmjtzWPmUJdCfHiRbH 6YMSd6epgmvUHV+cPBWTfMAx8L3dVU4gnp7ZGl8kT+QQlH0YfYBh8Xzw37vOTxqwST0h 9JCd3mYjMABsjmMntppBxoM/by34dDjXbHZQ3G/45duZmmGcw+Z49/mBbRMAhUw/OB4E SZtg== X-Received: by 10.58.8.82 with SMTP id p18mr13295788vea.54.1359886694077; Sun, 03 Feb 2013 02:18:14 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp40415vec; Sun, 3 Feb 2013 02:18:13 -0800 (PST) X-Received: by 10.66.9.2 with SMTP id v2mr43194490paa.18.1359886693270; Sun, 03 Feb 2013 02:18:13 -0800 (PST) Received: from mail-da0-f46.google.com (mail-da0-f46.google.com [209.85.210.46]) by mx.google.com with ESMTPS id ax9si12801916pbd.274.2013.02.03.02.18.12 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 03 Feb 2013 02:18:13 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.46 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.210.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.46 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) smtp.mail=haojian.zhuang@linaro.org Received: by mail-da0-f46.google.com with SMTP id p5so2273777dak.5 for ; Sun, 03 Feb 2013 02:18:12 -0800 (PST) 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 Cc: patches@linaro.org, Haojian Zhuang 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: ALoCoQmvaRau5L6fYUHJslK4wpWdRX5CuKmW9cVDzlT4b8beWy5ogZkORVacfWZZBud1TtTDPYPr 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; }