qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Eduardo Habkost <eduardo@habkost.net>,
	Laurent Vivier <laurent@vivier.eu>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>, John Snow <jsnow@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Fam Zheng <fam@euphon.net>
Subject: Re: [PATCH 2/4] hw: Replace dev->parent_bus by qdev_get_parent_bus(dev)
Date: Mon, 13 Feb 2023 00:03:28 +0100	[thread overview]
Message-ID: <88026156-1838-bb8e-c637-b59a26759cc3@linaro.org> (raw)
In-Reply-To: <20230212224730.51438-3-philmd@linaro.org>

On 12/2/23 23:47, Philippe Mathieu-Daudé wrote:
> DeviceState::parent_bus is an internal field and should be
> accessed by the qdev_get_parent_bus() helper. Replace all
> uses in hw/ except the QDev uses in hw/core/.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/audio/intel-hda.c                |  2 +-
>   hw/block/fdc.c                      |  2 +-
>   hw/block/swim.c                     |  2 +-
>   hw/ide/qdev.c                       |  4 ++--
>   hw/net/virtio-net.c                 |  2 +-
>   hw/pci-bridge/pci_expander_bridge.c |  2 +-
>   hw/scsi/scsi-bus.c                  |  2 +-
>   hw/usb/bus.c                        |  2 +-
>   hw/usb/desc.c                       |  2 +-
>   hw/usb/dev-smartcard-reader.c       | 16 ++++++++--------
>   10 files changed, 18 insertions(+), 18 deletions(-)

I missed:

-- >8 --
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 6bc239a981..ec38828da0 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -103,14 +103,14 @@ HDACodecDevice *hda_codec_find(HDACodecBus *bus, 
uint32_t cad)

  void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t 
response)
  {
-    HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
+    HDACodecBus *bus = HDA_BUS(qdev_get_parent_bus(DEVICE(dev)));
      bus->response(dev, solicited, response);
  }

  bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
                      uint8_t *buf, uint32_t len)
  {
-    HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
+    HDACodecBus *bus = HDA_BUS(qdev_get_parent_bus(DEVICE(dev)));
      return bus->xfer(dev, stnr, output, buf, len);
  }

