Skip to contentSkip to conversation

Minor USB fixes

PATCH NAK Brad Hards 3 participants 11 messages Apr 13, 2011 – Apr 25, 2011

lore
Share & tools
lore

Brad Hards

author
#0 lore raw

cover Minor USB fixes

1 fixes spellos in the mass-storage driver
2-4 fix issues in Linux usb pass-through code.

author
#1 lore raw

PATCH 1/4 usb: trivial spelling fixes

---
 hw/usb-msd.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/usb-msd.c +2 -2
index 76f5b02..947fd3f 100644
@@ -33,7 +33,7 @@ do { printf("usb-msd: " fmt , ## __VA_ARGS__); } while (0)
 
 enum USBMSDMode {
     USB_MSDM_CBW, /* Command Block.  */
-    USB_MSDM_DATAOUT, /* Tranfer data to device.  */
+    USB_MSDM_DATAOUT, /* Transfer data to device.  */
     USB_MSDM_DATAIN, /* Transfer data from device.  */
     USB_MSDM_CSW /* Command Status.  */
 };
@@ -253,7 +253,7 @@ static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,
         usb_msd_copy_data(s);
         if (s->usb_len == 0) {
             /* Set s->packet to NULL before calling usb_packet_complete
-               because annother request may be issued before
+               because another request may be issued before
                usb_packet_complete returns.  */
             DPRINTF("Packet complete %p\n", p);
             s->packet = NULL;
Signature · 1 line
1.7.1
author
#2 lore raw

PATCH 2/4 usb: initialise data element in Linux USB_DISCONNECT ioctl.

In reply to Brad Hards

This isn't used, but leaving it empty causes valgrind noise.

---
 usb-linux.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
usb-linux.c +1 -0
index 255009f..d958853 100644
@@ -344,6 +344,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
         for (interface = 0; interface < nb_interfaces; interface++) {
             ctrl.ioctl_code = USBDEVFS_DISCONNECT;
             ctrl.ifno = interface;
+            ctrl.data = 0;
             ret = ioctl(dev->fd, USBDEVFS_IOCTL, &ctrl);
             if (ret < 0 && errno != ENODATA) {
                 perror("USBDEVFS_DISCONNECT");
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 3/4 usb: fix spelling errors in usb-linux.c

In reply to Brad Hards
---
 usb-linux.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
usb-linux.c +2 -2
index d958853..1f33c2c 100644
@@ -107,7 +107,7 @@ enum {
 /*
  * Control transfer state.
  * Note that 'buffer' _must_ follow 'req' field because
- * we need contigious buffer when we submit control URB.
+ * we need contiguous buffer when we submit control URB.
  */
 struct ctrl_struct {
     uint16_t len;
@@ -580,7 +580,7 @@ static int usb_host_handle_control(USBHostDevice *s, USBPacket *p)
     /*
      * Setup ctrl transfer.
      *
-     * s->ctrl is layed out such that data buffer immediately follows
+     * s->ctrl is laid out such that data buffer immediately follows
      * 'req' struct which is exactly what usbdevfs expects.
      */
     urb = &aurb->urb;
Signature · 1 line
1.7.1
author
#4 lore raw

PATCH 4/4 usb: use DPRINTF instead of printf for some simple cases

In reply to Brad Hards
---
 usb-linux.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
usb-linux.c +8 -8
index 1f33c2c..b02a0f9 100644
@@ -233,8 +233,8 @@ static void async_complete(void *opaque)
                 return;
             }
             if (errno == ENODEV && !s->closing) {
-                printf("husb: device %d.%d disconnected\n",
-                       s->bus_num, s->addr);
+                DPRINTF("husb: device %d.%d disconnected\n",
+                        s->bus_num, s->addr);
                 usb_host_close(s);
                 usb_host_auto_check(NULL);
                 return;
@@ -320,7 +320,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
         }
         config_descr_len = dev->descr[i];
 
-        printf("husb: config #%d need %d\n", dev->descr[i + 5], configuration);
+        DPRINTF("husb: config #%d need %d\n", dev->descr[i + 5], configuration);
 
         if (configuration < 0 || configuration == dev->descr[i + 5]) {
             configuration = dev->descr[i + 5];
@@ -359,7 +359,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
         ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE, &interface);
         if (ret < 0) {
             if (errno == EBUSY) {
-                printf("husb: update iface. device already grabbed\n");
+                DPRINTF("husb: update iface. device already grabbed\n");
             } else {
                 perror("husb: failed to claim interface");
             }
@@ -368,8 +368,8 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
         }
     }
 
-    printf("husb: %d interfaces claimed for configuration %d\n",
-           nb_interfaces, configuration);
+    DPRINTF("husb: %d interfaces claimed for configuration %d\n",
+            nb_interfaces, configuration);
 
     dev->ninterfaces   = nb_interfaces;
     dev->configuration = configuration;
@@ -929,7 +929,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
     if (dev->fd != -1) {
         goto fail;
     }
-    printf("husb: open device %d.%d\n", bus_num, addr);
+    DPRINTF("husb: open device %d.%d\n", bus_num, addr);
 
     if (!usb_host_device_path) {
         perror("husb: USB Host Device Path not set");
@@ -984,7 +984,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
         goto fail;
     }
 
-    printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
+    DPRINTF("husb: grabbed usb device %d.%d\n", bus_num, addr);
 
     ret = usb_linux_update_endp_table(dev);
     if (ret) {
Signature · 1 line
1.7.1
#5 lore raw

Re: [Qemu-devel] [PATCH 4/4] usb: use DPRINTF instead of printf for some simple cases

Quoted 4 lines · Brad Hards

---
 usb-linux.c |   16 ++++++++--------

 1 files changed, 8 insertions(+), 8 deletions(-)

Some of these printfs look like they might be useful given that the current USB support is known to be imperfect and frequently causes questions from users. By changing them to DPRINTF() you are making these message available only to developers and not users.

Any thoughts from people who use or have written the usb-linux.c code?

Stefan

#6 lore raw

Re: [Qemu-devel] [PATCH 4/4] usb: use DPRINTF instead of printf for some simple cases

In reply to Brad Hards

Hi,

Quoted 10 lines · Brad Hards
---
  usb-linux.c |   16 ++++++++--------
  1 files changed, 8 insertions(+), 8 deletions(-)
usb-linux.c +0 -0
index 1f33c2c..b02a0f9 100644

usb-linux.c static void async_complete(void *opaque) · line 240

Quoted 10 lines
usb-linux.c +2 -2
@@ -233,8 +233,8 @@ static void async_complete(void *opaque)
                  return;
              }
              if (errno == ENODEV&&  !s->closing) {
-                printf("husb: device %d.%d disconnected\n",
-                       s->bus_num, s->addr);
+                DPRINTF("husb: device %d.%d disconnected\n",
+                        s->bus_num, s->addr);
                  usb_host_close(s);
                  usb_host_auto_check(NULL);
                  return;

I think this one should stay a regular printf, in case the disconnect is unintentional people may think it is a qemu problem without the printf.

usb-linux.c static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) · line 326

Quoted 9 lines
usb-linux.c +1 -1
@@ -320,7 +320,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
          }
          config_descr_len = dev->descr[i];
 
-        printf("husb: config #%d need %d\n", dev->descr[i + 5], configuration);
+        DPRINTF("husb: config #%d need %d\n", dev->descr[i + 5], configuration);
 
          if (configuration<  0 || configuration == dev->descr[i + 5]) {
              configuration = dev->descr[i + 5];

Ack.

usb-linux.c static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) · line 365

Quoted 9 lines
usb-linux.c +1 -1
@@ -359,7 +359,7 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
          ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE,&interface);
          if (ret<  0) {
              if (errno == EBUSY) {
-                printf("husb: update iface. device already grabbed\n");
+                DPRINTF("husb: update iface. device already grabbed\n");
              } else {
                  perror("husb: failed to claim interface");
              }

Nack, this is an error condition, so it should not be a DPRINTF.

usb-linux.c static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) · line 375

Quoted 11 lines
usb-linux.c +2 -2
@@ -368,8 +368,8 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
          }
      }
 
-    printf("husb: %d interfaces claimed for configuration %d\n",
-           nb_interfaces, configuration);
+    DPRINTF("husb: %d interfaces claimed for configuration %d\n",
+            nb_interfaces, configuration);
 
      dev->ninterfaces   = nb_interfaces;
      dev->configuration = configuration;

Ack.

usb-linux.c static int usb_host_open(USBHostDevice *dev, int bus_num, · line 935

Quoted 9 lines
usb-linux.c +1 -1
@@ -929,7 +929,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
      if (dev->fd != -1) {
          goto fail;
      }
-    printf("husb: open device %d.%d\n", bus_num, addr);
+    DPRINTF("husb: open device %d.%d\n", bus_num, addr);
 
      if (!usb_host_device_path) {
          perror("husb: USB Host Device Path not set");

Ack.

usb-linux.c static int usb_host_open(USBHostDevice *dev, int bus_num, · line 990

Quoted 9 lines
usb-linux.c +1 -1
@@ -984,7 +984,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
          goto fail;
      }
 
-    printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
+    DPRINTF("husb: grabbed usb device %d.%d\n", bus_num, addr);
 
      ret = usb_linux_update_endp_table(dev);
      if (ret) {

Ack.

author
#7 lore raw

Re: [Qemu-devel] [PATCH 4/4] usb: use DPRINTF instead of printf for some simple cases

Quoted 7 lines · Hans de Goede
Quoted 7 lines
(quoted diff) +0 -0
@@ -359,7 +359,7 @@ static int usb_host_claim_interfaces(USBHostDevice
 *dev, int configuration)
 
          ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE,&interface);
          if (ret<  0) {
              if (errno == EBUSY) {
 
Quoted 8 lines
Quoted 6 lines
usb-linux.c +1 -1
-                printf("husb: update iface. device already grabbed\n");
+                DPRINTF("husb: update iface. device already grabbed\n");
              } else {
                  perror("husb: failed to claim interface");
              }

Nack, this is an error condition, so it should not be a DPRINTF.

Then should it go to stderr instead of stdout?

(There are other places in this code where we use fprintf(stderr, ...) to indicate error conditions.)

Brad

author
#8 lore raw

Re: [Qemu-devel] [PATCH 4/4] usb: use DPRINTF instead of printf for some simple cases

Quoted 17 lines · On Thursday 14 April 2011 08:01:43 Brad Hards wrote:
Quoted 16 lines · Hans de Goede
Quoted 16 lines
(quoted diff) +0 -1
@@ -359,7 +359,7 @@ static int usb_host_claim_interfaces(USBHostDevice
 *dev, int configuration)
 
          ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE,&interface);
          if (ret<  0) {
 
              if (errno == EBUSY) {
 
-                printf("husb: update iface. device already

grabbed\n"); + DPRINTF("husb: update iface. device
already grabbed\n");

              } else {
              
                  perror("husb: failed to claim interface");
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
              }

Nack, this is an error condition, so it should not be a DPRINTF.

Then should it go to stderr instead of stdout?

(There are other places in this code where we use fprintf(stderr, ...) to indicate error conditions.)

ping?

Brad

#9 lore raw
In reply to Brad Hards
Quoted 2 lines · Brad Hards

1 fixes spellos in the mass-storage driver
2-4 fix issues in Linux usb pass-through code.

I left a comment on patch 4 and will wait for activity on that email thread. Otherwise these could go via the trivial-patches tree and I'll add them once discussion has finished.

Stefan

#10 lore raw
In reply to Brad Hards
Quoted 2 lines · Brad Hards

1 fixes spellos in the mass-storage driver
2-4 fix issues in Linux usb pass-through code.

Patches 1-3 merged into the trivial patches tree. Patch 4 should be a separate patch and needs Ack from Hans.

I will send a pull request to the qemu.git maintainers:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

For more information, see
http://wiki.qemu.org/Contribute/TrivialPatches.

Stefan