[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] hw: Replace dev->parent_bus by qdev_get_parent_bus(dev)
From: |
Philippe Mathieu-Daudé |
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 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 |
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;
---