Patchwork [11/12] usb: move USB_REQ_SET_ADDRESS handling to common code

login
register
mail settings
Submitter Gerd Hoffmann
Date Nov. 29, 2010, 4:04 p.m.
Message ID <1291046649-19353-12-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/73446/
State New
Headers show

Comments

Gerd Hoffmann - Nov. 29, 2010, 4:04 p.m.
USB_REQ_SET_ADDRESS handling is identical in *all* emulated devices.
Move it to common code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb-bt.c     |    4 ----
 hw/usb-desc.c   |    4 ++++
 hw/usb-hid.c    |    4 ----
 hw/usb-hub.c    |    4 ----
 hw/usb-msd.c    |    4 ----
 hw/usb-net.c    |    5 -----
 hw/usb-serial.c |    4 ----
 hw/usb-wacom.c  |    4 ----
 8 files changed, 4 insertions(+), 29 deletions(-)

Patch

diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index 44da655..cb51750 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -412,10 +412,6 @@  static int usb_bt_handle_control(USBDevice *dev, int request, int value,
         }
         ret = 0;
         break;
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
     case DeviceRequest | USB_REQ_GET_CONFIGURATION:
         data[0] = 1;
         ret = 1;
diff --git a/hw/usb-desc.c b/hw/usb-desc.c
index 59af8e2..36dabec 100644
--- a/hw/usb-desc.c
+++ b/hw/usb-desc.c
@@ -268,6 +268,10 @@  int usb_desc_handle_control(USBDevice *dev, int request, int value,
 
     assert(desc != NULL);
     switch(request) {
+    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
+        dev->addr = value;
+        ret = 0;
+        break;
     case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
         ret = usb_desc_get_descriptor(dev, value, data, length);
         break;
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 2efdc3b..a5e3804 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -694,10 +694,6 @@  static int usb_hid_handle_control(USBDevice *dev, int request, int value,
         }
         ret = 0;
         break;
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
     case DeviceRequest | USB_REQ_GET_CONFIGURATION:
         data[0] = 1;
         ret = 1;
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 0f8d060..51a67a2 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -297,10 +297,6 @@  static int usb_hub_handle_control(USBDevice *dev, int request, int value,
         }
         ret = 0;
         break;
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
     case DeviceRequest | USB_REQ_GET_CONFIGURATION:
         data[0] = 1;
         ret = 1;
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 7b6a0d7..a4d5c49 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -260,10 +260,6 @@  static int usb_msd_handle_control(USBDevice *dev, int request, int value,
         }
         ret = 0;
         break;
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
     case DeviceRequest | USB_REQ_GET_CONFIGURATION:
         data[0] = 1;
         ret = 1;
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 057c753..502a079 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1071,11 +1071,6 @@  static int usb_net_handle_control(USBDevice *dev, int request, int value,
         ret = 0;
         break;
 
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
-
     case ClassInterfaceOutRequest | USB_CDC_SEND_ENCAPSULATED_COMMAND:
         if (!s->rndis || value || index != 0)
             goto fail;
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index 85d8d3f..e3cc49a 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -253,10 +253,6 @@  static int usb_serial_handle_control(USBDevice *dev, int request, int value,
         }
         ret = 0;
         break;
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
     case DeviceRequest | USB_REQ_GET_CONFIGURATION:
         data[0] = 1;
         ret = 1;
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index d0263a6..6b50b06 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -283,10 +283,6 @@  static int usb_wacom_handle_control(USBDevice *dev, int request, int value,
         }
         ret = 0;
         break;
-    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-        dev->addr = value;
-        ret = 0;
-        break;
     case DeviceRequest | USB_REQ_GET_CONFIGURATION:
         data[0] = 1;
         ret = 1;