Commit fd9bb53942a7ca3398a63f2c238afd8fbed3ec0e

Authored by Bartlomiej Zolnierkiewicz
1 parent 438c470261

ide: add ->fixup method to ide_hwif_t

* Add ->fixup method to ide_hwif_t.

* Set hwif->fixup in ide_pci_setup_ports() to d->fixup.

* Use hwif->fixup in probe_hwif().

* Use probe_hwif_init() instead of probe_hwif_init_with_fixup() in
  ide_setup_pci_device().

* Add 'fixup' argument to ide_register_hw() and use it to set hwif->fixup,
  update all ide_register_hw() users accordingly.

* Convert ide-cs/delkin_cb host drivers to use ide_register_hw().

* Restore hwif->fixup in ide_hwif_restore().

* Remove ide_register_hw_with_fixup(), probe_hwif_init_with_fixup()
  and 'fixup' argument from probe_hwif().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

Showing 17 changed files with 39 additions and 50 deletions Side-by-side Diff

drivers/ide/arm/bast-ide.c
... ... @@ -45,7 +45,7 @@
45 45 hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
46 46 hw.irq = irq;
47 47  
48   - ide_register_hw(&hw, 0, hwif);
  48 + ide_register_hw(&hw, NULL, 0, hwif);
49 49  
50 50 return 0;
51 51 }
drivers/ide/arm/ide_arm.c
... ... @@ -31,6 +31,6 @@
31 31 memset(&hw, 0, sizeof(hw));
32 32 ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206);
33 33 hw.irq = IDE_ARM_IRQ;
34   - ide_register_hw(&hw, 1, NULL);
  34 + ide_register_hw(&hw, NULL, 1, NULL);
35 35 }
drivers/ide/cris/ide-cris.c
... ... @@ -782,7 +782,7 @@
782 782 ide_offsets,
783 783 0, 0, cris_ide_ack_intr,
784 784 ide_default_irq(0));
785   - ide_register_hw(&hw, 1, &hwif);
  785 + ide_register_hw(&hw, NULL, 1, &hwif);
786 786 hwif->mmio = 1;
787 787 hwif->chipset = ide_etrax100;
788 788 hwif->set_pio_mode = &cris_set_pio_mode;
drivers/ide/h8300/ide-h8300.c
... ... @@ -101,7 +101,7 @@
101 101 hw_setup(&hw);
102 102  
103 103 /* register if */
104   - idx = ide_register_hw(&hw, 1, &hwif);
  104 + idx = ide_register_hw(&hw, NULL, 1, &hwif);
