diff mbox

[1/4] SCSI-hotdel: Add detach method to LSI SCSI driver

Message ID 1253287594-12905-2-git-send-email-wolfgang.mauerer@siemens.com
State Superseded
Headers show

Commit Message

Wolfgang Mauerer Sept. 18, 2009, 3:26 p.m. UTC
Introduce lsi_scsi_detach, which destroys and de-registers
a device from the LSI SCSI host

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/lsi53c895a.c |   16 ++++++++++++++++
 hw/pci.h        |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)

Comments

Gerd Hoffmann Sept. 21, 2009, 7:46 a.m. UTC | #1
> diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
> index 62bdca8..7e975b4 100644
> --- a/hw/lsi53c895a.c
> +++ b/hw/lsi53c895a.c
> @@ -1959,6 +1959,22 @@ static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
>       cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr);
>   }
>
> +void lsi_scsi_detach(DeviceState *host, BlockDriverState *bd, int id)
> +{
> +    LSIState *s = (LSIState *)host;
> +
> +    if (id>= LSI_MAX_DEVS || id<  0) {
> +        BADF("Bad Device ID %d\n", id);
> +        return;
> +    }
> +
> +    if (s->bus->devs[id]) {
> +        DPRINTF("Destroying device %d\n", id);
> +        s->bus->devs[id]->info->destroy(s->bus->devs[id]);
> +    }
> +    s->bus->devs[id] = NULL;
> +}
> +

Wrong place.  It should go to scsi-bus.c, it is the reverse of the 
scsi_qdev_init function.

cheers,
   Gerd
diff mbox

Patch

diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 62bdca8..7e975b4 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -1959,6 +1959,22 @@  static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
     cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr);
 }
 
+void lsi_scsi_detach(DeviceState *host, BlockDriverState *bd, int id)
+{
+    LSIState *s = (LSIState *)host;
+
+    if (id >= LSI_MAX_DEVS || id < 0) {
+        BADF("Bad Device ID %d\n", id);
+        return;
+    }
+
+    if (s->bus->devs[id]) {
+        DPRINTF("Destroying device %d\n", id);
+        s->bus->devs[id]->info->destroy(s->bus->devs[id]);
+    }
+    s->bus->devs[id] = NULL;
+}
+
 static void lsi_scsi_save(QEMUFile *f, void *opaque)
 {
     LSIState *s = opaque;
diff --git a/hw/pci.h b/hw/pci.h
index 4e901be..1127c87 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -382,6 +382,7 @@  PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
 
 /* lsi53c895a.c */
 #define LSI_MAX_DEVS 7
+void lsi_scsi_detach(DeviceState *host, BlockDriverState *bd, int id);
 
 /* vmware_vga.c */
 void pci_vmsvga_init(PCIBus *bus);