Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762044AbcKDWU3 (ORCPT ); Fri, 4 Nov 2016 18:20:29 -0400 Received: from mail-qt0-f177.google.com ([209.85.216.177]:34448 "EHLO mail-qt0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753224AbcKDWU0 (ORCPT ); Fri, 4 Nov 2016 18:20:26 -0400 MIME-Version: 1.0 In-Reply-To: <1478089037-26441-1-git-send-email-ldewangan@nvidia.com> References: <1478089037-26441-1-git-send-email-ldewangan@nvidia.com> From: Linus Walleij Date: Fri, 4 Nov 2016 23:20:24 +0100 Message-ID: Subject: Re: [PATCH 1/1] gpio: lib: Add gpio_is_enabled() to get pin mode To: Laxman Dewangan Cc: Alexandre Courbot , Arnd Bergmann , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arch@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 Content-Length: 1700 Lines: 49 On Wed, Nov 2, 2016 at 1:17 PM, Laxman Dewangan wrote: > Many of devices/SoCs supports the GPIO and special IO function > from their pins. On such cases, there is always configuration > bits to select the mode of pin as GPIO or as the special IO mode. > The functional modes are selected by pinmux option. > > When device booted and reach to kernel, it is not possible to get > the current configuration of pin whether it is in GPIO mode or > in special IO mode without configurations. > > Add APIs to return the current mode of pins without requesting it > as GPIO to find out the current mode. > This helps on dumping the pin configuration from debug/test utility > to get the current mode GPIO or functional mode. > > The typical utility looks as: > pin_dump(pin) > { > if(gpio_is_enabled(pin)) { > dump direction using get_direction() > } else { > dump pinmux option and its configurations. > } > } Yeah but since pinctrl and pinmux has its own debugfs files why is this necessary? I understand it is convenient but only for debugging right? They the inconvenience of using pinctrls debugfs files should be bearable. Also it is possible for any GPIO chip to implement its own debug print if they like, check what we do in ->dbg_show in drivers/pinctrl/nomadik/pinctrl-nomadik.c for example. If the use is for debug prints, keep it driver-local. (...) > +static inline int gpio_is_enabled(unsigned gpio) > +{ > + return gpiod_is_enabled(gpio_to_desc(gpio)); > +} NAK why would be encourage the non-descriptor interface by adding to it? Better only offer this to the descriptor users. Yours, Linus Walleij