diff options
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r-- | drivers/ide/ide-lib.c | 24 |
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); void ide_set_pio(ide_drive_t *drive, u8 req_pio) { ide_hwif_t *hwif = drive->hwif; + const struct ide_port_ops *port_ops = hwif->port_ops; u8 host_pio, pio; - if (hwif->set_pio_mode == NULL || + if (port_ops == NULL || port_ops->set_pio_mode == NULL || (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) return; @@ -343,29 +344,30 @@ void ide_toggle_bounce(ide_drive_t *drive, int on) int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) { ide_hwif_t *hwif = drive->hwif; + const struct ide_port_ops *port_ops = hwif->port_ops; if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) return 0; - if (hwif->set_pio_mode == NULL) + if (port_ops == NULL || port_ops->set_pio_mode == NULL) return -1; /* * TODO: temporary hack for some legacy host drivers that didn't * set transfer mode on the device in ->set_pio_mode method... */ - if (hwif->set_dma_mode == NULL) { - hwif->set_pio_mode(drive, mode - XFER_PIO_0); + if (port_ops->set_dma_mode == NULL) { + port_ops->set_pio_mode(drive, mode - XFER_PIO_0); return 0; } if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { if (ide_config_drive_speed(drive, mode)) return -1; - hwif->set_pio_mode(drive, mode - XFER_PIO_0); + port_ops->set_pio_mode(drive, mode - XFER_PIO_0); return 0; } else { - hwif->set_pio_mode(drive, mode - XFER_PIO_0); + port_ops->set_pio_mode(drive, mode - XFER_PIO_0); return ide_config_drive_speed(drive, mode); } } @@ -373,20 +375,21 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) { ide_hwif_t *hwif = drive->hwif; + const struct ide_port_ops *port_ops = hwif->port_ops; if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) return 0; - if (hwif->set_dma_mode == NULL) + if (port_ops == NULL || port_ops->set_dma_mode == NULL) return -1; if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { if (ide_config_drive_speed(drive, mode)) return -1; - hwif->set_dma_mode(drive, mode); + port_ops->set_dma_mode(drive, mode); return 0; } else { - hwif->set_dma_mode(drive, mode); + port_ops->set_dma_mode(drive, mode); return ide_config_drive_speed(drive, mode); } } @@ -406,8 +409,9 @@ EXPORT_SYMBOL_GPL(ide_set_dma_mode); int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) { ide_hwif_t *hwif = drive->hwif; + const struct ide_port_ops *port_ops = hwif->port_ops; - if (hwif->set_dma_mode == NULL || + if (port_ops == NULL || port_ops->set_dma_mode == NULL || (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) return -1; |