From: Greg KH <gregkh@linuxfoundation.org>
To: Roland Stigge <stigge@antcom.de>
Cc: grant.likely@secretlab.ca, linus.walleij@linaro.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, w.sang@pengutronix.de,
jbe@pengutronix.de, plagnioj@jcrosoft.com, highguy@gmail.com,
broonie@opensource.wolfsonmicro.com, daniel-gl@gmx.net,
rmallon@gmail.com
Subject: Re: [PATCH RFC 02/15 v5] gpio: Add sysfs support to block GPIO API
Date: Wed, 17 Oct 2012 12:05:20 -0700 [thread overview]
Message-ID: <20121017190520.GC25996@kroah.com> (raw)
In-Reply-To: <1350477107-26512-3-git-send-email-stigge@antcom.de>
On Wed, Oct 17, 2012 at 02:31:34PM +0200, Roland Stigge wrote:
> This patch adds sysfs support to the block GPIO API.
>
> Signed-off-by: Roland Stigge <stigge@antcom.de>
>
> ---
> Documentation/ABI/testing/sysfs-gpio | 6
> drivers/gpio/gpiolib.c | 214 +++++++++++++++++++++++++++++++++++
> include/asm-generic/gpio.h | 11 +
> include/linux/gpio.h | 13 ++
> 4 files changed, 243 insertions(+), 1 deletion(-)
>
> --- linux-2.6.orig/Documentation/ABI/testing/sysfs-gpio
> +++ linux-2.6/Documentation/ABI/testing/sysfs-gpio
> @@ -24,4 +24,8 @@ Description:
> /base ... (r/o) same as N
> /label ... (r/o) descriptive, not necessarily unique
> /ngpio ... (r/o) number of GPIOs; numbered N to N + (ngpio - 1)
> -
> + /blockN ... for each GPIO block #N
> + /ngpio ... (r/o) number of GPIOs in this group
> + /exported ... sysfs export state of this group (0, 1)
> + /value ... current value as 32 or 64 bit integer in decimal
> + (only available if /exported is 1)
I think you need some more documentation here, as I just noticed
something "odd":
> +static int gpio_block_value_unexport(struct gpio_block *block)
> +{
> + struct device *dev;
> + int i;
> +
> + dev = class_find_device(&gpio_block_class, NULL, block, match_export);
> + if (!dev)
> + return -ENODEV;
> +
> + for (i = 0; i < block->ngpio; i++)
> + gpio_free(block->gpio[i]);
> +
> + device_remove_file(dev, &dev_attr_block_value);
> +
> + return 0;
> +}
Wait, what? You are removing a sysfs file in this function, from within
a sysfs write:
> +static ssize_t gpio_block_exported_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t size)
> +{
> + long value;
> + int status;
> + struct gpio_block *block = dev_get_drvdata(dev);
> + int exported = gpio_block_value_is_exported(block);
> +
> + status = kstrtoul(buf, 0, &value);
> + if (status < 0)
> + goto err;
> +
> + if (value != exported) {
> + if (value)
> + status = gpio_block_value_export(block);
> + else
> + status = gpio_block_value_unexport(block);
That looks like a recipie for disaster. Why do you allow userspace to
do this?
Anyway, the other fixups for how you create/destroy the attribute files
looks great, thanks for making those changes.
greg k-h
next prev parent reply other threads:[~2012-10-17 19:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 12:31 [PATCH RFC 00/15 v5] gpio: Add block GPIO Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 01/15 v5] gpio: Add a block GPIO API to gpiolib Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 02/15 v5] gpio: Add sysfs support to block GPIO API Roland Stigge
2012-10-17 19:05 ` Greg KH [this message]
2012-10-18 10:07 ` Roland Stigge
2012-10-19 10:35 ` Linus Walleij
2012-10-19 11:51 ` Roland Stigge
2012-10-22 8:55 ` Linus Walleij
2012-10-22 9:05 ` Roland Stigge
2012-10-19 18:02 ` Greg KH
2012-10-22 8:54 ` Linus Walleij
2012-10-17 12:31 ` [PATCH RFC 03/15 v5] gpiolib: Fix default attributes for class Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 04/15 v5] gpio: Add device tree support to block GPIO API Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 05/15 v5] gpio-max730x: Add " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 06/15 v5] gpio-lpc32xx: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 07/15 v5] gpio-generic: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 08/15 v5] gpio-pca953x: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 09/15 v5] gpio-em: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 10/15 v5] gpio-pl061: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 11/15 v5] gpio-max732x: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 12/15 v5] gpio-pcf857x: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 13/15 v5] gpio-xilinx: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 14/15 v5] gpio-vt8500: " Roland Stigge
2012-10-17 12:31 ` [PATCH RFC 15/15 v5] gpio-ucb1400: " Roland Stigge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121017190520.GC25996@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=daniel-gl@gmx.net \
--cc=grant.likely@secretlab.ca \
--cc=highguy@gmail.com \
--cc=jbe@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=plagnioj@jcrosoft.com \
--cc=rmallon@gmail.com \
--cc=stigge@antcom.de \
--cc=w.sang@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox