Feature request with code: add USB device "port" and "manufacturer" attributes‏

Michael T raselmsh at hotmail.com
Fri Nov 21 12:46:04 PST 2008


Hello,
 
I would like to request the addition to hal of the "port number" and "manufacturer
string" attributes for USB devices (info.subsystem = 'usb_device') as they are
present in the deprecated usbfs devices file.  The manufacturer string is
sometimes, but not consistently, available now as the "vendor" attribute, but I
need to be able to access it reliably.  Its value can be taken straight from
sysfs.  The port number can be parsed from the sysfs path string using the
following code, which might be placed in the usb_add() function in
hald/linux/device.c:
 
{
    const char *last_dash = strrchr (sysfs_path, '-');
    const char *last_dot = strrchr (sysfs_path, '.');
    const char *last = last_dash < last_dot ? last_dot : last_dash;
    if (last != NULL && *(last + 1)>= '0' && *(last + 1) <= '9')
    {
        unsigned long port;
        char *endptr;
        errno = 0;
        port = strtoul (last + 1, &endptr, 10);
        if (errno == 0 && *endptr == '\0' && port < 256)
            hal_device_property_set_uint64 (d, "usb_device.port_number", port);
    }
 
}
 
(you may use this code as you like).  If I understand the relevent section of
Linux Device Drivers, 3rd edition (co-authored by Greg KH) correctly, this
method of obtaining the port value is "supported" by the kernel.  The link to
the section is http://www.linuxdriver.co.il/ldd3/chp-13-sect-2.shtml.
 
Thanks!
 
Regards,
 
Michael


_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us


More information about the hal mailing list