Skip to content

Commit

Permalink
usb: usb-bt QOMify
Browse files Browse the repository at this point in the history
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
gongleiarei authored and kraxel committed May 8, 2015
1 parent 0389a0b commit a293e82
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions hw/usb/dev-bluetooth.c
Expand Up @@ -49,6 +49,9 @@ struct USBBtState {
} outcmd, outacl, outsco;
};

#define TYPE_USB_BT "usb-bt-dongle"
#define USB_BT(obj) OBJECT_CHECK(struct USBBtState, (obj), TYPE_USB_BT)

#define USB_EVT_EP 1
#define USB_ACL_EP 2
#define USB_SCO_EP 3
Expand Down Expand Up @@ -503,7 +506,7 @@ static void usb_bt_handle_destroy(USBDevice *dev)

static void usb_bt_realize(USBDevice *dev, Error **errp)
{
struct USBBtState *s = DO_UPCAST(struct USBBtState, dev, dev);
struct USBBtState *s = USB_BT(dev);

usb_desc_create_serial(dev);
usb_desc_init(dev);
Expand All @@ -523,7 +526,7 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
USBDevice *dev;
struct USBBtState *s;
HCIInfo *hci;
const char *name = "usb-bt-dongle";
const char *name = TYPE_USB_BT;

if (*cmdline) {
hci = hci_init(cmdline);
Expand All @@ -534,7 +537,7 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
return NULL;

dev = usb_create(bus, name);
s = DO_UPCAST(struct USBBtState, dev, dev);
s = USB_BT(dev);
s->hci = hci;
return dev;
}
Expand All @@ -561,7 +564,7 @@ static void usb_bt_class_initfn(ObjectClass *klass, void *data)
}

static const TypeInfo bt_info = {
.name = "usb-bt-dongle",
.name = TYPE_USB_BT,
.parent = TYPE_USB_DEVICE,
.instance_size = sizeof(struct USBBtState),
.class_init = usb_bt_class_initfn,
Expand All @@ -570,7 +573,7 @@ static const TypeInfo bt_info = {
static void usb_bt_register_types(void)
{
type_register_static(&bt_info);
usb_legacy_register("usb-bt-dongle", "bt", usb_bt_init);
usb_legacy_register(TYPE_USB_BT, "bt", usb_bt_init);
}

type_init(usb_bt_register_types)

0 comments on commit a293e82

Please sign in to comment.