Skip to content

RFC qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro

Philippe Mathieu-Daudé qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3hw/qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macroinclude/hw/qdev-core.h+28 -01 reply
2/3hw/usb: Declare QOM macros using QDEV_DECLARE_DEV_BUS_TYPES()include/hw/usb.h+4 -40 replies
3/3hw/usb: Use USB_DEVICE_GET_BUS() macrohw/usb/bus.c hw/usb/core.c hw/usb/dev-hub.c +3 more+16 -210 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/3] qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro

Experiment after discussing with Thomas around qdev_get_parent_bus:
https://lore.kernel.org/qemu-devel/[email protected]/

When a QDev plug on a QBus, we'll always use qdev_get_parent_bus() at least once with this type. Why not provide a consistent defined macro instead of:
1/ adding an inlined helper such usb_bus_from_device()
or scsi_bus_from_device() with different type checks,
2/ open-code calls to qdev_get_parent_bus() with unsafe casts
?

This RFC series introduce a QDev-equivalent of QOM DECLARE_TYPES macro, to be used with a (device, bus) tuple, and declaring the equivalent device_GET_BUS() macro.

hw/usb/ is converted as an example.

Philippe Mathieu-Daudé (3):
hw/qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro hw/usb: Declare QOM macros using QDEV_DECLARE_DEV_BUS_TYPES() hw/usb: Use USB_DEVICE_GET_BUS() macro

 hw/usb/bus.c           | 10 +++++-----
 hw/usb/core.c          |  6 +++---
 hw/usb/dev-hub.c       |  4 ++--
 hw/usb/dev-serial.c    | 10 +++++-----
 hw/usb/hcd-xhci.c      |  2 +-
 include/hw/qdev-core.h | 28 ++++++++++++++++++++++++++++
 include/hw/usb.h       | 13 ++++---------
 7 files changed, 48 insertions(+), 25 deletions(-)
Signature · 1 line
2.38.1