From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/8] switch scsi bus to inplace allocation.
Date: Fri, 18 Sep 2009 11:24:06 +0200 [thread overview]
Message-ID: <1253265851-28919-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1253265851-28919-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/esp.c | 10 +++++-----
hw/lsi53c895a.c | 12 ++++++------
hw/scsi-bus.c | 9 +++------
hw/scsi-disk.h | 4 ++--
hw/usb-msd.c | 6 +++---
5 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/hw/esp.c b/hw/esp.c
index b5ddfb2..951770d 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -63,7 +63,7 @@ struct ESPState {
uint8_t ti_buf[TI_BUFSZ];
uint32_t sense;
uint32_t dma;
- SCSIBus *bus;
+ SCSIBus bus;
SCSIDevice *current_dev;
uint8_t cmdbuf[TI_BUFSZ];
uint32_t cmdlen;
@@ -191,7 +191,7 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf)
s->async_len = 0;
}
- if (target >= ESP_MAX_DEVS || !s->bus->devs[target]) {
+ if (target >= ESP_MAX_DEVS || !s->bus.devs[target]) {
// No such drive
s->rregs[ESP_RSTAT] = 0;
s->rregs[ESP_RINTR] = INTR_DC;
@@ -199,7 +199,7 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf)
esp_raise_irq(s);
return 0;
}
- s->current_dev = s->bus->devs[target];
+ s->current_dev = s->bus.devs[target];
return dmalen;
}
@@ -692,8 +692,8 @@ static int esp_init1(SysBusDevice *dev)
qdev_init_gpio_in(&dev->qdev, parent_esp_reset, 1);
- s->bus = scsi_bus_new(&dev->qdev, 0, ESP_MAX_DEVS, esp_command_complete);
- scsi_bus_legacy_handle_cmdline(s->bus);
+ scsi_bus_new(&s->bus, &dev->qdev, 0, ESP_MAX_DEVS, esp_command_complete);
+ scsi_bus_legacy_handle_cmdline(&s->bus);
return 0;
}
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 62bdca8..7c45391 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -193,7 +193,7 @@ typedef struct {
* 2 if processing DMA from lsi_execute_script.
* 3 if a DMA operation is in progress. */
int waiting;
- SCSIBus *bus;
+ SCSIBus bus;
SCSIDevice *current_dev;
int current_lun;
/* The tag is a combination of the device ID and the SCSI tag. */
@@ -585,7 +585,7 @@ static void lsi_reselect(LSIState *s, uint32_t tag)
id = (tag >> 8) & 0xf;
s->ssid = id | 0x80;
DPRINTF("Reselected target %d\n", id);
- s->current_dev = s->bus->devs[id];
+ s->current_dev = s->bus.devs[id];
s->current_tag = tag;
s->scntl1 |= LSI_SCNTL1_CON;
lsi_set_phase(s, PHASE_MI);
@@ -1041,7 +1041,7 @@ again:
}
s->sstat0 |= LSI_SSTAT0_WOA;
s->scntl1 &= ~LSI_SCNTL1_IARB;
- if (id >= LSI_MAX_DEVS || !s->bus->devs[id]) {
+ if (id >= LSI_MAX_DEVS || !s->bus.devs[id]) {
DPRINTF("Selected absent target %d\n", id);
lsi_script_scsi_interrupt(s, 0, LSI_SIST1_STO);
lsi_disconnect(s);
@@ -1052,7 +1052,7 @@ again:
/* ??? Linux drivers compain when this is set. Maybe
it only applies in low-level mode (unimplemented).
lsi_script_scsi_interrupt(s, LSI_SIST0_CMP, 0); */
- s->current_dev = s->bus->devs[id];
+ s->current_dev = s->bus.devs[id];
s->current_tag = id << 8;
s->scntl1 |= LSI_SCNTL1_CON;
if (insn & (1 << 3)) {
@@ -2178,8 +2178,8 @@ static int lsi_scsi_init(PCIDevice *dev)
lsi_soft_reset(s);
- s->bus = scsi_bus_new(&dev->qdev, 1, LSI_MAX_DEVS, lsi_command_complete);
- scsi_bus_legacy_handle_cmdline(s->bus);
+ scsi_bus_new(&s->bus, &dev->qdev, 1, LSI_MAX_DEVS, lsi_command_complete);
+ scsi_bus_legacy_handle_cmdline(&s->bus);
register_savevm("lsiscsi", -1, 0, lsi_scsi_save, lsi_scsi_load, s);
return 0;
}
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 16afa05..881e363 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -15,17 +15,14 @@ static struct BusInfo scsi_bus_info = {
static int next_scsi_bus;
/* Create a scsi bus, and attach devices to it. */
-SCSIBus *scsi_bus_new(DeviceState *host, int tcq, int ndev,
- scsi_completionfn complete)
+void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
+ scsi_completionfn complete)
{
- SCSIBus *bus;
-
- bus = FROM_QBUS(SCSIBus, qbus_create(&scsi_bus_info, host, NULL));
+ qbus_create_inplace(&bus->qbus, &scsi_bus_info, host, NULL);
bus->busnr = next_scsi_bus++;
bus->tcq = tcq;
bus->ndev = ndev;
bus->complete = complete;
- return bus;
}
static int scsi_qdev_init(DeviceState *qdev, DeviceInfo *base)
diff --git a/hw/scsi-disk.h b/hw/scsi-disk.h
index febde44..b6b6c12 100644
--- a/hw/scsi-disk.h
+++ b/hw/scsi-disk.h
@@ -52,8 +52,8 @@ struct SCSIBus {
SCSIDevice *devs[8];
};
-SCSIBus *scsi_bus_new(DeviceState *host, int tcq, int ndev,
- scsi_completionfn complete);
+void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
+ scsi_completionfn complete);
void scsi_qdev_register(SCSIDeviceInfo *info);
static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index aa0ce6a..6b9c8a5 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -45,7 +45,7 @@ typedef struct {
uint32_t data_len;
uint32_t residue;
uint32_t tag;
- SCSIBus *bus;
+ SCSIBus bus;
DriveInfo *dinfo;
SCSIDevice *scsi_dev;
int result;
@@ -527,8 +527,8 @@ static int usb_msd_initfn(USBDevice *dev)
}
s->dev.speed = USB_SPEED_FULL;
- s->bus = scsi_bus_new(&s->dev.qdev, 0, 1, usb_msd_command_complete);
- s->scsi_dev = scsi_bus_legacy_add_drive(s->bus, s->dinfo, 0);
+ scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete);
+ s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, s->dinfo, 0);
usb_msd_handle_reset(dev);
return 0;
}
--
1.6.2.5
next prev parent reply other threads:[~2009-09-18 9:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 9:24 [Qemu-devel] [PATCH 0/8] qdev: allow embedded bus structs Gerd Hoffmann
2009-09-18 9:24 ` [Qemu-devel] [PATCH 1/8] allow qdev busses allocations be inplace Gerd Hoffmann
2009-09-18 9:24 ` [Qemu-devel] [PATCH 2/8] qdev: device free fixups Gerd Hoffmann
2009-09-18 9:24 ` Gerd Hoffmann [this message]
2009-09-18 9:24 ` [Qemu-devel] [PATCH 4/8] switch usb bus to inplace allocation Gerd Hoffmann
2009-09-18 9:24 ` [Qemu-devel] [PATCH 5/8] switch ide " Gerd Hoffmann
2009-09-18 9:24 ` [Qemu-devel] [PATCH 6/8] support inplace allocation for pci bus, split irq init Gerd Hoffmann
2009-09-18 9:24 ` [Qemu-devel] [PATCH 7/8] convert pci bridge to qdev Gerd Hoffmann
2009-09-18 9:24 ` [Qemu-devel] [PATCH 8/8] piix_pci: kill PIIX3IrqState Gerd Hoffmann
2009-09-18 22:15 ` [Qemu-devel] [PATCH 0/8] qdev: allow embedded bus structs Markus Armbruster
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=1253265851-28919-4-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--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).