提交 8337606d 编写于 作者: K Kevin Wolf

ide: Factor ide_dma_set_inactive out

Several places that stop a DMA transfer duplicate this code. Factor it out into
a common function.
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 11a3cb81
...@@ -473,6 +473,14 @@ static void dma_buf_commit(IDEState *s, int is_write) ...@@ -473,6 +473,14 @@ static void dma_buf_commit(IDEState *s, int is_write)
qemu_sglist_destroy(&s->sg); qemu_sglist_destroy(&s->sg);
} }
static void ide_dma_set_inactive(BMDMAState *bm)
{
bm->status &= ~BM_STATUS_DMAING;
bm->dma_cb = NULL;
bm->unit = -1;
bm->aiocb = NULL;
}
void ide_dma_error(IDEState *s) void ide_dma_error(IDEState *s)
{ {
ide_transfer_stop(s); ide_transfer_stop(s);
...@@ -587,11 +595,8 @@ static void ide_read_dma_cb(void *opaque, int ret) ...@@ -587,11 +595,8 @@ static void ide_read_dma_cb(void *opaque, int ret)
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus); ide_set_irq(s->bus);
eot: eot:
bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
bm->dma_cb = NULL; ide_dma_set_inactive(bm);
bm->unit = -1;
bm->aiocb = NULL;
return; return;
} }
...@@ -733,11 +738,8 @@ static void ide_write_dma_cb(void *opaque, int ret) ...@@ -733,11 +738,8 @@ static void ide_write_dma_cb(void *opaque, int ret)
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus); ide_set_irq(s->bus);
eot: eot:
bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
bm->dma_cb = NULL; ide_dma_set_inactive(bm);
bm->unit = -1;
bm->aiocb = NULL;
return; return;
} }
...@@ -1061,11 +1063,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) ...@@ -1061,11 +1063,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s->bus); ide_set_irq(s->bus);
eot: eot:
bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
bm->dma_cb = NULL; ide_dma_set_inactive(bm);
bm->unit = -1;
bm->aiocb = NULL;
return; return;
} }
...@@ -2954,12 +2953,10 @@ void ide_dma_cancel(BMDMAState *bm) ...@@ -2954,12 +2953,10 @@ void ide_dma_cancel(BMDMAState *bm)
printf("aio_cancel\n"); printf("aio_cancel\n");
#endif #endif
bdrv_aio_cancel(bm->aiocb); bdrv_aio_cancel(bm->aiocb);
bm->aiocb = NULL;
} }
bm->status &= ~BM_STATUS_DMAING;
/* cancel DMA request */ /* cancel DMA request */
bm->unit = -1; ide_dma_set_inactive(bm);
bm->dma_cb = NULL;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册