Re: Device Node and corresponding device

On 07/11/05 12:33, kristofer hansson wrote:
> I have multiple usbdux devices connected, when removing one of them I 
> want to run a usb hotplug removal script in which I call "comedi_config 
> -r /dev/comedi[devicenr]" for the specific device only.
>  
> I need to find out the specific device node nr of the device that is 
> beeing unpluged, in order to avoid having to remove all devices and then 
> re-register them again.

It's not possible at the moment.

> This could also be usefull when connecting a new usb dux and there by 
> only calling "comedi_config -i firmware /dev/comedi[devicenr] usbdux" 
> once instead of calling it multiple times, once for each device as in 
> the current /etc/hotplug/usb/usbdux script.
>  
> How and when does comedi/usbdux bind a newly connected udb device to a 
> specific device node in /dev ?

The usbdux driver has an array usbduxsub[] holding details of connected 
USB devices and whether or not they have been bound to a comedi device 
number.  The driver's usbdux_attach function (called while processing 
the comedi_config command) just looks for the first USB device in that 
array that has not been bound to a comedi device number yet.

The driver does not process any options allowing a specific USB device 
to be bound.  One fairly simple addition to the driver would be to 
support options to match the bus and device numbers.  That sort of 
information changes according to which port the device is plugged into 
and the order in which the hubs are detected, etc., but it's a start. 
It would probably be enough to be able to use udev RUN rules to tie a 
device with a specific serial number string to a specific comedi device 
number, because along with the serial number string that you match, you 
also get its current position on the USB bus.  You would need two udev 
RUN rules for each serial number: one to run a specific command when the 
matching device is added and another when it is removed.  The downside 
is that udev needs a 2.6 kernel.  It might be possible to do something 
similar with hotplug scripts if you can look up the serial number string 
within the hotplug script and map that to a comedi device number.  Well 
as this paragraph has turned out quite long, I guess I should remind you 
that a driver mod would be required to do any of this!

> The scripts to call when recieving an usb add or remove event are 
> defined in /etc/hotplug/usb.agent

-- 
-=( Ian Abbott _at_ MEV Ltd.    E-mail: <abbotti_at_mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

Received on 2005-11-08Z12:54:06