Skip to content

Commit 784506c

Browse files
committed
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: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 4764b68 commit 784506c

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎drivers/ide/ide-dma.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,6 @@ static int ide_tune_dma(ide_drive_t *drive)
706706
if (!speed)
707707
return 0;
708708

709-
if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
710-
return 1;
711-
712709
if (ide_set_dma_mode(drive, speed))
713710
return 0;
714711

‎drivers/ide/ide-io.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,6 @@ static ide_startstop_t do_special (ide_drive_t *drive)
726726
s->b.set_tune = 0;
727727

728728
if (set_pio_mode_abuse(drive->hwif, req_pio)) {
729-
730-
if (hwif->set_pio_mode == NULL)
731-
return ide_stopped;
732-
733729
/*
734730
* take ide_lock for drive->[no_]unmask/[no_]io_32bit
735731
*/

‎drivers/ide/ide-lib.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ void ide_set_pio(ide_drive_t *drive, u8 req_pio)
290290
ide_hwif_t *hwif = drive->hwif;
291291
u8 host_pio, pio;
292292

293-
if (hwif->set_pio_mode == NULL)
293+
if (hwif->set_pio_mode == NULL ||
294+
(hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
294295
return;
295296

296297
BUG_ON(hwif->pio_mask == 0x00);
@@ -343,6 +344,9 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
343344
{
344345
ide_hwif_t *hwif = drive->hwif;
345346

347+
if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
348+
return 0;
349+
346350
if (hwif->set_pio_mode == NULL)
347351
return -1;
348352

@@ -370,6 +374,9 @@ int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
370374
{
371375
ide_hwif_t *hwif = drive->hwif;
372376

377+
if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
378+
return 0;
379+
373380
if (hwif->set_dma_mode == NULL)
374381
return -1;
375382

@@ -400,7 +407,8 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
400407
{
401408
ide_hwif_t *hwif = drive->hwif;
402409

403-
if (hwif->set_dma_mode == NULL)
410+
if (hwif->set_dma_mode == NULL ||
411+
(hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
404412
return -1;
405413

406414
rate = ide_rate_filter(drive, rate);

‎drivers/ide/ide.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,13 @@ int set_using_dma(ide_drive_t *drive, int arg)
584584
int set_pio_mode(ide_drive_t *drive, int arg)
585585
{
586586
struct request rq;
587+
ide_hwif_t *hwif = drive->hwif;
587588

588589
if (arg < 0 || arg > 255)
589590
return -EINVAL;
590591

591-
if (drive->hwif->set_pio_mode == NULL)
592+
if (hwif->set_pio_mode == NULL ||
593+
(hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
592594
return -ENOSYS;
593595

594596
if (drive->special.b.set_tune)

0 commit comments

Comments
 (0)