Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752217AbdC0I5u (ORCPT ); Mon, 27 Mar 2017 04:57:50 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:35375 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752041AbdC0I5h (ORCPT ); Mon, 27 Mar 2017 04:57:37 -0400 MIME-Version: 1.0 In-Reply-To: <913cf9807c7c351bb7dabac9b3336431dac060e5.1490120798.git-series.gregory.clement@free-electrons.com> References: <913cf9807c7c351bb7dabac9b3336431dac060e5.1490120798.git-series.gregory.clement@free-electrons.com> From: Linus Walleij Date: Mon, 27 Mar 2017 10:57:15 +0200 Message-ID: Subject: Re: [PATCH v2 4/7] pinctrl: armada-37xx: Add gpio support To: Gregory CLEMENT Cc: "linux-gpio@vger.kernel.org" , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Thomas Petazzoni , "linux-arm-kernel@lists.infradead.org" , Rob Herring , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Nadav Haklai , Victor Gu , Marcin Wojtas , Wilson Ding , Hua Jing , Neta Zur Hershkovits Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1545 Lines: 50 On Tue, Mar 21, 2017 at 7:28 PM, Gregory CLEMENT wrote: You should add something to your Kconfig including: select GPIOLIB select OF_GPIO or so... or depends on. You certainly need them. > +static int armada_37xx_gpiochip_register(struct platform_device *pdev, > + struct armada_37xx_pinctrl *info) > +{ > + struct device_node *np; > + struct gpio_chip *gc; > + int ret = -ENODEV; > + > + for_each_child_of_node(info->dev->of_node, np) { > + if (of_find_property(np, "gpio-controller", NULL)) { > + ret = 0; > + break; > + } > + }; OK so several GPIO chips as subnodes, why not one device per chip? Or have we discussed this before? It seems a bit weird, apparently there is just one node with a gpio-controller, as you're just adding one pin range. What happens if there would be two gpio-controllers? The second is just ignored without error? > + ret = gpiochip_add_data(gc, info); > + if (ret) > + return ret; Can't you use devm_gpiochip_add_data()? > + ret = gpiochip_add_pin_range(&info->gpio_chip, dev_name(dev), 0, > + pinbase, info->data->nr_pins); > + if (ret) > + return ret; Why can't you put the range(s) into the device tree? We already have code in drivers/gpio/gpiolib-of.c to do this for you. And generic range definition bindings. Yours, Linus Walleij