[Nut-upsuser] Nut-upsuser Digest, Vol 36, Issue 5

Arjen de Korte nut+users at de-korte.org
Tue Jun 10 08:58:11 UTC 2008


> It is possible at least on linux to get the port associated with a device
> from userspace - I'd assume that on each platform it's possible, just that
> libusb is incomplete (on top of being undocumented).
>
> Here's a patch for matching portnum on linux, with a few pieces pulled
> from libusb. It lacks autoconf macros to isolate it -- but it does appear
> to work.

I appreciate the effort you took here. Before investing lots of time in
cleaning up this patch, consider the following.

Besides some (easy to fix) coding style issues (see 'docs/developers.txt')
your patch breaks the existing behaviour of hotplugging devices in a
different (physical) port. Note that on reconnection (with the exact
matcher), we don't match on the 'Bus' parameter so that it is possible to
move a UPS to a different (physical) port. Likewise, you shouldn't match
on the 'Port' by default either. Probably the cleanest way to fix this, is
by only adding these to the exact matcher, if they are specified in
'ups.conf'.

Having said this, I'm uncertain how portable this mechanism would be in
the first place. What we definitly don't want, is that changes in the
USB_DEVFS_PATH propagate into the drivers (and I'm really not sure that
this isn't the case now).

The above will be a moot issue, once the device matching code from the USB
drivers is removed and replaced by a useable HAL interface (and let the
kernel handle the (re)connection of drivers). As such, the existing
matching mechanism is a gross hack at best and your patch will only add to
the mess we already have. Therefor, I'm not in favor of entering this
patch into the mainstream development code.

Best regards, Arjen
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsuser mailing list