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]
Date:	Wed, 9 Jul 2014 13:52:54 +0200 (CEST)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	Rob Jones <rob.jones@...ethink.co.uk>
cc:	Himangi Saraogi <himangi774@...il.com>,
	Linus Walleij <linus.walleij@...aro.org>,
	Alexandre Courbot <gnurou@...il.com>,
	linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
	Randy Dunlap <rdunlap@...radead.org>,
	linux-doc@...r.kernel.org, Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>,
	Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.de>,
	patches@...nsource.wolfsonmicro.com, alsa-devel@...a-project.org,
	Eric Miao <eric.y.miao@...il.com>,
	Russell King <linux@....linux.org.uk>,
	Haojian Zhuang <haojian.zhuang@...il.com>,
	linux-arm-kernel@...ts.infradead.org,
	Philipp Zabel <philipp.zabel@...il.com>,
	Paul Parsons <lost.distance@...oo.com>, julia.lawall@...6.fr
Subject: Re: [PATCH 1/5] gpiolib: devres: Introduce the function
 devm_request_gpio_array



On Wed, 9 Jul 2014, Rob Jones wrote:

> Please note that I submitted a patch on 02/07/14 to create this
> function which was acked by Linus Walleij on 05/07/14.
>
> Great minds think alike, and all that.
>
> However, I think that the version I submitted better replicates the
> original (non devm) functionality, see below.
>
> I didn't, however, add it to the documentation. +1 on that.
>
> On 06/07/14 18:47, Himangi Saraogi wrote:
> > This patch introduces the function devm_request_gpio_array that
> > allocates multiple GPIOs in a single call in a managed manner. The
> > function is also included in the documentation and a declaration is
> > added in include/linux/gpio.h.
> >
> > Signed-off-by: Himangi Saraogi <himangi774@...il.com>
> > ---
> >   Documentation/driver-model/devres.txt |  1 +
> >   drivers/gpio/devres.c                 | 21 +++++++++++++++++++++
> >   include/linux/gpio.h                  |  2 ++
> >   3 files changed, 24 insertions(+)
> >
> > diff --git a/Documentation/driver-model/devres.txt
> > b/Documentation/driver-model/devres.txt
> > index 9e2098e..756f6cf 100644
> > --- a/Documentation/driver-model/devres.txt
> > +++ b/Documentation/driver-model/devres.txt
> > @@ -337,6 +337,7 @@ GPIO
> >     devm_gpiod_put()
> >     devm_gpio_request()
> >     devm_gpio_request_one()
> > +  devm_gpio_request_array()
> >     devm_gpio_free()
> >
> >   SND
> > diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
> > index 65978cf..adae7fa 100644
> > --- a/drivers/gpio/devres.c
> > +++ b/drivers/gpio/devres.c
> > @@ -229,6 +229,27 @@ int devm_gpio_request_one(struct device *dev, unsigned
> > gpio,
> >   EXPORT_SYMBOL(devm_gpio_request_one);
> >
> >   /**
> > + *	devm_gpio_request_array - request multiple GPIOs in a single call
> > + *	@dev:   device to request for
> > + *	@array:	array of the 'struct gpio'
> > + *	@num:	how many GPIOs in the array
> > + */
> > +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
> > +			    size_t num)
> > +{
> > +	int i, err;
> > +
> > +	for (i = 0; i < num; i++, array++) {
> > +		err = devm_gpio_request_one(dev, array->gpio, array->flags,
> > +					    array->label);
> > +		if (err)
> > +			return err;
>
> The failure path in the version I submitted frees up any already
> allocated gpios on the first failure.

Himangi first proposed doing that, but I thought it was not really in the
spirit of devm functions, which is to leave that implicit.  No strong
opinion on the matter, though.

julia


>
> > +	}
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_gpio_request_array);
> > +
> > +/**
> >    *      devm_gpio_free - free a GPIO
> >    *      @dev: device to free GPIO for
> >    *      @gpio: GPIO to free
> > diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> > index 85aa5d0..c85f243 100644
> > --- a/include/linux/gpio.h
> > +++ b/include/linux/gpio.h
> > @@ -84,6 +84,8 @@ struct device;
> >   int devm_gpio_request(struct device *dev, unsigned gpio, const char
> > *label);
> >   int devm_gpio_request_one(struct device *dev, unsigned gpio,
> >   			  unsigned long flags, const char *label);
> > +int devm_gpio_request_array(struct device *dev, const struct gpio *array,
> > +			    size_t num);
> >   void devm_gpio_free(struct device *dev, unsigned int gpio);
> >
> >   #else /* ! CONFIG_GPIOLIB */
> >
>
> --
> Rob Jones
> Codethink Ltd
> mailto:rob.jones@...ethink.co.uk
> tel:+44 161 236 5575
>
--
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