diff mbox series

[5/9] hw/usb/hcd-uhci: Replace container_of() by UHCI_GET_CLASS() QOM macro

Message ID 20230220150515.32549-6-philmd@linaro.org
State New
Headers show
Series hw/usb: Cleanups around QOM style | expand

Commit Message

Philippe Mathieu-Daudé Feb. 20, 2023, 3:05 p.m. UTC
By using the QOM UHCI_GET_CLASS() cast macro we don't to
use the intermediate PCIDeviceClass variable.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/usb/hcd-uhci.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Richard Henderson Feb. 20, 2023, 7:11 p.m. UTC | #1
On 2/20/23 05:05, Philippe Mathieu-Daudé wrote:
> By using the QOM UHCI_GET_CLASS() cast macro we don't to
> use the intermediate PCIDeviceClass variable.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/usb/hcd-uhci.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index f77ffda69a..8ac1175ad2 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1159,8 +1159,7 @@  static USBBusOps uhci_bus_ops = {
 void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
 {
     Error *err = NULL;
-    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
-    UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class);
+    UHCIPCIDeviceClass *u = UHCI_GET_CLASS(dev);
     UHCIState *s = UHCI(dev);
     uint8_t *pci_conf = s->dev.config;
     int i;
@@ -1267,7 +1266,7 @@  void uhci_data_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
-    UHCIPCIDeviceClass *u = container_of(k, UHCIPCIDeviceClass, parent_class);
+    UHCIPCIDeviceClass *u = UHCI_CLASS(klass);
     UHCIInfo *info = data;
 
     k->realize = info->realize ? info->realize : usb_uhci_common_realize;