diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-31 14:15:21 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-31 14:15:21 -0400 |
commit | 8a4a5738ba499083cf4c5668895efe220b1946d3 (patch) | |
tree | 78272b711b31f43526d2c665478cc3bdb0b6e393 /drivers/ide | |
parent | 7526efaafdc835b8d6b22aa1a302e14651373908 (diff) |
ide: add ->dma_check method
* Add (an optional) ->dma_check method for checking if DMA can be
used for a given command and fail DMA setup in ide_dma_prepare()
if necessary.
* Convert alim15x3 and trm290 host drivers to use ->dma_check.
* Rename ali15x3_dma_setup() to ali_dma_check() while at it.
There should be no functional changes caused by this patch.
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/alim15x3.c | 9 | ||||
-rw-r--r-- | drivers/ide/ide-dma.c | 5 | ||||
-rw-r--r-- | drivers/ide/trm290.c | 17 |
3 files changed, 19 insertions, 12 deletions
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index d3faf0b97f42..537da1cde16d 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c | |||
@@ -189,20 +189,20 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
189 | } | 189 | } |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * ali15x3_dma_setup - begin a DMA phase | 192 | * ali_dma_check - DMA check |
193 | * @drive: target device | 193 | * @drive: target device |
194 | * @cmd: command | 194 | * @cmd: command |
195 | * | 195 | * |
196 | * Returns 1 if the DMA cannot be performed, zero on success. | 196 | * Returns 1 if the DMA cannot be performed, zero on success. |
197 | */ | 197 | */ |
198 | 198 | ||
199 | static int ali15x3_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) | 199 | static int ali_dma_check(ide_drive_t *drive, struct ide_cmd *cmd) |
200 | { | 200 | { |
201 | if (m5229_revision < 0xC2 && drive->media != ide_disk) { | 201 | if (m5229_revision < 0xC2 && drive->media != ide_disk) { |
202 | if (cmd->tf_flags & IDE_TFLAG_WRITE) | 202 | if (cmd->tf_flags & IDE_TFLAG_WRITE) |
203 | return 1; /* try PIO instead of DMA */ | 203 | return 1; /* try PIO instead of DMA */ |
204 | } | 204 | } |
205 | return ide_dma_setup(drive, cmd); | 205 | return 0; |
206 | } | 206 | } |
207 | 207 | ||
208 | /** | 208 | /** |
@@ -503,11 +503,12 @@ static const struct ide_port_ops ali_port_ops = { | |||
503 | 503 | ||
504 | static const struct ide_dma_ops ali_dma_ops = { | 504 | static const struct ide_dma_ops ali_dma_ops = { |
505 | .dma_host_set = ide_dma_host_set, | 505 | .dma_host_set = ide_dma_host_set, |
506 | .dma_setup = ali15x3_dma_setup, | 506 | .dma_setup = ide_dma_setup, |
507 | .dma_start = ide_dma_start, | 507 | .dma_start = ide_dma_start, |
508 | .dma_end = ide_dma_end, | 508 | .dma_end = ide_dma_end, |
509 | .dma_test_irq = ide_dma_test_irq, | 509 | .dma_test_irq = ide_dma_test_irq, |
510 | .dma_lost_irq = ide_dma_lost_irq, | 510 | .dma_lost_irq = ide_dma_lost_irq, |
511 | .dma_check = ali_dma_check, | ||
511 | .dma_timer_expiry = ide_dma_sff_timer_expiry, | 512 | .dma_timer_expiry = ide_dma_sff_timer_expiry, |
512 | .dma_sff_read_status = ide_dma_sff_read_status, | 513 | .dma_sff_read_status = ide_dma_sff_read_status, |
513 | }; | 514 | }; |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index cf5897f5533f..c0505e2dfc2e 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -566,9 +566,12 @@ EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); | |||
566 | 566 | ||
567 | int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd) | 567 | int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd) |
568 | { | 568 | { |
569 | const struct ide_dma_ops *dma_ops = drive->hwif->dma_ops; | ||
570 | |||
569 | if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || | 571 | if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || |
572 | (dma_ops->dma_check && dma_ops->dma_check(drive, cmd)) || | ||
570 | ide_build_sglist(drive, cmd) == 0 || | 573 | ide_build_sglist(drive, cmd) == 0 || |
571 | drive->hwif->dma_ops->dma_setup(drive, cmd)) | 574 | dma_ops->dma_setup(drive, cmd)) |
572 | return 1; | 575 | return 1; |
573 | return 0; | 576 | return 0; |
574 | } | 577 | } |
diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c index b91bb709af40..1076efd050dc 100644 --- a/drivers/ide/trm290.c +++ b/drivers/ide/trm290.c | |||
@@ -176,19 +176,21 @@ static void trm290_selectproc (ide_drive_t *drive) | |||
176 | trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA)); | 176 | trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA)); |
177 | } | 177 | } |
178 | 178 | ||
179 | static int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) | 179 | static int trm290_dma_check(ide_drive_t *drive, struct ide_cmd *cmd) |
180 | { | 180 | { |
181 | ide_hwif_t *hwif = drive->hwif; | ||
182 | unsigned int count, rw; | ||
183 | |||
184 | if (cmd->tf_flags & IDE_TFLAG_WRITE) { | 181 | if (cmd->tf_flags & IDE_TFLAG_WRITE) { |
185 | #ifdef TRM290_NO_DMA_WRITES | 182 | #ifdef TRM290_NO_DMA_WRITES |
186 | /* always use PIO for writes */ | 183 | /* always use PIO for writes */ |
187 | return 1; | 184 | return 1; |
188 | #endif | 185 | #endif |
189 | rw = 1; | 186 | } |
190 | } else | 187 | return 0; |
191 | rw = 2; | 188 | } |
189 | |||
190 | static int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) | ||
191 | { | ||
192 | ide_hwif_t *hwif = drive->hwif; | ||
193 | unsigned int count, rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 2; | ||
192 | 194 | ||
193 | count = ide_build_dmatable(drive, cmd); | 195 | count = ide_build_dmatable(drive, cmd); |
194 | if (count == 0) { | 196 | if (count == 0) { |
@@ -312,6 +314,7 @@ static struct ide_dma_ops trm290_dma_ops = { | |||
312 | .dma_end = trm290_dma_end, | 314 | .dma_end = trm290_dma_end, |
313 | .dma_test_irq = trm290_dma_test_irq, | 315 | .dma_test_irq = trm290_dma_test_irq, |
314 | .dma_lost_irq = ide_dma_lost_irq, | 316 | .dma_lost_irq = ide_dma_lost_irq, |
317 | .dma_check = trm290_dma_check, | ||
315 | }; | 318 | }; |
316 | 319 | ||
317 | static const struct ide_port_info trm290_chipset __devinitdata = { | 320 | static const struct ide_port_info trm290_chipset __devinitdata = { |