From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UorFD-0007r5-7w for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:26:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UorF8-0005jq-LA for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:26:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UorF8-0005jm-Cx for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:26:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5I8QLLL011625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jun 2013 04:26:21 -0400 From: Kevin Wolf Date: Tue, 18 Jun 2013 10:25:56 +0200 Message-Id: <1371543971-23241-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1371543971-23241-1-git-send-email-kwolf@redhat.com> References: <1371543971-23241-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 02/17] ide: Convert WIN_DSM to ide_cmd_table handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com Signed-off-by: Kevin Wolf --- hw/ide/core.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index cd9de14..567515e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1004,6 +1004,21 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) } } +static bool cmd_data_set_management(IDEState *s, uint8_t cmd) +{ + switch (s->feature) { + case DSM_TRIM: + if (s->bs) { + ide_sector_start_dma(s, IDE_DMA_TRIM); + return false; + } + break; + } + + ide_abort_command(s); + return true; +} + #define HD_OK (1u << IDE_HD) #define CD_OK (1u << IDE_CD) #define CFA_OK (1u << IDE_CFATA) @@ -1021,7 +1036,7 @@ static const struct { } ide_cmd_table[0x100] = { /* NOP not implemented, mandatory for CD */ [CFA_REQ_EXT_ERROR_CODE] = { NULL, CFA_OK }, - [WIN_DSM] = { NULL, ALL_OK }, + [WIN_DSM] = { cmd_data_set_management, ALL_OK }, [WIN_DEVICE_RESET] = { NULL, CD_OK }, [WIN_RECAL] = { NULL, HD_CFA_OK }, [WIN_READ] = { NULL, ALL_OK }, @@ -1129,18 +1144,6 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val) } switch(val) { - case WIN_DSM: - switch (s->feature) { - case DSM_TRIM: - if (!s->bs) { - goto abort_cmd; - } - ide_sector_start_dma(s, IDE_DMA_TRIM); - break; - default: - goto abort_cmd; - } - break; case WIN_IDENTIFY: if (s->bs && s->drive_kind != IDE_CD) { if (s->drive_kind != IDE_CFATA) -- 1.8.1.4