public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Kay Sievers <kay.sievers@vrfy.org>,
	Federico Vaga <federico.vaga@gmail.com>
Cc: Alessandro Rubini <rubini@gnudd.com>, linux-kernel@vger.kernel.org
Subject: Re: How to make a bus with heterogeneous devices?
Date: Fri, 2 Mar 2012 14:38:53 -0800	[thread overview]
Message-ID: <20120302223853.GA24929@kroah.com> (raw)
In-Reply-To: <1380686.VGpImaUmFA@harkonnen>

On Fri, Mar 02, 2012 at 11:18:59AM +0100, Federico Vaga wrote:
> > That's fine, it is what happens with lots of drivers, you can do this
> > with the default attribute group assigned to that driver, right?
> 
> We can't because a driver can handle devices with different set of 
> attributes. We  can't use device->groups because only if match succeed 
> we know which attributes add to the device.
> That's because the same driver handles several similar devices, to avoid 
> proliferation of almost-identical drivers. So the drivers attaches 
> attributes to the device after match succeeds.

Unless you manage the uevents by "hand", you can run into big problems
with userspace tools if you add the attributes after the device is
matched to a driver.  Be very careful here.

> The solution that I temporarily  implemented is the following:
> 
> > > [...]
> > > 3- Attributes may be added after match succeeds, before calling
> > > probe.
> > > This cam be done with a "raw" call to sysfs_create_group(); then
> > > groups cna be added to dev->groups so they will be removed on
> > > device_unregister().
> > > [...]
> 
> (with calling probe I mean calling "my" driver probe)
> 
> I know it's not a nice solution and I know it's not nice add groups to 
> device->groups after registration. I can use sysfs_create_group() and 
> sysfs_remove_group() without touching the device.

It's not an issue of "touching" the device, it's an issue of "userspace
just got missed all of those attributes", so your tools will be all
confused.  The kernel has no problem with it :)

> > I think you need to look at how the system bus is handled.  It just 
> > went into 3.3-rc and allows for "different" types of devices to all be 
> > on the same bus, with different drivers and attributes.  Let me know if 
> > how that works does not work out for you.
> 
> (thank you for the reference to the patches)
> 
> I think it doesn't work in our case for the same reason we can't use 
> device_driver->groups: we know too late in the register process which 
> attributes add to a device, practically at the end of the registration.
> Maybe I'm missing something.

I think you are.

Kay, you know this area of the driver core better than I do at the
moment, given your most recent changes here.  Any reason why Alessandro
and Federico can't do the same thing that the sysdev rework did for
their devices here?

thanks,

greg k-h

  reply	other threads:[~2012-03-02 22:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24 15:20 How to make a bus with heterogeneous devices? Alessandro Rubini
2012-02-25  0:40 ` Greg Kroah-Hartman
2012-02-29 13:57   ` Federico Vaga
2012-02-29 23:58     ` Greg Kroah-Hartman
2012-03-02 10:18   ` Federico Vaga
2012-03-02 22:38     ` Greg Kroah-Hartman [this message]
2012-03-03 11:43       ` Kay Sievers
2012-03-03 15:44         ` Federico Vaga
2012-03-04 18:59           ` Kay Sievers
2012-03-12 15:08         ` Federico Vaga

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=20120302223853.GA24929@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=federico.vaga@gmail.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rubini@gnudd.com \
    /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