aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 92a6c7bcf527..41a128f52112 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -76,37 +76,24 @@ EXPORT_SYMBOL(ide_xfer_verbose);
76 * Given the available transfer modes this function returns 76 * Given the available transfer modes this function returns
77 * the best available speed at or below the speed requested. 77 * the best available speed at or below the speed requested.
78 * 78 *
79 * FIXME: filter also PIO/SWDMA/MWDMA modes 79 * TODO: check device PIO capabilities
80 */ 80 */
81 81
82u8 ide_rate_filter(ide_drive_t *drive, u8 speed) 82u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
83{ 83{
84#ifdef CONFIG_BLK_DEV_IDEDMA
85 ide_hwif_t *hwif = drive->hwif; 84 ide_hwif_t *hwif = drive->hwif;
86 u8 mask = hwif->ultra_mask, mode = XFER_MW_DMA_2; 85 u8 mode = ide_find_dma_mode(drive, speed);
87
88 if (hwif->udma_filter)
89 mask = hwif->udma_filter(drive);
90
91 /*
92 * TODO: speed > XFER_UDMA_2 extra check is needed to avoid false
93 * cable warning from eighty_ninty_three(), moving ide_rate_filter()
94 * calls from ->speedproc to core code will make this hack go away
95 */
96 if (speed > XFER_UDMA_2) {
97 if ((mask & 0x78) && (eighty_ninty_three(drive) == 0))
98 mask &= 0x07;
99 }
100 86
101 if (mask) 87 if (mode == 0) {
102 mode = fls(mask) - 1 + XFER_UDMA_0; 88 if (hwif->pio_mask)
89 mode = fls(hwif->pio_mask) - 1 + XFER_PIO_0;
90 else
91 mode = XFER_PIO_4;
92 }
103 93
104// printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); 94// printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed);
105 95
106 return min(speed, mode); 96 return min(speed, mode);
107#else /* !CONFIG_BLK_DEV_IDEDMA */
108 return min(speed, (u8)XFER_PIO_4);
109#endif /* CONFIG_BLK_DEV_IDEDMA */
110} 97}
111 98
112EXPORT_SYMBOL(ide_rate_filter); 99EXPORT_SYMBOL(ide_rate_filter);