Skip to contentSkip to conversation

fix usb-hid SET_IDLE behaviour

PATCH Applied Stefano Stabellini 4 participants 5 messages Jan 7, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix usb-hid SET_IDLE behaviour

Hi all,
the usb-hid spec states that the SET_IDLE request has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues a GET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seen SET_VALUE with both bytes set to 0 so far, but still it is wrong.

---

hw/usb-hid.c +2 -2
index 972543f..76fdce6 100644
@@ -65,7 +65,7 @@ typedef struct USBHIDState {
     };
     int kind;
     int protocol;
-    int idle;
+    uint8_t idle;
     int changed;
     void *datain_opaque;
     void (*datain)(void *);
@@ -794,7 +794,7 @@ static int usb_hid_handle_control(USBDevice *dev, int request, int value,
         data[0] = s->idle;
         break;
     case SET_IDLE:
-        s->idle = value;
+        s->idle = (uint8_t) (value >> 8);
         ret = 0;
         break;
     default:
Reviewed-by Stefano Stabellini on v1 1/1
#1 lore raw

Stefano Stabellini writes ("[Qemu-devel] [PATCH] fix usb-hid SET_IDLE behaviour"):

Quoted 11 lines

the usb-hid spec states that the SET_IDLE request has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues a GET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seen SET_VALUE with both bytes set to 0 so far, but still it is wrong.

Stefano's patch looks good to me.

Ian.

#2 lore raw
Quoted 12 lines · Ian Jackson

Stefano Stabellini writes ("[Qemu-devel] [PATCH] fix usb-hid SET_IDLE behaviour"):

Quoted 10 lines

the usb-hid spec states that the SET_IDLE request has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues a GET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seen SET_VALUE with both bytes set to 0 so far, but still it is wrong.

Quoted 7 lines
Quoted 2 lines

Stefano's patch looks good to me.

Shouldn't that be Ian rather than Stefano? :-)

Alex

#3 lore raw

Alexander Graf writes ("Re: [Qemu-devel] [PATCH] fix usb-hid SET_IDLE behaviour"):

Quoted 4 lines
Quoted 1 line · Ian Jackson

Shouldn't that be Ian rather than Stefano? :-)

Sorry, I'm an idiot :-).

Ian.

#4 lore raw
In reply to Stefano Stabellini
Quoted 11 lines · Stefano Stabellini

Hi all,
the usb-hid spec states that the SET_IDLE request has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues a GET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seen SET_VALUE with both bytes set to 0 so far, but still it is wrong.

Quoted 2 lines

Applied. Thanks.

Regards,

Anthony Liguori