aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
Diffstat (limited to 'hw/usb')
-rw-r--r--hw/usb/dev-network.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 9be3a64006..743c231d6b 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -648,6 +648,9 @@ typedef struct USBNetState {
QTAILQ_HEAD(rndis_resp_head, rndis_response) rndis_resp;
} USBNetState;
+#define TYPE_USB_NET "usb-net"
+#define USB_NET(obj) OBJECT_CHECK(USBNetState, (obj), TYPE_USB_NET)
+
static int is_rndis(USBNetState *s)
{
return s->dev.config->bConfigurationValue == DEV_RNDIS_CONFIG_VALUE;
@@ -1347,7 +1350,7 @@ static NetClientInfo net_usbnet_info = {
static void usb_net_realize(USBDevice *dev, Error **errrp)
{
- USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
+ USBNetState *s = USB_NET(dev);
usb_desc_create_serial(dev);
usb_desc_init(dev);
@@ -1380,7 +1383,7 @@ static void usb_net_realize(USBDevice *dev, Error **errrp)
static void usb_net_instance_init(Object *obj)
{
USBDevice *dev = USB_DEVICE(obj);
- USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
+ USBNetState *s = USB_NET(dev);
device_add_bootindex_property(obj, &s->conf.bootindex,
"bootindex", "/ethernet-phy@0",
@@ -1441,7 +1444,7 @@ static void usb_net_class_initfn(ObjectClass *klass, void *data)
}
static const TypeInfo net_info = {
- .name = "usb-net",
+ .name = TYPE_USB_NET,
.parent = TYPE_USB_DEVICE,
.instance_size = sizeof(USBNetState),
.class_init = usb_net_class_initfn,
@@ -1451,7 +1454,7 @@ static const TypeInfo net_info = {
static void usb_net_register_types(void)
{
type_register_static(&net_info);
- usb_legacy_register("usb-net", "net", usb_net_init);
+ usb_legacy_register(TYPE_USB_NET, "net", usb_net_init);
}
type_init(usb_net_register_types)