Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754924AbcJYE52 (ORCPT ); Tue, 25 Oct 2016 00:57:28 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:61981 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbcJYE51 (ORCPT ); Tue, 25 Oct 2016 00:57:27 -0400 To: Linus Walleij , CC: "linux-gpio@vger.kernel.org" , , , , , "linux-kernel@vger.kernel.org" From: Deepak Das Subject: [PATCH] gpio: mxc: Shift generic request/free after gpiochip registration Message-ID: <580EE62D.4090704@mentor.com> Date: Tue, 25 Oct 2016 10:27:17 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [137.202.0.87] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1846 Lines: 50 generic gpio request/free should be added after gpiocip registration to validate mapping of gpiochip with pinctrl subsystem. gpiochip->pin_ranges list contains the information used by pinctrl subsystem to configure corresponding pins for gpio usage. This list will be empty if gpiochip fails to map with pinctrl subsystem for any reason. For Ex.:- generic gpio request/free should not be used if IOMUX pin controller device node is disabled in device tree. This commit checks above list and skips adding generic gpio request/free if list is found empty. Signed-off-by: Deepak Das Signed-off-by: Vladimir Zapolskiy --- drivers/gpio/gpio-mxc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index c1a1e00..9f79a9f 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -458,11 +458,6 @@ static int mxc_gpio_probe(struct platform_device *pdev) if (err) goto out_bgio; - if (of_property_read_bool(np, "gpio-ranges")) { - port->gc.request = gpiochip_generic_request; - port->gc.free = gpiochip_generic_free; - } - port->gc.to_irq = mxc_gpio_to_irq; port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : pdev->id * 32; @@ -471,6 +466,11 @@ static int mxc_gpio_probe(struct platform_device *pdev) if (err) goto out_bgio; + if (!list_empty(&port->gc.pin_ranges)) { + port->gc.request = gpiochip_generic_request; + port->gc.free = gpiochip_generic_free; + } + irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id()); if (irq_base < 0) { err = irq_base; -- 1.9.1