Commit ba02430f authored by Anthony Liguori's avatar Anthony Liguori

usb: separate out legacy usb registration from type registration

Type registeration is going to get turned into a QOM call so decouple the
legacy support.
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 7f595609
......@@ -704,7 +704,8 @@ static struct DeviceInfo usb_audio_info = {
static void usb_audio_register_devices(void)
{
usb_qdev_register(&usb_audio_info, "audio", NULL);
usb_qdev_register(&usb_audio_info);
usb_legacy_register("usb-audio", "audio", NULL);
}
device_init(usb_audio_register_devices)
......@@ -550,6 +550,6 @@ static struct DeviceInfo bt_info = {
static void usb_bt_register_devices(void)
{
usb_qdev_register(&bt_info, NULL, NULL);
usb_qdev_register(&bt_info);
}
device_init(usb_bt_register_devices)
......@@ -208,25 +208,27 @@ typedef struct LegacyUSBFactory
static GSList *legacy_usb_factory;
void usb_qdev_register(DeviceInfo *info,
const char *usbdevice_name,
USBDevice *(*usbdevice_init)(const char *params))
void usb_legacy_register(const char *typename, const char *usbdevice_name,
USBDevice *(*usbdevice_init)(const char *params))
{
info->bus_info = &usb_bus_info;
info->init = usb_qdev_init;
info->unplug = qdev_simple_unplug_cb;
info->exit = usb_qdev_exit;
qdev_register_subclass(info, TYPE_USB_DEVICE);
if (usbdevice_name) {
LegacyUSBFactory *f = g_malloc0(sizeof(*f));
f->name = info->name;
f->name = typename;
f->usbdevice_name = usbdevice_name;
f->usbdevice_init = usbdevice_init;
legacy_usb_factory = g_slist_append(legacy_usb_factory, f);
}
}
void usb_qdev_register(DeviceInfo *info)
{
info->bus_info = &usb_bus_info;
info->init = usb_qdev_init;
info->unplug = qdev_simple_unplug_cb;
info->exit = usb_qdev_exit;
qdev_register_subclass(info, TYPE_USB_DEVICE);
}
USBDevice *usb_create(USBBus *bus, const char *name)
{
DeviceState *dev;
......
......@@ -1352,6 +1352,7 @@ static TypeInfo ccid_card_type_info = {
static void ccid_register_devices(void)
{
type_register_static(&ccid_card_type_info);
usb_qdev_register(&ccid_info, "ccid", NULL);
usb_qdev_register(&ccid_info);
usb_legacy_register(CCID_DEV_NAME, "ccid", NULL);
}
device_init(ccid_register_devices)
......@@ -617,8 +617,11 @@ static struct DeviceInfo usb_keyboard_info = {
static void usb_hid_register_devices(void)
{
usb_qdev_register(&usb_tablet_info, "tablet", NULL);
usb_qdev_register(&usb_mouse_info, "mouse", NULL);
usb_qdev_register(&usb_keyboard_info, "keyboard", NULL);
usb_qdev_register(&usb_tablet_info);
usb_legacy_register("usb-tablet", "tablet", NULL);
usb_qdev_register(&usb_mouse_info);
usb_legacy_register("usb-mouse", "mouse", NULL);
usb_qdev_register(&usb_keyboard_info);
usb_legacy_register("usb-kbd", "keyboard", NULL);
}
device_init(usb_hid_register_devices)
......@@ -557,6 +557,6 @@ static struct DeviceInfo hub_info = {
static void usb_hub_register_devices(void)
{
usb_qdev_register(&hub_info, NULL, NULL);
usb_qdev_register(&hub_info);
}
device_init(usb_hub_register_devices)
......@@ -667,6 +667,7 @@ static struct DeviceInfo msd_info = {
static void usb_msd_register_devices(void)
{
usb_qdev_register(&msd_info, "disk", usb_msd_init);
usb_qdev_register(&msd_info);
usb_legacy_register("usb-storage", "disk", usb_msd_init);
}
device_init(usb_msd_register_devices)
......@@ -1413,6 +1413,7 @@ static struct DeviceInfo net_info = {
static void usb_net_register_devices(void)
{
usb_qdev_register(&net_info, "net", usb_net_init);
usb_qdev_register(&net_info);
usb_legacy_register("usb-net", "net", usb_net_init);
}
device_init(usb_net_register_devices)
......@@ -622,7 +622,9 @@ static struct DeviceInfo braille_info = {
static void usb_serial_register_devices(void)
{
usb_qdev_register(&serial_info, "serial", usb_serial_init);
usb_qdev_register(&braille_info, "braille", usb_braille_init);
usb_qdev_register(&serial_info);
usb_legacy_register("usb-serial", "serial", usb_serial_init);
usb_qdev_register(&braille_info);
usb_legacy_register("usb-braille", "braille", usb_braille_init);
}
device_init(usb_serial_register_devices)
......@@ -373,6 +373,7 @@ static struct DeviceInfo wacom_info = {
static void usb_wacom_register_devices(void)
{
usb_qdev_register(&wacom_info, "wacom-tablet", NULL);
usb_qdev_register(&wacom_info);
usb_legacy_register("usb-wacom-tablet", "wacom-tablet", NULL);
}
device_init(usb_wacom_register_devices)
......@@ -418,9 +418,9 @@ struct USBBusOps {
void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host);
USBBus *usb_bus_find(int busnr);
void usb_qdev_register(DeviceInfo *info,
const char *usbdevice_name,
USBDevice *(*usbdevice_init)(const char *params));
void usb_qdev_register(DeviceInfo *info);
void usb_legacy_register(const char *typename, const char *usbdevice_name,
USBDevice *(*usbdevice_init)(const char *params));
USBDevice *usb_create(USBBus *bus, const char *name);
USBDevice *usb_create_simple(USBBus *bus, const char *name);
USBDevice *usbdevice_create(const char *cmdline);
......
......@@ -1434,7 +1434,8 @@ static struct DeviceInfo usb_host_dev_info = {
static void usb_host_register_devices(void)
{
usb_qdev_register(&usb_host_dev_info, "host", usb_host_device_open);
usb_qdev_register(&usb_host_dev_info);
usb_legacy_register("usb-host", "host", usb_host_device_open);
}
device_init(usb_host_register_devices)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment