Message ID | 1409906256-11368-19-git-send-email-arei.gonglei@huawei.com |
---|---|
State | New |
Headers | show |
> +static void usb_host_instance_init(Object *obj) > +{ > + USBDevice *udev = USB_DEVICE(obj); > + USBHostDevice *s = USB_HOST_DEVICE(udev); > + > + device_add_bootindex_property(obj, &s->bootindex, > + "bootindex", NULL, > + &udev->qdev, NULL); > + object_property_set_int(obj, -1, "bootindex", NULL); I think the object_property_set_int() call can be moved to device_add_bootindex_property, so there is no need to duplicate the call to init bootindex with -1 in all devices. cheers, Gerd
Hi, > From: Gerd Hoffmann [mailto:kraxel@redhat.com] > Sent: Friday, September 05, 2014 5:06 PM > Subject: Re: [PATCH v7 18/28] host-libusb: remove bootindex property from > qdev to qom > > > +static void usb_host_instance_init(Object *obj) > > +{ > > + USBDevice *udev = USB_DEVICE(obj); > > + USBHostDevice *s = USB_HOST_DEVICE(udev); > > + > > + device_add_bootindex_property(obj, &s->bootindex, > > + "bootindex", NULL, > > + &udev->qdev, NULL); > > + object_property_set_int(obj, -1, "bootindex", NULL); > > I think the object_property_set_int() call can be moved to > device_add_bootindex_property, so there is no need to duplicate the call > to init bootindex with -1 in all devices. > Good idea. Thanks! Will fix this. Best regards, -Gonglei
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index c189147..a2fa70e 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -980,6 +980,17 @@ static int usb_host_initfn(USBDevice *udev) return 0; } +static void usb_host_instance_init(Object *obj) +{ + USBDevice *udev = USB_DEVICE(obj); + USBHostDevice *s = USB_HOST_DEVICE(udev); + + device_add_bootindex_property(obj, &s->bootindex, + "bootindex", NULL, + &udev->qdev, NULL); + object_property_set_int(obj, -1, "bootindex", NULL); +} + static void usb_host_handle_destroy(USBDevice *udev) { USBHostDevice *s = USB_HOST_DEVICE(udev); @@ -1464,7 +1475,6 @@ static Property usb_host_dev_properties[] = { DEFINE_PROP_UINT32("productid", USBHostDevice, match.product_id, 0), DEFINE_PROP_UINT32("isobufs", USBHostDevice, iso_urb_count, 4), DEFINE_PROP_UINT32("isobsize", USBHostDevice, iso_urb_frames, 32), - DEFINE_PROP_INT32("bootindex", USBHostDevice, bootindex, -1), DEFINE_PROP_UINT32("loglevel", USBHostDevice, loglevel, LIBUSB_LOG_LEVEL_WARNING), DEFINE_PROP_BIT("pipeline", USBHostDevice, options, @@ -1497,6 +1507,7 @@ static TypeInfo usb_host_dev_info = { .parent = TYPE_USB_DEVICE, .instance_size = sizeof(USBHostDevice), .class_init = usb_host_class_initfn, + .instance_init = usb_host_instance_init, }; static void usb_host_register_types(void)