ide: sanitize handling of IDE_HFLAG_NO_SET_MODE host flag
PATCH 3/4 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'.
--- drivers/ide/ide-dma.c | 3 --- drivers/ide/ide-io.c | 4 ---- drivers/ide/ide-lib.c | 12 ++++++++++-- drivers/ide/ide.c | 4 +++- 4 files changed, 13 insertions(+), 10 deletions(-)
drivers/ide/ide-dma.c +0 -3
@@ -706,9 +706,6 @@ static int ide_tune_dma(ide_drive_t *driif (!speed)return 0 ; -if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) -return 1 ; -if (ide_set_dma_mode (drive, speed))return 0 ;
drivers/ide/ide-io.c +0 -4
@@ -726,10 +726,6 @@ static ide_startstop_t do_special (ide_d s->b.set_tune =0 ;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 */
drivers/ide/ide-lib.c +10 -2
@@ -300,7 +300,8 @@ void ide_set_pio(ide_drive_t *drive, u8ide_hwif_t *hwif = drive->hwif;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 ;BUG_ON (hwif->pio_mask ==0x00 );
@@ -353,6 +354,9 @@ int ide_set_pio_mode(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif; +if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) +return 0 ; +if (hwif->set_pio_mode ==NULL )return -1 ;
@@ -380,6 +384,9 @@ int ide_set_dma_mode(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif; +if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) +return 0 ; +if (hwif->set_dma_mode ==NULL )return -1 ;
@@ -410,7 +417,8 @@ int ide_set_xfer_rate(ide_drive_t *drive {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 ; rate =ide_rate_filter (drive, rate);
drivers/ide/ide.c +3 -1
@@ -586,11 +586,13 @@ out:int set_pio_mode (ide_drive_t *drive,int arg) {struct request rq; +ide_hwif_t *hwif = drive->hwif;if (arg <0 || arg >255 )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 ;if (drive->special.b.set_tune)
Hello.
Quoted 17 lines · Bartlomiej Zolnierkiewicz
* Check for
IDE_HFLAG_NO_SET_MODEhost flag inide_set_pio(), ide_set_[pio,dma]_mode(),ide_set_xfer_rate()andset_pio_mode().* Remove no longer needed
IDE_HFLAG_NO_SET_MODEhost flag checking fromide_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 Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/ide-lib.c
===================================================================
drivers/ide/ide-lib.c int ide_set_pio_mode(ide_drive_t *drive, · line 359
Quoted 6 lines
drivers/ide/ide-lib.c +3
-0@@ -353,6 +354,9 @@ int ide_set_pio_mode(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif; +if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) +return 0 ; +
Shouldn't this be considered an error?
drivers/ide/ide-lib.c int ide_set_dma_mode(ide_drive_t *drive, · line 389
Quoted 10 lines
drivers/ide/ide-lib.c +3
-0if (hwif->set_pio_mode ==NULL )return -1 ;@@ -380,6 +384,9 @@ int ide_set_dma_mode(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif; +if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) +return 0 ; +
Same here....
drivers/ide/ide-lib.c int ide_set_xfer_rate(ide_drive_t *drive · line 422
Quoted 11 lines
drivers/ide/ide-lib.c +2
-1if (hwif->set_dma_mode ==NULL )return -1 ;@@ -410,7 +417,8 @@ int ide_set_xfer_rate(ide_drive_t *drive {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 ;
Hm, this is was not considered an error before...
MBR, Sergei
Hi,
Quoted 24 lines · Sergei Shtylyov
Hello.
Quoted 20 lines · Bartlomiej Zolnierkiewicz
* Check for
IDE_HFLAG_NO_SET_MODEhost flag inide_set_pio(), ide_set_[pio,dma]_mode(),ide_set_xfer_rate()andset_pio_mode().* Remove no longer needed
IDE_HFLAG_NO_SET_MODEhost flag checking fromide_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 Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/ide-lib.c
===================================================================drivers/ide/ide-lib.c +0
-0@@ -353,6 +354,9 @@ int ide_set_pio_mode(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif;
Quoted 5 lines
drivers/ide/ide-lib.c int ide_set_pio_mode(ide_drive_t *drive, · line 359
Quoted 3 lines
drivers/ide/ide-lib.c +3
-0+if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) +return 0 ; +Shouldn't this be considered an error?
Nope, we want to cheat kernel-level PIO tuning into succeeding. ;)
[ This host flag is used by it821x in "smart" mode so HW takes care of
tuning transfer mode on controller / device itself. ]
Quoted 7 lines
Quoted 7 lines
drivers/ide/ide-lib.c +0
-0if (hwif->set_pio_mode ==NULL )return -1 ;@@ -380,6 +384,9 @@ int ide_set_dma_mode(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif;
Quoted 5 lines
drivers/ide/ide-lib.c int ide_set_pio_mode(ide_drive_t *drive, · line 359
Quoted 3 lines
drivers/ide/ide-lib.c +3
-0+if (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ) +return 0 ; +Same here....
same for DMA tuning
Quoted 7 lines
Quoted 7 lines
drivers/ide/ide-lib.c +0
-0if (hwif->set_dma_mode ==NULL )return -1 ;@@ -410,7 +417,8 @@ int ide_set_xfer_rate(ide_drive_t *drive {ide_hwif_t *hwif = drive->hwif;
Quoted 6 lines
drivers/ide/ide-lib.c int ide_set_xfer_rate(ide_drive_t *drive · line 422
Quoted 4 lines
drivers/ide/ide-lib.c +2
-1-if (hwif->set_dma_mode ==NULL ) +if (hwif->set_dma_mode ==NULL || + (hwif->host_flags &IDE_HFLAG_NO_SET_MODE ))return -1 ;Hm, this is was not considered an error before...
Yep, but transfer mode changes are unsupported on it821x in "smart" mode.
PS Thanks for detailed review of 'struct ide_dma_ops' patch
(I'll recast the patch as soon as possible, hopefully tomorrow).
Thanks,
Bart