qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro
@ 2023-02-13 10:56 Philippe Mathieu-Daudé
  2023-02-13 10:56 ` [RFC PATCH 1/3] hw/qdev: " Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:56 UTC (permalink / raw)
  To: qemu-devel, Eduardo Habkost
  Cc: Peter Maydell, Gerd Hoffmann, Edgar E . Iglesias, Igor Mammedov,
	Samuel Thibault, Paolo Bonzini, Markus Armbruster,
	Daniel P. Berrangé, Mark Cave-Ayland, Thomas Huth,
	Philippe Mathieu-Daudé

Experiment after discussing with Thomas around qdev_get_parent_bus:
https://lore.kernel.org/qemu-devel/ad356f64-dca0-8117-d22a-a530e620ddb0@redhat.com/

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(-)

-- 
2.38.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-01 15:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-13 10:56 [RFC PATCH 0/3] qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro Philippe Mathieu-Daudé
2023-02-13 10:56 ` [RFC PATCH 1/3] hw/qdev: " Philippe Mathieu-Daudé
2023-03-01 14:59   ` Daniel P. Berrangé
2023-02-13 10:56 ` [RFC PATCH 2/3] hw/usb: Declare QOM macros using QDEV_DECLARE_DEV_BUS_TYPES() Philippe Mathieu-Daudé
2023-02-13 10:56 ` [RFC PATCH 3/3] hw/usb: Use USB_DEVICE_GET_BUS() macro Philippe Mathieu-Daudé
2023-03-01 14:42 ` [RFC PATCH 0/3] qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro Igor Mammedov
2023-03-01 15:02   ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).