[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 045/197] usb: get rid of info pointer
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH v3 045/197] usb: get rid of info pointer |
Date: |
Mon, 12 Dec 2011 14:18:41 -0600 |
---
hw/usb-bus.c | 154 ++++++++++++++++++++++++++++++++-------------------------
hw/usb.h | 1 -
2 files changed, 86 insertions(+), 69 deletions(-)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 24a805d..8d9c82d 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -67,21 +67,103 @@ USBBus *usb_bus_find(int busnr)
static int usb_device_init(USBDevice *dev)
{
- if (dev->info->init) {
- return dev->info->init(dev);
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->init) {
+ return info->init(dev);
}
return 0;
}
+static void usb_device_handle_destroy(USBDevice *dev)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->handle_destroy) {
+ info->handle_destroy(dev);
+ }
+}
+
+int usb_device_handle_packet(USBDevice *dev, USBPacket *p)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->handle_packet) {
+ return info->handle_packet(dev, p);
+ }
+ return -ENOSYS;
+}
+
+void usb_device_cancel_packet(USBDevice *dev, USBPacket *p)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->cancel_packet) {
+ info->cancel_packet(dev, p);
+ }
+}
+
+void usb_device_handle_attach(USBDevice *dev)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->handle_attach) {
+ info->handle_attach(dev);
+ }
+}
+
+void usb_device_handle_reset(USBDevice *dev)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->handle_reset) {
+ info->handle_reset(dev);
+ }
+}
+
+int usb_device_handle_control(USBDevice *dev, USBPacket *p, int request,
+ int value, int index, int length, uint8_t *data)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->handle_control) {
+ return info->handle_control(dev, p, request, value, index, length,
+ data);
+ }
+ return -ENOSYS;
+}
+
+int usb_device_handle_data(USBDevice *dev, USBPacket *p)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ if (info->handle_data) {
+ return info->handle_data(dev, p);
+ }
+ return -ENOSYS;
+}
+
+const char *usb_device_get_product_desc(USBDevice *dev)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ return info->product_desc;
+}
+
+const USBDesc *usb_device_get_usb_desc(USBDevice *dev)
+{
+ USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev,
+ qdev_get_info(DEVICE(dev)));
+ return info->usb_desc;
+}
+
static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
USBDevice *dev = USB_DEVICE(qdev);
- USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);
int rc;
pstrcpy(dev->product_desc, sizeof(dev->product_desc),
usb_device_get_product_desc(dev));
- dev->info = info;
dev->auto_attach = 1;
QLIST_INIT(&dev->strings);
rc = usb_claim_port(dev);
@@ -105,13 +187,6 @@ err:
return rc;
}
-static void usb_device_handle_destroy(USBDevice *dev)
-{
- if (dev->info->handle_destroy) {
- dev->info->handle_destroy(dev);
- }
-}
-
static int usb_qdev_exit(DeviceState *qdev)
{
USBDevice *dev = USB_DEVICE(qdev);
@@ -495,63 +570,6 @@ USBDevice *usbdevice_create(const char *cmdline)
return usb->usbdevice_init(params);
}
-int usb_device_handle_packet(USBDevice *dev, USBPacket *p)
-{
- if (dev->info->handle_packet) {
- return dev->info->handle_packet(dev, p);
- }
- return -ENOSYS;
-}
-
-void usb_device_cancel_packet(USBDevice *dev, USBPacket *p)
-{
- if (dev->info->cancel_packet) {
- dev->info->cancel_packet(dev, p);
- }
-}
-
-void usb_device_handle_attach(USBDevice *dev)
-{
- if (dev->info->handle_attach) {
- dev->info->handle_attach(dev);
- }
-}
-
-void usb_device_handle_reset(USBDevice *dev)
-{
- if (dev->info->handle_reset) {
- dev->info->handle_reset(dev);
- }
-}
-
-int usb_device_handle_control(USBDevice *dev, USBPacket *p, int request,
- int value, int index, int length, uint8_t *data)
-{
- if (dev->info->handle_control) {
- return dev->info->handle_control(dev, p, request, value, index, length,
- data);
- }
- return -ENOSYS;
-}
-
-int usb_device_handle_data(USBDevice *dev, USBPacket *p)
-{
- if (dev->info->handle_data) {
- return dev->info->handle_data(dev, p);
- }
- return -ENOSYS;
-}
-
-const char *usb_device_get_product_desc(USBDevice *dev)
-{
- return dev->info->product_desc;
-}
-
-const USBDesc *usb_device_get_usb_desc(USBDevice *dev)
-{
- return dev->info->usb_desc;
-}
-
static TypeInfo usb_device_type_info = {
.name = TYPE_USB_DEVICE,
.parent = TYPE_DEVICE,
diff --git a/hw/usb.h b/hw/usb.h
index e05c00d..ee780b0 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -179,7 +179,6 @@ typedef struct USBDeviceClass {
/* definition of a USB device */
struct USBDevice {
DeviceState qdev;
- USBDeviceInfo *info;
USBPort *port;
char *port_path;
void *opaque;
--
1.7.4.1
- [Qemu-devel] [PATCH v3 023/197] pc: fill out most of the composition tree, (continued)
- [Qemu-devel] [PATCH v3 023/197] pc: fill out most of the composition tree, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 024/197] i440fx: split out piix3 device, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 025/197] i440fx: rename piix_pci -> i440fx, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 033/197] a little better approach to this, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 034/197] qdev: add isa-device as a subclass of device, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 035/197] isa: more isa stuff, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 036/197] qom: make pcidevice part of the hierarchy, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 039/197] virtio-serial-port, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 040/197] get rid of more DO_UPCAST, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 042/197] isa: move methods from isadeviceinfo to isadeviceclass, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 045/197] usb: get rid of info pointer,
Anthony Liguori <=
- [Qemu-devel] [PATCH v3 047/197] usb: use a factory instead of doing silly things for legacy, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 046/197] usb: promote all of the methods for USBDevice to class methods, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 049/197] usb-hid: simply class initialization a bit, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 051/197] drop info link in SCSIDeviceInfo, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 048/197] usb: kill USBDeviceInfo, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 052/197] move methods out of SCSIDeviceInfo into SCSIDeviceClass, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 054/197] get rid of CCIDCardInfo, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 056/197] add I2CSlave to the type hierarchy, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 055/197] rename i2c_slave -> I2CSlave, Anthony Liguori, 2011/12/12
- [Qemu-devel] [PATCH v3 058/197] fixup type registration, Anthony Liguori, 2011/12/12