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: <25715349.xM7UOyLcLb@vostro.rjw.lan>
Date:	Mon, 20 Oct 2014 01:58:57 +0200
From:	"Rafael J. Wysocki" <rjw@...ysocki.net>
To:	Arnd Bergmann <arnd@...db.de>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Grant Likely <grant.likely@...aro.org>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
	Aaron Lu <aaron.lu@...el.com>, devicetree@...r.kernel.org,
	Linus Walleij <linus.walleij@...aro.org>,
	Alexandre Courbot <gnurou@...il.com>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Bryan Wu <cooloney@...il.com>,
	Darren Hart <dvhart@...ux.intel.com>,
	Mark Rutland <mark.rutland@....com>
Subject: Re: [PATCH v5 10/12] gpio: Support for unified device properties interface

On Saturday, October 18, 2014 11:47:41 AM Arnd Bergmann wrote:
> On Friday 17 October 2014 20:09:51 Arnd Bergmann wrote:
> > On October 17, 2014 2:16:00 PM CEST, "Rafael J. Wysocki" <rjw@...ysocki.net> wrote:
> > >From: Mika Westerberg <mika.westerberg@...ux.intel.com>
> > >
> > >Some drivers need to deal with only firmware representation of its
> > >GPIOs. An example would be a GPIO button array driver where each button
> > >is described as a separate firmware node in device tree. Typically
> > >these
> > >child nodes do not have physical representation in the Linux device
> > >model.
> > >
> > >In order to help device drivers to handle such firmware child nodes we
> > >add dev[m]_get_named_gpiod_from_child() that takes a child firmware
> > >node pointer as its second argument (the first one is the parent device
> > >itself), finds the GPIO using whatever is the underlying firmware
> > >method, and requests the GPIO properly.
> > 
> > Could we also have a wrapper around this function without a "name" argument,
> > using just the index?
> 
> Expanding on this thought: I think we should mandate for new bindings
> that they use either a name and no index, or an index but not name,
> and I also think that for named gpios, we should try to converge on a
> common naming scheme. As discussed, we will probably want to support all
> the existing ways to do this even with ACPI and with the unified
> interface, but it doesn't have to be the obvious way.
> 
> We could do it like this:
> 
> // internal implementation, may be called from drivers with legacy bindings 
> struct gpio_desc *__fwnode_get_gpiod_from_property(struct fwnode_handle *fwnode,
>                                            const char *propname, int index)
> {
> 	... /* your current code */
> }
> 
> // recommended interface
> static inline struct gpio_desc *fwnode_get_gpiod(struct fwnode_handle *fwnode,
> 						  int index)
> {
> 	return __fwnode_get_gpiod_from_property(fwnode, "gpios", index);
> }
> 
> // alternative interface
> struct gpio_desc *fwnode_get_gpiod(struct fwnode_handle *fwnode, const char *name)
> {
> 	char propname[64];
> 	int ret;
> 	
> 	ret = snprintf(propname, sizeof(propname), "%s-gpios", name);
> 	if (ret > sizeof(propname))
> 		return -EINVAL;
> 
> 	return __fwnode_get_gpiod_from_property(fwnode, propname, 0);
> }
> 
> The above is just a suggestion, I'm hoping for the GPIO maintainers to
> provide more guidance if they have other ideas.

Actually, since the two last patches in the series, which currently are
the only users of these new functions, both pass "gpios" as the property
name and 0 as the index, I can simplify the functions so that (a)
fwnode_get_gpiod() takes fwnode and name and then simply passes 0 as the
index to either of_get_named_gpiod_flags() or acpi_get_gpiod_by_index()
and (b) devm_get_named_gpiod_from_child() takes only dev and fwnode (child)
and passes "gpios" as the property name to fwnode_get_gpiod().  The name
of devm_get_named_gpiod_from_child() could then be changed to something
like devm_get_gpiod_from_child() even.

If anyone in the future needs anything more general, they can simply
add more complexity to that code, but for now we can go for a simplified
interface just fine.

Rafael

--
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