From 7c03a899e6e4030a88bd42c4d494e3a7521806ea Mon Sep 17 00:00:00 2001 From: Gonglei Date: Wed, 6 May 2015 20:55:28 +0800 Subject: [PATCH] usb: usb-mtp QOMify Signed-off-by: Gonglei Signed-off-by: Gerd Hoffmann --- hw/usb/dev-mtp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 108ece8190..c9c1f3210c 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -130,6 +130,9 @@ struct MTPState { QTAILQ_HEAD(, MTPObject) objects; }; +#define TYPE_USB_MTP "usb-mtp" +#define USB_MTP(obj) OBJECT_CHECK(MTPState, (obj), TYPE_USB_MTP) + #define QEMU_STORAGE_ID 0x00010001 #define MTP_FLAG_WRITABLE 0 @@ -878,7 +881,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c) static void usb_mtp_handle_reset(USBDevice *dev) { - MTPState *s = DO_UPCAST(MTPState, dev, dev); + MTPState *s = USB_MTP(dev); trace_usb_mtp_reset(s->dev.addr); @@ -914,7 +917,7 @@ static void usb_mtp_cancel_packet(USBDevice *dev, USBPacket *p) static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p) { - MTPState *s = DO_UPCAST(MTPState, dev, dev); + MTPState *s = USB_MTP(dev); MTPControl cmd; mtp_container container; uint32_t params[5]; @@ -1062,7 +1065,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p) static void usb_mtp_realize(USBDevice *dev, Error **errp) { - MTPState *s = DO_UPCAST(MTPState, dev, dev); + MTPState *s = USB_MTP(dev); usb_desc_create_serial(dev); usb_desc_init(dev); @@ -1113,7 +1116,7 @@ static void usb_mtp_class_initfn(ObjectClass *klass, void *data) } static TypeInfo mtp_info = { - .name = "usb-mtp", + .name = TYPE_USB_MTP, .parent = TYPE_USB_DEVICE, .instance_size = sizeof(MTPState), .class_init = usb_mtp_class_initfn,