aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/dev-hub.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2015-05-06 20:55:27 +0800
committerGerd Hoffmann <kraxel@redhat.com>2015-05-08 13:01:07 +0200
commite81b13ad94803bf13491bb71c8a76a5d7db9ddf1 (patch)
tree9804386fd42c15a0730387a962b8be1f3bb0de64 /hw/usb/dev-hub.c
parentf56691295e38429bbfe476d57676c53bcb1fd437 (diff)
usb: usb-hub QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/dev-hub.c')
-rw-r--r--hw/usb/dev-hub.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 0482f58719..c8c6855505 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -41,6 +41,9 @@ typedef struct USBHubState {
USBHubPort ports[NUM_PORTS];
} USBHubState;
+#define TYPE_USB_HUB "usb-hub"
+#define USB_HUB(obj) OBJECT_CHECK(USBHubState, (obj), TYPE_USB_HUB)
+
#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)
@@ -227,7 +230,7 @@ static void usb_hub_complete(USBPort *port, USBPacket *packet)
static USBDevice *usb_hub_find_device(USBDevice *dev, uint8_t addr)
{
- USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
+ USBHubState *s = USB_HUB(dev);
USBHubPort *port;
USBDevice *downstream;
int i;
@@ -247,7 +250,7 @@ static USBDevice *usb_hub_find_device(USBDevice *dev, uint8_t addr)
static void usb_hub_handle_reset(USBDevice *dev)
{
- USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
+ USBHubState *s = USB_HUB(dev);
USBHubPort *port;
int i;
@@ -513,7 +516,7 @@ static USBPortOps usb_hub_port_ops = {
static void usb_hub_realize(USBDevice *dev, Error **errp)
{
- USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
+ USBHubState *s = USB_HUB(dev);
USBHubPort *port;
int i;
@@ -577,7 +580,7 @@ static void usb_hub_class_initfn(ObjectClass *klass, void *data)
}
static const TypeInfo hub_info = {
- .name = "usb-hub",
+ .name = TYPE_USB_HUB,
.parent = TYPE_USB_DEVICE,
.instance_size = sizeof(USBHubState),
.class_init = usb_hub_class_initfn,