@@ -344,7 +344,7 @@ static void intel_hda_corb_run(IntelHDAState *d)
  static void intel_hda_response(HDACodecDevice *dev, bool solicited, 
uint32_t response)
  {
      const MemTxAttrs attrs = { .memory = true };
-    HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
+    HDACodecBus *bus = HDA_BUS(qdev_get_parent_bus(DEVICE(dev)));
      IntelHDAState *d = container_of(bus, IntelHDAState, codecs);
      hwaddr addr;
      uint32_t wp, ex;
@@ -399,7 +399,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, 
uint32_t stnr, bool output,
                             uint8_t *buf, uint32_t len)
  {
      const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
-    HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
+    HDACodecBus *bus = HDA_BUS(qdev_get_parent_bus(DEVICE(dev)));
      IntelHDAState *d = container_of(bus, IntelHDAState, codecs);
      hwaddr addr;
      uint32_t s, copy, left;
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 96582ce49b..6ae2627a56 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -164,7 +164,7 @@ typedef struct IDEDrive {

  static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error 
**errp)
  {
-    IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
+    IDEBus *bus = DO_UPCAST(IDEBus, qbus, 
qdev_get_parent_bus(DEVICE(dev)));
      IDEState *s = bus->ifs + dev->unit;
      int ret;

diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 9d4fec2c04..dfc5c436bd 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -382,7 +382,7 @@ static void rtas_quiesce(PowerPCCPU *cpu, 
SpaprMachineState *spapr,

  static SpaprVioDevice *reg_conflict(SpaprVioDevice *dev)
  {
-    SpaprVioBus *bus = SPAPR_VIO_BUS(dev->qdev.parent_bus);
+    SpaprVioBus *bus = SPAPR_VIO_BUS(qdev_get_parent_bus(DEVICE(dev)));
      BusChild *kid;
      SpaprVioDevice *other;

@@ -492,7 +492,7 @@ static void spapr_vio_busdev_realize(DeviceState 
*qdev, Error **errp)
          }
      } else {
          /* Need to assign an address */
-        SpaprVioBus *bus = SPAPR_VIO_BUS(dev->qdev.parent_bus);
+        SpaprVioBus *bus = SPAPR_VIO_BUS(qdev_get_parent_bus(DEVICE(dev)));

          do {
              dev->reg = bus->next_reg++;
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 3127cd7273..7b2a82b335 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -104,7 +104,7 @@ static void scsi_device_unrealize(SCSIDevice *s)
  int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf,
                         size_t buf_len, void *hba_private)
  {
-    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
+    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, 
qdev_get_parent_bus(DEVICE(dev)));
      int rc;

      assert(cmd->len == 0);
@@ -250,7 +250,7 @@ static bool scsi_bus_check_address(BusState *qbus, 
DeviceState *qdev, Error **er
  static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
  {
      SCSIDevice *dev = SCSI_DEVICE(qdev);
-    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
+    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, 
qdev_get_parent_bus(DEVICE(dev)));
      bool is_free;
      Error *local_err = NULL;

@@ -705,7 +705,7 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps 
*reqops, SCSIDevice *d,
  SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
                            uint8_t *buf, size_t buf_len, void *hba_private)
  {
-    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
+    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, 
qdev_get_parent_bus(DEVICE(d)));
      const SCSIReqOps *ops;
      SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(d);
      SCSIRequest *req;
@@ -1353,7 +1353,7 @@ int scsi_req_parse_cdb(SCSIDevice *dev, 
SCSICommand *cmd, uint8_t *buf,

  void scsi_device_report_change(SCSIDevice *dev, SCSISense sense)
  {
-    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
+    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, 
qdev_get_parent_bus(DEVICE(dev)));

      scsi_device_set_ua(dev, sense);
      if (bus->info->change) {
@@ -1372,7 +1372,7 @@ void scsi_req_unref(SCSIRequest *req)
  {
      assert(req->refcount > 0);
      if (--req->refcount == 0) {
-        BusState *qbus = req->dev->qdev.parent_bus;
+        BusState *qbus = qdev_get_parent_bus(DEVICE(req->dev));
          SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qbus);

          if (bus->info->free_request && req->hba_private) {
@@ -1444,7 +1444,7 @@ void scsi_req_print(SCSIRequest *req)
      int i;

      fprintf(fp, "[%s id=%d] %s",
-            req->dev->qdev.parent_bus->name,
+            qdev_get_parent_bus(DEVICE(req->dev))->name,
              req->dev->id,
              scsi_command_name(req->cmd.buf[0]));
      for (i = 1; i < req->cmd.len; i++) {
@@ -1698,7 +1698,7 @@ static int put_scsi_requests(QEMUFile *f, void 
*pv, size_t size,
                               const VMStateField *field, JSONWriter 
*vmdesc)
  {
      SCSIDevice *s = pv;
-    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus);
+    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, 
qdev_get_parent_bus(DEVICE(s)));
      SCSIRequest *req;

      QTAILQ_FOREACH(req, &s->requests, next) {
@@ -1726,7 +1726,7 @@ static int get_scsi_requests(QEMUFile *f, void 
*pv, size_t size,
                               const VMStateField *field)
  {
      SCSIDevice *s = pv;
-    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus);
+    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, 
qdev_get_parent_bus(DEVICE(s)));
      int8_t sbyte;

      while ((sbyte = qemu_get_sbyte(f)) > 0) {
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index 6ea4b64fe7..843dde8851 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -177,7 +177,7 @@ static inline void scsi_bus_init(SCSIBus *bus, 
size_t bus_size,

  static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
  {
-    return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
+    return DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(d)));
  }

  SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 32c23a5ca2..b2111bb1c7 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -520,7 +520,7 @@ void usb_check_attach(USBDevice *dev, Error **errp);

  static inline USBBus *usb_bus_from_device(USBDevice *d)
  {
-    return DO_UPCAST(USBBus, qbus, d->qdev.parent_bus);
+    return DO_UPCAST(USBBus, qbus, qdev_get_parent_bus(DEVICE(d)));
  }

  extern const VMStateDescription vmstate_usb_device;
---


  reply	other threads:[~2023-02-12 23:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12 22:47 [PATCH 0/4] hw/qdev: Housekeeping around qdev_get_parent_bus() Philippe Mathieu-Daudé
2023-02-12 22:47 ` [PATCH 1/4] hw/qdev: Constify DeviceState* argument of qdev_get_parent_bus() Philippe Mathieu-Daudé
2023-02-13 22:55   ` Richard Henderson
2023-02-12 22:47 ` [PATCH 2/4] hw: Replace dev->parent_bus by qdev_get_parent_bus(dev) Philippe Mathieu-Daudé
2023-02-12 23:03   ` Philippe Mathieu-Daudé [this message]
2023-02-13 23:19     ` Richard Henderson
2023-02-14 11:33       ` Philippe Mathieu-Daudé
2023-02-12 22:47 ` [PATCH 3/4] hw: Use qdev_get_parent_bus() in qdev_get_own_fw_dev_path_from_handler() Philippe Mathieu-Daudé
2023-02-13 23:29   ` Richard Henderson
2023-02-14 11:26     ` Philippe Mathieu-Daudé
2023-02-12 22:47 ` [PATCH 4/4] qdev-monitor: Use qdev_get_parent_bus() in bus_print_dev() Philippe Mathieu-Daudé
2023-02-13 23:31   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88026156-1838-bb8e-c637-b59a26759cc3@linaro.org \
    --to=philmd@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=eduardo@habkost.net \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).