From patchwork Tue Dec 2 04:32:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunlei He X-Patchwork-Id: 416689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B649B1402A7 for ; Tue, 2 Dec 2014 15:33:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754189AbaLBEd6 (ORCPT ); Mon, 1 Dec 2014 23:33:58 -0500 Received: from [119.145.14.66] ([119.145.14.66]:11986 "EHLO szxga03-in.huawei.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754158AbaLBEd5 (ORCPT ); Mon, 1 Dec 2014 23:33:57 -0500 Received: from 172.24.2.119 (EHLO szxeml460-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AYA69549; Tue, 02 Dec 2014 12:33:20 +0800 (CST) Received: from localhost (10.111.64.99) by szxeml460-hub.china.huawei.com (10.82.67.203) with Microsoft SMTP Server id 14.3.158.1; Tue, 2 Dec 2014 12:33:11 +0800 From: Yunlei He To: , , CC: , , , Yunlei He , Xinwei Kong Subject: [PATCH 1/2] gpio: pl061: hook request if gpio-ranges avaiable Date: Tue, 2 Dec 2014 12:32:59 +0800 Message-ID: <1417494780-3704-2-git-send-email-heyunlei@huawei.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1417494780-3704-1-git-send-email-heyunlei@huawei.com> References: <1417494780-3704-1-git-send-email-heyunlei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.111.64.99] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A02020A.547D4110.015E, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: cd8e8293a911148301632d34a9d4c3c2 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Gpio-ranges property is useful to represent which GPIOs correspond to which pins on which pin controllers. But there may be some gpios without pinctrl operation. So check whether gpio-ranges property exists in device node first. Signed-off-by: Yunlei He Signed-off-by: Xinwei Kong Signed-off-by: Haojian Zhuang --- drivers/gpio/gpio-pl061.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 84b49cf..15d1885 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -52,28 +52,34 @@ struct pl061_gpio { void __iomem *base; struct gpio_chip gc; + bool uses_pinctrl; #ifdef CONFIG_PM struct pl061_context_save_regs csave_regs; #endif }; -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset) +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset) { /* * Map back to global GPIO space and request muxing, the direction * parameter does not matter for this controller. */ - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - return pinctrl_request_gpio(gpio); + if (chip->uses_pinctrl) + return pinctrl_request_gpio(gpio); + return 0; } -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset) +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset) { - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - pinctrl_free_gpio(gpio); + if (chip->uses_pinctrl) + pinctrl_free_gpio(gpio); } static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) @@ -263,6 +269,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR(chip->base); spin_lock_init(&chip->lock); + if (of_property_read_bool(dev->of_node, "gpio-ranges")) + chip->uses_pinctrl = true; chip->gc.request = pl061_gpio_request; chip->gc.free = pl061_gpio_free;