105 105 if (idx == -1) {
106 106 printk(KERN_ERR "ide-h8300: IDE I/F register failed\n");
107 107 return;
drivers/ide/ide-pnp.c
... ... @@ -42,7 +42,7 @@
42 42 hw.irq = pnp_irq(dev, 0);
43 43 hw.dma = NO_DMA;
44 44  
45   - index = ide_register_hw(&hw, 1, &hwif);
  45 + index = ide_register_hw(&hw, NULL, 1, &hwif);
46 46  
47 47 if (index != -1) {
48 48 printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index);
drivers/ide/ide-probe.c
... ... @@ -717,7 +717,7 @@
717 717 * This routine only knows how to look for drive units 0 and 1
718 718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
719 719 */
720   -static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
  720 +static void probe_hwif(ide_hwif_t *hwif)
721 721 {
722 722 unsigned long flags;
723 723 unsigned int irqd;
... ... @@ -819,8 +819,8 @@
819 819 return;
820 820 }
821 821  
822   - if (fixup)
823   - fixup(hwif);
  822 + if (hwif->fixup)
  823 + hwif->fixup(hwif);
824 824  
825 825 for (unit = 0; unit < MAX_DRIVES; ++unit) {
826 826 ide_drive_t *drive = &hwif->drives[unit];
827 827  
... ... @@ -861,9 +861,9 @@
861 861 static int hwif_init(ide_hwif_t *hwif);
862 862 static void hwif_register_devices(ide_hwif_t *hwif);
863 863  
864   -int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
  864 +int probe_hwif_init(ide_hwif_t *hwif)
865 865 {
866   - probe_hwif(hwif, fixup);
  866 + probe_hwif(hwif);
867 867  
868 868 if (!hwif_init(hwif)) {
869 869 printk(KERN_INFO "%s: failed to initialize IDE interface\n",
... ... @@ -877,11 +877,6 @@
877 877 return 0;
878 878 }
879 879  
880   -int probe_hwif_init(ide_hwif_t *hwif)
881   -{
882   - return probe_hwif_init_with_fixup(hwif, NULL);
883   -}
884   -
885 880 EXPORT_SYMBOL(probe_hwif_init);
886 881  
887 882 #if MAX_HWIFS > 1
... ... @@ -1394,7 +1389,7 @@
1394 1389  
1395 1390 for (index = 0; index < MAX_HWIFS; ++index)
1396 1391 if (probe[index])
1397   - probe_hwif(&ide_hwifs[index], NULL);
  1392 + probe_hwif(&ide_hwifs[index]);
1398 1393 for (index = 0; index < MAX_HWIFS; ++index)
1399 1394 if (probe[index])
1400 1395 hwif_init(&ide_hwifs[index]);
... ... @@ -391,6 +391,8 @@
391 391 hwif->cds = tmp_hwif->cds;
392 392 #endif
393 393  
  394 + hwif->fixup = tmp_hwif->fixup;
  395 +
394 396 hwif->set_pio_mode = tmp_hwif->set_pio_mode;
395 397 hwif->set_dma_mode = tmp_hwif->set_dma_mode;
396 398 hwif->mdma_filter = tmp_hwif->mdma_filter;
397 399  
398 400  
... ... @@ -660,11 +662,11 @@
660 662 }
661 663  
662 664 /**
663   - * ide_register_hw_with_fixup - register IDE interface
  665 + * ide_register_hw - register IDE interface
664 666 * @hw: hardware registers
  667 + * @fixup: fixup function
665 668 * @initializing: set while initializing built-in drivers
666 669 * @hwifp: pointer to returned hwif
667   - * @fixup: fixup function
668 670 *
669 671 * Register an IDE interface, specifying exactly the registers etc.
670 672 * Set init=1 iff calling before probes have taken place.
... ... @@ -672,9 +674,8 @@
672 674 * Returns -1 on error.
673 675 */
674 676  
675   -int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing,
676   - ide_hwif_t **hwifp,
677   - void(*fixup)(ide_hwif_t *hwif))
  677 +int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
  678 + int initializing, ide_hwif_t **hwifp)
678 679 {
679 680 int index, retry = 1;
680 681 ide_hwif_t *hwif;
681 682  
... ... @@ -710,11 +711,12 @@
710 711 memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
711 712 hwif->irq = hw->irq;
712 713 hwif->noprobe = 0;
  714 + hwif->fixup = fixup;
713 715 hwif->chipset = hw->chipset;
714 716 hwif->gendev.parent = hw->dev;
715 717  
716 718 if (!initializing) {
717   - probe_hwif_init_with_fixup(hwif, fixup);
  719 + probe_hwif_init(hwif);
718 720 ide_proc_register_port(hwif);
719 721 }
720 722  
... ... @@ -724,13 +726,6 @@
724 726 return (initializing || hwif->present) ? index : -1;
725 727 }
726 728  
727   -EXPORT_SYMBOL(ide_register_hw_with_fixup);
728   -
729   -int ide_register_hw(hw_regs_t *hw, int initializing, ide_hwif_t **hwifp)
730   -{
731   - return ide_register_hw_with_fixup(hw, initializing, hwifp, NULL);
732   -}
733   -
734 729 EXPORT_SYMBOL(ide_register_hw);
735 730  
736 731 /*
... ... @@ -1046,7 +1041,7 @@
1046 1041 ide_init_hwif_ports(&hw, (unsigned long) args[0],
1047 1042 (unsigned long) args[1], NULL);
1048 1043 hw.irq = args[2];
1049   - if (ide_register_hw(&hw, 0, NULL) == -1)
  1044 + if (ide_register_hw(&hw, NULL, 0, NULL) == -1)
1050 1045 return -EIO;
1051 1046 return 0;
1052 1047 }
drivers/ide/legacy/buddha.c
... ... @@ -212,8 +212,8 @@
212 212 // xsurf_iops,
213 213 IRQ_AMIGA_PORTS);
214 214 }
215   -
216   - index = ide_register_hw(&hw, 1, &hwif);
  215 +
  216 + index = ide_register_hw(&hw, NULL, 1, &hwif);
217 217 if (index != -1) {
218 218 hwif->mmio = 1;
219 219 printk("ide%d: ", index);
drivers/ide/legacy/falconide.c
... ... @@ -72,7 +72,7 @@
72 72 0, 0, NULL,
73 73 // falconide_iops,
74 74 IRQ_MFP_IDE);
75   - index = ide_register_hw(&hw, 1, NULL);
  75 + index = ide_register_hw(&hw, NULL, 1, NULL);
76 76  
77 77 if (index != -1)
78 78 printk("ide%d: Falcon IDE interface\n", index);
drivers/ide/legacy/gayle.c
... ... @@ -165,7 +165,7 @@
165 165 // &gayle_iops,
166 166 IRQ_AMIGA_PORTS);
167 167  
168   - index = ide_register_hw(&hw, 1, &hwif);
  168 + index = ide_register_hw(&hw, NULL, 1, &hwif);
169 169 if (index != -1) {
170 170 hwif->mmio = 1;
171 171 switch (i) {
drivers/ide/legacy/ide-cs.c
... ... @@ -153,7 +153,7 @@
153 153 hw.irq = irq;
154 154 hw.chipset = ide_pci;
155 155 hw.dev = &handle->dev;
156   - return ide_register_hw_with_fixup(&hw, 0, NULL, ide_undecoded_slave);
  156 + return ide_register_hw(&hw, &ide_undecoded_slave, 0, NULL);
157 157 }
158 158  
159 159 /*======================================================================
drivers/ide/legacy/macide.c
... ... @@ -93,21 +93,21 @@
93 93 0, 0, macide_ack_intr,
94 94 // quadra_ide_iops,
95 95 IRQ_NUBUS_F);
96   - index = ide_register_hw(&hw, 1, &hwif);
  96 + index = ide_register_hw(&hw, NULL, 1, &hwif);
97 97 break;
98 98 case MAC_IDE_PB:
99 99 ide_setup_ports(&hw, IDE_BASE, macide_offsets,
100 100 0, 0, macide_ack_intr,
101 101 // macide_pb_iops,
102 102 IRQ_NUBUS_C);
103   - index = ide_register_hw(&hw, 1, &hwif);
  103 + index = ide_register_hw(&hw, NULL, 1, &hwif);
104 104 break;
105 105 case MAC_IDE_BABOON:
106 106 ide_setup_ports(&hw, BABOON_BASE, macide_offsets,
107 107 0, 0, NULL,
108 108 // macide_baboon_iops,
109 109 IRQ_BABOON_1);
110   - index = ide_register_hw(&hw, 1, &hwif);
  110 + index = ide_register_hw(&hw, NULL, 1, &hwif);
111 111 if (index == -1) break;
112 112 if (macintosh_config->ident == MAC_MODEL_PB190) {
113 113  
drivers/ide/legacy/q40ide.c
... ... @@ -142,7 +142,7 @@
142 142 0, NULL,
143 143 // m68kide_iops,
144 144 q40ide_default_irq(pcide_bases[i]));
145   - index = ide_register_hw(&hw, 1, &hwif);
  145 + index = ide_register_hw(&hw, NULL, 1, &hwif);
146 146 // **FIXME**
147 147 if (index != -1)
148 148 hwif->mmio = 1;
drivers/ide/pci/delkin_cb.c
... ... @@ -80,7 +80,7 @@
80 80 hw.irq = dev->irq;
81 81 hw.chipset = ide_pci; /* this enables IRQ sharing */
82 82  
83   - rc = ide_register_hw_with_fixup(&hw, 0, &hwif, ide_undecoded_slave);
  83 + rc = ide_register_hw(&hw, &ide_undecoded_slave, 0, &hwif);
84 84 if (rc < 0) {
85 85 printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
86 86 pci_disable_device(dev);
drivers/ide/setup-pci.c
... ... @@ -567,6 +567,8 @@
567 567 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
568 568 hwif->irq = port ? 15 : 14;
569 569  
  570 + hwif->fixup = d->fixup;
  571 +
570 572 hwif->host_flags = d->host_flags;
571 573 hwif->pio_mask = d->pio_mask;
572 574  
573 575  
... ... @@ -692,9 +694,9 @@
692 694 mate = &ide_hwifs[index_list.b.high];
693 695  
694 696 if (hwif)
695   - probe_hwif_init_with_fixup(hwif, d->fixup);
  697 + probe_hwif_init(hwif);
696 698 if (mate)
697   - probe_hwif_init_with_fixup(mate, d->fixup);
  699 + probe_hwif_init(mate);
698 700  
699 701 if (hwif)
700 702 ide_proc_register_port(hwif);
drivers/macintosh/mediabay.c
... ... @@ -563,7 +563,7 @@
563 563 ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL);
564 564 hw.irq = bay->cd_irq;
565 565 hw.chipset = ide_pmac;
566   - bay->cd_index = ide_register_hw(&hw, 0, NULL);
  566 + bay->cd_index = ide_register_hw(&hw, NULL, 0, NULL);
567 567 pmu_resume();
568 568 }
569 569 if (bay->cd_index == -1) {
... ... @@ -223,12 +223,8 @@
223 223 struct device *dev;
224 224 } hw_regs_t;
225 225  
226   -/*
227   - * Register new hardware with ide
228   - */
229   -int ide_register_hw(hw_regs_t *, int, struct hwif_s **);
230   -int ide_register_hw_with_fixup(hw_regs_t *, int, struct hwif_s **,
231   - void (*)(struct hwif_s *));
  226 +int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int,
  227 + struct hwif_s **);
232 228  
233 229 /*
234 230 * Set up hw_regs_t structure before calling ide_register_hw (optional)
... ... @@ -727,6 +723,8 @@
727 723 u8 (*mdma_filter)(ide_drive_t *);
728 724 u8 (*udma_filter)(ide_drive_t *);
729 725  
  726 + void (*fixup)(struct hwif_s *);
  727 +
730 728 void (*ata_input_data)(ide_drive_t *, void *, u32);
731 729 void (*ata_output_data)(ide_drive_t *, void *, u32);
732 730  
... ... @@ -1380,7 +1378,6 @@
1380 1378  
1381 1379 void ide_undecoded_slave(ide_hwif_t *);
1382 1380  
1383   -int probe_hwif_init_with_fixup(ide_hwif_t *, void (*)(ide_hwif_t *));
1384 1381 extern int probe_hwif_init(ide_hwif_t *);
1385 1382  
1386 1383 static inline void *ide_get_hwifdata (ide_hwif_t * hwif)