diff options
author | Pantelis Koukousoulas <pktoss@gmail.com> | 2013-12-16 09:42:49 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2014-02-18 15:39:12 +0100 |
commit | bd93976a1ad9cca9636da66dfde98a41e573130c (patch) | |
tree | 3c337768b23ec9c6ae31f6e92bb21d162db3cd18 | |
parent | 46eef33b89e936ca793e13c4aeea1414e97e8dbb (diff) | |
download | qemu-bd93976a1ad9cca9636da66dfde98a41e573130c.tar.gz qemu-bd93976a1ad9cca9636da66dfde98a41e573130c.tar.bz2 qemu-bd93976a1ad9cca9636da66dfde98a41e573130c.zip |
usb: Remove magic constants from device bmAttributes
Replace magic constants in device bmAttributes with symbolic ones
from Linux kernel ch9.h
Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | hw/usb/desc.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-audio.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-bluetooth.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-hid.c | 8 | ||||
-rw-r--r-- | hw/usb/dev-hub.c | 3 | ||||
-rw-r--r-- | hw/usb/dev-network.c | 4 | ||||
-rw-r--r-- | hw/usb/dev-serial.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-smartcard-reader.c | 3 | ||||
-rw-r--r-- | hw/usb/dev-storage.c | 6 | ||||
-rw-r--r-- | hw/usb/dev-uas.c | 4 | ||||
-rw-r--r-- | hw/usb/dev-wacom.c | 2 | ||||
-rw-r--r-- | include/hw/usb.h | 5 |
12 files changed, 25 insertions, 18 deletions
diff --git a/hw/usb/desc.c b/hw/usb/desc.c index f133ddb9db..ab48691363 100644 --- a/hw/usb/desc.c +++ b/hw/usb/desc.c @@ -759,7 +759,7 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p, * We return the same value that a configured device would return if * it used the first configuration. */ - if (config->bmAttributes & 0x40) { + if (config->bmAttributes & USB_CFG_ATT_SELFPOWER) { data[0] |= 1 << USB_DEVICE_SELF_POWERED; } if (dev->remote_wakeup) { diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index c5420eb057..bfebfe90f3 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -224,7 +224,7 @@ static const USBDescDevice desc_device = { .bNumInterfaces = 2, .bConfigurationValue = DEV_CONFIG_VALUE, .iConfiguration = STRING_CONFIG, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .bMaxPower = 0x32, .nif = ARRAY_SIZE(desc_iface), .ifs = desc_iface, diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c index 7f292b1ae6..a9661d2801 100644 --- a/hw/usb/dev-bluetooth.c +++ b/hw/usb/dev-bluetooth.c @@ -229,7 +229,7 @@ static const USBDescDevice desc_device_bluetooth = { { .bNumInterfaces = 2, .bConfigurationValue = 1, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .bMaxPower = 0, .nif = ARRAY_SIZE(desc_iface_bluetooth), .ifs = desc_iface_bluetooth, diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 2966066682..f36e617632 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -202,7 +202,7 @@ static const USBDescDevice desc_device_mouse = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_MOUSE, - .bmAttributes = 0xa0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface_mouse, @@ -219,7 +219,7 @@ static const USBDescDevice desc_device_tablet = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_TABLET, - .bmAttributes = 0xa0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface_tablet, @@ -236,7 +236,7 @@ static const USBDescDevice desc_device_tablet2 = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_TABLET, - .bmAttributes = 0xa0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface_tablet2, @@ -253,7 +253,7 @@ static const USBDescDevice desc_device_keyboard = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_KEYBOARD, - .bmAttributes = 0xa0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface_keyboard, diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index 58647b4859..bc03531666 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -119,7 +119,8 @@ static const USBDescDevice desc_device_hub = { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .bmAttributes = 0xe0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER | + USB_CFG_ATT_WAKEUP, .nif = 1, .ifs = &desc_iface_hub, }, diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 4c532b7d6a..d3fadbe2c7 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -266,7 +266,7 @@ static const USBDescDevice desc_device_net = { .bNumInterfaces = 2, .bConfigurationValue = DEV_RNDIS_CONFIG_VALUE, .iConfiguration = STRING_RNDIS, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .bMaxPower = 0x32, .nif = ARRAY_SIZE(desc_iface_rndis), .ifs = desc_iface_rndis, @@ -274,7 +274,7 @@ static const USBDescDevice desc_device_net = { .bNumInterfaces = 2, .bConfigurationValue = DEV_CONFIG_VALUE, .iConfiguration = STRING_CDC, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .bMaxPower = 0x32, .nif = ARRAY_SIZE(desc_iface_cdc), .ifs = desc_iface_cdc, diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 0b150d43fb..d3606142c9 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -144,7 +144,7 @@ static const USBDescDevice desc_device = { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .bmAttributes = 0x80, + .bmAttributes = USB_CFG_ATT_ONE, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface0, diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 8c7a61ebe1..470e69ffc8 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -463,7 +463,8 @@ static const USBDescDevice desc_device = { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .bmAttributes = 0xe0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER | + USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface0, diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index c434c5680f..2852669d57 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -117,7 +117,7 @@ static const USBDescDevice desc_device_full = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_FULL, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .nif = 1, .ifs = &desc_iface_full, }, @@ -152,7 +152,7 @@ static const USBDescDevice desc_device_high = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_HIGH, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .nif = 1, .ifs = &desc_iface_high, }, @@ -189,7 +189,7 @@ static const USBDescDevice desc_device_super = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_SUPER, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .nif = 1, .ifs = &desc_iface_super, }, diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 997b715952..9832385119 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -286,7 +286,7 @@ static const USBDescDevice desc_device_high = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_HIGH, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .nif = 1, .ifs = &desc_iface_high, }, @@ -302,7 +302,7 @@ static const USBDescDevice desc_device_super = { .bNumInterfaces = 1, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_SUPER, - .bmAttributes = 0xc0, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_SELFPOWER, .nif = 1, .ifs = &desc_iface_super, }, diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c index 1b092358f9..1b73fd0aab 100644 --- a/hw/usb/dev-wacom.c +++ b/hw/usb/dev-wacom.c @@ -107,7 +107,7 @@ static const USBDescDevice desc_device_wacom = { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .bmAttributes = 0x80, + .bmAttributes = USB_CFG_ATT_ONE, .bMaxPower = 40, .nif = 1, .ifs = &desc_iface_wacom, diff --git a/include/hw/usb.h b/include/hw/usb.h index 3ef7af7413..1919bdc09d 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -157,6 +157,11 @@ #define USB_DEV_CAP_USB2_EXT 0x02 #define USB_DEV_CAP_SUPERSPEED 0x03 +#define USB_CFG_ATT_ONE (1 << 7) /* should always be set */ +#define USB_CFG_ATT_SELFPOWER (1 << 6) +#define USB_CFG_ATT_WAKEUP (1 << 5) +#define USB_CFG_ATT_BATTERY (1 << 4) + #define USB_ENDPOINT_XFER_CONTROL 0 #define USB_ENDPOINT_XFER_ISOC 1 #define USB_ENDPOINT_XFER_BULK 2 |