diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:31 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:31 -0500 |
commit | 36501650ec45b1db308c3b51886044863be2d762 (patch) | |
tree | 74cf9d9f313e510f8424f9bac35da8d61cce9f7b /drivers/ide/pci/it821x.c | |
parent | f6fb786d6dcdd7d730e4fba620b071796f487e1b (diff) |
ide: keep pointer to struct device instead of struct pci_dev in ide_hwif_t
Keep pointer to struct device instead of struct pci_dev in ide_hwif_t.
While on it:
* Use *dev->dma_mask instead of pci_dev->dma_mask in ide_toggle_bounce().
There should be no functionality changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r-- | drivers/ide/pci/it821x.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index e610a5340fdc..c0797b82ce78 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -113,7 +113,8 @@ static int it8212_noraid; | |||
113 | 113 | ||
114 | static void it821x_program(ide_drive_t *drive, u16 timing) | 114 | static void it821x_program(ide_drive_t *drive, u16 timing) |
115 | { | 115 | { |
116 | ide_hwif_t *hwif = drive->hwif; | 116 | ide_hwif_t *hwif = drive->hwif; |
117 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
117 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 118 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
118 | int channel = hwif->channel; | 119 | int channel = hwif->channel; |
119 | u8 conf; | 120 | u8 conf; |
@@ -123,7 +124,8 @@ static void it821x_program(ide_drive_t *drive, u16 timing) | |||
123 | conf = timing >> 8; | 124 | conf = timing >> 8; |
124 | else | 125 | else |
125 | conf = timing & 0xFF; | 126 | conf = timing & 0xFF; |
126 | pci_write_config_byte(hwif->pci_dev, 0x54 + 4 * channel, conf); | 127 | |
128 | pci_write_config_byte(dev, 0x54 + 4 * channel, conf); | ||
127 | } | 129 | } |
128 | 130 | ||
129 | /** | 131 | /** |
@@ -137,7 +139,8 @@ static void it821x_program(ide_drive_t *drive, u16 timing) | |||
137 | 139 | ||
138 | static void it821x_program_udma(ide_drive_t *drive, u16 timing) | 140 | static void it821x_program_udma(ide_drive_t *drive, u16 timing) |
139 | { | 141 | { |
140 | ide_hwif_t *hwif = drive->hwif; | 142 | ide_hwif_t *hwif = drive->hwif; |
143 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
141 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 144 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
142 | int channel = hwif->channel; | 145 | int channel = hwif->channel; |
143 | int unit = drive->select.b.unit; | 146 | int unit = drive->select.b.unit; |
@@ -148,11 +151,12 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing) | |||
148 | conf = timing >> 8; | 151 | conf = timing >> 8; |
149 | else | 152 | else |
150 | conf = timing & 0xFF; | 153 | conf = timing & 0xFF; |
151 | if(itdev->timing10 == 0) | 154 | |
152 | pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + unit, conf); | 155 | if (itdev->timing10 == 0) |
156 | pci_write_config_byte(dev, 0x56 + 4 * channel + unit, conf); | ||
153 | else { | 157 | else { |
154 | pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel, conf); | 158 | pci_write_config_byte(dev, 0x56 + 4 * channel, conf); |
155 | pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + 1, conf); | 159 | pci_write_config_byte(dev, 0x56 + 4 * channel + 1, conf); |
156 | } | 160 | } |
157 | } | 161 | } |
158 | 162 | ||
@@ -167,6 +171,7 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing) | |||
167 | static void it821x_clock_strategy(ide_drive_t *drive) | 171 | static void it821x_clock_strategy(ide_drive_t *drive) |
168 | { | 172 | { |
169 | ide_hwif_t *hwif = drive->hwif; | 173 | ide_hwif_t *hwif = drive->hwif; |
174 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
170 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 175 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
171 | 176 | ||
172 | u8 unit = drive->select.b.unit; | 177 | u8 unit = drive->select.b.unit; |
@@ -205,10 +210,11 @@ static void it821x_clock_strategy(ide_drive_t *drive) | |||
205 | itdev->clock_mode = ATA_50; | 210 | itdev->clock_mode = ATA_50; |
206 | sel = 1; | 211 | sel = 1; |
207 | } | 212 | } |
208 | pci_read_config_byte(hwif->pci_dev, 0x50, &v); | 213 | |
214 | pci_read_config_byte(dev, 0x50, &v); | ||
209 | v &= ~(1 << (1 + hwif->channel)); | 215 | v &= ~(1 << (1 + hwif->channel)); |
210 | v |= sel << (1 + hwif->channel); | 216 | v |= sel << (1 + hwif->channel); |
211 | pci_write_config_byte(hwif->pci_dev, 0x50, v); | 217 | pci_write_config_byte(dev, 0x50, v); |
212 | 218 | ||
213 | /* | 219 | /* |
214 | * Reprogram the UDMA/PIO of the pair drive for the switch | 220 | * Reprogram the UDMA/PIO of the pair drive for the switch |
@@ -282,7 +288,8 @@ static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
282 | 288 | ||
283 | static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | 289 | static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) |
284 | { | 290 | { |
285 | ide_hwif_t *hwif = drive->hwif; | 291 | ide_hwif_t *hwif = drive->hwif; |
292 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
286 | struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); | 293 | struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); |
287 | int unit = drive->select.b.unit; | 294 | int unit = drive->select.b.unit; |
288 | int channel = hwif->channel; | 295 | int channel = hwif->channel; |
@@ -297,12 +304,12 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | |||
297 | itdev->udma[unit] = UDMA_OFF; | 304 | itdev->udma[unit] = UDMA_OFF; |
298 | 305 | ||
299 | /* UDMA bits off - Revision 0x10 do them in pairs */ | 306 | /* UDMA bits off - Revision 0x10 do them in pairs */ |
300 | pci_read_config_byte(hwif->pci_dev, 0x50, &conf); | 307 | pci_read_config_byte(dev, 0x50, &conf); |
301 | if(itdev->timing10) | 308 | if (itdev->timing10) |
302 | conf |= channel ? 0x60: 0x18; | 309 | conf |= channel ? 0x60: 0x18; |
303 | else | 310 | else |
304 | conf |= 1 << (3 + 2 * channel + unit); | 311 | conf |= 1 << (3 + 2 * channel + unit); |
305 | pci_write_config_byte(hwif->pci_dev, 0x50, conf); | 312 | pci_write_config_byte(dev, 0x50, conf); |
306 | 313 | ||
307 | it821x_clock_strategy(drive); | 314 | it821x_clock_strategy(drive); |
308 | /* FIXME: do we need to program this ? */ | 315 | /* FIXME: do we need to program this ? */ |
@@ -320,7 +327,8 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | |||
320 | 327 | ||
321 | static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) | 328 | static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) |
322 | { | 329 | { |
323 | ide_hwif_t *hwif = drive->hwif; | 330 | ide_hwif_t *hwif = drive->hwif; |
331 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
324 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 332 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
325 | int unit = drive->select.b.unit; | 333 | int unit = drive->select.b.unit; |
326 | int channel = hwif->channel; | 334 | int channel = hwif->channel; |
@@ -337,12 +345,12 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) | |||
337 | itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ | 345 | itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ |
338 | 346 | ||
339 | /* UDMA on. Again revision 0x10 must do the pair */ | 347 | /* UDMA on. Again revision 0x10 must do the pair */ |
340 | pci_read_config_byte(hwif->pci_dev, 0x50, &conf); | 348 | pci_read_config_byte(dev, 0x50, &conf); |
341 | if(itdev->timing10) | 349 | if (itdev->timing10) |
342 | conf &= channel ? 0x9F: 0xE7; | 350 | conf &= channel ? 0x9F: 0xE7; |
343 | else | 351 | else |
344 | conf &= ~ (1 << (3 + 2 * channel + unit)); | 352 | conf &= ~ (1 << (3 + 2 * channel + unit)); |
345 | pci_write_config_byte(hwif->pci_dev, 0x50, conf); | 353 | pci_write_config_byte(dev, 0x50, conf); |
346 | 354 | ||
347 | it821x_clock_strategy(drive); | 355 | it821x_clock_strategy(drive); |
348 | it821x_program_udma(drive, itdev->udma[unit]); | 356 | it821x_program_udma(drive, itdev->udma[unit]); |
@@ -520,6 +528,7 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive) | |||
520 | 528 | ||
521 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 529 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
522 | { | 530 | { |
531 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
523 | struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); | 532 | struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); |
524 | u8 conf; | 533 | u8 conf; |
525 | 534 | ||
@@ -532,7 +541,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
532 | 541 | ||
533 | ide_set_hwifdata(hwif, idev); | 542 | ide_set_hwifdata(hwif, idev); |
534 | 543 | ||
535 | pci_read_config_byte(hwif->pci_dev, 0x50, &conf); | 544 | pci_read_config_byte(dev, 0x50, &conf); |
536 | if (conf & 1) { | 545 | if (conf & 1) { |
537 | idev->smart = 1; | 546 | idev->smart = 1; |
538 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 547 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
@@ -555,7 +564,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
555 | * this is necessary. | 564 | * this is necessary. |
556 | */ | 565 | */ |
557 | 566 | ||
558 | pci_read_config_byte(hwif->pci_dev, 0x08, &conf); | 567 | pci_read_config_byte(dev, 0x08, &conf); |
559 | if (conf == 0x10) { | 568 | if (conf == 0x10) { |
560 | idev->timing10 = 1; | 569 | idev->timing10 = 1; |
561 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 570 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |