ide: sanitize handling of IDE_HFLAG_NO_SET_MODE host flag

* Check for IDE_HFLAG_NO_SET_MODE host flag in ide_set_pio(),
  ide_set_[pio,dma]_mode(), ide_set_xfer_rate() and set_pio_mode().

* Remove no longer needed IDE_HFLAG_NO_SET_MODE host flag checking
  from ide_tune_dma().

* Remove superfluous ->set_pio_mode checking from do_special().

This is a part of preparations for adding 'struct ide_port_ops'.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 4764b684
...@@ -706,9 +706,6 @@ static int ide_tune_dma(ide_drive_t *drive) ...@@ -706,9 +706,6 @@ static int ide_tune_dma(ide_drive_t *drive)
if (!speed) if (!speed)
return 0; return 0;
if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
return 1;
if (ide_set_dma_mode(drive, speed)) if (ide_set_dma_mode(drive, speed))
return 0; return 0;
......
...@@ -726,10 +726,6 @@ static ide_startstop_t do_special (ide_drive_t *drive) ...@@ -726,10 +726,6 @@ static ide_startstop_t do_special (ide_drive_t *drive)
s->b.set_tune = 0; s->b.set_tune = 0;
if (set_pio_mode_abuse(drive->hwif, req_pio)) { if (set_pio_mode_abuse(drive->hwif, req_pio)) {
if (hwif->set_pio_mode == NULL)
return ide_stopped;
/* /*
* take ide_lock for drive->[no_]unmask/[no_]io_32bit * take ide_lock for drive->[no_]unmask/[no_]io_32bit
*/ */
......
...@@ -290,7 +290,8 @@ void ide_set_pio(ide_drive_t *drive, u8 req_pio) ...@@ -290,7 +290,8 @@ void ide_set_pio(ide_drive_t *drive, u8 req_pio)
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
u8 host_pio, pio; u8 host_pio, pio;
if (hwif->set_pio_mode == NULL) if (hwif->set_pio_mode == NULL ||
(hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
return; return;
BUG_ON(hwif->pio_mask == 0x00); BUG_ON(hwif->pio_mask == 0x00);
...@@ -343,6 +344,9 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) ...@@ -343,6 +344,9 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
return 0;
if (hwif->set_pio_mode == NULL) if (hwif->set_pio_mode == NULL)
return -1; return -1;
...@@ -370,6 +374,9 @@ int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) ...@@ -370,6 +374,9 @@ int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
return 0;
if (hwif->set_dma_mode == NULL) if (hwif->set_dma_mode == NULL)
return -1; return -1;
...@@ -400,7 +407,8 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) ...@@ -400,7 +407,8 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
if (hwif->set_dma_mode == NULL) if (hwif->set_dma_mode == NULL ||
(hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
return -1; return -1;
rate = ide_rate_filter(drive, rate); rate = ide_rate_filter(drive, rate);
......
...@@ -584,11 +584,13 @@ out: ...@@ -584,11 +584,13 @@ out:
int set_pio_mode(ide_drive_t *drive, int arg) int set_pio_mode(ide_drive_t *drive, int arg)
{ {
struct request rq; struct request rq;
ide_hwif_t *hwif = drive->hwif;
if (arg < 0 || arg > 255) if (arg < 0 || arg > 255)
return -EINVAL; return -EINVAL;
if (drive->hwif->set_pio_mode == NULL) if (hwif->set_pio_mode == NULL ||
(hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
return -ENOSYS; return -ENOSYS;
if (drive->special.b.set_tune) if (drive->special.b.set_tune)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment