aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Ramos <joao.ramos@inov.pt>2009-06-15 16:13:44 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-06-15 16:13:44 -0400
commit5bfb151f1f565e6082304a30e8c81dfb6ed0b0c8 (patch)
tree331727c29645788035c4f4b0e617f8f0c9c52e1d
parent3779f818a42879038c4be8bc83123432b774279d (diff)
ide: do not access ide_drive_t 'drive_data' field directly
Change ide_drive_t 'drive_data' field from 'unsigned int' type to 'void *' type, allowing a wider range of values/types to be stored in this field. Added 'ide_get_drivedata' and 'ide_set_drivedata' helpers to get and set the 'drive_data' field. Fixed all host drivers to maintain coherency with the change in the 'drive_data' field type. Signed-off-by: Joao Ramos <joao.ramos@inov.pt> [bart: fix qd65xx build, cast to 'unsigned long', minor Coding Style fixups] Acked-by: Sergei Shtylyov <sshtylyov@ru.montavista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/cmd64x.c8
-rw-r--r--drivers/ide/cs5536.c23
-rw-r--r--drivers/ide/ht6560b.c33
-rw-r--r--drivers/ide/icside.c10
-rw-r--r--drivers/ide/opti621.c8
-rw-r--r--drivers/ide/qd65xx.c11
-rw-r--r--drivers/ide/qd65xx.h11
-rw-r--r--drivers/ide/sl82c105.c18
-rw-r--r--include/linux/ide.h12
9 files changed, 94 insertions, 40 deletions
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
index fd904e923a9f..03c86209446f 100644
--- a/drivers/ide/cmd64x.c
+++ b/drivers/ide/cmd64x.c
@@ -118,8 +118,9 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio)
118 ide_hwif_t *hwif = drive->hwif; 118 ide_hwif_t *hwif = drive->hwif;
119 struct pci_dev *dev = to_pci_dev(hwif->dev); 119 struct pci_dev *dev = to_pci_dev(hwif->dev);
120 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);
121 unsigned long setup_count;
121 unsigned int cycle_time; 122 unsigned int cycle_time;
122 u8 setup_count, arttim = 0; 123 u8 arttim = 0;
123 124
124 static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; 125 static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
125 static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; 126 static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23};
@@ -140,10 +141,11 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio)
140 if (hwif->channel) { 141 if (hwif->channel) {
141 ide_drive_t *pair = ide_get_pair_dev(drive); 142 ide_drive_t *pair = ide_get_pair_dev(drive);
142 143
143 drive->drive_data = setup_count; 144 ide_set_drivedata(drive, (void *)setup_count);
144 145
145 if (pair) 146 if (pair)
146 setup_count = max_t(u8, setup_count, pair->drive_data); 147 setup_count = max_t(u8, setup_count,
148 (unsigned long)ide_get_drivedata(pair));
147 } 149 }
148 150
149 if (setup_count > 5) /* shouldn't actually happen... */ 151 if (setup_count > 5) /* shouldn't actually happen... */
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c
index 0332a95eefd4..9623b852c616 100644
--- a/drivers/ide/cs5536.c
+++ b/drivers/ide/cs5536.c
@@ -146,14 +146,16 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
146 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); 146 struct pci_dev *pdev = to_pci_dev(drive->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 u32 cast; 150 u32 cast;
150 u8 cmd_pio = pio; 151 u8 cmd_pio = pio;
151 152
152 if (pair) 153 if (pair)
153 cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4)); 154 cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4));
154 155
155 drive->drive_data &= (IDE_DRV_MASK << 8); 156 timings &= (IDE_DRV_MASK << 8);
156 drive->drive_data |= drv_timings[pio]; 157 timings |= drv_timings[pio];
158 ide_set_drivedata(drive, (void *)timings);
157 159
158 cs5536_program_dtc(drive, drv_timings[pio]); 160 cs5536_program_dtc(drive, drv_timings[pio]);
159 161
@@ -186,6 +188,7 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
186 188
187 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); 189 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
188 int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT; 190 int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT;
191 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
189 u32 etc; 192 u32 etc;
190 193
191 cs5536_read(pdev, ETC, &etc); 194 cs5536_read(pdev, ETC, &etc);
@@ -195,8 +198,9 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
195 etc |= udma_timings[mode - XFER_UDMA_0] << dshift; 198 etc |= udma_timings[mode - XFER_UDMA_0] << dshift;
196 } else { /* MWDMA */ 199 } else { /* MWDMA */
197 etc &= ~(IDE_ETC_UDMA_MASK << dshift); 200 etc &= ~(IDE_ETC_UDMA_MASK << dshift);
198 drive->drive_data &= IDE_DRV_MASK; 201 timings &= IDE_DRV_MASK;
199 drive->drive_data |= mwdma_timings[mode - XFER_MW_DMA_0] << 8; 202 timings |= mwdma_timings[mode - XFER_MW_DMA_0] << 8;
203 ide_set_drivedata(drive, (void *)timings);
200 } 204 }
201 205
202 cs5536_write(pdev, ETC, etc); 206 cs5536_write(pdev, ETC, etc);
@@ -204,9 +208,11 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
204 208
205static void cs5536_dma_start(ide_drive_t *drive) 209static void cs5536_dma_start(ide_drive_t *drive)
206{ 210{
211 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
212
207 if (drive->current_speed < XFER_UDMA_0 && 213 if (drive->current_speed < XFER_UDMA_0 &&
208 (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK)) 214 (timings >> 8) != (timings & IDE_DRV_MASK))
209 cs5536_program_dtc(drive, drive->drive_data >> 8); 215 cs5536_program_dtc(drive, timings >> 8);
210 216
211 ide_dma_start(drive); 217 ide_dma_start(drive);
212} 218}
@@ -214,10 +220,11 @@ static void cs5536_dma_start(ide_drive_t *drive)
214static int cs5536_dma_end(ide_drive_t *drive) 220static int cs5536_dma_end(ide_drive_t *drive)
215{ 221{
216 int ret = ide_dma_end(drive); 222 int ret = ide_dma_end(drive);
223 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
217 224
218 if (drive->current_speed < XFER_UDMA_0 && 225 if (drive->current_speed < XFER_UDMA_0 &&
219 (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK)) 226 (timings >> 8) != (timings & IDE_DRV_MASK))
220 cs5536_program_dtc(drive, drive->drive_data & IDE_DRV_MASK); 227 cs5536_program_dtc(drive, timings & IDE_DRV_MASK);
221 228
222 return ret; 229 return ret;
223} 230}
diff --git a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c
index 2fb0f2965009..aafed8060e17 100644
--- a/drivers/ide/ht6560b.c
+++ b/drivers/ide/ht6560b.c
@@ -44,7 +44,12 @@
44 * bit3 (0x08): "1" 3 cycle time, "0" 2 cycle time (?) 44 * bit3 (0x08): "1" 3 cycle time, "0" 2 cycle time (?)
45 */ 45 */
46#define HT_CONFIG_PORT 0x3e6 46#define HT_CONFIG_PORT 0x3e6
47#define HT_CONFIG(drivea) (u8)(((drivea)->drive_data & 0xff00) >> 8) 47
48static inline u8 HT_CONFIG(ide_drive_t *drive)
49{
50 return ((unsigned long)ide_get_drivedata(drive) & 0xff00) >> 8;
51}
52
48/* 53/*
49 * FIFO + PREFETCH (both a/b-model) 54 * FIFO + PREFETCH (both a/b-model)
50 */ 55 */
@@ -90,7 +95,11 @@
90 * Active Time for each drive. Smaller value gives higher speed. 95 * Active Time for each drive. Smaller value gives higher speed.
91 * In case of failures you should probably fall back to a higher value. 96 * In case of failures you should probably fall back to a higher value.
92 */ 97 */
93#define HT_TIMING(drivea) (u8)((drivea)->drive_data & 0x00ff) 98static inline u8 HT_TIMING(ide_drive_t *drive)
99{
100 return (unsigned long)ide_get_drivedata(drive) & 0x00ff;
101}
102
94#define HT_TIMING_DEFAULT 0xff 103#define HT_TIMING_DEFAULT 0xff
95 104
96/* 105/*
@@ -242,23 +251,27 @@ static DEFINE_SPINLOCK(ht6560b_lock);
242 */ 251 */
243static void ht_set_prefetch(ide_drive_t *drive, u8 state) 252static void ht_set_prefetch(ide_drive_t *drive, u8 state)
244{ 253{
245 unsigned long flags; 254 unsigned long flags, config;
246 int t = HT_PREFETCH_MODE << 8; 255 int t = HT_PREFETCH_MODE << 8;
247 256
248 spin_lock_irqsave(&ht6560b_lock, flags); 257 spin_lock_irqsave(&ht6560b_lock, flags);
249 258
259 config = (unsigned long)ide_get_drivedata(drive);
260
250 /* 261 /*
251 * Prefetch mode and unmask irq seems to conflict 262 * Prefetch mode and unmask irq seems to conflict
252 */ 263 */
253 if (state) { 264 if (state) {
254 drive->drive_data |= t; /* enable prefetch mode */ 265 config |= t; /* enable prefetch mode */
255 drive->dev_flags |= IDE_DFLAG_NO_UNMASK; 266 drive->dev_flags |= IDE_DFLAG_NO_UNMASK;
256 drive->dev_flags &= ~IDE_DFLAG_UNMASK; 267 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
257 } else { 268 } else {
258 drive->drive_data &= ~t; /* disable prefetch mode */ 269 config &= ~t; /* disable prefetch mode */
259 drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK; 270 drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK;
260 } 271 }
261 272
273 ide_set_drivedata(drive, (void *)config);
274
262 spin_unlock_irqrestore(&ht6560b_lock, flags); 275 spin_unlock_irqrestore(&ht6560b_lock, flags);
263 276
264#ifdef DEBUG 277#ifdef DEBUG
@@ -268,7 +281,7 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state)
268 281
269static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) 282static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio)
270{ 283{
271 unsigned long flags; 284 unsigned long flags, config;
272 u8 timing; 285 u8 timing;
273 286
274 switch (pio) { 287 switch (pio) {
@@ -281,8 +294,10 @@ static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio)
281 timing = ht_pio2timings(drive, pio); 294 timing = ht_pio2timings(drive, pio);
282 295
283 spin_lock_irqsave(&ht6560b_lock, flags); 296 spin_lock_irqsave(&ht6560b_lock, flags);
284 drive->drive_data &= 0xff00; 297 config = (unsigned long)ide_get_drivedata(drive);
285 drive->drive_data |= timing; 298 config &= 0xff00;
299 config |= timing;
300 ide_set_drivedata(drive, (void *)config);
286 spin_unlock_irqrestore(&ht6560b_lock, flags); 301 spin_unlock_irqrestore(&ht6560b_lock, flags);
287 302
288#ifdef DEBUG 303#ifdef DEBUG
@@ -299,7 +314,7 @@ static void __init ht6560b_init_dev(ide_drive_t *drive)
299 if (hwif->channel) 314 if (hwif->channel)
300 t |= (HT_SECONDARY_IF << 8); 315 t |= (HT_SECONDARY_IF << 8);
301 316
302 drive->drive_data = t; 317 ide_set_drivedata(drive, (void *)t);
303} 318}
304 319
305static int probe_ht6560b; 320static int probe_ht6560b;
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 5af3d0ffaf0a..0f67f1abbbd3 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -187,7 +187,8 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = {
187 */ 187 */
188static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) 188static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
189{ 189{
190 int cycle_time, use_dma_info = 0; 190 unsigned long cycle_time;
191 int use_dma_info = 0;
191 192
192 switch (xfer_mode) { 193 switch (xfer_mode) {
193 case XFER_MW_DMA_2: 194 case XFER_MW_DMA_2:
@@ -218,10 +219,11 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
218 if (use_dma_info && drive->id[ATA_ID_EIDE_DMA_TIME] > cycle_time) 219 if (use_dma_info && drive->id[ATA_ID_EIDE_DMA_TIME] > cycle_time)
219 cycle_time = drive->id[ATA_ID_EIDE_DMA_TIME]; 220 cycle_time = drive->id[ATA_ID_EIDE_DMA_TIME];
220 221
221 drive->drive_data = cycle_time; 222 ide_set_drivedata(drive, (void *)cycle_time);
222 223
223 printk("%s: %s selected (peak %dMB/s)\n", drive->name, 224 printk("%s: %s selected (peak %dMB/s)\n", drive->name,
224 ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); 225 ide_xfer_verbose(xfer_mode),
226 2000 / (unsigned long)ide_get_drivedata(drive));
225} 227}
226 228
227static const struct ide_port_ops icside_v6_port_ops = { 229static const struct ide_port_ops icside_v6_port_ops = {
@@ -277,7 +279,7 @@ static int icside_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
277 /* 279 /*
278 * Select the correct timing for this drive. 280 * Select the correct timing for this drive.
279 */ 281 */
280 set_dma_speed(ec->dma, drive->drive_data); 282 set_dma_speed(ec->dma, (unsigned long)ide_get_drivedata(drive));
281 283
282 /* 284 /*
283 * Tell the DMA engine about the SG table and 285 * Tell the DMA engine about the SG table and
diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c
index 6048eda3cd61..f1d70d6630fe 100644
--- a/drivers/ide/opti621.c
+++ b/drivers/ide/opti621.c
@@ -138,6 +138,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
138 ide_hwif_t *hwif = drive->hwif; 138 ide_hwif_t *hwif = drive->hwif;
139 ide_drive_t *pair = ide_get_pair_dev(drive); 139 ide_drive_t *pair = ide_get_pair_dev(drive);
140 unsigned long flags; 140 unsigned long flags;
141 unsigned long mode = XFER_PIO_0 + pio, pair_mode;
141 u8 tim, misc, addr_pio = pio, clk; 142 u8 tim, misc, addr_pio = pio, clk;
142 143
143 /* DRDY is default 2 (by OPTi Databook) */ 144 /* DRDY is default 2 (by OPTi Databook) */
@@ -150,11 +151,12 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
150 { 0x48, 0x34, 0x21, 0x10, 0x10 } /* 25 MHz */ 151 { 0x48, 0x34, 0x21, 0x10, 0x10 } /* 25 MHz */
151 }; 152 };
152 153
153 drive->drive_data = XFER_PIO_0 + pio; 154 ide_set_drivedata(drive, (void *)mode);
154 155
155 if (pair) { 156 if (pair) {
156 if (pair->drive_data && pair->drive_data < drive->drive_data) 157 pair_mode = (unsigned long)ide_get_drivedata(pair);
157 addr_pio = pair->drive_data - XFER_PIO_0; 158 if (pair_mode && pair_mode < mode)
159 addr_pio = pair_mode - XFER_PIO_0;
158 } 160 }
159 161
160 spin_lock_irqsave(&opti621_lock, flags); 162 spin_lock_irqsave(&opti621_lock, flags);
diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c
index c9a134986891..74696edc8d1d 100644
--- a/drivers/ide/qd65xx.c
+++ b/drivers/ide/qd65xx.c
@@ -180,8 +180,11 @@ static int qd_find_disk_type (ide_drive_t *drive,
180 180
181static void qd_set_timing (ide_drive_t *drive, u8 timing) 181static void qd_set_timing (ide_drive_t *drive, u8 timing)
182{ 182{
183 drive->drive_data &= 0xff00; 183 unsigned long data = (unsigned long)ide_get_drivedata(drive);
184 drive->drive_data |= timing; 184
185 data &= 0xff00;
186 data |= timing;
187 ide_set_drivedata(drive, (void *)data);
185 188
186 printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); 189 printk(KERN_DEBUG "%s: %#x\n", drive->name, timing);
187} 190}
@@ -292,7 +295,7 @@ static void __init qd6500_init_dev(ide_drive_t *drive)
292 u8 base = (hwif->config_data & 0xff00) >> 8; 295 u8 base = (hwif->config_data & 0xff00) >> 8;
293 u8 config = QD_CONFIG(hwif); 296 u8 config = QD_CONFIG(hwif);
294 297
295 drive->drive_data = QD6500_DEF_DATA; 298 ide_set_drivedata(drive, (void *)QD6500_DEF_DATA);
296} 299}
297 300
298static void __init qd6580_init_dev(ide_drive_t *drive) 301static void __init qd6580_init_dev(ide_drive_t *drive)
@@ -308,7 +311,7 @@ static void __init qd6580_init_dev(ide_drive_t *drive)
308 } else 311 } else
309 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA; 312 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA;
310 313
311 drive->drive_data = (drive->dn & 1) ? t2 : t1; 314 ide_set_drivedata(drive, (void *)((drive->dn & 1) ? t2 : t1));
312} 315}
313 316
314static const struct ide_tp_ops qd65xx_tp_ops = { 317static const struct ide_tp_ops qd65xx_tp_ops = {
diff --git a/drivers/ide/qd65xx.h b/drivers/ide/qd65xx.h
index d7e67a1a1dcc..1fba2a5f281c 100644
--- a/drivers/ide/qd65xx.h
+++ b/drivers/ide/qd65xx.h
@@ -31,8 +31,15 @@
31 31
32#define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) 32#define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff)
33 33
34#define QD_TIMING(drive) (u8)(((drive)->drive_data) & 0x00ff) 34static inline u8 QD_TIMING(ide_drive_t *drive)
35#define QD_TIMREG(drive) (u8)((((drive)->drive_data) & 0xff00) >> 8) 35{
36 return (unsigned long)ide_get_drivedata(drive) & 0x00ff;
37}
38
39static inline u8 QD_TIMREG(ide_drive_t *drive)
40{
41 return ((unsigned long)ide_get_drivedata(drive) & 0xff00) >> 8;
42}
36 43
37#define QD6500_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08)) 44#define QD6500_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08))
38#define QD6580_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00)) 45#define QD6580_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00))
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
index 6246bea585c4..d698da470d6f 100644
--- a/drivers/ide/sl82c105.c
+++ b/drivers/ide/sl82c105.c
@@ -73,6 +73,7 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio)
73static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) 73static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio)
74{ 74{
75 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 75 struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
76 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
76 int reg = 0x44 + drive->dn * 4; 77 int reg = 0x44 + drive->dn * 4;
77 u16 drv_ctrl; 78 u16 drv_ctrl;
78 79
@@ -82,8 +83,9 @@ static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio)
82 * Store the PIO timings so that we can restore them 83 * Store the PIO timings so that we can restore them
83 * in case DMA will be turned off... 84 * in case DMA will be turned off...
84 */ 85 */
85 drive->drive_data &= 0xffff0000; 86 timings &= 0xffff0000;
86 drive->drive_data |= drv_ctrl; 87 timings |= drv_ctrl;
88 ide_set_drivedata(drive, (void *)timings);
87 89
88 pci_write_config_word(dev, reg, drv_ctrl); 90 pci_write_config_word(dev, reg, drv_ctrl);
89 pci_read_config_word (dev, reg, &drv_ctrl); 91 pci_read_config_word (dev, reg, &drv_ctrl);
@@ -99,6 +101,7 @@ static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio)
99static void sl82c105_set_dma_mode(ide_drive_t *drive, const u8 speed) 101static void sl82c105_set_dma_mode(ide_drive_t *drive, const u8 speed)
100{ 102{
101 static u16 mwdma_timings[] = {0x0707, 0x0201, 0x0200}; 103 static u16 mwdma_timings[] = {0x0707, 0x0201, 0x0200};
104 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
102 u16 drv_ctrl; 105 u16 drv_ctrl;
103 106
104 DBG(("sl82c105_tune_chipset(drive:%s, speed:%s)\n", 107 DBG(("sl82c105_tune_chipset(drive:%s, speed:%s)\n",
@@ -110,8 +113,9 @@ static void sl82c105_set_dma_mode(ide_drive_t *drive, const u8 speed)
110 * Store the DMA timings so that we can actually program 113 * Store the DMA timings so that we can actually program
111 * them when DMA will be turned on... 114 * them when DMA will be turned on...
112 */ 115 */
113 drive->drive_data &= 0x0000ffff; 116 timings &= 0x0000ffff;
114 drive->drive_data |= (unsigned long)drv_ctrl << 16; 117 timings |= (unsigned long)drv_ctrl << 16;
118 ide_set_drivedata(drive, (void *)timings);
115} 119}
116 120
117static int sl82c105_test_irq(ide_hwif_t *hwif) 121static int sl82c105_test_irq(ide_hwif_t *hwif)
@@ -194,7 +198,8 @@ static void sl82c105_dma_start(ide_drive_t *drive)
194 198
195 DBG(("%s(drive:%s)\n", __func__, drive->name)); 199 DBG(("%s(drive:%s)\n", __func__, drive->name));
196 200
197 pci_write_config_word(dev, reg, drive->drive_data >> 16); 201 pci_write_config_word(dev, reg,
202 (unsigned long)ide_get_drivedata(drive) >> 16);
198 203
199 sl82c105_reset_host(dev); 204 sl82c105_reset_host(dev);
200 ide_dma_start(drive); 205 ide_dma_start(drive);
@@ -219,7 +224,8 @@ static int sl82c105_dma_end(ide_drive_t *drive)
219 224
220 ret = ide_dma_end(drive); 225 ret = ide_dma_end(drive);
221 226
222 pci_write_config_word(dev, reg, drive->drive_data); 227 pci_write_config_word(dev, reg,
228 (unsigned long)ide_get_drivedata(drive));
223 229
224 return ret; 230 return ret;
225} 231}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 08c91e21cf47..95c6e00a72e8 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -532,7 +532,7 @@ struct ide_drive_s {
532 532
533 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 533 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
534 unsigned int cyl; /* "real" number of cyls */ 534 unsigned int cyl; /* "real" number of cyls */
535 unsigned int drive_data; /* used by set_pio_mode/dev_select() */ 535 void *drive_data; /* used by set_pio_mode/dev_select() */
536 unsigned int failures; /* current failure count */ 536 unsigned int failures; /* current failure count */
537 unsigned int max_failures; /* maximum allowed failure count */ 537 unsigned int max_failures; /* maximum allowed failure count */
538 u64 probed_capacity;/* initial/native media capacity */ 538 u64 probed_capacity;/* initial/native media capacity */
@@ -1550,6 +1550,16 @@ static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
1550 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; 1550 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL;
1551} 1551}
1552 1552
1553static inline void *ide_get_drivedata(ide_drive_t *drive)
1554{
1555 return drive->drive_data;
1556}
1557
1558static inline void ide_set_drivedata(ide_drive_t *drive, void *data)
1559{
1560 drive->drive_data = data;
1561}
1562
1553#define ide_port_for_each_dev(i, dev, port) \ 1563#define ide_port_for_each_dev(i, dev, port) \
1554 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) 1564 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
1555 1565