]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
staging: usbip: userspace: show product name in `list -l' command
authorKurt Kanzenbach <ly80toro@cip.cs.fau.de>
Thu, 4 Apr 2013 14:03:16 +0000 (16:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2013 21:22:52 +0000 (14:22 -0700)
The `usbip list -l' command shows your local usb-devices.
Example:
 $ usbip list -l
 $ Local USB devices
 $ =================
 $ - busid 1-1 (13fe:1d00)
 $         1-1:1.0 -> usb-storage
 $
 $ - busid 1-2 (0409:55aa)
 $         1-2:1.0 -> hub

However this list command doesn't show which device is connected
to this busid. Therefore you have to use another tool e.g. lsusb
to determine that.

This patches adds the possibility to see which device that is.
Example:
 $ usbip list -l
 $ Local USB devices
 $ =================
 $ - busid 1-1 (13fe:1d00)
 $   Kingston Technology Company Inc. : DataTraveler 2.0 1GB/4GB Flash Drive / Patriot Xporter 4GB Flash
 $         1-1:1.0 -> usb-storage
 $
 $ - busid 1-2 (0409:55aa)
 $   NEC Corp. : Hub (0409:55aa)
 $         1-2:1.0 -> hub

If parsable is specified the info will be not printed.

Signed-off-by: Kurt Kanzenbach <ly80toro@cip.cs.fau.de>
Signed-off-by: Stefan Reif <ke42caxa@cip.cs.fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/usbip/userspace/src/usbip_list.c

index ed30d910e0375916544360cbf39c216d6a97946f..ff56255f497a2bac813cdcdd22417f9f44845cd0 100644 (file)
@@ -159,6 +159,12 @@ static void print_device(char *busid, char *vendor, char *product,
                printf(" - busid %s (%.4s:%.4s)\n", busid, vendor, product);
 }
 
+static void print_product_name(char *product_name, bool parsable)
+{
+       if (!parsable)
+               printf("   %s\n", product_name);
+}
+
 static void print_interface(char *busid, char *driver, bool parsable)
 {
        if (parsable)
@@ -189,6 +195,7 @@ static int list_devices(bool parsable)
 {
        char bus_type[] = "usb";
        char busid[SYSFS_BUS_ID_SIZE];
+       char product_name[128];
        struct sysfs_bus *ubus;
        struct sysfs_device *dev;
        struct sysfs_device *intf;
@@ -231,8 +238,13 @@ static int list_devices(bool parsable)
                        goto err_out;
                }
 
+               /* get product name */
+               usbip_names_get_product(product_name, sizeof(product_name),
+                                       strtol(idVendor->value, NULL, 16),
+                                       strtol(idProduct->value, NULL, 16));
                print_device(dev->bus_id, idVendor->value, idProduct->value,
                             parsable);
+               print_product_name(product_name, parsable);
 
                for (i = 0; i < atoi(bNumIntfs->value); i++) {
                        snprintf(busid, sizeof(busid), "%s:%.1s.%d",