aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2015-05-06 20:55:28 +0800
committerGerd Hoffmann <kraxel@redhat.com>2015-05-08 13:01:07 +0200
commit7c03a899e6e4030a88bd42c4d494e3a7521806ea (patch)
treed12ac52f836c6b50e9d6d95502a675436c57b46d /hw/usb
parente81b13ad94803bf13491bb71c8a76a5d7db9ddf1 (diff)
usb: usb-mtp QOMify
Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb')
-rw-r--r--hw/usb/dev-mtp.c11
1 files 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,