aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 16:25:14 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 16:25:14 -0400
commitac95beedf8bc97b24f9540d4da9952f07221c023 (patch)
treec29837142c8083b6fcaf1767abcb0a4533676cd1 /drivers/ide/ide-lib.c
parent4a27214d7be31e122db4102166f49ec15958e8e9 (diff)
ide: add struct ide_port_ops (take 2)
* Move hooks for port/host specific methods from ide_hwif_t to 'struct ide_port_ops'. * Add 'const struct ide_port_ops *port_ops' to 'struct ide_port_info' and ide_hwif_t. * Update host drivers and core code accordingly. While at it: * Rename ata66_*() cable detect functions to *_cable_detect() to match the standard naming. (Suggested by Sergei Shtylyov) v2: * Fix build for bast-ide. (Noticed by Andrew Morton) Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index c859de77aa8f..46443f163154 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -288,9 +288,10 @@ EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
288void ide_set_pio(ide_drive_t *drive, u8 req_pio) 288void ide_set_pio(ide_drive_t *drive, u8 req_pio)
289{ 289{
290 ide_hwif_t *hwif = drive->hwif; 290 ide_hwif_t *hwif = drive->hwif;
291 const struct ide_port_ops *port_ops = hwif->port_ops;
291 u8 host_pio, pio; 292 u8 host_pio, pio;
292 293
293 if (hwif->set_pio_mode == NULL || 294 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
294 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 295 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
295 return; 296 return;
296 297
@@ -343,29 +344,30 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
343int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) 344int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
344{ 345{
345 ide_hwif_t *hwif = drive->hwif; 346 ide_hwif_t *hwif = drive->hwif;
347 const struct ide_port_ops *port_ops = hwif->port_ops;
346 348
347 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 349 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
348 return 0; 350 return 0;
349 351
350 if (hwif->set_pio_mode == NULL) 352 if (port_ops == NULL || port_ops->set_pio_mode == NULL)
351 return -1; 353 return -1;
352 354
353 /* 355 /*
354 * TODO: temporary hack for some legacy host drivers that didn't 356 * TODO: temporary hack for some legacy host drivers that didn't
355 * set transfer mode on the device in ->set_pio_mode method... 357 * set transfer mode on the device in ->set_pio_mode method...
356 */ 358 */
357 if (hwif->set_dma_mode == NULL) { 359 if (port_ops->set_dma_mode == NULL) {
358 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 360 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
359 return 0; 361 return 0;
360 } 362 }
361 363
362 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 364 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
363 if (ide_config_drive_speed(drive, mode)) 365 if (ide_config_drive_speed(drive, mode))
364 return -1; 366 return -1;
365 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 367 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
366 return 0; 368 return 0;
367 } else { 369 } else {
368 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 370 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
369 return ide_config_drive_speed(drive, mode); 371 return ide_config_drive_speed(drive, mode);
370 } 372 }
371} 373}
@@ -373,20 +375,21 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
373int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) 375int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
374{ 376{
375 ide_hwif_t *hwif = drive->hwif; 377 ide_hwif_t *hwif = drive->hwif;
378 const struct ide_port_ops *port_ops = hwif->port_ops;
376 379
377 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 380 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
378 return 0; 381 return 0;
379 382
380 if (hwif->set_dma_mode == NULL) 383 if (port_ops == NULL || port_ops->set_dma_mode == NULL)
381 return -1; 384 return -1;
382 385
383 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 386 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
384 if (ide_config_drive_speed(drive, mode)) 387 if (ide_config_drive_speed(drive, mode))
385 return -1; 388 return -1;
386 hwif->set_dma_mode(drive, mode); 389 port_ops->set_dma_mode(drive, mode);
387 return 0; 390 return 0;
388 } else { 391 } else {
389 hwif->set_dma_mode(drive, mode); 392 port_ops->set_dma_mode(drive, mode);
390 return ide_config_drive_speed(drive, mode); 393 return ide_config_drive_speed(drive, mode);
391 } 394 }
392} 395}
@@ -406,8 +409,9 @@ EXPORT_SYMBOL_GPL(ide_set_dma_mode);
406int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) 409int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
407{ 410{
408 ide_hwif_t *hwif = drive->hwif; 411 ide_hwif_t *hwif = drive->hwif;
412 const struct ide_port_ops *port_ops = hwif->port_ops;
409 413
410 if (hwif->set_dma_mode == NULL || 414 if (port_ops == NULL || port_ops->set_dma_mode == NULL ||
411 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 415 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
412 return -1; 416 return -1;
413 417