tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: RFC: device attachment/detachment



On Tue, May 05, 2009 at 08:45:43AM +0200, Christoph Egger wrote:
> Yes. And from code reading it sounds more logical to register a device
> _after_ it successfully attached.

There are both uses combined into device_register():

 - A vga card may be console or not, the information needs to be available
   before the driver attaches (as it does some things differently if console).
   On some ports this information is prepared in device_register() - for 
   example by comparing firmware handles in the attach args with firmware
   environment vars. This sometimes can't be done in the attach function 
   itself, because we do not want to invade bus specific code with
   #ifdef sparc crap.

 - A disk device might be the boot device, which is currently found out
   by comparing the firmware handle to another firmware environment var.
   The result is not needed imediately, so this could be moved to post-attach
   time.

Just examples - there are lots of other uses in the tree.

So we have two options:

 - split device_register() into a pre attach and a post attach function,
   the latter only being called when attaching did work
 - add a device_unregister() call if attachment fails

The latter should also be used when the device detaches, which makes this
a cleaner solution.

Martin


Home | Main Index | Thread Index | Old Index