From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13Xa-0007oE-8b for qemu-devel@nongnu.org; Tue, 16 Dec 2014 20:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y13XT-0002TL-Dv for qemu-devel@nongnu.org; Tue, 16 Dec 2014 20:36:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13XT-0002TH-73 for qemu-devel@nongnu.org; Tue, 16 Dec 2014 20:36:31 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBH1aUYg006981 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 16 Dec 2014 20:36:30 -0500 From: John Snow Date: Tue, 16 Dec 2014 20:35:53 -0500 Message-Id: <1418780167-16231-4-git-send-email-jsnow@redhat.com> In-Reply-To: <1418780167-16231-1-git-send-email-jsnow@redhat.com> References: <1418780167-16231-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH v2 03/17] ide: introduce ide_register_restart_cb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow From: Paolo Bonzini A helper is added that registers the IDEDMAOp .restart_cb() via qemu_add_vm_change_state_handler instead of requiring each HBA to register the callback themselves. Signed-off-by: Paolo Bonzini Signed-off-by: John Snow --- hw/ide/cmd646.c | 3 +-- hw/ide/core.c | 5 +++++ hw/ide/internal.h | 1 + hw/ide/piix.c | 3 +-- hw/ide/via.c | 3 +-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index c8b0322..0374653 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -368,8 +368,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; - qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, - &d->bmdma[i].dma); + ide_register_restart_cb(&d->bus[i]); } vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d); diff --git a/hw/ide/core.c b/hw/ide/core.c index d4af5e2..179a001 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2330,6 +2330,11 @@ static const IDEDMAOps ide_dma_nop_ops = { .restart_cb = ide_nop_restart, }; +void ide_register_restart_cb(IDEBus *bus) +{ + qemu_add_vm_change_state_handler(bus->dma->ops->restart_cb, bus->dma); +} + static IDEDMA ide_dma_nop = { .ops = &ide_dma_nop_ops, .aiocb = NULL, diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 59e24e2..73c5e63 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -548,6 +548,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, int chs_trans); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); +void ide_register_restart_cb(IDEBus *bus); void ide_exec_cmd(IDEBus *bus, uint32_t val); void ide_dma_cb(void *opaque, int ret); diff --git a/hw/ide/piix.c b/hw/ide/piix.c index b0172fb..247dd4f 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -143,8 +143,7 @@ static void pci_piix_init_ports(PCIIDEState *d) { bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; - qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, - &d->bmdma[i].dma); + ide_register_restart_cb(&d->bus[i]); } } diff --git a/hw/ide/via.c b/hw/ide/via.c index 4d8089d..fb3d8a0 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -166,8 +166,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) { bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; - qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, - &d->bmdma[i].dma); + ide_register_restart_cb(&d->bus[i]); } } -- 1.9.3