aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/aec62xx.c6
-rw-r--r--drivers/ide/ali14xx.c3
-rw-r--r--drivers/ide/alim15x3.c7
-rw-r--r--drivers/ide/amd74xx.c4
-rw-r--r--drivers/ide/at91_ide.c5
-rw-r--r--drivers/ide/atiixp.c7
-rw-r--r--drivers/ide/au1xxx-ide.c5
-rw-r--r--drivers/ide/cmd640.c3
-rw-r--r--drivers/ide/cmd64x.c4
-rw-r--r--drivers/ide/cs5520.c7
-rw-r--r--drivers/ide/cs5530.c7
-rw-r--r--drivers/ide/cs5535.c6
-rw-r--r--drivers/ide/cs5536.c7
-rw-r--r--drivers/ide/cy82c693.c5
-rw-r--r--drivers/ide/dtc2278.c4
-rw-r--r--drivers/ide/hpt366.c4
-rw-r--r--drivers/ide/ht6560b.c3
-rw-r--r--drivers/ide/ide-devsets.c4
-rw-r--r--drivers/ide/ide-xfer-mode.c6
-rw-r--r--drivers/ide/it8172.c10
-rw-r--r--drivers/ide/it8213.c14
-rw-r--r--drivers/ide/it821x.c6
-rw-r--r--drivers/ide/jmicron.c2
-rw-r--r--drivers/ide/opti621.c6
-rw-r--r--drivers/ide/palm_bk3710.c5
-rw-r--r--drivers/ide/pdc202xx_new.c4
-rw-r--r--drivers/ide/pdc202xx_old.c4
-rw-r--r--drivers/ide/piix.c14
-rw-r--r--drivers/ide/pmac.c5
-rw-r--r--drivers/ide/qd65xx.c10
-rw-r--r--drivers/ide/sc1200.c4
-rw-r--r--drivers/ide/scc_pata.c6
-rw-r--r--drivers/ide/serverworks.c5
-rw-r--r--drivers/ide/siimage.c6
-rw-r--r--drivers/ide/sis5513.c4
-rw-r--r--drivers/ide/sl82c105.c5
-rw-r--r--drivers/ide/slc90e66.c13
-rw-r--r--drivers/ide/tc86c001.c4
-rw-r--r--drivers/ide/triflex.c4
-rw-r--r--drivers/ide/tx4938ide.c5
-rw-r--r--drivers/ide/tx4939ide.c4
-rw-r--r--drivers/ide/umc8672.c5
-rw-r--r--drivers/ide/via82cxxx.c6
-rw-r--r--include/linux/ide.h2
44 files changed, 129 insertions, 121 deletions
diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c
index 4c869872eb9a..3790847361c3 100644
--- a/drivers/ide/aec62xx.c
+++ b/drivers/ide/aec62xx.c
@@ -134,10 +134,10 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
134 local_irq_restore(flags); 134 local_irq_restore(flags);
135} 135}
136 136
137static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) 137static void aec_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
138{ 138{
139 drive->dma_mode = pio + XFER_PIO_0; 139 drive->dma_mode = drive->pio_mode;
140 drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); 140 hwif->port_ops->set_dma_mode(drive, drive->dma_mode);
141} 141}
142 142
143static int init_chipset_aec62xx(struct pci_dev *dev) 143static int init_chipset_aec62xx(struct pci_dev *dev)
diff --git a/drivers/ide/ali14xx.c b/drivers/ide/ali14xx.c
index 90da1f953ed0..25b9fe3a9f8e 100644
--- a/drivers/ide/ali14xx.c
+++ b/drivers/ide/ali14xx.c
@@ -109,13 +109,14 @@ static DEFINE_SPINLOCK(ali14xx_lock);
109 * This function computes timing parameters 109 * This function computes timing parameters
110 * and sets controller registers accordingly. 110 * and sets controller registers accordingly.
111 */ 111 */
112static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) 112static void ali14xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
113{ 113{
114 int driveNum; 114 int driveNum;
115 int time1, time2; 115 int time1, time2;
116 u8 param1, param2, param3, param4; 116 u8 param1, param2, param3, param4;
117 unsigned long flags; 117 unsigned long flags;
118 int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; 118 int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
119 const u8 pio = drive->pio_mode - XFER_PIO_0;
119 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); 120 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
120 121
121 /* calculate timing, according to PIO mode */ 122 /* calculate timing, according to PIO mode */
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
index 8f03cce055fa..28cee1055f76 100644
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -63,15 +63,14 @@ static void ali_fifo_control(ide_hwif_t *hwif, ide_drive_t *drive, int on)
63 63
64/** 64/**
65 * ali_set_pio_mode - set host controller for PIO mode 65 * ali_set_pio_mode - set host controller for PIO mode
66 * @hwif: port
66 * @drive: drive 67 * @drive: drive
67 * @pio: PIO mode number
68 * 68 *
69 * Program the controller for the given PIO mode. 69 * Program the controller for the given PIO mode.
70 */ 70 */
71 71
72static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) 72static void ali_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
73{ 73{
74 ide_hwif_t *hwif = drive->hwif;
75 struct pci_dev *dev = to_pci_dev(hwif->dev); 74 struct pci_dev *dev = to_pci_dev(hwif->dev);
76 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 75 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
77 unsigned long T = 1000000 / bus_speed; /* PCI clock based */ 76 unsigned long T = 1000000 / bus_speed; /* PCI clock based */
@@ -79,7 +78,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
79 u8 unit = drive->dn & 1; 78 u8 unit = drive->dn & 1;
80 struct ide_timing t; 79 struct ide_timing t;
81 80
82 ide_timing_compute(drive, XFER_PIO_0 + pio, &t, T, 1); 81 ide_timing_compute(drive, drive->pio_mode, &t, T, 1);
83 82
84 t.setup = clamp_val(t.setup, 1, 8) & 7; 83 t.setup = clamp_val(t.setup, 1, 8) & 7;
85 t.active = clamp_val(t.active, 1, 8) & 7; 84 t.active = clamp_val(t.active, 1, 8) & 7;
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
index 108e9b676859..3eee7be7ca6f 100644
--- a/drivers/ide/amd74xx.c
+++ b/drivers/ide/amd74xx.c
@@ -108,9 +108,9 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed)
108 * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning. 108 * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning.
109 */ 109 */
110 110
111static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) 111static void amd_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
112{ 112{
113 amd_set_drive(drive, XFER_PIO_0 + pio); 113 amd_set_drive(drive, drive->pio_mode);
114} 114}
115 115
116static void amd7409_cable_detect(struct pci_dev *dev) 116static void amd7409_cable_detect(struct pci_dev *dev)
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c
index 248219a89a68..000a78e5246c 100644
--- a/drivers/ide/at91_ide.c
+++ b/drivers/ide/at91_ide.c
@@ -172,11 +172,12 @@ static void at91_ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
172 leave_16bit(chipselect, mode); 172 leave_16bit(chipselect, mode);
173} 173}
174 174
175static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) 175static void at91_ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
176{ 176{
177 struct ide_timing *timing; 177 struct ide_timing *timing;
178 u8 chipselect = drive->hwif->select_data; 178 u8 chipselect = hwif->select_data;
179 int use_iordy = 0; 179 int use_iordy = 0;
180 const u8 pio = drive->pio_mode - XFER_PIO_0;
180 181
181 pdbg("chipselect %u pio %u\n", chipselect, pio); 182 pdbg("chipselect %u pio %u\n", chipselect, pio);
182 183
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c
index 837322b10a4c..b6848dfb93b0 100644
--- a/drivers/ide/atiixp.c
+++ b/drivers/ide/atiixp.c
@@ -42,19 +42,20 @@ static DEFINE_SPINLOCK(atiixp_lock);
42 42
43/** 43/**
44 * atiixp_set_pio_mode - set host controller for PIO mode 44 * atiixp_set_pio_mode - set host controller for PIO mode
45 * @hwif: port
45 * @drive: drive 46 * @drive: drive
46 * @pio: PIO mode number
47 * 47 *
48 * Set the interface PIO mode. 48 * Set the interface PIO mode.
49 */ 49 */
50 50
51static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) 51static void atiixp_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
52{ 52{
53 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 53 struct pci_dev *dev = to_pci_dev(hwif->dev);
54 unsigned long flags; 54 unsigned long flags;
55 int timing_shift = (drive->dn ^ 1) * 8; 55 int timing_shift = (drive->dn ^ 1) * 8;
56 u32 pio_timing_data; 56 u32 pio_timing_data;
57 u16 pio_mode_data; 57 u16 pio_mode_data;
58 const u8 pio = drive->pio_mode - XFER_PIO_0;
58 59
59 spin_lock_irqsave(&atiixp_lock, flags); 60 spin_lock_irqsave(&atiixp_lock, flags);
60 61
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 87cef0c440ad..c90e9b0a9f6e 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -99,12 +99,11 @@ static void au1xxx_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
99} 99}
100#endif 100#endif
101 101
102static void au1xxx_set_pio_mode(ide_drive_t *drive, const u8 pio) 102static void au1xxx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
103{ 103{
104 int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2); 104 int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2);
105 105
106 /* set pio mode! */ 106 switch (drive->pio_mode - XFER_PIO_0) {
107 switch(pio) {
108 case 0: 107 case 0:
109 mem_sttime = SBC_IDE_TIMING(PIO0); 108 mem_sttime = SBC_IDE_TIMING(PIO0);
110 109
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c
index 1a32d62ed86b..c7d46a3d347a 100644
--- a/drivers/ide/cmd640.c
+++ b/drivers/ide/cmd640.c
@@ -572,9 +572,10 @@ static void cmd640_set_mode(ide_drive_t *drive, unsigned int index,
572 program_drive_counts(drive, index); 572 program_drive_counts(drive, index);
573} 573}
574 574
575static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) 575static void cmd640_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
576{ 576{
577 unsigned int index = 0, cycle_time; 577 unsigned int index = 0, cycle_time;
578 const u8 pio = drive->pio_mode - XFER_PIO_0;
578 u8 b; 579 u8 b;
579 580
580 switch (pio) { 581 switch (pio) {
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
index 9f89f3116df0..0b11745937e7 100644
--- a/drivers/ide/cmd64x.c
+++ b/drivers/ide/cmd64x.c
@@ -127,8 +127,10 @@ static void cmd64x_program_timings(ide_drive_t *drive, u8 mode)
127 * Special cases are 8: prefetch off, 9: prefetch on (both never worked) 127 * Special cases are 8: prefetch off, 9: prefetch on (both never worked)
128 */ 128 */
129 129
130static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio) 130static void cmd64x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
131{ 131{
132 const u8 pio = drive->pio_mode - XFER_PIO_0;
133
132 /* 134 /*
133 * Filter out the prefetch control values 135 * Filter out the prefetch control values
134 * to prevent PIO5 from being programmed 136 * to prevent PIO5 from being programmed
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
index 09f98ed0731f..b8094f049f3e 100644
--- a/drivers/ide/cs5520.c
+++ b/drivers/ide/cs5520.c
@@ -57,11 +57,11 @@ static struct pio_clocks cs5520_pio_clocks[]={
57 {1, 2, 1} 57 {1, 2, 1}
58}; 58};
59 59
60static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) 60static void cs5520_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
61{ 61{
62 ide_hwif_t *hwif = drive->hwif;
63 struct pci_dev *pdev = to_pci_dev(hwif->dev); 62 struct pci_dev *pdev = to_pci_dev(hwif->dev);
64 int controller = drive->dn > 1 ? 1 : 0; 63 int controller = drive->dn > 1 ? 1 : 0;
64 const u8 pio = drive->pio_mode - XFER_PIO_0;
65 65
66 /* 8bit CAT/CRT - 8bit command timing for channel */ 66 /* 8bit CAT/CRT - 8bit command timing for channel */
67 pci_write_config_byte(pdev, 0x62 + controller, 67 pci_write_config_byte(pdev, 0x62 + controller,
@@ -85,7 +85,8 @@ static void cs5520_set_dma_mode(ide_drive_t *drive, const u8 speed)
85{ 85{
86 printk(KERN_ERR "cs55x0: bad ide timing.\n"); 86 printk(KERN_ERR "cs55x0: bad ide timing.\n");
87 87
88 cs5520_set_pio_mode(drive, 0); 88 drive->pio_mode = XFER_PIO_0 + 0;
89 cs5520_set_pio_mode(drive->hwif, drive);
89} 90}
90 91
91static const struct ide_port_ops cs5520_port_ops = { 92static const struct ide_port_ops cs5520_port_ops = {
diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c
index 40bf05eddf6e..4ced40255ad6 100644
--- a/drivers/ide/cs5530.c
+++ b/drivers/ide/cs5530.c
@@ -41,8 +41,8 @@ static unsigned int cs5530_pio_timings[2][5] = {
41 41
42/** 42/**
43 * cs5530_set_pio_mode - set host controller for PIO mode 43 * cs5530_set_pio_mode - set host controller for PIO mode
44 * @hwif: port
44 * @drive: drive 45 * @drive: drive
45 * @pio: PIO mode number
46 * 46 *
47 * Handles setting of PIO mode for the chipset. 47 * Handles setting of PIO mode for the chipset.
48 * 48 *
@@ -50,10 +50,11 @@ static unsigned int cs5530_pio_timings[2][5] = {
50 * will have valid default PIO timings set up before we get here. 50 * will have valid default PIO timings set up before we get here.
51 */ 51 */
52 52
53static void cs5530_set_pio_mode(ide_drive_t *drive, const u8 pio) 53static void cs5530_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
54{ 54{
55 unsigned long basereg = CS5530_BASEREG(drive->hwif); 55 unsigned long basereg = CS5530_BASEREG(hwif);
56 unsigned int format = (inl(basereg + 4) >> 31) & 1; 56 unsigned int format = (inl(basereg + 4) >> 31) & 1;
57 const u8 pio = drive->pio_mode - XFER_PIO_0;
57 58
58 outl(cs5530_pio_timings[format][pio], basereg + ((drive->dn & 1)<<3)); 59 outl(cs5530_pio_timings[format][pio], basereg + ((drive->dn & 1)<<3));
59} 60}
diff --git a/drivers/ide/cs5535.c b/drivers/ide/cs5535.c
index b883838adc24..7974415ea89f 100644
--- a/drivers/ide/cs5535.c
+++ b/drivers/ide/cs5535.c
@@ -142,15 +142,15 @@ static void cs5535_set_dma_mode(ide_drive_t *drive, const u8 speed)
142 142
143/** 143/**
144 * cs5535_set_pio_mode - set host controller for PIO mode 144 * cs5535_set_pio_mode - set host controller for PIO mode
145 * @hwif: port
145 * @drive: drive 146 * @drive: drive
146 * @pio: PIO mode number
147 * 147 *
148 * A callback from the upper layers for PIO-only tuning. 148 * A callback from the upper layers for PIO-only tuning.
149 */ 149 */
150 150
151static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio) 151static void cs5535_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
152{ 152{
153 cs5535_set_speed(drive, XFER_PIO_0 + pio); 153 cs5535_set_speed(drive, drive->pio_mode);
154} 154}
155 155
156static u8 cs5535_cable_detect(ide_hwif_t *hwif) 156static u8 cs5535_cable_detect(ide_hwif_t *hwif)
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c
index 9623b852c616..b518ef0e9a35 100644
--- a/drivers/ide/cs5536.c
+++ b/drivers/ide/cs5536.c
@@ -125,11 +125,11 @@ static u8 cs5536_cable_detect(ide_hwif_t *hwif)
125 125
126/** 126/**
127 * cs5536_set_pio_mode - PIO timing setup 127 * cs5536_set_pio_mode - PIO timing setup
128 * @hwif: ATA port
128 * @drive: ATA device 129 * @drive: ATA device
129 * @pio: PIO mode number
130 */ 130 */
131 131
132static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio) 132static void cs5536_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
133{ 133{
134 static const u8 drv_timings[5] = { 134 static const u8 drv_timings[5] = {
135 0x98, 0x55, 0x32, 0x21, 0x20, 135 0x98, 0x55, 0x32, 0x21, 0x20,
@@ -143,11 +143,12 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
143 0x99, 0x92, 0x90, 0x22, 0x20, 143 0x99, 0x92, 0x90, 0x22, 0x20,
144 }; 144 };
145 145
146 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); 146 struct pci_dev *pdev = to_pci_dev(hwif->dev);
147 ide_drive_t *pair = ide_get_pair_dev(drive); 147 ide_drive_t *pair = ide_get_pair_dev(drive);
148 int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; 148 int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT;
149 unsigned long timings = (unsigned long)ide_get_drivedata(drive); 149 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
150 u32 cast; 150 u32 cast;
151 const u8 pio = drive->pio_mode - XFER_PIO_0;
151 u8 cmd_pio = pio; 152 u8 cmd_pio = pio;
152 153
153 if (pair) 154 if (pair)
diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c
index fbf3dcc26577..ead65c394f00 100644
--- a/drivers/ide/cy82c693.c
+++ b/drivers/ide/cy82c693.c
@@ -80,9 +80,8 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
80 outb(data, CY82_DATA_PORT); 80 outb(data, CY82_DATA_PORT);
81} 81}
82 82
83static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) 83static void cy82c693_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
84{ 84{
85 ide_hwif_t *hwif = drive->hwif;
86 struct pci_dev *dev = to_pci_dev(hwif->dev); 85 struct pci_dev *dev = to_pci_dev(hwif->dev);
87 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 86 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
88 const unsigned long T = 1000000 / bus_speed; 87 const unsigned long T = 1000000 / bus_speed;
@@ -101,7 +100,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
101 } 100 }
102 } 101 }
103 102
104 ide_timing_compute(drive, XFER_PIO_0 + pio, &t, T, 1); 103 ide_timing_compute(drive, drive->pio_mode, &t, T, 1);
105 104
106 time_16 = clamp_val(t.recover - 1, 0, 15) | 105 time_16 = clamp_val(t.recover - 1, 0, 15) |
107 (clamp_val(t.active - 1, 0, 15) << 4); 106 (clamp_val(t.active - 1, 0, 15) << 4);
diff --git a/drivers/ide/dtc2278.c b/drivers/ide/dtc2278.c
index c6b138122981..6929f7fce93a 100644
--- a/drivers/ide/dtc2278.c
+++ b/drivers/ide/dtc2278.c
@@ -68,11 +68,11 @@ static void sub22 (char b, char c)
68 68
69static DEFINE_SPINLOCK(dtc2278_lock); 69static DEFINE_SPINLOCK(dtc2278_lock);
70 70
71static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) 71static void dtc2278_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
72{ 72{
73 unsigned long flags; 73 unsigned long flags;
74 74
75 if (pio >= 3) { 75 if (drive->pio_mode >= XFER_PIO_3) {
76 spin_lock_irqsave(&dtc2278_lock, flags); 76 spin_lock_irqsave(&dtc2278_lock, flags);
77 /* 77 /*
78 * This enables PIO mode4 (3?) on the first interface 78 * This enables PIO mode4 (3?) on the first interface
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index 4d90ac2dbb1b..f1dec519a9e6 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -651,9 +651,9 @@ static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
651 pci_write_config_dword(dev, itr_addr, new_itr); 651 pci_write_config_dword(dev, itr_addr, new_itr);
652} 652}
653 653
654static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) 654static void hpt3xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
655{ 655{
656 hpt3xx_set_mode(drive, XFER_PIO_0 + pio); 656 hpt3xx_set_mode(drive, drive->pio_mode);
657} 657}
658 658
659static void hpt3xx_maskproc(ide_drive_t *drive, int mask) 659static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
diff --git a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c
index aafed8060e17..d81e49680c3f 100644
--- a/drivers/ide/ht6560b.c
+++ b/drivers/ide/ht6560b.c
@@ -279,9 +279,10 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state)
279#endif 279#endif
280} 280}
281 281
282static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) 282static void ht6560b_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
283{ 283{
284 unsigned long flags, config; 284 unsigned long flags, config;
285 const u8 pio = drive->pio_mode - XFER_PIO_0;
285 u8 timing; 286 u8 timing;
286 287
287 switch (pio) { 288 switch (pio) {
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index cb3341ce655c..c6935c78757c 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
@@ -112,10 +112,10 @@ static int set_pio_mode(ide_drive_t *drive, int arg)
112 112
113 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ 113 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */
114 spin_lock_irqsave(&hwif->lock, flags); 114 spin_lock_irqsave(&hwif->lock, flags);
115 port_ops->set_pio_mode(drive, arg); 115 port_ops->set_pio_mode(hwif, drive);
116 spin_unlock_irqrestore(&hwif->lock, flags); 116 spin_unlock_irqrestore(&hwif->lock, flags);
117 } else 117 } else
118 port_ops->set_pio_mode(drive, arg); 118 port_ops->set_pio_mode(hwif, drive);
119 } else { 119 } else {
120 int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); 120 int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
121 121
diff --git a/drivers/ide/ide-xfer-mode.c b/drivers/ide/ide-xfer-mode.c
index c2323869d92a..a62fb03fc1cc 100644
--- a/drivers/ide/ide-xfer-mode.c
+++ b/drivers/ide/ide-xfer-mode.c
@@ -136,7 +136,7 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
136 */ 136 */
137 if (port_ops->set_dma_mode == NULL) { 137 if (port_ops->set_dma_mode == NULL) {
138 drive->pio_mode = mode; 138 drive->pio_mode = mode;
139 port_ops->set_pio_mode(drive, mode - XFER_PIO_0); 139 port_ops->set_pio_mode(hwif, drive);
140 return 0; 140 return 0;
141 } 141 }
142 142
@@ -144,11 +144,11 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
144 if (ide_config_drive_speed(drive, mode)) 144 if (ide_config_drive_speed(drive, mode))
145 return -1; 145 return -1;
146 drive->pio_mode = mode; 146 drive->pio_mode = mode;
147 port_ops->set_pio_mode(drive, mode - XFER_PIO_0); 147 port_ops->set_pio_mode(hwif, drive);
148 return 0; 148 return 0;
149 } else { 149 } else {
150 drive->pio_mode = mode; 150 drive->pio_mode = mode;
151 port_ops->set_pio_mode(drive, mode - XFER_PIO_0); 151 port_ops->set_pio_mode(hwif, drive);
152 return ide_config_drive_speed(drive, mode); 152 return ide_config_drive_speed(drive, mode);
153 } 153 }
154} 154}
diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c
index 0d266a5b524d..9dfdc8741a7b 100644
--- a/drivers/ide/it8172.c
+++ b/drivers/ide/it8172.c
@@ -37,12 +37,12 @@
37 37
38#define DRV_NAME "IT8172" 38#define DRV_NAME "IT8172"
39 39
40static void it8172_set_pio_mode(ide_drive_t *drive, const u8 pio) 40static void it8172_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
41{ 41{
42 ide_hwif_t *hwif = drive->hwif;
43 struct pci_dev *dev = to_pci_dev(hwif->dev); 42 struct pci_dev *dev = to_pci_dev(hwif->dev);
44 u16 drive_enables; 43 u16 drive_enables;
45 u32 drive_timing; 44 u32 drive_timing;
45 const u8 pio = drive->pio_mode - XFER_PIO_0;
46 46
47 /* 47 /*
48 * The highest value of DIOR/DIOW pulse width and recovery time 48 * The highest value of DIOR/DIOW pulse width and recovery time
@@ -98,14 +98,14 @@ static void it8172_set_dma_mode(ide_drive_t *drive, const u8 speed)
98 pci_write_config_byte(dev, 0x4a, reg4a | u_speed); 98 pci_write_config_byte(dev, 0x4a, reg4a | u_speed);
99 } else { 99 } else {
100 const u8 mwdma_to_pio[] = { 0, 3, 4 }; 100 const u8 mwdma_to_pio[] = { 0, 3, 4 };
101 u8 pio;
102 101
103 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 102 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
104 pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed); 103 pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
105 104
106 pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; 105 drive->pio_mode =
106 mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
107 107
108 it8172_set_pio_mode(drive, pio); 108 it8172_set_pio_mode(hwif, drive);
109 } 109 }
110} 110}
111 111
diff --git a/drivers/ide/it8213.c b/drivers/ide/it8213.c
index 47976167796a..492c07d5f4f3 100644
--- a/drivers/ide/it8213.c
+++ b/drivers/ide/it8213.c
@@ -17,15 +17,14 @@
17 17
18/** 18/**
19 * it8213_set_pio_mode - set host controller for PIO mode 19 * it8213_set_pio_mode - set host controller for PIO mode
20 * @hwif: port
20 * @drive: drive 21 * @drive: drive
21 * @pio: PIO mode number
22 * 22 *
23 * Set the interface PIO mode. 23 * Set the interface PIO mode.
24 */ 24 */
25 25
26static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) 26static void it8213_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
27{ 27{
28 ide_hwif_t *hwif = drive->hwif;
29 struct pci_dev *dev = to_pci_dev(hwif->dev); 28 struct pci_dev *dev = to_pci_dev(hwif->dev);
30 int is_slave = drive->dn & 1; 29 int is_slave = drive->dn & 1;
31 int master_port = 0x40; 30 int master_port = 0x40;
@@ -35,6 +34,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio)
35 u8 slave_data; 34 u8 slave_data;
36 static DEFINE_SPINLOCK(tune_lock); 35 static DEFINE_SPINLOCK(tune_lock);
37 int control = 0; 36 int control = 0;
37 const u8 pio = drive->pio_mode - XFER_PIO_0;
38 38
39 static const u8 timings[][2] = { 39 static const u8 timings[][2] = {
40 { 0, 0 }, 40 { 0, 0 },
@@ -120,7 +120,6 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
120 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 120 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
121 } else { 121 } else {
122 const u8 mwdma_to_pio[] = { 0, 3, 4 }; 122 const u8 mwdma_to_pio[] = { 0, 3, 4 };
123 u8 pio;
124 123
125 if (reg48 & u_flag) 124 if (reg48 & u_flag)
126 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 125 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
@@ -132,11 +131,12 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
132 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 131 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
133 132
134 if (speed >= XFER_MW_DMA_0) 133 if (speed >= XFER_MW_DMA_0)
135 pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; 134 drive->pio_mode =
135 mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
136 else 136 else
137 pio = 2; /* only SWDMA2 is allowed */ 137 drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
138 138
139 it8213_set_pio_mode(drive, pio); 139 it8213_set_pio_mode(hwif, drive);
140 } 140 }
141} 141}
142 142
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
index 51aa745246dc..69becb7b9656 100644
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -228,18 +228,18 @@ static void it821x_clock_strategy(ide_drive_t *drive)
228 228
229/** 229/**
230 * it821x_set_pio_mode - set host controller for PIO mode 230 * it821x_set_pio_mode - set host controller for PIO mode
231 * @hwif: port
231 * @drive: drive 232 * @drive: drive
232 * @pio: PIO mode number
233 * 233 *
234 * Tune the host to the desired PIO mode taking into the consideration 234 * Tune the host to the desired PIO mode taking into the consideration
235 * the maximum PIO mode supported by the other device on the cable. 235 * the maximum PIO mode supported by the other device on the cable.
236 */ 236 */
237 237
238static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) 238static void it821x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
239{ 239{
240 ide_hwif_t *hwif = drive->hwif;
241 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 240 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
242 ide_drive_t *pair = ide_get_pair_dev(drive); 241 ide_drive_t *pair = ide_get_pair_dev(drive);
242 const u8 pio = drive->pio_mode - XFER_PIO_0;
243 u8 unit = drive->dn & 1, set_pio = pio; 243 u8 unit = drive->dn & 1, set_pio = pio;
244 244
245 /* Spec says 89 ref driver uses 88 */ 245 /* Spec says 89 ref driver uses 88 */
diff --git a/drivers/ide/jmicron.c b/drivers/ide/jmicron.c
index bf2be6431b20..ebffb904ed24 100644
--- a/drivers/ide/jmicron.c
+++ b/drivers/ide/jmicron.c
@@ -80,7 +80,7 @@ static u8 jmicron_cable_detect(ide_hwif_t *hwif)
80 return ATA_CBL_PATA80; 80 return ATA_CBL_PATA80;
81} 81}
82 82
83static void jmicron_set_pio_mode(ide_drive_t *drive, const u8 pio) 83static void jmicron_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
84{ 84{
85} 85}
86 86
diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c
index 2052788fab7a..1a53a4c375ed 100644
--- a/drivers/ide/opti621.c
+++ b/drivers/ide/opti621.c
@@ -62,12 +62,12 @@ static u8 read_reg(int reg)
62 return ret; 62 return ret;
63} 63}
64 64
65static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) 65static void opti621_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
66{ 66{
67 ide_hwif_t *hwif = drive->hwif;
68 ide_drive_t *pair = ide_get_pair_dev(drive); 67 ide_drive_t *pair = ide_get_pair_dev(drive);
69 unsigned long flags; 68 unsigned long flags;
70 unsigned long mode = XFER_PIO_0 + pio, pair_mode; 69 unsigned long mode = drive->pio_mode, pair_mode;
70 const u8 pio = mode - XFER_PIO_0;
71 u8 tim, misc, addr_pio = pio, clk; 71 u8 tim, misc, addr_pio = pio, clk;
72 72
73 /* DRDY is default 2 (by OPTi Databook) */ 73 /* DRDY is default 2 (by OPTi Databook) */
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
index f8eddf05ecb8..0f262d07c378 100644
--- a/drivers/ide/palm_bk3710.c
+++ b/drivers/ide/palm_bk3710.c
@@ -203,12 +203,13 @@ static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed)
203 } 203 }
204} 204}
205 205
206static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio) 206static void palm_bk3710_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
207{ 207{
208 unsigned int cycle_time; 208 unsigned int cycle_time;
209 int is_slave = drive->dn & 1; 209 int is_slave = drive->dn & 1;
210 ide_drive_t *mate; 210 ide_drive_t *mate;
211 void __iomem *base = (void *)drive->hwif->dma_base; 211 void __iomem *base = (void *)hwif->dma_base;
212 const u8 pio = drive->pio_mode - XFER_PIO_0;
212 213
213 /* 214 /*
214 * Obtain the drive PIO data for tuning the Palm Chip registers 215 * Obtain the drive PIO data for tuning the Palm Chip registers
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
index 65ba8239e7b5..874acd2bb6e6 100644
--- a/drivers/ide/pdc202xx_new.c
+++ b/drivers/ide/pdc202xx_new.c
@@ -167,11 +167,11 @@ static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed)
167 } 167 }
168} 168}
169 169
170static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) 170static void pdcnew_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
171{ 171{
172 ide_hwif_t *hwif = drive->hwif;
173 struct pci_dev *dev = to_pci_dev(hwif->dev); 172 struct pci_dev *dev = to_pci_dev(hwif->dev);
174 u8 adj = (drive->dn & 1) ? 0x08 : 0x00; 173 u8 adj = (drive->dn & 1) ? 0x08 : 0x00;
174 const u8 pio = drive->pio_mode - XFER_PIO_0;
175 175
176 if (max_dma_rate(dev) == 4) { 176 if (max_dma_rate(dev) == 4) {
177 set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); 177 set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c);
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 1d20594ee420..402aab7f3baa 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -76,9 +76,9 @@ static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed)
76 } 76 }
77} 77}
78 78
79static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) 79static void pdc202xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
80{ 80{
81 pdc202xx_set_mode(drive, XFER_PIO_0 + pio); 81 pdc202xx_set_mode(drive, drive->pio_mode);
82} 82}
83 83
84static int pdc202xx_test_irq(ide_hwif_t *hwif) 84static int pdc202xx_test_irq(ide_hwif_t *hwif)
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
index bf14f39bd3a7..64b3041daa60 100644
--- a/drivers/ide/piix.c
+++ b/drivers/ide/piix.c
@@ -59,15 +59,14 @@ static int no_piix_dma;
59 59
60/** 60/**
61 * piix_set_pio_mode - set host controller for PIO mode 61 * piix_set_pio_mode - set host controller for PIO mode
62 * @port: port
62 * @drive: drive 63 * @drive: drive
63 * @pio: PIO mode number
64 * 64 *
65 * Set the interface PIO mode based upon the settings done by AMI BIOS. 65 * Set the interface PIO mode based upon the settings done by AMI BIOS.
66 */ 66 */
67 67
68static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) 68static void piix_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
69{ 69{
70 ide_hwif_t *hwif = drive->hwif;
71 struct pci_dev *dev = to_pci_dev(hwif->dev); 70 struct pci_dev *dev = to_pci_dev(hwif->dev);
72 int is_slave = drive->dn & 1; 71 int is_slave = drive->dn & 1;
73 int master_port = hwif->channel ? 0x42 : 0x40; 72 int master_port = hwif->channel ? 0x42 : 0x40;
@@ -77,6 +76,7 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
77 u8 slave_data; 76 u8 slave_data;
78 static DEFINE_SPINLOCK(tune_lock); 77 static DEFINE_SPINLOCK(tune_lock);
79 int control = 0; 78 int control = 0;
79 const u8 pio = drive->pio_mode - XFER_PIO_0;
80 80
81 /* ISP RTC */ 81 /* ISP RTC */
82 static const u8 timings[][2]= { 82 static const u8 timings[][2]= {
@@ -176,7 +176,6 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
176 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 176 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
177 } else { 177 } else {
178 const u8 mwdma_to_pio[] = { 0, 3, 4 }; 178 const u8 mwdma_to_pio[] = { 0, 3, 4 };
179 u8 pio;
180 179
181 if (reg48 & u_flag) 180 if (reg48 & u_flag)
182 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 181 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
@@ -188,11 +187,12 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
188 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 187 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
189 188
190 if (speed >= XFER_MW_DMA_0) 189 if (speed >= XFER_MW_DMA_0)
191 pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; 190 drive->pio_mode =
191 mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
192 else 192 else
193 pio = 2; /* only SWDMA2 is allowed */ 193 drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
194 194
195 piix_set_pio_mode(drive, pio); 195 piix_set_pio_mode(hwif, drive);
196 } 196 }
197} 197}
198 198
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 7a4e788cab2f..a167968a2d42 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -496,12 +496,11 @@ static void pmac_write_devctl(ide_hwif_t *hwif, u8 ctl)
496/* 496/*
497 * Old tuning functions (called on hdparm -p), sets up drive PIO timings 497 * Old tuning functions (called on hdparm -p), sets up drive PIO timings
498 */ 498 */
499static void 499static void pmac_ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
500pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
501{ 500{
502 ide_hwif_t *hwif = drive->hwif;
503 pmac_ide_hwif_t *pmif = 501 pmac_ide_hwif_t *pmif =
504 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 502 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
503 const u8 pio = drive->pio_mode - XFER_PIO_0;
505 struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio); 504 struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio);
506 u32 *timings, t; 505 u32 *timings, t;
507 unsigned accessTicks, recTicks; 506 unsigned accessTicks, recTicks;
diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c
index 74696edc8d1d..3f0244fd8e62 100644
--- a/drivers/ide/qd65xx.c
+++ b/drivers/ide/qd65xx.c
@@ -189,15 +189,13 @@ static void qd_set_timing (ide_drive_t *drive, u8 timing)
189 printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); 189 printk(KERN_DEBUG "%s: %#x\n", drive->name, timing);
190} 190}
191 191
192static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) 192static void qd6500_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
193{ 193{
194 u16 *id = drive->id; 194 u16 *id = drive->id;
195 int active_time = 175; 195 int active_time = 175;
196 int recovery_time = 415; /* worst case values from the dos driver */ 196 int recovery_time = 415; /* worst case values from the dos driver */
197 197
198 /* 198 /* FIXME: use drive->pio_mode value */
199 * FIXME: use "pio" value
200 */
201 if (!qd_find_disk_type(drive, &active_time, &recovery_time) && 199 if (!qd_find_disk_type(drive, &active_time, &recovery_time) &&
202 (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) && 200 (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) &&
203 id[ATA_ID_EIDE_PIO] >= 240) { 201 id[ATA_ID_EIDE_PIO] >= 240) {
@@ -211,9 +209,9 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio)
211 active_time, recovery_time)); 209 active_time, recovery_time));
212} 210}
213 211
214static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) 212static void qd6580_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
215{ 213{
216 ide_hwif_t *hwif = drive->hwif; 214 const u8 pio = drive->pio_mode - XFER_PIO_0;
217 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); 215 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
218 unsigned int cycle_time; 216 unsigned int cycle_time;
219 int active_time = 175; 217 int active_time = 175;
diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c
index d467478d68da..bb0166e460ab 100644
--- a/drivers/ide/sc1200.c
+++ b/drivers/ide/sc1200.c
@@ -193,10 +193,10 @@ static int sc1200_dma_end(ide_drive_t *drive)
193 * will have valid default PIO timings set up before we get here. 193 * will have valid default PIO timings set up before we get here.
194 */ 194 */
195 195
196static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) 196static void sc1200_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
197{ 197{
198 ide_hwif_t *hwif = drive->hwif;
199 int mode = -1; 198 int mode = -1;
199 const u8 pio = drive->pio_mode - XFER_PIO_0;
200 200
201 /* 201 /*
202 * bad abuse of ->set_pio_mode interface 202 * bad abuse of ->set_pio_mode interface
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 1104bb301eb9..23e16e4460ee 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -199,16 +199,15 @@ scc_ide_outsl(unsigned long port, void *addr, u32 count)
199 199
200/** 200/**
201 * scc_set_pio_mode - set host controller for PIO mode 201 * scc_set_pio_mode - set host controller for PIO mode
202 * @hwif: port
202 * @drive: drive 203 * @drive: drive
203 * @pio: PIO mode number
204 * 204 *
205 * Load the timing settings for this device mode into the 205 * Load the timing settings for this device mode into the
206 * controller. 206 * controller.
207 */ 207 */
208 208
209static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) 209static void scc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
210{ 210{
211 ide_hwif_t *hwif = drive->hwif;
212 struct scc_ports *ports = ide_get_hwifdata(hwif); 211 struct scc_ports *ports = ide_get_hwifdata(hwif);
213 unsigned long ctl_base = ports->ctl; 212 unsigned long ctl_base = ports->ctl;
214 unsigned long cckctrl_port = ctl_base + 0xff0; 213 unsigned long cckctrl_port = ctl_base + 0xff0;
@@ -216,6 +215,7 @@ static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio)
216 unsigned long pioct_port = ctl_base + 0x004; 215 unsigned long pioct_port = ctl_base + 0x004;
217 unsigned long reg; 216 unsigned long reg;
218 int offset; 217 int offset;
218 const u8 pio = drive->pio_mode - XFER_PIO_0;
219 219
220 reg = in_be32((void __iomem *)cckctrl_port); 220 reg = in_be32((void __iomem *)cckctrl_port);
221 if (reg & CCKCTRL_ATACLKOEN) { 221 if (reg & CCKCTRL_ATACLKOEN) {
diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c
index 657f0433ec50..a56bc51ae032 100644
--- a/drivers/ide/serverworks.c
+++ b/drivers/ide/serverworks.c
@@ -106,12 +106,13 @@ static u8 svwks_csb_check (struct pci_dev *dev)
106 return 0; 106 return 0;
107} 107}
108 108
109static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio) 109static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
110{ 110{
111 static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 111 static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
112 static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; 112 static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 };
113 113
114 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 114 struct pci_dev *dev = to_pci_dev(hwif->dev);
115 const u8 pio = drive->pio_mode - XFER_PIO_0;
115 116
116 pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); 117 pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]);
117 118
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c
index d95df528562f..97266958f744 100644
--- a/drivers/ide/siimage.c
+++ b/drivers/ide/siimage.c
@@ -229,19 +229,18 @@ static u8 sil_sata_udma_filter(ide_drive_t *drive)
229 229
230/** 230/**
231 * sil_set_pio_mode - set host controller for PIO mode 231 * sil_set_pio_mode - set host controller for PIO mode
232 * @hwif: port
232 * @drive: drive 233 * @drive: drive
233 * @pio: PIO mode number
234 * 234 *
235 * Load the timing settings for this device mode into the 235 * Load the timing settings for this device mode into the
236 * controller. 236 * controller.
237 */ 237 */
238 238
239static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) 239static void sil_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
240{ 240{
241 static const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 }; 241 static const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 };
242 static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 }; 242 static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 };
243 243
244 ide_hwif_t *hwif = drive->hwif;
245 struct pci_dev *dev = to_pci_dev(hwif->dev); 244 struct pci_dev *dev = to_pci_dev(hwif->dev);
246 ide_drive_t *pair = ide_get_pair_dev(drive); 245 ide_drive_t *pair = ide_get_pair_dev(drive);
247 u32 speedt = 0; 246 u32 speedt = 0;
@@ -249,6 +248,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
249 unsigned long addr = siimage_seldev(drive, 0x04); 248 unsigned long addr = siimage_seldev(drive, 0x04);
250 unsigned long tfaddr = siimage_selreg(hwif, 0x02); 249 unsigned long tfaddr = siimage_selreg(hwif, 0x02);
251 unsigned long base = (unsigned long)hwif->hwif_data; 250 unsigned long base = (unsigned long)hwif->hwif_data;
251 const u8 pio = drive->pio_mode - XFER_PIO_0;
252 u8 tf_pio = pio; 252 u8 tf_pio = pio;
253 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 253 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
254 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 254 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c
index 468706082fb5..5a0192060531 100644
--- a/drivers/ide/sis5513.c
+++ b/drivers/ide/sis5513.c
@@ -290,10 +290,10 @@ static void config_drive_art_rwp(ide_drive_t *drive)
290 pci_write_config_byte(dev, 0x4b, rw_prefetch); 290 pci_write_config_byte(dev, 0x4b, rw_prefetch);
291} 291}
292 292
293static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) 293static void sis_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
294{ 294{
295 config_drive_art_rwp(drive); 295 config_drive_art_rwp(drive);
296 sis_program_timings(drive, XFER_PIO_0 + pio); 296 sis_program_timings(drive, drive->pio_mode);
297} 297}
298 298
299static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) 299static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode)
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
index 3c2bbf0057ea..419cd3bc6c84 100644
--- a/drivers/ide/sl82c105.c
+++ b/drivers/ide/sl82c105.c
@@ -63,12 +63,13 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio)
63/* 63/*
64 * Configure the chipset for PIO mode. 64 * Configure the chipset for PIO mode.
65 */ 65 */
66static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) 66static void sl82c105_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
67{ 67{
68 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 68 struct pci_dev *dev = to_pci_dev(hwif->dev);
69 unsigned long timings = (unsigned long)ide_get_drivedata(drive); 69 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
70 int reg = 0x44 + drive->dn * 4; 70 int reg = 0x44 + drive->dn * 4;
71 u16 drv_ctrl; 71 u16 drv_ctrl;
72 const u8 pio = drive->pio_mode - XFER_PIO_0;
72 73
73 drv_ctrl = get_pio_timings(drive, pio); 74 drv_ctrl = get_pio_timings(drive, pio);
74 75
diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c
index 1ccfb40e7215..019777522cd2 100644
--- a/drivers/ide/slc90e66.c
+++ b/drivers/ide/slc90e66.c
@@ -18,9 +18,8 @@
18 18
19static DEFINE_SPINLOCK(slc90e66_lock); 19static DEFINE_SPINLOCK(slc90e66_lock);
20 20
21static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) 21static void slc90e66_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
22{ 22{
23 ide_hwif_t *hwif = drive->hwif;
24 struct pci_dev *dev = to_pci_dev(hwif->dev); 23 struct pci_dev *dev = to_pci_dev(hwif->dev);
25 int is_slave = drive->dn & 1; 24 int is_slave = drive->dn & 1;
26 int master_port = hwif->channel ? 0x42 : 0x40; 25 int master_port = hwif->channel ? 0x42 : 0x40;
@@ -29,6 +28,8 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
29 u16 master_data; 28 u16 master_data;
30 u8 slave_data; 29 u8 slave_data;
31 int control = 0; 30 int control = 0;
31 const u8 pio = drive->pio_mode - XFER_PIO_0;
32
32 /* ISP RTC */ 33 /* ISP RTC */
33 static const u8 timings[][2] = { 34 static const u8 timings[][2] = {
34 { 0, 0 }, 35 { 0, 0 },
@@ -98,7 +99,6 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
98 } 99 }
99 } else { 100 } else {
100 const u8 mwdma_to_pio[] = { 0, 3, 4 }; 101 const u8 mwdma_to_pio[] = { 0, 3, 4 };
101 u8 pio;
102 102
103 if (reg48 & u_flag) 103 if (reg48 & u_flag)
104 pci_write_config_word(dev, 0x48, reg48 & ~u_flag); 104 pci_write_config_word(dev, 0x48, reg48 & ~u_flag);
@@ -106,11 +106,12 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
106 pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); 106 pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
107 107
108 if (speed >= XFER_MW_DMA_0) 108 if (speed >= XFER_MW_DMA_0)
109 pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; 109 drive->pio_mode =
110 mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0;
110 else 111 else
111 pio = 2; /* only SWDMA2 is allowed */ 112 drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */
112 113
113 slc90e66_set_pio_mode(drive, pio); 114 slc90e66_set_pio_mode(hwif, drive);
114 } 115 }
115} 116}
116 117
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c
index 05a93d6baecc..f2cb62bf3f22 100644
--- a/drivers/ide/tc86c001.c
+++ b/drivers/ide/tc86c001.c
@@ -41,9 +41,9 @@ static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed)
41 outw(scr, scr_port); 41 outw(scr, scr_port);
42} 42}
43 43
44static void tc86c001_set_pio_mode(ide_drive_t *drive, const u8 pio) 44static void tc86c001_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
45{ 45{
46 tc86c001_set_mode(drive, XFER_PIO_0 + pio); 46 tc86c001_set_mode(drive, drive->pio_mode);
47} 47}
48 48
49/* 49/*
diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c
index 8773c3ba7462..d34a7eecdea5 100644
--- a/drivers/ide/triflex.c
+++ b/drivers/ide/triflex.c
@@ -82,9 +82,9 @@ static void triflex_set_mode(ide_drive_t *drive, const u8 speed)
82 pci_write_config_dword(dev, channel_offset, triflex_timings); 82 pci_write_config_dword(dev, channel_offset, triflex_timings);
83} 83}
84 84
85static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio) 85static void triflex_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
86{ 86{
87 triflex_set_mode(drive, XFER_PIO_0 + pio); 87 triflex_set_mode(drive, drive->pio_mode);
88} 88}
89 89
90static const struct ide_port_ops triflex_port_ops = { 90static const struct ide_port_ops triflex_port_ops = {
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index fd59c0d235b5..326d4683488b 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -56,11 +56,10 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch,
56 &tx4938_ebuscptr->cr[ebus_ch]); 56 &tx4938_ebuscptr->cr[ebus_ch]);
57} 57}
58 58
59static void tx4938ide_set_pio_mode(ide_drive_t *drive, const u8 pio) 59static void tx4938ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
60{ 60{
61 ide_hwif_t *hwif = drive->hwif;
62 struct tx4938ide_platform_info *pdata = hwif->dev->platform_data; 61 struct tx4938ide_platform_info *pdata = hwif->dev->platform_data;
63 u8 safe = pio; 62 u8 safe = drive->pio_mode - XFER_PIO_0;
64 ide_drive_t *pair; 63 ide_drive_t *pair;
65 64
66 pair = ide_get_pair_dev(drive); 65 pair = ide_get_pair_dev(drive);
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 64b58ecc3f0e..5228a4786de5 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -104,11 +104,11 @@ static void tx4939ide_writeb(u8 val, void __iomem *base, u32 reg)
104 104
105#define TX4939IDE_BASE(hwif) ((void __iomem *)(hwif)->extra_base) 105#define TX4939IDE_BASE(hwif) ((void __iomem *)(hwif)->extra_base)
106 106
107static void tx4939ide_set_pio_mode(ide_drive_t *drive, const u8 pio) 107static void tx4939ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
108{ 108{
109 ide_hwif_t *hwif = drive->hwif;
110 int is_slave = drive->dn; 109 int is_slave = drive->dn;
111 u32 mask, val; 110 u32 mask, val;
111 const u8 pio = drive->pio_mode - XFER_PIO_0;
112 u8 safe = pio; 112 u8 safe = pio;
113 ide_drive_t *pair; 113 ide_drive_t *pair;
114 114
diff --git a/drivers/ide/umc8672.c b/drivers/ide/umc8672.c
index 60f936e2319c..47adcd09cb26 100644
--- a/drivers/ide/umc8672.c
+++ b/drivers/ide/umc8672.c
@@ -104,10 +104,11 @@ static void umc_set_speeds(u8 speeds[])
104 speeds[0], speeds[1], speeds[2], speeds[3]); 104 speeds[0], speeds[1], speeds[2], speeds[3]);
105} 105}
106 106
107static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) 107static void umc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
108{ 108{
109 ide_hwif_t *hwif = drive->hwif, *mate = hwif->mate; 109 ide_hwif_t *mate = hwif->mate;
110 unsigned long uninitialized_var(flags); 110 unsigned long uninitialized_var(flags);
111 const u8 pio = drive->pio_mode - XFER_PIO_0;
111 112
112 printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", 113 printk("%s: setting umc8672 to PIO mode%d (speed %d)\n",
113 drive->name, pio, pio_to_umc[pio]); 114 drive->name, pio, pio_to_umc[pio]);
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index fbecf8ea8207..6d995fc9d4f5 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -208,15 +208,15 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed)
208 208
209/** 209/**
210 * via_set_pio_mode - set host controller for PIO mode 210 * via_set_pio_mode - set host controller for PIO mode
211 * @hwif: port
211 * @drive: drive 212 * @drive: drive
212 * @pio: PIO mode number
213 * 213 *
214 * A callback from the upper layers for PIO-only tuning. 214 * A callback from the upper layers for PIO-only tuning.
215 */ 215 */
216 216
217static void via_set_pio_mode(ide_drive_t *drive, const u8 pio) 217static void via_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
218{ 218{
219 via_set_drive(drive, XFER_PIO_0 + pio); 219 via_set_drive(drive, drive->pio_mode);
220} 220}
221 221
222static struct via_isa_bridge *via_config_find(struct pci_dev **isa) 222static struct via_isa_bridge *via_config_find(struct pci_dev **isa)
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 746ef9fdabcb..803ec306883c 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -624,7 +624,7 @@ extern const struct ide_tp_ops default_tp_ops;
624 */ 624 */
625struct ide_port_ops { 625struct ide_port_ops {
626 void (*init_dev)(ide_drive_t *); 626 void (*init_dev)(ide_drive_t *);
627 void (*set_pio_mode)(ide_drive_t *, const u8); 627 void (*set_pio_mode)(struct hwif_s *, ide_drive_t *);
628 void (*set_dma_mode)(ide_drive_t *, const u8); 628 void (*set_dma_mode)(ide_drive_t *, const u8);
629 int (*reset_poll)(ide_drive_t *); 629 int (*reset_poll)(ide_drive_t *);
630 void (*pre_reset)(ide_drive_t *); 630 void (*pre_reset)(ide_drive_t *);