public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roland Stigge <stigge@antcom.de>
To: Greg KH <gregkh@linuxfoundation.org>
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/11 v4] gpio: Add sysfs support to block GPIO API
Date: Wed, 17 Oct 2012 10:39:25 +0200	[thread overview]
Message-ID: <507E6EBD.6040101@antcom.de> (raw)
In-Reply-To: <20121016164326.GA4858@kroah.com>

On 10/16/2012 06:43 PM, Greg KH wrote:
> On Tue, Oct 16, 2012 at 02:53:45PM +0200, Roland Stigge wrote:
>> On 10/16/2012 01:57 AM, Greg KH wrote:
>>> On Tue, Oct 16, 2012 at 01:31:18AM +0200, Roland Stigge wrote:
>>>> +int gpio_block_export(struct gpio_block *block)
>>>> +{
>>>> +	int		status;
>>>> +	struct device	*dev;
>>>> +
>>>> +	/* can't export until sysfs is available ... */
>>>> +	if (!gpio_class.p) {
>>>> +		pr_debug("%s: called too early!\n", __func__);
>>>> +		return -ENOENT;
>>>> +	}
>>>> +
>>>> +	mutex_lock(&sysfs_lock);
>>>> +	dev = device_create(&gpio_class, NULL, MKDEV(0, 0), block,
>>>> +			    block->name);
>>>> +	if (!IS_ERR(dev))
>>>> +		status = sysfs_create_group(&dev->kobj, &gpio_block_attr_group);
>>>> +	else
>>>> +		status = PTR_ERR(dev);
>>>> +	mutex_unlock(&sysfs_lock);
>>>
>>> You just raced with userspace telling it that the device was present,
>>> yet the attributes are not there.  Don't do that, use the default class
>>> attributes for the class and then the driver core will create them
>>> automagically without needing to this "by hand" at all.
>>
>> I guess you mean class attributes like gpio_class_attrs[] of gpio_class?
> 
> Yes.
> 
>> Aren't class attributes specific to a class only (i.e. only one
>> attribute at the root for all devices)? What I needed above are
>> attributes for the block itself (of which there can be several). So we
>> need device attributes for each block, not class attributes here.
> 
> Yes, that is what the dev_attrs field in 'struct class' is for.

That's what I was missing. Will update.

Thanks,

Roland

  parent reply	other threads:[~2012-10-17  8:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15 23:31 [PATCH RFC 00/11 v4] gpio: Add block GPIO Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 01/11 v4] gpio: Add a block GPIO API to gpiolib Roland Stigge
2012-10-16  0:18   ` Ryan Mallon
2012-10-15 23:31 ` [PATCH RFC 02/11 v4] gpio: Add sysfs support to block GPIO API Roland Stigge
2012-10-15 23:57   ` Greg KH
2012-10-16 12:53     ` Roland Stigge
2012-10-16 16:43       ` Greg KH
2012-10-16 17:27         ` Linus Walleij
2012-10-16 17:40           ` Greg KH
2012-10-16 21:08             ` Linus Walleij
2012-10-16 21:25               ` Greg KH
2012-10-17  8:39         ` Roland Stigge [this message]
2012-10-15 23:31 ` [PATCH RFC 03/11 v4] gpio: Add device tree " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 04/11 v4] gpio-max730x: Add " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 05/11 v4] gpio-lpc32xx: " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 06/11 v4] gpio-generic: " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 07/11 v4] gpio-pca953x: " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 08/11 v4] gpio-em: " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 09/11 v4] gpio-pl061: " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 10/11 v4] gpio-max732x: " Roland Stigge
2012-10-15 23:31 ` [PATCH RFC 11/11 v4] gpio-pcf857x: " 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=507E6EBD.6040101@antcom.de \
    --to=stigge@antcom.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=daniel-gl@gmx.net \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --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=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