[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/12] ide: cmd646 we can get the pci device with co
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 10/12] ide: cmd646 we can get the pci device with container_of |
Date: |
Wed, 7 Oct 2009 16:56:27 +0200 |
Signed-off-by: Juan Quintela <address@hidden>
---
hw/ide/cmd646.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 37cfe01..a36c3b5 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -68,10 +68,19 @@ static void ide_map(PCIDevice *pci_dev, int region_num,
}
}
+static PCIIDEState *pci_from_bm(BMDMAState *bm)
+{
+ if (bm->unit == 0) {
+ return container_of(bm, PCIIDEState, bmdma[0]);
+ } else {
+ return container_of(bm, PCIIDEState, bmdma[1]);
+ }
+}
+
static uint32_t bmdma_readb(void *opaque, uint32_t addr)
{
BMDMAState *bm = opaque;
- PCIIDEState *pci_dev;
+ PCIIDEState *pci_dev = pci_from_bm(bm);
uint32_t val;
switch(addr & 3) {
@@ -79,14 +88,12 @@ static uint32_t bmdma_readb(void *opaque, uint32_t addr)
val = bm->cmd;
break;
case 1:
- pci_dev = bm->pci_dev;
val = pci_dev->dev.config[MRDMODE];
break;
case 2:
val = bm->status;
break;
case 3:
- pci_dev = bm->pci_dev;
if (bm == &pci_dev->bmdma[0]) {
val = pci_dev->dev.config[UDIDETCR0];
} else {
@@ -106,13 +113,12 @@ static uint32_t bmdma_readb(void *opaque, uint32_t addr)
static void bmdma_writeb(void *opaque, uint32_t addr, uint32_t val)
{
BMDMAState *bm = opaque;
- PCIIDEState *pci_dev;
+ PCIIDEState *pci_dev = pci_from_bm(bm);
#ifdef DEBUG_IDE
printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val);
#endif
switch(addr & 3) {
case 1:
- pci_dev = bm->pci_dev;
pci_dev->dev.config[MRDMODE] =
(pci_dev->dev.config[MRDMODE] & ~0x30) | (val & 0x30);
cmd646_update_irq(pci_dev);
@@ -121,7 +127,6 @@ static void bmdma_writeb(void *opaque, uint32_t addr,
uint32_t val)
bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val &
0x06);
break;
case 3:
- pci_dev = bm->pci_dev;
if (bm == &pci_dev->bmdma[0])
pci_dev->dev.config[UDIDETCR0] = val;
else
--
1.6.2.5
- [Qemu-devel] [PATCH 00/12] PCI IDE cleanup, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 01/12] ide: change cast to DO_UPCAST, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 02/12] ide: Remove cast in pci_register_bar, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 03/12] ide: Remove duplicated definitions, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 04/12] ide: remove uselsess casts from void *, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 06/12] ide: export needed ide-pci functions for split, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 05/12] ide: create ide/pci.h for common ide pci definitions, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 07/12] ide: split cmd646 and piix from pci.c, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 08/12] ide: PCIIDEState type field is not needed anymore, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 09/12] ide: 'secondary' field is only used by cmd646, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 10/12] ide: cmd646 we can get the pci device with container_of,
Juan Quintela <=
- [Qemu-devel] [PATCH 12/12] ide: BMDMAState don't need a pci_dev field anymore, Juan Quintela, 2009/10/07
- [Qemu-devel] [PATCH 11/12] ide: cmd646 ->unit has just the value that we want, Juan Quintela, 2009/10/07