aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-26 14:13:03 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-26 14:13:03 -0500
commitf01393e48c44e30f7c9a36c8b98a07b0232580fe (patch)
treed585310ef7ee6509285a96b849af2e544e5fea25
parent6dd9b8376adbee95ddc321cc83c7f641577e01f6 (diff)
ide: merge ->fixup and ->quirkproc methods
* Assign drive->quirk_list in ->quirkproc implementations: - hpt366.c::hpt3xx_quirkproc() - pdc202xx_new.c::pdcnew_quirkproc() - pdc202xx_old.c::pdc202xx_quirkproc() * Make ->quirkproc void. * Move calling ->quirkproc from do_identify() to probe_hwif(). * Convert it821x_fixups() to it821x_quirkproc() in it821x.c. * Convert siimage_fixup() to sil_quirkproc() in siimage.c, also remove no longer needed drive->present check from is_dev_seagate_sata(). * Convert ide_undecoded_slave() to accept 'drive' instead of 'hwif' as an argument. Then convert ide_register_hw() to accept 'quirkproc' argument instead of 'fixup' one. * Remove no longer needed ->fixup method. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-probe.c20
-rw-r--r--drivers/ide/ide.c8
-rw-r--r--drivers/ide/pci/hpt366.c11
-rw-r--r--drivers/ide/pci/it821x.c37
-rw-r--r--drivers/ide/pci/pdc202xx_new.c11
-rw-r--r--drivers/ide/pci/pdc202xx_old.c11
-rw-r--r--drivers/ide/pci/siimage.c15
-rw-r--r--drivers/ide/setup-pci.c2
-rw-r--r--include/linux/ide.h10
9 files changed, 57 insertions, 68 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index fa95e79b9505..c446e348e29a 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -235,9 +235,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
235 drive->media = ide_disk; 235 drive->media = ide_disk;
236 printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" ); 236 printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" );
237 237
238 if (hwif->quirkproc)
239 drive->quirk_list = hwif->quirkproc(drive);
240
241 return; 238 return;
242 239
243err_misc: 240err_misc:
@@ -676,19 +673,18 @@ out:
676 673
677/** 674/**
678 * ide_undecoded_slave - look for bad CF adapters 675 * ide_undecoded_slave - look for bad CF adapters
679 * @hwif: interface 676 * @drive1: drive
680 * 677 *
681 * Analyse the drives on the interface and attempt to decide if we 678 * Analyse the drives on the interface and attempt to decide if we
682 * have the same drive viewed twice. This occurs with crap CF adapters 679 * have the same drive viewed twice. This occurs with crap CF adapters
683 * and PCMCIA sometimes. 680 * and PCMCIA sometimes.
684 */ 681 */
685 682
686void ide_undecoded_slave(ide_hwif_t *hwif) 683void ide_undecoded_slave(ide_drive_t *drive1)
687{ 684{
688 ide_drive_t *drive0 = &hwif->drives[0]; 685 ide_drive_t *drive0 = &drive1->hwif->drives[0];
689 ide_drive_t *drive1 = &hwif->drives[1];
690 686
691 if (drive0->present == 0 || drive1->present == 0) 687 if ((drive1->dn & 1) == 0 || drive0->present == 0)
692 return; 688 return;
693 689
694 /* If the models don't match they are not the same product */ 690 /* If the models don't match they are not the same product */
@@ -817,8 +813,12 @@ static void probe_hwif(ide_hwif_t *hwif)
817 return; 813 return;
818 } 814 }
819 815
820 if (hwif->fixup) 816 for (unit = 0; unit < MAX_DRIVES; unit++) {
821 hwif->fixup(hwif); 817 ide_drive_t *drive = &hwif->drives[unit];
818
819 if (drive->present && hwif->quirkproc)
820 hwif->quirkproc(drive);
821 }
822 822
823 for (unit = 0; unit < MAX_DRIVES; ++unit) { 823 for (unit = 0; unit < MAX_DRIVES; ++unit) {
824 ide_drive_t *drive = &hwif->drives[unit]; 824 ide_drive_t *drive = &hwif->drives[unit];
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 7819fbd4d5fd..0d7328e0fb96 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -414,8 +414,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
414 hwif->cds = tmp_hwif->cds; 414 hwif->cds = tmp_hwif->cds;
415#endif 415#endif
416 416
417 hwif->fixup = tmp_hwif->fixup;
418
419 hwif->set_pio_mode = tmp_hwif->set_pio_mode; 417 hwif->set_pio_mode = tmp_hwif->set_pio_mode;
420 hwif->set_dma_mode = tmp_hwif->set_dma_mode; 418 hwif->set_dma_mode = tmp_hwif->set_dma_mode;
421 hwif->mdma_filter = tmp_hwif->mdma_filter; 419 hwif->mdma_filter = tmp_hwif->mdma_filter;
@@ -680,7 +678,7 @@ void ide_setup_ports ( hw_regs_t *hw,
680/** 678/**
681 * ide_register_hw - register IDE interface 679 * ide_register_hw - register IDE interface
682 * @hw: hardware registers 680 * @hw: hardware registers
683 * @fixup: fixup function 681 * @quirkproc: quirkproc function
684 * @initializing: set while initializing built-in drivers 682 * @initializing: set while initializing built-in drivers
685 * @hwifp: pointer to returned hwif 683 * @hwifp: pointer to returned hwif
686 * 684 *
@@ -690,7 +688,7 @@ void ide_setup_ports ( hw_regs_t *hw,
690 * Returns -1 on error. 688 * Returns -1 on error.
691 */ 689 */
692 690
693int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *), 691int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
694 int initializing, ide_hwif_t **hwifp) 692 int initializing, ide_hwif_t **hwifp)
695{ 693{
696 int index, retry = 1; 694 int index, retry = 1;
@@ -726,7 +724,7 @@ found:
726 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); 724 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
727 hwif->irq = hw->irq; 725 hwif->irq = hw->irq;
728 hwif->noprobe = 0; 726 hwif->noprobe = 0;
729 hwif->fixup = fixup; 727 hwif->quirkproc = quirkproc;
730 hwif->chipset = hw->chipset; 728 hwif->chipset = hw->chipset;
731 hwif->gendev.parent = hw->dev; 729 hwif->gendev.parent = hw->dev;
732 hwif->ack_intr = hw->ack_intr; 730 hwif->ack_intr = hw->ack_intr;
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 3777fb8c8043..12685939a813 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -725,15 +725,18 @@ static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
725 hpt3xx_set_mode(drive, XFER_PIO_0 + pio); 725 hpt3xx_set_mode(drive, XFER_PIO_0 + pio);
726} 726}
727 727
728static int hpt3xx_quirkproc(ide_drive_t *drive) 728static void hpt3xx_quirkproc(ide_drive_t *drive)
729{ 729{
730 struct hd_driveid *id = drive->id; 730 struct hd_driveid *id = drive->id;
731 const char **list = quirk_drives; 731 const char **list = quirk_drives;
732 732
733 while (*list) 733 while (*list)
734 if (strstr(id->model, *list++)) 734 if (strstr(id->model, *list++)) {
735 return 1; 735 drive->quirk_list = 1;
736 return 0; 736 return;
737 }
738
739 drive->quirk_list = 0;
737} 740}
738 741
739static void hpt3xx_maskproc(ide_drive_t *drive, int mask) 742static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 99b7d763b6c7..e610a5340fdc 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -431,33 +431,29 @@ static u8 __devinit ata66_it821x(ide_hwif_t *hwif)
431} 431}
432 432
433/** 433/**
434 * it821x_fixup - post init callback 434 * it821x_quirkproc - post init callback
435 * @hwif: interface 435 * @drive: drive
436 * 436 *
437 * This callback is run after the drives have been probed but 437 * This callback is run after the drive has been probed but
438 * before anything gets attached. It allows drivers to do any 438 * before anything gets attached. It allows drivers to do any
439 * final tuning that is needed, or fixups to work around bugs. 439 * final tuning that is needed, or fixups to work around bugs.
440 */ 440 */
441 441
442static void __devinit it821x_fixups(ide_hwif_t *hwif) 442static void __devinit it821x_quirkproc(ide_drive_t *drive)
443{ 443{
444 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 444 struct it821x_dev *itdev = ide_get_hwifdata(drive->hwif);
445 int i; 445 struct hd_driveid *id = drive->id;
446 u16 *idbits = (u16 *)drive->id;
446 447
447 if(!itdev->smart) { 448 if (!itdev->smart) {
448 /* 449 /*
449 * If we are in pass through mode then not much 450 * If we are in pass through mode then not much
450 * needs to be done, but we do bother to clear the 451 * needs to be done, but we do bother to clear the
451 * IRQ mask as we may well be in PIO (eg rev 0x10) 452 * IRQ mask as we may well be in PIO (eg rev 0x10)
452 * for now and we know unmasking is safe on this chipset. 453 * for now and we know unmasking is safe on this chipset.
453 */ 454 */
454 for (i = 0; i < 2; i++) { 455 drive->unmask = 1;
455 ide_drive_t *drive = &hwif->drives[i]; 456 } else {
456 if(drive->present)
457 drive->unmask = 1;
458 }
459 return;
460 }
461 /* 457 /*
462 * Perform fixups on smart mode. We need to "lose" some 458 * Perform fixups on smart mode. We need to "lose" some
463 * capabilities the firmware lacks but does not filter, and 459 * capabilities the firmware lacks but does not filter, and
@@ -465,16 +461,6 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
465 * in RAID mode. 461 * in RAID mode.
466 */ 462 */
467 463
468 for(i = 0; i < 2; i++) {
469 ide_drive_t *drive = &hwif->drives[i];
470 struct hd_driveid *id;
471 u16 *idbits;
472
473 if(!drive->present)
474 continue;
475 id = drive->id;
476 idbits = (u16 *)drive->id;
477
478 /* Check for RAID v native */ 464 /* Check for RAID v native */
479 if(strstr(id->model, "Integrated Technology Express")) { 465 if(strstr(id->model, "Integrated Technology Express")) {
480 /* In raid mode the ident block is slightly buggy 466 /* In raid mode the ident block is slightly buggy
@@ -537,6 +523,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
537 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); 523 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
538 u8 conf; 524 u8 conf;
539 525
526 hwif->quirkproc = &it821x_quirkproc;
527
540 if (idev == NULL) { 528 if (idev == NULL) {
541 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); 529 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
542 return; 530 return;
@@ -633,7 +621,6 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha
633 .name = name_str, \ 621 .name = name_str, \
634 .init_chipset = init_chipset_it821x, \ 622 .init_chipset = init_chipset_it821x, \
635 .init_hwif = init_hwif_it821x, \ 623 .init_hwif = init_hwif_it821x, \
636 .fixup = it821x_fixups, \
637 .host_flags = IDE_HFLAG_BOOTABLE, \ 624 .host_flags = IDE_HFLAG_BOOTABLE, \
638 .pio_mask = ATA_PIO4, \ 625 .pio_mask = ATA_PIO4, \
639 } 626 }
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index ef4a99b99d1f..89d2363a1ebd 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -203,14 +203,17 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
203 return ATA_CBL_PATA80; 203 return ATA_CBL_PATA80;
204} 204}
205 205
206static int pdcnew_quirkproc(ide_drive_t *drive) 206static void pdcnew_quirkproc(ide_drive_t *drive)
207{ 207{
208 const char **list, *model = drive->id->model; 208 const char **list, *model = drive->id->model;
209 209
210 for (list = pdc_quirk_drives; *list != NULL; list++) 210 for (list = pdc_quirk_drives; *list != NULL; list++)
211 if (strstr(model, *list) != NULL) 211 if (strstr(model, *list) != NULL) {
212 return 2; 212 drive->quirk_list = 2;
213 return 0; 213 return;
214 }
215
216 drive->quirk_list = 0;
214} 217}
215 218
216static void pdcnew_reset(ide_drive_t *drive) 219static void pdcnew_reset(ide_drive_t *drive)
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 67b2781e2213..3a1e081fe390 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -176,14 +176,17 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
176 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); 176 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
177} 177}
178 178
179static int pdc202xx_quirkproc (ide_drive_t *drive) 179static void pdc202xx_quirkproc(ide_drive_t *drive)
180{ 180{
181 const char **list, *model = drive->id->model; 181 const char **list, *model = drive->id->model;
182 182
183 for (list = pdc_quirk_drives; *list != NULL; list++) 183 for (list = pdc_quirk_drives; *list != NULL; list++)
184 if (strstr(model, *list) != NULL) 184 if (strstr(model, *list) != NULL) {
185 return 2; 185 drive->quirk_list = 2;
186 return 0; 186 return;
187 }
188
189 drive->quirk_list = 0;
187} 190}
188 191
189static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) 192static void pdc202xx_old_ide_dma_start(ide_drive_t *drive)
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 7b45eaf5afd9..908f37b4e0ee 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -713,9 +713,6 @@ static int is_dev_seagate_sata(ide_drive_t *drive)
713 const char *s = &drive->id->model[0]; 713 const char *s = &drive->id->model[0];
714 unsigned len; 714 unsigned len;
715 715
716 if (!drive->present)
717 return 0;
718
719 len = strnlen(s, sizeof(drive->id->model)); 716 len = strnlen(s, sizeof(drive->id->model));
720 717
721 if ((len > 4) && (!memcmp(s, "ST", 2))) { 718 if ((len > 4) && (!memcmp(s, "ST", 2))) {
@@ -730,18 +727,20 @@ static int is_dev_seagate_sata(ide_drive_t *drive)
730} 727}
731 728
732/** 729/**
733 * siimage_fixup - post probe fixups 730 * sil_quirkproc - post probe fixups
734 * @hwif: interface to fix up 731 * @drive: drive
735 * 732 *
736 * Called after drive probe we use this to decide whether the 733 * Called after drive probe we use this to decide whether the
737 * Seagate fixup must be applied. This used to be in init_iops but 734 * Seagate fixup must be applied. This used to be in init_iops but
738 * that can occur before we know what drives are present. 735 * that can occur before we know what drives are present.
739 */ 736 */
740 737
741static void __devinit siimage_fixup(ide_hwif_t *hwif) 738static void __devinit sil_quirkproc(ide_drive_t *drive)
742{ 739{
740 ide_hwif_t *hwif = drive->hwif;
741
743 /* Try and raise the rqsize */ 742 /* Try and raise the rqsize */
744 if (!is_sata(hwif) || !is_dev_seagate_sata(&hwif->drives[0])) 743 if (!is_sata(hwif) || !is_dev_seagate_sata(drive))
745 hwif->rqsize = 128; 744 hwif->rqsize = 128;
746} 745}
747 746
@@ -804,6 +803,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
804 803
805 hwif->set_pio_mode = &sil_set_pio_mode; 804 hwif->set_pio_mode = &sil_set_pio_mode;
806 hwif->set_dma_mode = &sil_set_dma_mode; 805 hwif->set_dma_mode = &sil_set_dma_mode;
806 hwif->quirkproc = &sil_quirkproc;
807 807
808 if (sata) { 808 if (sata) {
809 static int first = 1; 809 static int first = 1;
@@ -842,7 +842,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
842 .init_chipset = init_chipset_siimage, \ 842 .init_chipset = init_chipset_siimage, \
843 .init_iops = init_iops_siimage, \ 843 .init_iops = init_iops_siimage, \
844 .init_hwif = init_hwif_siimage, \ 844 .init_hwif = init_hwif_siimage, \
845 .fixup = siimage_fixup, \
846 .host_flags = IDE_HFLAG_BOOTABLE, \ 845 .host_flags = IDE_HFLAG_BOOTABLE, \
847 .pio_mask = ATA_PIO4, \ 846 .pio_mask = ATA_PIO4, \
848 .mwdma_mask = ATA_MWDMA2, \ 847 .mwdma_mask = ATA_MWDMA2, \
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index bbfdf7e0f182..d89f84d41b08 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -555,8 +555,6 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int
555 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) 555 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
556 hwif->irq = port ? 15 : 14; 556 hwif->irq = port ? 15 : 14;
557 557
558 hwif->fixup = d->fixup;
559
560 hwif->host_flags = d->host_flags; 558 hwif->host_flags = d->host_flags;
561 hwif->pio_mask = d->pio_mask; 559 hwif->pio_mask = d->pio_mask;
562 560
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ffb76d0d0814..dd50a5c5ec10 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -199,7 +199,8 @@ typedef struct hw_regs_s {
199 199
200struct hwif_s * ide_find_port(unsigned long); 200struct hwif_s * ide_find_port(unsigned long);
201 201
202int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int, 202struct ide_drive_s;
203int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *), int,
203 struct hwif_s **); 204 struct hwif_s **);
204 205
205void ide_setup_ports( hw_regs_t *hw, 206void ide_setup_ports( hw_regs_t *hw,
@@ -527,15 +528,13 @@ typedef struct hwif_s {
527 /* special host masking for drive selection */ 528 /* special host masking for drive selection */
528 void (*maskproc)(ide_drive_t *, int); 529 void (*maskproc)(ide_drive_t *, int);
529 /* check host's drive quirk list */ 530 /* check host's drive quirk list */
530 int (*quirkproc)(ide_drive_t *); 531 void (*quirkproc)(ide_drive_t *);
531 /* driver soft-power interface */ 532 /* driver soft-power interface */
532 int (*busproc)(ide_drive_t *, int); 533 int (*busproc)(ide_drive_t *, int);
533#endif 534#endif
534 u8 (*mdma_filter)(ide_drive_t *); 535 u8 (*mdma_filter)(ide_drive_t *);
535 u8 (*udma_filter)(ide_drive_t *); 536 u8 (*udma_filter)(ide_drive_t *);
536 537
537 void (*fixup)(struct hwif_s *);
538
539 void (*ata_input_data)(ide_drive_t *, void *, u32); 538 void (*ata_input_data)(ide_drive_t *, void *, u32);
540 void (*ata_output_data)(ide_drive_t *, void *, u32); 539 void (*ata_output_data)(ide_drive_t *, void *, u32);
541 540
@@ -1108,7 +1107,6 @@ struct ide_port_info {
1108 void (*init_iops)(ide_hwif_t *); 1107 void (*init_iops)(ide_hwif_t *);
1109 void (*init_hwif)(ide_hwif_t *); 1108 void (*init_hwif)(ide_hwif_t *);
1110 void (*init_dma)(ide_hwif_t *, unsigned long); 1109 void (*init_dma)(ide_hwif_t *, unsigned long);
1111 void (*fixup)(ide_hwif_t *);
1112 ide_pci_enablebit_t enablebits[2]; 1110 ide_pci_enablebit_t enablebits[2];
1113 hwif_chipset_t chipset; 1111 hwif_chipset_t chipset;
1114 u8 extra; 1112 u8 extra;
@@ -1203,7 +1201,7 @@ extern void ide_unregister (unsigned int index);
1203void ide_register_region(struct gendisk *); 1201void ide_register_region(struct gendisk *);
1204void ide_unregister_region(struct gendisk *); 1202void ide_unregister_region(struct gendisk *);
1205 1203
1206void ide_undecoded_slave(ide_hwif_t *); 1204void ide_undecoded_slave(ide_drive_t *);
1207 1205
1208int ide_device_add(u8 idx[4]); 1206int ide_device_add(u8 idx[4]);
1209 1207