Devicetree
 help / color / mirror / Atom feed
From: Greg KH <gregkh-l3A5Bk7waGM@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: Dirk Eibach <eibach-dJ+jgKLZIg4@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Kay Sievers <kay.sievers-tD+1rO4QERM@public.gmane.org>
Subject: Re: [PATCH v4] hwmon: Add support for Texas Instruments ADS1015
Date: Thu, 3 Mar 2011 11:47:47 -0800	[thread overview]
Message-ID: <20110303194747.GB31661@suse.de> (raw)
In-Reply-To: <20110303175050.GC22940-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>

On Thu, Mar 03, 2011 at 10:50:50AM -0700, Grant Likely wrote:
> > +	i2c_set_clientdata(client, data);
> > +	mutex_init(&data->update_lock);
> > +
> > +	/* build sysfs attribute group */
> > +	data->attr_group.attrs = data->attr_table;
> > +	exported_channels = ads1015_get_exported_channels(client);
> > +	for (k = 0; k < ADS1015_CONFIG_CHANNELS; ++k) {
> > +		if (!(exported_channels & (1<<k)))
> > +			continue;
> > +		data->attr_table[n++] =
> > +			all_attributes[k];
> > +	}
> > +	err = sysfs_create_group(&client->dev.kobj, &data->attr_group);
> > +	if (err)
> > +		goto exit_free;
> 
> I suspect there are lifecycle issues here.  Attributes should not be
> added to a device after the device is registered.  If adding
> attributes, then a new struct device should be allocated, added to the
> attribute group, and then registered as a child of the i2c_device.
> Otherwise the attributes are not available at uevent time, which means
> userspace (udev) may not be able to do the right things with the
> device when the device appears.
> 
> Kay/GregKH, do I have this right?

You have it right that the attributes need to be added earlier, yes.
But I don't recommend using a whole new struct device for this, each
subsystem should have a way to add groups of attributes for their
devices to properly show up before the uevent happens.

I don't recall what the hwmon subsystem does for this, I'm sure it is
somewhere in there...

thanks,

greg k-h

  parent reply	other threads:[~2011-03-03 19:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03  7:45 [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Dirk Eibach
     [not found] ` <1299138343-12773-1-git-send-email-eibach-dJ+jgKLZIg4@public.gmane.org>
2011-03-03 17:50   ` Grant Likely
     [not found]     ` <20110303175050.GC22940-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-03-03 19:47       ` Greg KH [this message]
2011-03-03 20:02       ` Wolfram Sang
     [not found]         ` <20110303200236.GA17132-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-03-03 21:15           ` Grant Likely

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=20110303194747.GB31661@suse.de \
    --to=gregkh-l3a5bk7wagm@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=eibach-dJ+jgKLZIg4@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=kay.sievers-tD+1rO4QERM@public.gmane.org \
    /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