diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-11 17:54:00 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-11 17:54:00 -0400 |
commit | f44ae58a273b1b051122784a159ad608b7205afd (patch) | |
tree | df16a35742b10c7eff79cbb10294b92aa45e263a /drivers/ide | |
parent | ca1997c1f35891b9e5d6c71ac587f97216886194 (diff) |
icside: fix ->speedproc to return on unsupported modes (take 5)
* All other implementations of ->speedproc return zero on success
and non-zero on failure. Currently it doesn't matter for icside host
driver and isn't a bug per se since:
- ide_set_xfer_rate() return value is ignored by all IDE core users
- icside doesn't (yet!) use ide_tune_dma() in icside_dma_check()
but sooner or later we will need to fix anyway - so lets do it now.
* icside_set_speed() happily accepts unsupported transfer modes which
results in drive->drive_data being set to the maximum value (480)
and drive->current_speed being set to the unsupported transfer mode.
Fix it.
v2:
* The initial version of the patch was broken because it didn't take into
the account (the different from usual) return values of icside_set_speed()
(Noticed by Russell).
v3:
* Remove no longer needed initialization/checking of cycle_time
(Noticed by Sergei).
* No need to set drive->drive_data if DMA is not going to be used
(Noticed by Sergei).
* Remove incorrect setting of drive->current_speed
(Noticed by Sergei).
* Move ide_config_drive_speed() at the end of icside_set_speed().
v4:
* If DMA mode is not found in icside_dma_check() then just return "-1" and
don't call icside_set_speed() (v3 got it wrong and "1" was returned instead).
v5:
* Return "-1"/"0" in icside_set_speed() instead of icside_dma_check() return
value (just like it was before this patch).
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/arm/icside.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 99a27f2dc03a..7912a471f10d 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -250,7 +250,7 @@ static void icside_build_sglist(ide_drive_t *drive, struct request *rq) | |||
250 | */ | 250 | */ |
251 | static int icside_set_speed(ide_drive_t *drive, const u8 xfer_mode) | 251 | static int icside_set_speed(ide_drive_t *drive, const u8 xfer_mode) |
252 | { | 252 | { |
253 | int on = 0, cycle_time = 0, use_dma_info = 0; | 253 | int cycle_time, use_dma_info = 0; |
254 | 254 | ||
255 | switch (xfer_mode) { | 255 | switch (xfer_mode) { |
256 | case XFER_MW_DMA_2: | 256 | case XFER_MW_DMA_2: |
@@ -272,6 +272,8 @@ static int icside_set_speed(ide_drive_t *drive, const u8 xfer_mode) | |||
272 | case XFER_SW_DMA_0: | 272 | case XFER_SW_DMA_0: |
273 | cycle_time = 480; | 273 | cycle_time = 480; |
274 | break; | 274 | break; |
275 | default: | ||
276 | return 1; | ||
275 | } | 277 | } |
276 | 278 | ||
277 | /* | 279 | /* |
@@ -283,17 +285,10 @@ static int icside_set_speed(ide_drive_t *drive, const u8 xfer_mode) | |||
283 | 285 | ||
284 | drive->drive_data = cycle_time; | 286 | drive->drive_data = cycle_time; |
285 | 287 | ||
286 | if (cycle_time && ide_config_drive_speed(drive, xfer_mode) == 0) | ||
287 | on = 1; | ||
288 | else | ||
289 | drive->drive_data = 480; | ||
290 | |||
291 | printk("%s: %s selected (peak %dMB/s)\n", drive->name, | 288 | printk("%s: %s selected (peak %dMB/s)\n", drive->name, |
292 | ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); | 289 | ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); |
293 | 290 | ||
294 | drive->current_speed = xfer_mode; | 291 | return ide_config_drive_speed(drive, xfer_mode); |
295 | |||
296 | return on; | ||
297 | } | 292 | } |
298 | 293 | ||
299 | static void icside_dma_host_off(ide_drive_t *drive) | 294 | static void icside_dma_host_off(ide_drive_t *drive) |
@@ -320,8 +315,7 @@ static int icside_dma_check(ide_drive_t *drive) | |||
320 | { | 315 | { |
321 | struct hd_driveid *id = drive->id; | 316 | struct hd_driveid *id = drive->id; |
322 | ide_hwif_t *hwif = HWIF(drive); | 317 | ide_hwif_t *hwif = HWIF(drive); |
323 | int xfer_mode = XFER_PIO_2; | 318 | int xfer_mode = 0; |
324 | int on; | ||
325 | 319 | ||
326 | if (!(id->capability & 1) || !hwif->autodma) | 320 | if (!(id->capability & 1) || !hwif->autodma) |
327 | goto out; | 321 | goto out; |
@@ -350,9 +344,10 @@ static int icside_dma_check(ide_drive_t *drive) | |||
350 | } | 344 | } |
351 | 345 | ||
352 | out: | 346 | out: |
353 | on = icside_set_speed(drive, xfer_mode); | 347 | if (xfer_mode == 0) |
348 | return -1; | ||
354 | 349 | ||
355 | return on ? 0 : -1; | 350 | return icside_set_speed(drive, xfer_mode) ? -1 : 0; |
356 | } | 351 | } |
357 | 352 | ||
358 | static int icside_dma_end(ide_drive_t *drive) | 353 | static int icside_dma_end(ide_drive_t *drive) |