aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 7031a8dcf692..6f04ea3e93a8 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -85,7 +85,7 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
85 mode = XFER_PIO_4; 85 mode = XFER_PIO_4;
86 } 86 }
87 87
88// printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); 88/* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */
89 89
90 return min(speed, mode); 90 return min(speed, mode);
91} 91}
@@ -274,16 +274,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
274 if (overridden) 274 if (overridden)
275 printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n", 275 printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n",
276 drive->name); 276 drive->name);
277
278 /*
279 * Conservative "downgrade" for all pre-ATA2 drives
280 */
281 if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 &&
282 pio_mode && pio_mode < 4) {
283 pio_mode--;
284 printk(KERN_INFO "%s: applying conservative "
285 "PIO \"downgrade\"\n", drive->name);
286 }
287 } 277 }
288 278
289 if (pio_mode > max_mode) 279 if (pio_mode > max_mode)
@@ -298,9 +288,11 @@ EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
298void ide_set_pio(ide_drive_t *drive, u8 req_pio) 288void ide_set_pio(ide_drive_t *drive, u8 req_pio)
299{ 289{
300 ide_hwif_t *hwif = drive->hwif; 290 ide_hwif_t *hwif = drive->hwif;
291 const struct ide_port_ops *port_ops = hwif->port_ops;
301 u8 host_pio, pio; 292 u8 host_pio, pio;
302 293
303 if (hwif->set_pio_mode == NULL) 294 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
295 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
304 return; 296 return;
305 297
306 BUG_ON(hwif->pio_mask == 0x00); 298 BUG_ON(hwif->pio_mask == 0x00);
@@ -352,26 +344,30 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
352int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) 344int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
353{ 345{
354 ide_hwif_t *hwif = drive->hwif; 346 ide_hwif_t *hwif = drive->hwif;
347 const struct ide_port_ops *port_ops = hwif->port_ops;
348
349 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
350 return 0;
355 351
356 if (hwif->set_pio_mode == NULL) 352 if (port_ops == NULL || port_ops->set_pio_mode == NULL)
357 return -1; 353 return -1;
358 354
359 /* 355 /*
360 * TODO: temporary hack for some legacy host drivers that didn't 356 * TODO: temporary hack for some legacy host drivers that didn't
361 * set transfer mode on the device in ->set_pio_mode method... 357 * set transfer mode on the device in ->set_pio_mode method...
362 */ 358 */
363 if (hwif->set_dma_mode == NULL) { 359 if (port_ops->set_dma_mode == NULL) {
364 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 360 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
365 return 0; 361 return 0;
366 } 362 }
367 363
368 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 364 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
369 if (ide_config_drive_speed(drive, mode)) 365 if (ide_config_drive_speed(drive, mode))
370 return -1; 366 return -1;
371 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 367 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
372 return 0; 368 return 0;
373 } else { 369 } else {
374 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 370 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
375 return ide_config_drive_speed(drive, mode); 371 return ide_config_drive_speed(drive, mode);
376 } 372 }
377} 373}
@@ -379,17 +375,21 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
379int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) 375int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
380{ 376{
381 ide_hwif_t *hwif = drive->hwif; 377 ide_hwif_t *hwif = drive->hwif;
378 const struct ide_port_ops *port_ops = hwif->port_ops;
379
380 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
381 return 0;
382 382
383 if (hwif->set_dma_mode == NULL) 383 if (port_ops == NULL || port_ops->set_dma_mode == NULL)
384 return -1; 384 return -1;
385 385
386 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 386 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
387 if (ide_config_drive_speed(drive, mode)) 387 if (ide_config_drive_speed(drive, mode))
388 return -1; 388 return -1;
389 hwif->set_dma_mode(drive, mode); 389 port_ops->set_dma_mode(drive, mode);
390 return 0; 390 return 0;
391 } else { 391 } else {
392 hwif->set_dma_mode(drive, mode); 392 port_ops->set_dma_mode(drive, mode);
393 return ide_config_drive_speed(drive, mode); 393 return ide_config_drive_speed(drive, mode);
394 } 394 }
395} 395}
@@ -409,8 +409,10 @@ EXPORT_SYMBOL_GPL(ide_set_dma_mode);
409int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) 409int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
410{ 410{
411 ide_hwif_t *hwif = drive->hwif; 411 ide_hwif_t *hwif = drive->hwif;
412 const struct ide_port_ops *port_ops = hwif->port_ops;
412 413
413 if (hwif->set_dma_mode == NULL) 414 if (port_ops == NULL || port_ops->set_dma_mode == NULL ||
415 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
414 return -1; 416 return -1;
415 417
416 rate = ide_rate_filter(drive, rate); 418 rate = ide_rate_filter(drive, rate);