lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1299467241.11719.145.camel@ptyser-laptop>
Date:	Sun, 06 Mar 2011 21:07:21 -0600
From:	Peter Tyser <ptyser@...-inc.com>
To:	Grant Likely <grant.likely@...retlab.ca>
Cc:	linux-kernel@...r.kernel.org, Alek Du <alek.du@...el.com>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	Eric Miao <eric.y.miao@...il.com>,
	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>,
	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	Joe Perches <joe@...ches.com>,
	Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [PATCH v5 2/4] gpiolib: Add ability to get GPIO direction

On Sun, 2011-03-06 at 00:30 -0700, Grant Likely wrote:
> On Tue, Mar 01, 2011 at 05:28:18PM -0600, Peter Tyser wrote:
> > Add a new get_direction() function to the gpio_chip structure.  This is
> > useful so that the direction of a GPIO can be determined when its
> > initially exported.  Previously, the direction defaulted to "unknown"
> > regardless of the actual configuration of the GPIO.
> > 
> > If a GPIO driver implements get_direction(), it is called in
> > gpio_request() to set the initial direction of the GPIO accurately.
> 
> I don't like this approach.  It effectively creates two methods for
> determining the direction of a gpio; either ask the driver, or read
> the flags value.  Currently, only gpio_request() actually uses the
> first option, but it still leaves the ambiguity.
> 
> Instead, the driver should be able to preload the direction flag at or
> shortly after gpiochip_add() time.  No need for a new callback hook
> from what I can see.

The callback hook was used because the gpio_desc[] structure was local
to gpiolib.c.  The code would have to be restructured a bit to allow
drivers to set the flags themselves.  I can do that if you'd prefer, but
don't think it'd be all that much cleaner.

Also, I thought it made sense to read the direction of the GPIO in
gpio_request() because that's the point that the GPIO comes under the
GPIO subsystem's control.  Prior to that, there's a chance the direction
could be changed by platform code, or another driver, etc, so reading
the direction in gpiochip_add() may result in out-of-date directions.

The reading of the direction could also be put in chip drivers'
request() function.  That would get rid of the callback and still ensure
the direction is up-to-date.

I think the current patch seems cleaner than the alternatives, but will
change if you'd prefer.

Best,
Peter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