Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932288AbaLBO2P (ORCPT ); Tue, 2 Dec 2014 09:28:15 -0500 Received: from mail-ig0-f169.google.com ([209.85.213.169]:50249 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932228AbaLBO2N (ORCPT ); Tue, 2 Dec 2014 09:28:13 -0500 MIME-Version: 1.0 In-Reply-To: References: <1416527684-19017-1-git-send-email-bparrot@ti.com> <1416527684-19017-2-git-send-email-bparrot@ti.com> <20141202002244.GB24551@ti.com> Date: Tue, 2 Dec 2014 15:28:11 +0100 Message-ID: Subject: Re: [Patch v2 1/2] gpio: add GPIO hogging mechanism From: Linus Walleij To: Alexandre Courbot Cc: Benoit Parrot , Pantelis Antoniou , Jiri Prchal , Maxime Ripard , "linux-gpio@vger.kernel.org" , Linux Kernel Mailing List , "devicetree@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 2, 2014 at 3:10 PM, Alexandre Courbot wrote: > On Tue, Dec 2, 2014 at 9:22 AM, Benoit Parrot wrote: >>> > + } >>> > + >>> > + if (tmp > MAX_PHANDLE_ARGS) { >>> > + desc = ERR_PTR(-EINVAL); >>> > + goto out; >>> > + } >>> > + >>> > + gg_data.gpiospec.args_count = tmp; >>> > + gg_data.gpiospec.np = chip_np; >>> > + for (i = 0; i < tmp; i++) { >>> > + ret = of_property_read_u32(np, "gpios", >>> > + &gg_data.gpiospec.args[i]); >>> > + if (ret) { >>> > + desc = ERR_PTR(ret); >>> > + goto out; >>> > + } >>> > + } >>> > + >>> > + gpiochip_find(&gg_data, of_gpiochip_find_and_xlate); >>> >>> This seems to work but only supports one GPIO per hog node. It would >>> be nice to be able to specify several GPIOs to which the same settings >>> need to be applied. >> >> This is on purpose following Linus Walleij's comment. > > Could you point me to his comment? My bad for not remembering what he > said, but I'd like to understand why. Said in previous message I think: either one-per-node or lists directly in the gpiochip node. >>> Using this function means that a GPIO chip module cannot be unloaded >>> if it uses GPIO hogs. Is it the intended behavior? If not, please use >>> gpiochip_request_own_desc() instead, and make sure to call >>> gpiochip_free_own_desc() for each hog when the driver is unloaded. >> >> So I guess we could add a undo_gpio_hog() function and hook it up under of_gpiochip_remove(). >> Now instead of maintaining a seperate structure just to keep track of hogged descriptor, >> would it be acceptable to add a new "gpio_desc.flags" value in gpiolib.h says: >> >> #define FLAG_GPIO_IS_HOGGED 10 >> >> And key on that at removal time instead of creating a list and having to maintain that? > > Definitely, that would be even better I think. Clever. Go for this. >>> I would suggest to factorize this code that is similar to the one >>> found in __gpiod_get_index(). Do all the DT parsing in a function that >>> just returns a descriptor and the >> >> I would tend to agree. >> But as Linus suggested I was trying to contain the changes to gpiolib_of.c only. > > If we add a FLAG_GPIO_IS_HOGGED and undo the hogs when the chip is > unloaded, I would say that this becomes a gpiolib feature. Moving it > here would also allow non-DT GPIO providers to implement hogs (it > should be particularly easy to implement for platform data). Linus, do > you agree? Yes, this is better and leaves the door open for other users. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/