[PATCH 2/6] drivers/base: add bus for System-on-Chip devices

Greg KH gregkh at suse.de
Tue Oct 18 10:41:09 EDT 2011


On Tue, Oct 18, 2011 at 04:14:02PM +0200, Arnd Bergmann wrote:
> On Tuesday 18 October 2011, Lee Jones wrote:
> > >> +struct device *soc_device_register(struct soc_device_attribute *soc_dev_attr)
> > >> +{
> > >> +    struct soc_device *soc_dev;
> > >> +    static atomic_t soc_device_num = ATOMIC_INIT(0);
> > > 
> > > No, please don't do this, use the proper kernel interface to dynamically
> > > handle numbering devices (hint, if you unload a SOC device, you will
> > > never reclaim that device number, which isn't that nice.)
> > 
> > Again, some help would really be appreciated here. I searched the kernel
> > last time you mentioned numbering, but this is all I came up with.
> 
> I guess the correct interface to use here would be an "ida", see
> linux/idr.h. However, I'm not convinced that's actually worth the
> extra space for maintaining it here.

Why?  That is the interface for this type of thing, it's very simple to
use, and it handles all of the logic for you for this type of thing.

Please don't roll your own solutions for things when there is already
code in the kernel to do it.

> IMHO, we could also remove the soc_device_unregister() function entirely
> and add a comment along the lines of 
> /*
>  * If you really need to add hot-pluggable soc_devices, add a
>  * soc_device_unregister function and turn the number generation
>  * into an IDA.
>  */

No, please provide this.  I want to see it tested, as when it is, then
the code will be fixed properly as right now it does some things it
shouldn't be doing in this regard.

greg k-h



More information about the linux-arm-kernel mailing list