aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-06-12 12:29:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-12 12:29:42 -0400
commitd614aec4752f8c61b2e7cb77806b6bd59aa50836 (patch)
tree3b0cfb3085c43415931dbf18666d582fb8ae3c75 /drivers
parentdb8e7f10ed67933ca272f4030eb7057b7f13de07 (diff)
parentad7c52d0988a8965989dc06d630c52a5bde849d5 (diff)
Merge branch 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (29 commits) ide: re-implement ide_pci_init_one() on top of ide_pci_init_two() ide: unexport ide_find_dma_mode() ide: fix PowerMac bootup oops ide: skip probe if there are no devices on the port (v2) sl82c105: add printk() logging facility ide-tape: fix proc warning ide: add IDE_DFLAG_NIEN_QUIRK device flag ide: respect quirk_drives[] list on all controllers hpt366: enable all quirks for devices on quirk_drives[] list hpt366: sync quirk_drives[] list with pdc202xx_{new,old}.c ide: remove superfluous SELECT_MASK() call from do_rw_taskfile() ide: remove superfluous SELECT_MASK() call from ide_driveid_update() icside: remove superfluous ->maskproc method ide-tape: fix IDE_AFLAG_* atomic accesses ide-tape: change IDE_AFLAG_IGNORE_DSC non-atomically pdc202xx_old: kill resetproc() method pdc202xx_old: don't call pdc202xx_reset() on IRQ timeout pdc202xx_old: use ide_dma_test_irq() ide: preserve Host Protected Area by default (v2) ide-gd: implement block device ->set_capacity method (v2) ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/at91_ide.c7
-rw-r--r--drivers/ide/au1xxx-ide.c8
-rw-r--r--drivers/ide/buddha.c9
-rw-r--r--drivers/ide/cmd640.c7
-rw-r--r--drivers/ide/cs5520.c4
-rw-r--r--drivers/ide/delkin_cb.c6
-rw-r--r--drivers/ide/falconide.c9
-rw-r--r--drivers/ide/gayle.c9
-rw-r--r--drivers/ide/hpt366.c25
-rw-r--r--drivers/ide/icside.c77
-rw-r--r--drivers/ide/ide-4drives.c6
-rw-r--r--drivers/ide/ide-atapi.c2
-rw-r--r--drivers/ide/ide-cs.c6
-rw-r--r--drivers/ide/ide-disk.c75
-rw-r--r--drivers/ide/ide-dma.c1
-rw-r--r--drivers/ide/ide-eh.c14
-rw-r--r--drivers/ide/ide-gd.c14
-rw-r--r--drivers/ide/ide-generic.c7
-rw-r--r--drivers/ide/ide-h8300.c10
-rw-r--r--drivers/ide/ide-io.c77
-rw-r--r--drivers/ide/ide-iops.c26
-rw-r--r--drivers/ide/ide-legacy.c7
-rw-r--r--drivers/ide/ide-pnp.c6
-rw-r--r--drivers/ide/ide-probe.c95
-rw-r--r--drivers/ide/ide-tape.c90
-rw-r--r--drivers/ide/ide-taskfile.c3
-rw-r--r--drivers/ide/ide.c10
-rw-r--r--drivers/ide/ide_platform.c9
-rw-r--r--drivers/ide/macide.c9
-rw-r--r--drivers/ide/palm_bk3710.c6
-rw-r--r--drivers/ide/pdc202xx_new.c26
-rw-r--r--drivers/ide/pdc202xx_old.c92
-rw-r--r--drivers/ide/pmac.c13
-rw-r--r--drivers/ide/q40ide.c11
-rw-r--r--drivers/ide/rapide.c8
-rw-r--r--drivers/ide/scc_pata.c6
-rw-r--r--drivers/ide/setup-pci.c85
-rw-r--r--drivers/ide/sgiioc4.c7
-rw-r--r--drivers/ide/siimage.c4
-rw-r--r--drivers/ide/sl82c105.c9
-rw-r--r--drivers/ide/tx4938ide.c5
-rw-r--r--drivers/ide/tx4939ide.c5
42 files changed, 383 insertions, 522 deletions
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c
index 403d0e4265db..fc0949a8cfde 100644
--- a/drivers/ide/at91_ide.c
+++ b/drivers/ide/at91_ide.c
@@ -216,6 +216,7 @@ static const struct ide_port_info at91_ide_port_info __initdata = {
216 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE | 216 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE |
217 IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS, 217 IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS,
218 .pio_mask = ATA_PIO6, 218 .pio_mask = ATA_PIO6,
219 .chipset = ide_generic,
219}; 220};
220 221
221/* 222/*
@@ -246,8 +247,7 @@ irqreturn_t at91_irq_handler(int irq, void *dev_id)
246static int __init at91_ide_probe(struct platform_device *pdev) 247static int __init at91_ide_probe(struct platform_device *pdev)
247{ 248{
248 int ret; 249 int ret;
249 hw_regs_t hw; 250 struct ide_hw hw, *hws[] = { &hw };
250 hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
251 struct ide_host *host; 251 struct ide_host *host;
252 struct resource *res; 252 struct resource *res;
253 unsigned long tf_base = 0, ctl_base = 0; 253 unsigned long tf_base = 0, ctl_base = 0;
@@ -304,10 +304,9 @@ static int __init at91_ide_probe(struct platform_device *pdev)
304 ide_std_init_ports(&hw, tf_base, ctl_base + 6); 304 ide_std_init_ports(&hw, tf_base, ctl_base + 6);
305 305
306 hw.irq = board->irq_pin; 306 hw.irq = board->irq_pin;
307 hw.chipset = ide_generic;
308 hw.dev = &pdev->dev; 307 hw.dev = &pdev->dev;
309 308
310 host = ide_host_alloc(&at91_ide_port_info, hws); 309 host = ide_host_alloc(&at91_ide_port_info, hws, 1);
311 if (!host) { 310 if (!host) {
312 perr("failed to allocate ide host\n"); 311 perr("failed to allocate ide host\n");
313 return -ENOMEM; 312 return -ENOMEM;
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 46013644c965..58121bd6c115 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -449,7 +449,7 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
449} 449}
450#endif 450#endif
451 451
452static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) 452static void auide_setup_ports(struct ide_hw *hw, _auide_hwif *ahwif)
453{ 453{
454 int i; 454 int i;
455 unsigned long *ata_regs = hw->io_ports_array; 455 unsigned long *ata_regs = hw->io_ports_array;
@@ -499,6 +499,7 @@ static const struct ide_port_info au1xxx_port_info = {
499#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 499#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
500 .mwdma_mask = ATA_MWDMA2, 500 .mwdma_mask = ATA_MWDMA2,
501#endif 501#endif
502 .chipset = ide_au1xxx,
502}; 503};
503 504
504static int au_ide_probe(struct platform_device *dev) 505static int au_ide_probe(struct platform_device *dev)
@@ -507,7 +508,7 @@ static int au_ide_probe(struct platform_device *dev)
507 struct resource *res; 508 struct resource *res;
508 struct ide_host *host; 509 struct ide_host *host;
509 int ret = 0; 510 int ret = 0;
510 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 511 struct ide_hw hw, *hws[] = { &hw };
511 512
512#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 513#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
513 char *mode = "MWDMA2"; 514 char *mode = "MWDMA2";
@@ -548,9 +549,8 @@ static int au_ide_probe(struct platform_device *dev)
548 auide_setup_ports(&hw, ahwif); 549 auide_setup_ports(&hw, ahwif);
549 hw.irq = ahwif->irq; 550 hw.irq = ahwif->irq;
550 hw.dev = &dev->dev; 551 hw.dev = &dev->dev;
551 hw.chipset = ide_au1xxx;
552 552
553 ret = ide_host_add(&au1xxx_port_info, hws, &host); 553 ret = ide_host_add(&au1xxx_port_info, hws, 1, &host);
554 if (ret) 554 if (ret)
555 goto out; 555 goto out;
556 556
diff --git a/drivers/ide/buddha.c b/drivers/ide/buddha.c
index d028f8864bc1..e3c6a5913305 100644
--- a/drivers/ide/buddha.c
+++ b/drivers/ide/buddha.c
@@ -121,7 +121,7 @@ static int xsurf_ack_intr(ide_hwif_t *hwif)
121 return 1; 121 return 1;
122} 122}
123 123
124static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, 124static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base,
125 unsigned long ctl, unsigned long irq_port, 125 unsigned long ctl, unsigned long irq_port,
126 ide_ack_intr_t *ack_intr) 126 ide_ack_intr_t *ack_intr)
127{ 127{
@@ -139,13 +139,12 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
139 139
140 hw->irq = IRQ_AMIGA_PORTS; 140 hw->irq = IRQ_AMIGA_PORTS;
141 hw->ack_intr = ack_intr; 141 hw->ack_intr = ack_intr;
142
143 hw->chipset = ide_generic;
144} 142}
145 143
146static const struct ide_port_info buddha_port_info = { 144static const struct ide_port_info buddha_port_info = {
147 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 145 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
148 .irq_flags = IRQF_SHARED, 146 .irq_flags = IRQF_SHARED,
147 .chipset = ide_generic,
149}; 148};
150 149
151 /* 150 /*
@@ -161,7 +160,7 @@ static int __init buddha_init(void)
161 160
162 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { 161 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
163 unsigned long board; 162 unsigned long board;
164 hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; 163 struct ide_hw hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS];
165 164
166 if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { 165 if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
167 buddha_num_hwifs = BUDDHA_NUM_HWIFS; 166 buddha_num_hwifs = BUDDHA_NUM_HWIFS;
@@ -225,7 +224,7 @@ fail_base2:
225 hws[i] = &hw[i]; 224 hws[i] = &hw[i];
226 } 225 }
227 226
228 ide_host_add(&buddha_port_info, hws, NULL); 227 ide_host_add(&buddha_port_info, hws, i, NULL);
229 } 228 }
230 229
231 return 0; 230 return 0;
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c
index 8890276fef7f..1683ed5c7329 100644
--- a/drivers/ide/cmd640.c
+++ b/drivers/ide/cmd640.c
@@ -708,7 +708,7 @@ static int __init cmd640x_init(void)
708 int second_port_cmd640 = 0, rc; 708 int second_port_cmd640 = 0, rc;
709 const char *bus_type, *port2; 709 const char *bus_type, *port2;
710 u8 b, cfr; 710 u8 b, cfr;
711 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; 711 struct ide_hw hw[2], *hws[2];
712 712
713 if (cmd640_vlb && probe_for_cmd640_vlb()) { 713 if (cmd640_vlb && probe_for_cmd640_vlb()) {
714 bus_type = "VLB"; 714 bus_type = "VLB";
@@ -762,11 +762,9 @@ static int __init cmd640x_init(void)
762 762
763 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 763 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
764 hw[0].irq = 14; 764 hw[0].irq = 14;
765 hw[0].chipset = ide_cmd640;
766 765
767 ide_std_init_ports(&hw[1], 0x170, 0x376); 766 ide_std_init_ports(&hw[1], 0x170, 0x376);
768 hw[1].irq = 15; 767 hw[1].irq = 15;
769 hw[1].chipset = ide_cmd640;
770 768
771 printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" 769 printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x"
772 "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); 770 "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr);
@@ -824,7 +822,8 @@ static int __init cmd640x_init(void)
824 cmd640_dump_regs(); 822 cmd640_dump_regs();
825#endif 823#endif
826 824
827 return ide_host_add(&cmd640_port_info, hws, NULL); 825 return ide_host_add(&cmd640_port_info, hws, second_port_cmd640 ? 2 : 1,
826 NULL);
828} 827}
829 828
830module_param_named(probe_vlb, cmd640_vlb, bool, 0); 829module_param_named(probe_vlb, cmd640_vlb, bool, 0);
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
index 87987a7d36c9..bd066bb9d611 100644
--- a/drivers/ide/cs5520.c
+++ b/drivers/ide/cs5520.c
@@ -110,7 +110,7 @@ static const struct ide_port_info cyrix_chipset __devinitdata = {
110static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) 110static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
111{ 111{
112 const struct ide_port_info *d = &cyrix_chipset; 112 const struct ide_port_info *d = &cyrix_chipset;
113 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 113 struct ide_hw hw[2], *hws[] = { NULL, NULL };
114 114
115 ide_setup_pci_noise(dev, d); 115 ide_setup_pci_noise(dev, d);
116 116
@@ -136,7 +136,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
136 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); 136 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
137 hw[0].irq = 14; 137 hw[0].irq = 14;
138 138
139 return ide_host_add(d, hws, NULL); 139 return ide_host_add(d, hws, 2, NULL);
140} 140}
141 141
142static const struct pci_device_id cs5520_pci_tbl[] = { 142static const struct pci_device_id cs5520_pci_tbl[] = {
diff --git a/drivers/ide/delkin_cb.c b/drivers/ide/delkin_cb.c
index f153b95619bb..1e10eba62ceb 100644
--- a/drivers/ide/delkin_cb.c
+++ b/drivers/ide/delkin_cb.c
@@ -68,6 +68,7 @@ static const struct ide_port_info delkin_cb_port_info = {
68 IDE_HFLAG_NO_DMA, 68 IDE_HFLAG_NO_DMA,
69 .irq_flags = IRQF_SHARED, 69 .irq_flags = IRQF_SHARED,
70 .init_chipset = delkin_cb_init_chipset, 70 .init_chipset = delkin_cb_init_chipset,
71 .chipset = ide_pci,
71}; 72};
72 73
73static int __devinit 74static int __devinit
@@ -76,7 +77,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
76 struct ide_host *host; 77 struct ide_host *host;
77 unsigned long base; 78 unsigned long base;
78 int rc; 79 int rc;
79 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 80 struct ide_hw hw, *hws[] = { &hw };
80 81
81 rc = pci_enable_device(dev); 82 rc = pci_enable_device(dev);
82 if (rc) { 83 if (rc) {
@@ -97,9 +98,8 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
97 ide_std_init_ports(&hw, base + 0x10, base + 0x1e); 98 ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
98 hw.irq = dev->irq; 99 hw.irq = dev->irq;
99 hw.dev = &dev->dev; 100 hw.dev = &dev->dev;
100 hw.chipset = ide_pci; /* this enables IRQ sharing */
101 101
102 rc = ide_host_add(&delkin_cb_port_info, hws, &host); 102 rc = ide_host_add(&delkin_cb_port_info, hws, 1, &host);
103 if (rc) 103 if (rc)
104 goto out_disable; 104 goto out_disable;
105 105
diff --git a/drivers/ide/falconide.c b/drivers/ide/falconide.c
index 0e2df6755ec9..22fa27389c3b 100644
--- a/drivers/ide/falconide.c
+++ b/drivers/ide/falconide.c
@@ -111,9 +111,10 @@ static const struct ide_port_info falconide_port_info = {
111 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | 111 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
112 IDE_HFLAG_NO_DMA, 112 IDE_HFLAG_NO_DMA,
113 .irq_flags = IRQF_SHARED, 113 .irq_flags = IRQF_SHARED,
114 .chipset = ide_generic,
114}; 115};
115 116
116static void __init falconide_setup_ports(hw_regs_t *hw) 117static void __init falconide_setup_ports(struct ide_hw *hw)
117{ 118{
118 int i; 119 int i;
119 120
@@ -128,8 +129,6 @@ static void __init falconide_setup_ports(hw_regs_t *hw)
128 129
129 hw->irq = IRQ_MFP_IDE; 130 hw->irq = IRQ_MFP_IDE;
130 hw->ack_intr = NULL; 131 hw->ack_intr = NULL;
131
132 hw->chipset = ide_generic;
133} 132}
134 133
135 /* 134 /*
@@ -139,7 +138,7 @@ static void __init falconide_setup_ports(hw_regs_t *hw)
139static int __init falconide_init(void) 138static int __init falconide_init(void)
140{ 139{
141 struct ide_host *host; 140 struct ide_host *host;
142 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 141 struct ide_hw hw, *hws[] = { &hw };
143 int rc; 142 int rc;
144 143
145 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) 144 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
@@ -154,7 +153,7 @@ static int __init falconide_init(void)
154 153
155 falconide_setup_ports(&hw); 154 falconide_setup_ports(&hw);
156 155
157 host = ide_host_alloc(&falconide_port_info, hws); 156 host = ide_host_alloc(&falconide_port_info, hws, 1);
158 if (host == NULL) { 157 if (host == NULL) {
159 rc = -ENOMEM; 158 rc = -ENOMEM;
160 goto err; 159 goto err;
diff --git a/drivers/ide/gayle.c b/drivers/ide/gayle.c
index c7119516c5a7..4451a6a5dfe0 100644
--- a/drivers/ide/gayle.c
+++ b/drivers/ide/gayle.c
@@ -88,7 +88,7 @@ static int gayle_ack_intr_a1200(ide_hwif_t *hwif)
88 return 1; 88 return 1;
89} 89}
90 90
91static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, 91static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
92 unsigned long ctl, unsigned long irq_port, 92 unsigned long ctl, unsigned long irq_port,
93 ide_ack_intr_t *ack_intr) 93 ide_ack_intr_t *ack_intr)
94{ 94{
@@ -106,14 +106,13 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base,
106 106
107 hw->irq = IRQ_AMIGA_PORTS; 107 hw->irq = IRQ_AMIGA_PORTS;
108 hw->ack_intr = ack_intr; 108 hw->ack_intr = ack_intr;
109
110 hw->chipset = ide_generic;
111} 109}
112 110
113static const struct ide_port_info gayle_port_info = { 111static const struct ide_port_info gayle_port_info = {
114 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | 112 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
115 IDE_HFLAG_NO_DMA, 113 IDE_HFLAG_NO_DMA,
116 .irq_flags = IRQF_SHARED, 114 .irq_flags = IRQF_SHARED,
115 .chipset = ide_generic,
117}; 116};
118 117
119 /* 118 /*
@@ -126,7 +125,7 @@ static int __init gayle_init(void)
126 unsigned long base, ctrlport, irqport; 125 unsigned long base, ctrlport, irqport;
127 ide_ack_intr_t *ack_intr; 126 ide_ack_intr_t *ack_intr;
128 int a4000, i, rc; 127 int a4000, i, rc;
129 hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; 128 struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS];
130 129
131 if (!MACH_IS_AMIGA) 130 if (!MACH_IS_AMIGA)
132 return -ENODEV; 131 return -ENODEV;
@@ -171,7 +170,7 @@ found:
171 hws[i] = &hw[i]; 170 hws[i] = &hw[i];
172 } 171 }
173 172
174 rc = ide_host_add(&gayle_port_info, hws, NULL); 173 rc = ide_host_add(&gayle_port_info, hws, i, NULL);
175 if (rc) 174 if (rc)
176 release_mem_region(res_start, res_n); 175 release_mem_region(res_start, res_n);
177 176
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index 0feb66c720e1..7ce68ef6b904 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -138,14 +138,6 @@
138#undef HPT_RESET_STATE_ENGINE 138#undef HPT_RESET_STATE_ENGINE
139#undef HPT_DELAY_INTERRUPT 139#undef HPT_DELAY_INTERRUPT
140 140
141static const char *quirk_drives[] = {
142 "QUANTUM FIREBALLlct08 08",
143 "QUANTUM FIREBALLP KA6.4",
144 "QUANTUM FIREBALLP LM20.4",
145 "QUANTUM FIREBALLP LM20.5",
146 NULL
147};
148
149static const char *bad_ata100_5[] = { 141static const char *bad_ata100_5[] = {
150 "IBM-DTLA-307075", 142 "IBM-DTLA-307075",
151 "IBM-DTLA-307060", 143 "IBM-DTLA-307060",
@@ -729,27 +721,13 @@ static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
729 hpt3xx_set_mode(drive, XFER_PIO_0 + pio); 721 hpt3xx_set_mode(drive, XFER_PIO_0 + pio);
730} 722}
731 723
732static void hpt3xx_quirkproc(ide_drive_t *drive)
733{
734 char *m = (char *)&drive->id[ATA_ID_PROD];
735 const char **list = quirk_drives;
736
737 while (*list)
738 if (strstr(m, *list++)) {
739 drive->quirk_list = 1;
740 return;
741 }
742
743 drive->quirk_list = 0;
744}
745
746static void hpt3xx_maskproc(ide_drive_t *drive, int mask) 724static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
747{ 725{
748 ide_hwif_t *hwif = drive->hwif; 726 ide_hwif_t *hwif = drive->hwif;
749 struct pci_dev *dev = to_pci_dev(hwif->dev); 727 struct pci_dev *dev = to_pci_dev(hwif->dev);
750 struct hpt_info *info = hpt3xx_get_info(hwif->dev); 728 struct hpt_info *info = hpt3xx_get_info(hwif->dev);
751 729
752 if (drive->quirk_list == 0) 730 if ((drive->dev_flags & IDE_DFLAG_NIEN_QUIRK) == 0)
753 return; 731 return;
754 732
755 if (info->chip_type >= HPT370) { 733 if (info->chip_type >= HPT370) {
@@ -1404,7 +1382,6 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
1404static const struct ide_port_ops hpt3xx_port_ops = { 1382static const struct ide_port_ops hpt3xx_port_ops = {
1405 .set_pio_mode = hpt3xx_set_pio_mode, 1383 .set_pio_mode = hpt3xx_set_pio_mode,
1406 .set_dma_mode = hpt3xx_set_mode, 1384 .set_dma_mode = hpt3xx_set_mode,
1407 .quirkproc = hpt3xx_quirkproc,
1408 .maskproc = hpt3xx_maskproc, 1385 .maskproc = hpt3xx_maskproc,
1409 .mdma_filter = hpt3xx_mdma_filter, 1386 .mdma_filter = hpt3xx_mdma_filter,
1410 .udma_filter = hpt3xx_udma_filter, 1387 .udma_filter = hpt3xx_udma_filter,
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 36da913cc553..5af3d0ffaf0a 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -65,8 +65,6 @@ static struct cardinfo icside_cardinfo_v6_2 = {
65}; 65};
66 66
67struct icside_state { 67struct icside_state {
68 unsigned int channel;
69 unsigned int enabled;
70 void __iomem *irq_port; 68 void __iomem *irq_port;
71 void __iomem *ioc_base; 69 void __iomem *ioc_base;
72 unsigned int sel; 70 unsigned int sel;
@@ -116,18 +114,11 @@ static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
116 struct icside_state *state = ec->irq_data; 114 struct icside_state *state = ec->irq_data;
117 void __iomem *base = state->irq_port; 115 void __iomem *base = state->irq_port;
118 116
119 state->enabled = 1; 117 writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
118 readb(base + ICS_ARCIN_V6_INTROFFSET_2);
120 119
121 switch (state->channel) { 120 writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
122 case 0: 121 readb(base + ICS_ARCIN_V6_INTROFFSET_1);
123 writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
124 readb(base + ICS_ARCIN_V6_INTROFFSET_2);
125 break;
126 case 1:
127 writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
128 readb(base + ICS_ARCIN_V6_INTROFFSET_1);
129 break;
130 }
131} 122}
132 123
133/* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) 124/* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
@@ -137,8 +128,6 @@ static void icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
137{ 128{
138 struct icside_state *state = ec->irq_data; 129 struct icside_state *state = ec->irq_data;
139 130
140 state->enabled = 0;
141
142 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); 131 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
143 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); 132 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
144} 133}
@@ -160,44 +149,6 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = {
160 .irqpending = icside_irqpending_arcin_v6, 149 .irqpending = icside_irqpending_arcin_v6,
161}; 150};
162 151
163/*
164 * Handle routing of interrupts. This is called before
165 * we write the command to the drive.
166 */
167static void icside_maskproc(ide_drive_t *drive, int mask)
168{
169 ide_hwif_t *hwif = drive->hwif;
170 struct expansion_card *ec = ECARD_DEV(hwif->dev);
171 struct icside_state *state = ecard_get_drvdata(ec);
172 unsigned long flags;
173
174 local_irq_save(flags);
175
176 state->channel = hwif->channel;
177
178 if (state->enabled && !mask) {
179 switch (hwif->channel) {
180 case 0:
181 writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
182 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
183 break;
184 case 1:
185 writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
186 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
187 break;
188 }
189 } else {
190 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
191 readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
192 }
193
194 local_irq_restore(flags);
195}
196
197static const struct ide_port_ops icside_v6_no_dma_port_ops = {
198 .maskproc = icside_maskproc,
199};
200
201#ifdef CONFIG_BLK_DEV_IDEDMA_ICS 152#ifdef CONFIG_BLK_DEV_IDEDMA_ICS
202/* 153/*
203 * SG-DMA support. 154 * SG-DMA support.
@@ -275,7 +226,6 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
275 226
276static const struct ide_port_ops icside_v6_port_ops = { 227static const struct ide_port_ops icside_v6_port_ops = {
277 .set_dma_mode = icside_set_dma_mode, 228 .set_dma_mode = icside_set_dma_mode,
278 .maskproc = icside_maskproc,
279}; 229};
280 230
281static void icside_dma_host_set(ide_drive_t *drive, int on) 231static void icside_dma_host_set(ide_drive_t *drive, int on)
@@ -320,11 +270,6 @@ static int icside_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
320 BUG_ON(dma_channel_active(ec->dma)); 270 BUG_ON(dma_channel_active(ec->dma));
321 271
322 /* 272 /*
323 * Ensure that we have the right interrupt routed.
324 */
325 icside_maskproc(drive, 0);
326
327 /*
328 * Route the DMA signals to the correct interface. 273 * Route the DMA signals to the correct interface.
329 */ 274 */
330 writeb(state->sel | hwif->channel, state->ioc_base); 275 writeb(state->sel | hwif->channel, state->ioc_base);
@@ -381,7 +326,7 @@ static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d)
381 return -EOPNOTSUPP; 326 return -EOPNOTSUPP;
382} 327}
383 328
384static void icside_setup_ports(hw_regs_t *hw, void __iomem *base, 329static void icside_setup_ports(struct ide_hw *hw, void __iomem *base,
385 struct cardinfo *info, struct expansion_card *ec) 330 struct cardinfo *info, struct expansion_card *ec)
386{ 331{
387 unsigned long port = (unsigned long)base + info->dataoffset; 332 unsigned long port = (unsigned long)base + info->dataoffset;
@@ -398,11 +343,11 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base,
398 343
399 hw->irq = ec->irq; 344 hw->irq = ec->irq;
400 hw->dev = &ec->dev; 345 hw->dev = &ec->dev;
401 hw->chipset = ide_acorn;
402} 346}
403 347
404static const struct ide_port_info icside_v5_port_info = { 348static const struct ide_port_info icside_v5_port_info = {
405 .host_flags = IDE_HFLAG_NO_DMA, 349 .host_flags = IDE_HFLAG_NO_DMA,
350 .chipset = ide_acorn,
406}; 351};
407 352
408static int __devinit 353static int __devinit
@@ -410,7 +355,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
410{ 355{
411 void __iomem *base; 356 void __iomem *base;
412 struct ide_host *host; 357 struct ide_host *host;
413 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 358 struct ide_hw hw, *hws[] = { &hw };
414 int ret; 359 int ret;
415 360
416 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); 361 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
@@ -431,7 +376,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
431 376
432 icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); 377 icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec);
433 378
434 host = ide_host_alloc(&icside_v5_port_info, hws); 379 host = ide_host_alloc(&icside_v5_port_info, hws, 1);
435 if (host == NULL) 380 if (host == NULL)
436 return -ENODEV; 381 return -ENODEV;
437 382
@@ -452,11 +397,11 @@ err_free:
452 397
453static const struct ide_port_info icside_v6_port_info __initdata = { 398static const struct ide_port_info icside_v6_port_info __initdata = {
454 .init_dma = icside_dma_off_init, 399 .init_dma = icside_dma_off_init,
455 .port_ops = &icside_v6_no_dma_port_ops,
456 .dma_ops = &icside_v6_dma_ops, 400 .dma_ops = &icside_v6_dma_ops,
457 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO, 401 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO,
458 .mwdma_mask = ATA_MWDMA2, 402 .mwdma_mask = ATA_MWDMA2,
459 .swdma_mask = ATA_SWDMA2, 403 .swdma_mask = ATA_SWDMA2,
404 .chipset = ide_acorn,
460}; 405};
461 406
462static int __devinit 407static int __devinit
@@ -466,7 +411,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
466 struct ide_host *host; 411 struct ide_host *host;
467 unsigned int sel = 0; 412 unsigned int sel = 0;
468 int ret; 413 int ret;
469 hw_regs_t hw[2], *hws[] = { &hw[0], &hw[1], NULL, NULL }; 414 struct ide_hw hw[2], *hws[] = { &hw[0], &hw[1] };
470 struct ide_port_info d = icside_v6_port_info; 415 struct ide_port_info d = icside_v6_port_info;
471 416
472 ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); 417 ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
@@ -506,7 +451,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
506 icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); 451 icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec);
507 icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); 452 icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec);
508 453
509 host = ide_host_alloc(&d, hws); 454 host = ide_host_alloc(&d, hws, 2);
510 if (host == NULL) 455 if (host == NULL)
511 return -ENODEV; 456 return -ENODEV;
512 457
diff --git a/drivers/ide/ide-4drives.c b/drivers/ide/ide-4drives.c
index 78aca75a2c48..979d342c338a 100644
--- a/drivers/ide/ide-4drives.c
+++ b/drivers/ide/ide-4drives.c
@@ -25,12 +25,13 @@ static const struct ide_port_info ide_4drives_port_info = {
25 .port_ops = &ide_4drives_port_ops, 25 .port_ops = &ide_4drives_port_ops,
26 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA | 26 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA |
27 IDE_HFLAG_4DRIVES, 27 IDE_HFLAG_4DRIVES,
28 .chipset = ide_4drives,
28}; 29};
29 30
30static int __init ide_4drives_init(void) 31static int __init ide_4drives_init(void)
31{ 32{
32 unsigned long base = 0x1f0, ctl = 0x3f6; 33 unsigned long base = 0x1f0, ctl = 0x3f6;
33 hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL }; 34 struct ide_hw hw, *hws[] = { &hw, &hw };
34 35
35 if (probe_4drives == 0) 36 if (probe_4drives == 0)
36 return -ENODEV; 37 return -ENODEV;
@@ -52,9 +53,8 @@ static int __init ide_4drives_init(void)
52 53
53 ide_std_init_ports(&hw, base, ctl); 54 ide_std_init_ports(&hw, base, ctl);
54 hw.irq = 14; 55 hw.irq = 14;
55 hw.chipset = ide_4drives;
56 56
57 return ide_host_add(&ide_4drives_port_info, hws, NULL); 57 return ide_host_add(&ide_4drives_port_info, hws, 2, NULL);
58} 58}
59 59
60module_init(ide_4drives_init); 60module_init(ide_4drives_init);
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 757e5956b132..bbdd2547f12a 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -259,7 +259,7 @@ void ide_retry_pc(ide_drive_t *drive)
259 pc->req_xfer = blk_rq_bytes(sense_rq); 259 pc->req_xfer = blk_rq_bytes(sense_rq);
260 260
261 if (drive->media == ide_tape) 261 if (drive->media == ide_tape)
262 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 262 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC;
263 263
264 /* 264 /*
265 * Push back the failed request and put request sense on top 265 * Push back the failed request and put request sense on top
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index 9e47f3529d55..527908ff298c 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -155,6 +155,7 @@ static const struct ide_port_info idecs_port_info = {
155 .port_ops = &idecs_port_ops, 155 .port_ops = &idecs_port_ops,
156 .host_flags = IDE_HFLAG_NO_DMA, 156 .host_flags = IDE_HFLAG_NO_DMA,
157 .irq_flags = IRQF_SHARED, 157 .irq_flags = IRQF_SHARED,
158 .chipset = ide_pci,
158}; 159};
159 160
160static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, 161static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
@@ -163,7 +164,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
163 struct ide_host *host; 164 struct ide_host *host;
164 ide_hwif_t *hwif; 165 ide_hwif_t *hwif;
165 int i, rc; 166 int i, rc;
166 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 167 struct ide_hw hw, *hws[] = { &hw };
167 168
168 if (!request_region(io, 8, DRV_NAME)) { 169 if (!request_region(io, 8, DRV_NAME)) {
169 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 170 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
@@ -181,10 +182,9 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
181 memset(&hw, 0, sizeof(hw)); 182 memset(&hw, 0, sizeof(hw));
182 ide_std_init_ports(&hw, io, ctl); 183 ide_std_init_ports(&hw, io, ctl);
183 hw.irq = irq; 184 hw.irq = irq;
184 hw.chipset = ide_pci;
185 hw.dev = &handle->dev; 185 hw.dev = &handle->dev;
186 186
187 rc = ide_host_add(&idecs_port_info, hws, &host); 187 rc = ide_host_add(&idecs_port_info, hws, 1, &host);
188 if (rc) 188 if (rc)
189 goto out_release; 189 goto out_release;
190 190
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index c6f7fcfb9d67..6a1de2169709 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -302,14 +302,12 @@ static const struct drive_list_entry hpa_list[] = {
302 { NULL, NULL } 302 { NULL, NULL }
303}; 303};
304 304
305static void idedisk_check_hpa(ide_drive_t *drive) 305static u64 ide_disk_hpa_get_native_capacity(ide_drive_t *drive, int lba48)
306{ 306{
307 unsigned long long capacity, set_max; 307 u64 capacity, set_max;
308 int lba48 = ata_id_lba48_enabled(drive->id);
309 308
310 capacity = drive->capacity64; 309 capacity = drive->capacity64;
311 310 set_max = idedisk_read_native_max_address(drive, lba48);
312 set_max = idedisk_read_native_max_address(drive, lba48);
313 311
314 if (ide_in_drive_list(drive->id, hpa_list)) { 312 if (ide_in_drive_list(drive->id, hpa_list)) {
315 /* 313 /*
@@ -320,9 +318,31 @@ static void idedisk_check_hpa(ide_drive_t *drive)
320 set_max--; 318 set_max--;
321 } 319 }
322 320
321 return set_max;
322}
323
324static u64 ide_disk_hpa_set_capacity(ide_drive_t *drive, u64 set_max, int lba48)
325{
326 set_max = idedisk_set_max_address(drive, set_max, lba48);
327 if (set_max)
328 drive->capacity64 = set_max;
329
330 return set_max;
331}
332
333static void idedisk_check_hpa(ide_drive_t *drive)
334{
335 u64 capacity, set_max;
336 int lba48 = ata_id_lba48_enabled(drive->id);
337
338 capacity = drive->capacity64;
339 set_max = ide_disk_hpa_get_native_capacity(drive, lba48);
340
323 if (set_max <= capacity) 341 if (set_max <= capacity)
324 return; 342 return;
325 343
344 drive->probed_capacity = set_max;
345
326 printk(KERN_INFO "%s: Host Protected Area detected.\n" 346 printk(KERN_INFO "%s: Host Protected Area detected.\n"
327 "\tcurrent capacity is %llu sectors (%llu MB)\n" 347 "\tcurrent capacity is %llu sectors (%llu MB)\n"
328 "\tnative capacity is %llu sectors (%llu MB)\n", 348 "\tnative capacity is %llu sectors (%llu MB)\n",
@@ -330,13 +350,13 @@ static void idedisk_check_hpa(ide_drive_t *drive)
330 capacity, sectors_to_MB(capacity), 350 capacity, sectors_to_MB(capacity),
331 set_max, sectors_to_MB(set_max)); 351 set_max, sectors_to_MB(set_max));
332 352
333 set_max = idedisk_set_max_address(drive, set_max, lba48); 353 if ((drive->dev_flags & IDE_DFLAG_NOHPA) == 0)
354 return;
334 355
335 if (set_max) { 356 set_max = ide_disk_hpa_set_capacity(drive, set_max, lba48);
336 drive->capacity64 = set_max; 357 if (set_max)
337 printk(KERN_INFO "%s: Host Protected Area disabled.\n", 358 printk(KERN_INFO "%s: Host Protected Area disabled.\n",
338 drive->name); 359 drive->name);
339 }
340} 360}
341 361
342static int ide_disk_get_capacity(ide_drive_t *drive) 362static int ide_disk_get_capacity(ide_drive_t *drive)
@@ -358,6 +378,8 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
358 drive->capacity64 = drive->cyl * drive->head * drive->sect; 378 drive->capacity64 = drive->cyl * drive->head * drive->sect;
359 } 379 }
360 380
381 drive->probed_capacity = drive->capacity64;
382
361 if (lba) { 383 if (lba) {
362 drive->dev_flags |= IDE_DFLAG_LBA; 384 drive->dev_flags |= IDE_DFLAG_LBA;
363 385
@@ -376,7 +398,7 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
376 "%llu sectors (%llu MB)\n", 398 "%llu sectors (%llu MB)\n",
377 drive->name, (unsigned long long)drive->capacity64, 399 drive->name, (unsigned long long)drive->capacity64,
378 sectors_to_MB(drive->capacity64)); 400 sectors_to_MB(drive->capacity64));
379 drive->capacity64 = 1ULL << 28; 401 drive->probed_capacity = drive->capacity64 = 1ULL << 28;
380 } 402 }
381 403
382 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && 404 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
@@ -392,6 +414,34 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
392 return 0; 414 return 0;
393} 415}
394 416
417static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity)
418{
419 u64 set = min(capacity, drive->probed_capacity);
420 u16 *id = drive->id;
421 int lba48 = ata_id_lba48_enabled(id);
422
423 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
424 ata_id_hpa_enabled(id) == 0)
425 goto out;
426
427 /*
428 * according to the spec the SET MAX ADDRESS command shall be
429 * immediately preceded by a READ NATIVE MAX ADDRESS command
430 */
431 capacity = ide_disk_hpa_get_native_capacity(drive, lba48);
432 if (capacity == 0)
433 goto out;
434
435 set = ide_disk_hpa_set_capacity(drive, set, lba48);
436 if (set) {
437 /* needed for ->resume to disable HPA */
438 drive->dev_flags |= IDE_DFLAG_NOHPA;
439 return set;
440 }
441out:
442 return drive->capacity64;
443}
444
395static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 445static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
396{ 446{
397 ide_drive_t *drive = q->queuedata; 447 ide_drive_t *drive = q->queuedata;
@@ -428,14 +478,14 @@ static int set_multcount(ide_drive_t *drive, int arg)
428 if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff)) 478 if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff))
429 return -EINVAL; 479 return -EINVAL;
430 480
431 if (drive->special.b.set_multmode) 481 if (drive->special_flags & IDE_SFLAG_SET_MULTMODE)
432 return -EBUSY; 482 return -EBUSY;
433 483
434 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 484 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
435 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 485 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
436 486
437 drive->mult_req = arg; 487 drive->mult_req = arg;
438 drive->special.b.set_multmode = 1; 488 drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
439 error = blk_execute_rq(drive->queue, NULL, rq, 0); 489 error = blk_execute_rq(drive->queue, NULL, rq, 0);
440 blk_put_request(rq); 490 blk_put_request(rq);
441 491
@@ -740,6 +790,7 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
740 790
741const struct ide_disk_ops ide_ata_disk_ops = { 791const struct ide_disk_ops ide_ata_disk_ops = {
742 .check = ide_disk_check, 792 .check = ide_disk_check,
793 .set_capacity = ide_disk_set_capacity,
743 .get_capacity = ide_disk_get_capacity, 794 .get_capacity = ide_disk_get_capacity,
744 .setup = ide_disk_setup, 795 .setup = ide_disk_setup,
745 .flush = ide_disk_flush, 796 .flush = ide_disk_flush,
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 001f68f0bb28..219e6fb78dc6 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -347,7 +347,6 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode)
347 347
348 return mode; 348 return mode;
349} 349}
350EXPORT_SYMBOL_GPL(ide_find_dma_mode);
351 350
352static int ide_tune_dma(ide_drive_t *drive) 351static int ide_tune_dma(ide_drive_t *drive)
353{ 352{
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index 5d5fb961b5ce..2b9141979613 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -52,7 +52,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
52 } 52 }
53 53
54 if ((rq->errors & ERROR_RECAL) == ERROR_RECAL) 54 if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
55 drive->special.b.recalibrate = 1; 55 drive->special_flags |= IDE_SFLAG_RECALIBRATE;
56 56
57 ++rq->errors; 57 ++rq->errors;
58 58
@@ -268,9 +268,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
268{ 268{
269 int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; 269 int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1;
270 270
271 drive->special.all = 0; 271 drive->special_flags =
272 drive->special.b.set_geometry = legacy; 272 legacy ? (IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE) : 0;
273 drive->special.b.recalibrate = legacy;
274 273
275 drive->mult_count = 0; 274 drive->mult_count = 0;
276 drive->dev_flags &= ~IDE_DFLAG_PARKED; 275 drive->dev_flags &= ~IDE_DFLAG_PARKED;
@@ -280,7 +279,7 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
280 drive->mult_req = 0; 279 drive->mult_req = 0;
281 280
282 if (drive->mult_req != drive->mult_count) 281 if (drive->mult_req != drive->mult_count)
283 drive->special.b.set_multmode = 1; 282 drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
284} 283}
285 284
286static void pre_reset(ide_drive_t *drive) 285static void pre_reset(ide_drive_t *drive)
@@ -408,8 +407,9 @@ static ide_startstop_t do_reset1(ide_drive_t *drive, int do_not_try_atapi)
408 /* more than enough time */ 407 /* more than enough time */
409 udelay(10); 408 udelay(10);
410 /* clear SRST, leave nIEN (unless device is on the quirk list) */ 409 /* clear SRST, leave nIEN (unless device is on the quirk list) */
411 tp_ops->write_devctl(hwif, (drive->quirk_list == 2 ? 0 : ATA_NIEN) | 410 tp_ops->write_devctl(hwif,
412 ATA_DEVCTL_OBS); 411 ((drive->dev_flags & IDE_DFLAG_NIEN_QUIRK) ? 0 : ATA_NIEN) |
412 ATA_DEVCTL_OBS);
413 /* more than enough time */ 413 /* more than enough time */
414 udelay(10); 414 udelay(10);
415 hwif->poll_timeout = jiffies + WAIT_WORSTCASE; 415 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 4b6b71e2cdf5..214119026b3f 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -287,6 +287,19 @@ static int ide_gd_media_changed(struct gendisk *disk)
287 return ret; 287 return ret;
288} 288}
289 289
290static unsigned long long ide_gd_set_capacity(struct gendisk *disk,
291 unsigned long long capacity)
292{
293 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
294 ide_drive_t *drive = idkp->drive;
295 const struct ide_disk_ops *disk_ops = drive->disk_ops;
296
297 if (disk_ops->set_capacity)
298 return disk_ops->set_capacity(drive, capacity);
299
300 return drive->capacity64;
301}
302
290static int ide_gd_revalidate_disk(struct gendisk *disk) 303static int ide_gd_revalidate_disk(struct gendisk *disk)
291{ 304{
292 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); 305 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
@@ -315,6 +328,7 @@ static struct block_device_operations ide_gd_ops = {
315 .locked_ioctl = ide_gd_ioctl, 328 .locked_ioctl = ide_gd_ioctl,
316 .getgeo = ide_gd_getgeo, 329 .getgeo = ide_gd_getgeo,
317 .media_changed = ide_gd_media_changed, 330 .media_changed = ide_gd_media_changed,
331 .set_capacity = ide_gd_set_capacity,
318 .revalidate_disk = ide_gd_revalidate_disk 332 .revalidate_disk = ide_gd_revalidate_disk
319}; 333};
320 334
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index 7812ca0be13b..54d7c4685d23 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -29,6 +29,7 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports");
29 29
30static const struct ide_port_info ide_generic_port_info = { 30static const struct ide_port_info ide_generic_port_info = {
31 .host_flags = IDE_HFLAG_NO_DMA, 31 .host_flags = IDE_HFLAG_NO_DMA,
32 .chipset = ide_generic,
32}; 33};
33 34
34#ifdef CONFIG_ARM 35#ifdef CONFIG_ARM
@@ -85,7 +86,7 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary)
85 86
86static int __init ide_generic_init(void) 87static int __init ide_generic_init(void)
87{ 88{
88 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 89 struct ide_hw hw, *hws[] = { &hw };
89 unsigned long io_addr; 90 unsigned long io_addr;
90 int i, rc = 0, primary = 0, secondary = 0; 91 int i, rc = 0, primary = 0, secondary = 0;
91 92
@@ -132,9 +133,7 @@ static int __init ide_generic_init(void)
132#else 133#else
133 hw.irq = legacy_irqs[i]; 134 hw.irq = legacy_irqs[i];
134#endif 135#endif
135 hw.chipset = ide_generic; 136 rc = ide_host_add(&ide_generic_port_info, hws, 1, NULL);
136
137 rc = ide_host_add(&ide_generic_port_info, hws, NULL);
138 if (rc) { 137 if (rc) {
139 release_region(io_addr + 0x206, 1); 138 release_region(io_addr + 0x206, 1);
140 release_region(io_addr, 8); 139 release_region(io_addr, 8);
diff --git a/drivers/ide/ide-h8300.c b/drivers/ide/ide-h8300.c
index c06ebdc4a130..520f42c5445a 100644
--- a/drivers/ide/ide-h8300.c
+++ b/drivers/ide/ide-h8300.c
@@ -64,26 +64,26 @@ static const struct ide_tp_ops h8300_tp_ops = {
64 64
65#define H8300_IDE_GAP (2) 65#define H8300_IDE_GAP (2)
66 66
67static inline void hw_setup(hw_regs_t *hw) 67static inline void hw_setup(struct ide_hw *hw)
68{ 68{
69 int i; 69 int i;
70 70
71 memset(hw, 0, sizeof(hw_regs_t)); 71 memset(hw, 0, sizeof(*hw));
72 for (i = 0; i <= 7; i++) 72 for (i = 0; i <= 7; i++)
73 hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; 73 hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i;
74 hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT; 74 hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT;
75 hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; 75 hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ;
76 hw->chipset = ide_generic;
77} 76}
78 77
79static const struct ide_port_info h8300_port_info = { 78static const struct ide_port_info h8300_port_info = {
80 .tp_ops = &h8300_tp_ops, 79 .tp_ops = &h8300_tp_ops,
81 .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, 80 .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA,
81 .chipset = ide_generic,
82}; 82};
83 83
84static int __init h8300_ide_init(void) 84static int __init h8300_ide_init(void)
85{ 85{
86 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 86 struct ide_hw hw, *hws[] = { &hw };
87 87
88 printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); 88 printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
89 89
@@ -96,7 +96,7 @@ static int __init h8300_ide_init(void)
96 96
97 hw_setup(&hw); 97 hw_setup(&hw);
98 98
99 return ide_host_add(&h8300_port_info, hws, NULL); 99 return ide_host_add(&h8300_port_info, hws, 1, NULL);
100 100
101out_busy: 101out_busy:
102 printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n"); 102 printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n");
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index bba4297f2f03..272cc38f6dbe 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -184,29 +184,42 @@ static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
184 tf->command = ATA_CMD_SET_MULTI; 184 tf->command = ATA_CMD_SET_MULTI;
185} 185}
186 186
187static ide_startstop_t ide_disk_special(ide_drive_t *drive) 187/**
188 * do_special - issue some special commands
189 * @drive: drive the command is for
190 *
191 * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS,
192 * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive.
193 */
194
195static ide_startstop_t do_special(ide_drive_t *drive)
188{ 196{
189 special_t *s = &drive->special;
190 struct ide_cmd cmd; 197 struct ide_cmd cmd;
191 198
199#ifdef DEBUG
200 printk(KERN_DEBUG "%s: %s: 0x%02x\n", drive->name, __func__,
201 drive->special_flags);
202#endif
203 if (drive->media != ide_disk) {
204 drive->special_flags = 0;
205 drive->mult_req = 0;
206 return ide_stopped;
207 }
208
192 memset(&cmd, 0, sizeof(cmd)); 209 memset(&cmd, 0, sizeof(cmd));
193 cmd.protocol = ATA_PROT_NODATA; 210 cmd.protocol = ATA_PROT_NODATA;
194 211
195 if (s->b.set_geometry) { 212 if (drive->special_flags & IDE_SFLAG_SET_GEOMETRY) {
196 s->b.set_geometry = 0; 213 drive->special_flags &= ~IDE_SFLAG_SET_GEOMETRY;
197 ide_tf_set_specify_cmd(drive, &cmd.tf); 214 ide_tf_set_specify_cmd(drive, &cmd.tf);
198 } else if (s->b.recalibrate) { 215 } else if (drive->special_flags & IDE_SFLAG_RECALIBRATE) {
199 s->b.recalibrate = 0; 216 drive->special_flags &= ~IDE_SFLAG_RECALIBRATE;
200 ide_tf_set_restore_cmd(drive, &cmd.tf); 217 ide_tf_set_restore_cmd(drive, &cmd.tf);
201 } else if (s->b.set_multmode) { 218 } else if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) {
202 s->b.set_multmode = 0; 219 drive->special_flags &= ~IDE_SFLAG_SET_MULTMODE;
203 ide_tf_set_setmult_cmd(drive, &cmd.tf); 220 ide_tf_set_setmult_cmd(drive, &cmd.tf);
204 } else if (s->all) { 221 } else
205 int special = s->all; 222 BUG();
206 s->all = 0;
207 printk(KERN_ERR "%s: bad special flag: 0x%02x\n", drive->name, special);
208 return ide_stopped;
209 }
210 223
211 cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; 224 cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
212 cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; 225 cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
@@ -217,31 +230,6 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive)
217 return ide_started; 230 return ide_started;
218} 231}
219 232
220/**
221 * do_special - issue some special commands
222 * @drive: drive the command is for
223 *
224 * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS,
225 * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive.
226 *
227 * It used to do much more, but has been scaled back.
228 */
229
230static ide_startstop_t do_special (ide_drive_t *drive)
231{
232 special_t *s = &drive->special;
233
234#ifdef DEBUG
235 printk("%s: do_special: 0x%02x\n", drive->name, s->all);
236#endif
237 if (drive->media == ide_disk)
238 return ide_disk_special(drive);
239
240 s->all = 0;
241 drive->mult_req = 0;
242 return ide_stopped;
243}
244
245void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd) 233void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd)
246{ 234{
247 ide_hwif_t *hwif = drive->hwif; 235 ide_hwif_t *hwif = drive->hwif;
@@ -351,7 +339,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
351 printk(KERN_ERR "%s: drive not ready for command\n", drive->name); 339 printk(KERN_ERR "%s: drive not ready for command\n", drive->name);
352 return startstop; 340 return startstop;
353 } 341 }
354 if (!drive->special.all) { 342
343 if (drive->special_flags == 0) {
355 struct ide_driver *drv; 344 struct ide_driver *drv;
356 345
357 /* 346 /*
@@ -499,11 +488,15 @@ repeat:
499 488
500 if ((hwif->host->host_flags & IDE_HFLAG_SERIALIZE) && 489 if ((hwif->host->host_flags & IDE_HFLAG_SERIALIZE) &&
501 hwif != prev_port) { 490 hwif != prev_port) {
491 ide_drive_t *cur_dev =
492 prev_port ? prev_port->cur_dev : NULL;
493
502 /* 494 /*
503 * set nIEN for previous port, drives in the 495 * set nIEN for previous port, drives in the
504 * quirk_list may not like intr setups/cleanups 496 * quirk list may not like intr setups/cleanups
505 */ 497 */
506 if (prev_port && prev_port->cur_dev->quirk_list == 0) 498 if (cur_dev &&
499 (cur_dev->dev_flags & IDE_DFLAG_NIEN_QUIRK) == 0)
507 prev_port->tp_ops->write_devctl(prev_port, 500 prev_port->tp_ops->write_devctl(prev_port,
508 ATA_NIEN | 501 ATA_NIEN |
509 ATA_DEVCTL_OBS); 502 ATA_DEVCTL_OBS);
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 06fe002116ec..fa047150a1c6 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -282,6 +282,29 @@ no_80w:
282 return 0; 282 return 0;
283} 283}
284 284
285static const char *nien_quirk_list[] = {
286 "QUANTUM FIREBALLlct08 08",
287 "QUANTUM FIREBALLP KA6.4",
288 "QUANTUM FIREBALLP KA9.1",
289 "QUANTUM FIREBALLP KX13.6",
290 "QUANTUM FIREBALLP KX20.5",
291 "QUANTUM FIREBALLP KX27.3",
292 "QUANTUM FIREBALLP LM20.4",
293 "QUANTUM FIREBALLP LM20.5",
294 NULL
295};
296
297void ide_check_nien_quirk_list(ide_drive_t *drive)
298{
299 const char **list, *m = (char *)&drive->id[ATA_ID_PROD];
300
301 for (list = nien_quirk_list; *list != NULL; list++)
302 if (strstr(m, *list) != NULL) {
303 drive->dev_flags |= IDE_DFLAG_NIEN_QUIRK;
304 return;
305 }
306}
307
285int ide_driveid_update(ide_drive_t *drive) 308int ide_driveid_update(ide_drive_t *drive)
286{ 309{
287 u16 *id; 310 u16 *id;
@@ -311,7 +334,6 @@ int ide_driveid_update(ide_drive_t *drive)
311 334
312 return 1; 335 return 1;
313out_err: 336out_err:
314 SELECT_MASK(drive, 0);
315 if (rc == 2) 337 if (rc == 2)
316 printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__); 338 printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__);
317 kfree(id); 339 kfree(id);
@@ -365,7 +387,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
365 387
366 tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); 388 tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES);
367 389
368 if (drive->quirk_list == 2) 390 if (drive->dev_flags & IDE_DFLAG_NIEN_QUIRK)
369 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); 391 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);
370 392
371 error = __ide_wait_stat(drive, drive->ready_stat, 393 error = __ide_wait_stat(drive, drive->ready_stat,
diff --git a/drivers/ide/ide-legacy.c b/drivers/ide/ide-legacy.c
index 8c5dcbf22547..b9654a7bb7be 100644
--- a/drivers/ide/ide-legacy.c
+++ b/drivers/ide/ide-legacy.c
@@ -1,7 +1,7 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3 3
4static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw, 4static void ide_legacy_init_one(struct ide_hw **hws, struct ide_hw *hw,
5 u8 port_no, const struct ide_port_info *d, 5 u8 port_no, const struct ide_port_info *d,
6 unsigned long config) 6 unsigned long config)
7{ 7{
@@ -33,7 +33,6 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
33 33
34 ide_std_init_ports(hw, base, ctl); 34 ide_std_init_ports(hw, base, ctl);
35 hw->irq = irq; 35 hw->irq = irq;
36 hw->chipset = d->chipset;
37 hw->config = config; 36 hw->config = config;
38 37
39 hws[port_no] = hw; 38 hws[port_no] = hw;
@@ -41,7 +40,7 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
41 40
42int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) 41int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
43{ 42{
44 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; 43 struct ide_hw hw[2], *hws[] = { NULL, NULL };
45 44
46 memset(&hw, 0, sizeof(hw)); 45 memset(&hw, 0, sizeof(hw));
47 46
@@ -53,6 +52,6 @@ int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
53 (d->host_flags & IDE_HFLAG_SINGLE)) 52 (d->host_flags & IDE_HFLAG_SINGLE))
54 return -ENOENT; 53 return -ENOENT;
55 54
56 return ide_host_add(d, hws, NULL); 55 return ide_host_add(d, hws, 2, NULL);
57} 56}
58EXPORT_SYMBOL_GPL(ide_legacy_device_add); 57EXPORT_SYMBOL_GPL(ide_legacy_device_add);
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index 6e80b774e88a..017b1df3b805 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -29,6 +29,7 @@ static struct pnp_device_id idepnp_devices[] = {
29 29
30static const struct ide_port_info ide_pnp_port_info = { 30static const struct ide_port_info ide_pnp_port_info = {
31 .host_flags = IDE_HFLAG_NO_DMA, 31 .host_flags = IDE_HFLAG_NO_DMA,
32 .chipset = ide_generic,
32}; 33};
33 34
34static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) 35static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
@@ -36,7 +37,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
36 struct ide_host *host; 37 struct ide_host *host;
37 unsigned long base, ctl; 38 unsigned long base, ctl;
38 int rc; 39 int rc;
39 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 40 struct ide_hw hw, *hws[] = { &hw };
40 41
41 printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); 42 printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
42 43
@@ -62,9 +63,8 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
62 memset(&hw, 0, sizeof(hw)); 63 memset(&hw, 0, sizeof(hw));
63 ide_std_init_ports(&hw, base, ctl); 64 ide_std_init_ports(&hw, base, ctl);
64 hw.irq = pnp_irq(dev, 0); 65 hw.irq = pnp_irq(dev, 0);
65 hw.chipset = ide_generic;
66 66
67 rc = ide_host_add(&ide_pnp_port_info, hws, &host); 67 rc = ide_host_add(&ide_pnp_port_info, hws, 1, &host);
68 if (rc) 68 if (rc)
69 goto out; 69 goto out;
70 70
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index c895ed52b2e8..f371b0de314f 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -97,7 +97,7 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
97 drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; 97 drive->mult_req = id[ATA_ID_MULTSECT] & 0xff;
98 98
99 if (drive->mult_req) 99 if (drive->mult_req)
100 drive->special.b.set_multmode = 1; 100 drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
101 } 101 }
102} 102}
103 103
@@ -465,23 +465,8 @@ static u8 probe_for_drive(ide_drive_t *drive)
465 int rc; 465 int rc;
466 u8 cmd; 466 u8 cmd;
467 467
468 /*
469 * In order to keep things simple we have an id
470 * block for all drives at all times. If the device
471 * is pre ATA or refuses ATA/ATAPI identify we
472 * will add faked data to this.
473 *
474 * Also note that 0 everywhere means "can't do X"
475 */
476
477 drive->dev_flags &= ~IDE_DFLAG_ID_READ; 468 drive->dev_flags &= ~IDE_DFLAG_ID_READ;
478 469
479 drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL);
480 if (drive->id == NULL) {
481 printk(KERN_ERR "ide: out of memory for id data.\n");
482 return 0;
483 }
484
485 m = (char *)&drive->id[ATA_ID_PROD]; 470 m = (char *)&drive->id[ATA_ID_PROD];
486 strcpy(m, "UNKNOWN"); 471 strcpy(m, "UNKNOWN");
487 472
@@ -497,7 +482,7 @@ static u8 probe_for_drive(ide_drive_t *drive)
497 } 482 }
498 483
499 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 484 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
500 goto out_free; 485 return 0;
501 486
502 /* identification failed? */ 487 /* identification failed? */
503 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 488 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
@@ -521,7 +506,7 @@ static u8 probe_for_drive(ide_drive_t *drive)
521 } 506 }
522 507
523 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 508 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
524 goto out_free; 509 return 0;
525 510
526 /* The drive wasn't being helpful. Add generic info only */ 511 /* The drive wasn't being helpful. Add generic info only */
527 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 512 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
@@ -535,9 +520,6 @@ static u8 probe_for_drive(ide_drive_t *drive)
535 } 520 }
536 521
537 return 1; 522 return 1;
538out_free:
539 kfree(drive->id);
540 return 0;
541} 523}
542 524
543static void hwif_release_dev(struct device *dev) 525static void hwif_release_dev(struct device *dev)
@@ -702,8 +684,14 @@ static int ide_probe_port(ide_hwif_t *hwif)
702 if (irqd) 684 if (irqd)
703 disable_irq(hwif->irq); 685 disable_irq(hwif->irq);
704 686
705 if (ide_port_wait_ready(hwif) == -EBUSY) 687 rc = ide_port_wait_ready(hwif);
706 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 688 if (rc == -ENODEV) {
689 printk(KERN_INFO "%s: no devices on the port\n", hwif->name);
690 goto out;
691 } else if (rc == -EBUSY)
692 printk(KERN_ERR "%s: not ready before the probe\n", hwif->name);
693 else
694 rc = -ENODEV;
707 695
708 /* 696 /*
709 * Second drive should only exist if first drive was found, 697 * Second drive should only exist if first drive was found,
@@ -714,7 +702,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
714 if (drive->dev_flags & IDE_DFLAG_PRESENT) 702 if (drive->dev_flags & IDE_DFLAG_PRESENT)
715 rc = 0; 703 rc = 0;
716 } 704 }
717 705out:
718 /* 706 /*
719 * Use cached IRQ number. It might be (and is...) changed by probe 707 * Use cached IRQ number. It might be (and is...) changed by probe
720 * code above 708 * code above
@@ -732,6 +720,8 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
732 int i; 720 int i;
733 721
734 ide_port_for_each_present_dev(i, drive, hwif) { 722 ide_port_for_each_present_dev(i, drive, hwif) {
723 ide_check_nien_quirk_list(drive);
724
735 if (port_ops && port_ops->quirkproc) 725 if (port_ops && port_ops->quirkproc)
736 port_ops->quirkproc(drive); 726 port_ops->quirkproc(drive);
737 } 727 }
@@ -817,8 +807,6 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
817 if (ide_init_queue(drive)) { 807 if (ide_init_queue(drive)) {
818 printk(KERN_ERR "ide: failed to init %s\n", 808 printk(KERN_ERR "ide: failed to init %s\n",
819 drive->name); 809 drive->name);
820 kfree(drive->id);
821 drive->id = NULL;
822 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 810 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
823 continue; 811 continue;
824 } 812 }
@@ -947,9 +935,6 @@ static void drive_release_dev (struct device *dev)
947 blk_cleanup_queue(drive->queue); 935 blk_cleanup_queue(drive->queue);
948 drive->queue = NULL; 936 drive->queue = NULL;
949 937
950 kfree(drive->id);
951 drive->id = NULL;
952
953 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 938 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
954 939
955 complete(&drive->gendev_rel_comp); 940 complete(&drive->gendev_rel_comp);
@@ -1035,6 +1020,15 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1035 if (port_ops && port_ops->init_dev) 1020 if (port_ops && port_ops->init_dev)
1036 port_ops->init_dev(drive); 1021 port_ops->init_dev(drive);
1037 } 1022 }
1023
1024 ide_port_for_each_dev(i, drive, hwif) {
1025 /*
1026 * default to PIO Mode 0 before we figure out
1027 * the most suited mode for the attached device
1028 */
1029 if (port_ops && port_ops->set_pio_mode)
1030 port_ops->set_pio_mode(drive, 0);
1031 }
1038} 1032}
1039 1033
1040static void ide_init_port(ide_hwif_t *hwif, unsigned int port, 1034static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
@@ -1042,8 +1036,7 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1042{ 1036{
1043 hwif->channel = port; 1037 hwif->channel = port;
1044 1038
1045 if (d->chipset) 1039 hwif->chipset = d->chipset ? d->chipset : ide_pci;
1046 hwif->chipset = d->chipset;
1047 1040
1048 if (d->init_iops) 1041 if (d->init_iops)
1049 d->init_iops(hwif); 1042 d->init_iops(hwif);
@@ -1124,16 +1117,19 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
1124 1117
1125 ide_port_for_each_dev(i, drive, hwif) { 1118 ide_port_for_each_dev(i, drive, hwif) {
1126 u8 j = (hwif->index * MAX_DRIVES) + i; 1119 u8 j = (hwif->index * MAX_DRIVES) + i;
1120 u16 *saved_id = drive->id;
1127 1121
1128 memset(drive, 0, sizeof(*drive)); 1122 memset(drive, 0, sizeof(*drive));
1123 memset(saved_id, 0, SECTOR_SIZE);
1124 drive->id = saved_id;
1129 1125
1130 drive->media = ide_disk; 1126 drive->media = ide_disk;
1131 drive->select = (i << 4) | ATA_DEVICE_OBS; 1127 drive->select = (i << 4) | ATA_DEVICE_OBS;
1132 drive->hwif = hwif; 1128 drive->hwif = hwif;
1133 drive->ready_stat = ATA_DRDY; 1129 drive->ready_stat = ATA_DRDY;
1134 drive->bad_wstat = BAD_W_STAT; 1130 drive->bad_wstat = BAD_W_STAT;
1135 drive->special.b.recalibrate = 1; 1131 drive->special_flags = IDE_SFLAG_RECALIBRATE |
1136 drive->special.b.set_geometry = 1; 1132 IDE_SFLAG_SET_GEOMETRY;
1137 drive->name[0] = 'h'; 1133 drive->name[0] = 'h';
1138 drive->name[1] = 'd'; 1134 drive->name[1] = 'd';
1139 drive->name[2] = 'a' + j; 1135 drive->name[2] = 'a' + j;
@@ -1168,11 +1164,10 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
1168 ide_port_init_devices_data(hwif); 1164 ide_port_init_devices_data(hwif);
1169} 1165}
1170 1166
1171static void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) 1167static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw)
1172{ 1168{
1173 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); 1169 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
1174 hwif->irq = hw->irq; 1170 hwif->irq = hw->irq;
1175 hwif->chipset = hw->chipset;
1176 hwif->dev = hw->dev; 1171 hwif->dev = hw->dev;
1177 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; 1172 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
1178 hwif->ack_intr = hw->ack_intr; 1173 hwif->ack_intr = hw->ack_intr;
@@ -1233,8 +1228,10 @@ static void ide_port_free_devices(ide_hwif_t *hwif)
1233 ide_drive_t *drive; 1228 ide_drive_t *drive;
1234 int i; 1229 int i;
1235 1230
1236 ide_port_for_each_dev(i, drive, hwif) 1231 ide_port_for_each_dev(i, drive, hwif) {
1232 kfree(drive->id);
1237 kfree(drive); 1233 kfree(drive);
1234 }
1238} 1235}
1239 1236
1240static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) 1237static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
@@ -1248,6 +1245,18 @@ static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
1248 if (drive == NULL) 1245 if (drive == NULL)
1249 goto out_nomem; 1246 goto out_nomem;
1250 1247
1248 /*
1249 * In order to keep things simple we have an id
1250 * block for all drives at all times. If the device
1251 * is pre ATA or refuses ATA/ATAPI identify we
1252 * will add faked data to this.
1253 *
1254 * Also note that 0 everywhere means "can't do X"
1255 */
1256 drive->id = kzalloc_node(SECTOR_SIZE, GFP_KERNEL, node);
1257 if (drive->id == NULL)
1258 goto out_nomem;
1259
1251 hwif->devices[i] = drive; 1260 hwif->devices[i] = drive;
1252 } 1261 }
1253 return 0; 1262 return 0;
@@ -1257,7 +1266,8 @@ out_nomem:
1257 return -ENOMEM; 1266 return -ENOMEM;
1258} 1267}
1259 1268
1260struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) 1269struct ide_host *ide_host_alloc(const struct ide_port_info *d,
1270 struct ide_hw **hws, unsigned int n_ports)
1261{ 1271{
1262 struct ide_host *host; 1272 struct ide_host *host;
1263 struct device *dev = hws[0] ? hws[0]->dev : NULL; 1273 struct device *dev = hws[0] ? hws[0]->dev : NULL;
@@ -1268,7 +1278,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
1268 if (host == NULL) 1278 if (host == NULL)
1269 return NULL; 1279 return NULL;
1270 1280
1271 for (i = 0; i < MAX_HOST_PORTS; i++) { 1281 for (i = 0; i < n_ports; i++) {
1272 ide_hwif_t *hwif; 1282 ide_hwif_t *hwif;
1273 int idx; 1283 int idx;
1274 1284
@@ -1288,6 +1298,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
1288 if (idx < 0) { 1298 if (idx < 0) {
1289 printk(KERN_ERR "%s: no free slot for interface\n", 1299 printk(KERN_ERR "%s: no free slot for interface\n",
1290 d ? d->name : "ide"); 1300 d ? d->name : "ide");
1301 ide_port_free_devices(hwif);
1291 kfree(hwif); 1302 kfree(hwif);
1292 continue; 1303 continue;
1293 } 1304 }
@@ -1344,7 +1355,7 @@ static void ide_disable_port(ide_hwif_t *hwif)
1344} 1355}
1345 1356
1346int ide_host_register(struct ide_host *host, const struct ide_port_info *d, 1357int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1347 hw_regs_t **hws) 1358 struct ide_hw **hws)
1348{ 1359{
1349 ide_hwif_t *hwif, *mate = NULL; 1360 ide_hwif_t *hwif, *mate = NULL;
1350 int i, j = 0; 1361 int i, j = 0;
@@ -1438,13 +1449,13 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1438} 1449}
1439EXPORT_SYMBOL_GPL(ide_host_register); 1450EXPORT_SYMBOL_GPL(ide_host_register);
1440 1451
1441int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws, 1452int ide_host_add(const struct ide_port_info *d, struct ide_hw **hws,
1442 struct ide_host **hostp) 1453 unsigned int n_ports, struct ide_host **hostp)
1443{ 1454{
1444 struct ide_host *host; 1455 struct ide_host *host;
1445 int rc; 1456 int rc;
1446 1457
1447 host = ide_host_alloc(d, hws); 1458 host = ide_host_alloc(d, hws, n_ports);
1448 if (host == NULL) 1459 if (host == NULL)
1449 return -ENOMEM; 1460 return -ENOMEM;
1450 1461
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index d9764f0bc82f..4b447a8a49d4 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -240,18 +240,27 @@ static struct class *idetape_sysfs_class;
240 240
241static void ide_tape_release(struct device *); 241static void ide_tape_release(struct device *);
242 242
243static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) 243static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];
244
245static struct ide_tape_obj *ide_tape_get(struct gendisk *disk, bool cdev,
246 unsigned int i)
244{ 247{
245 struct ide_tape_obj *tape = NULL; 248 struct ide_tape_obj *tape = NULL;
246 249
247 mutex_lock(&idetape_ref_mutex); 250 mutex_lock(&idetape_ref_mutex);
248 tape = ide_drv_g(disk, ide_tape_obj); 251
252 if (cdev)
253 tape = idetape_devs[i];
254 else
255 tape = ide_drv_g(disk, ide_tape_obj);
256
249 if (tape) { 257 if (tape) {
250 if (ide_device_get(tape->drive)) 258 if (ide_device_get(tape->drive))
251 tape = NULL; 259 tape = NULL;
252 else 260 else
253 get_device(&tape->dev); 261 get_device(&tape->dev);
254 } 262 }
263
255 mutex_unlock(&idetape_ref_mutex); 264 mutex_unlock(&idetape_ref_mutex);
256 return tape; 265 return tape;
257} 266}
@@ -267,24 +276,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
267} 276}
268 277
269/* 278/*
270 * The variables below are used for the character device interface. Additional
271 * state variables are defined in our ide_drive_t structure.
272 */
273static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];
274
275static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
276{
277 struct ide_tape_obj *tape = NULL;
278
279 mutex_lock(&idetape_ref_mutex);
280 tape = idetape_devs[i];
281 if (tape)
282 get_device(&tape->dev);
283 mutex_unlock(&idetape_ref_mutex);
284 return tape;
285}
286
287/*
288 * called on each failed packet command retry to analyze the request sense. We 279 * called on each failed packet command retry to analyze the request sense. We
289 * currently do not utilize this information. 280 * currently do not utilize this information.
290 */ 281 */
@@ -397,7 +388,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
397 if (readpos[0] & 0x4) { 388 if (readpos[0] & 0x4) {
398 printk(KERN_INFO "ide-tape: Block location is unknown" 389 printk(KERN_INFO "ide-tape: Block location is unknown"
399 "to the tape\n"); 390 "to the tape\n");
400 clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); 391 clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID),
392 &drive->atapi_flags);
401 uptodate = 0; 393 uptodate = 0;
402 err = IDE_DRV_ERROR_GENERAL; 394 err = IDE_DRV_ERROR_GENERAL;
403 } else { 395 } else {
@@ -406,7 +398,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
406 398
407 tape->partition = readpos[1]; 399 tape->partition = readpos[1];
408 tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); 400 tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]);
409 set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); 401 set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID),
402 &drive->atapi_flags);
410 } 403 }
411 } 404 }
412 405
@@ -656,15 +649,15 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
656 649
657 if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && 650 if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 &&
658 (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) 651 (rq->cmd[13] & REQ_IDETAPE_PC2) == 0)
659 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 652 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC;
660 653
661 if (drive->dev_flags & IDE_DFLAG_POST_RESET) { 654 if (drive->dev_flags & IDE_DFLAG_POST_RESET) {
662 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 655 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC;
663 drive->dev_flags &= ~IDE_DFLAG_POST_RESET; 656 drive->dev_flags &= ~IDE_DFLAG_POST_RESET;
664 } 657 }
665 658
666 if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && 659 if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) &&
667 (stat & ATA_DSC) == 0) { 660 !(stat & ATA_DSC)) {
668 if (postponed_rq == NULL) { 661 if (postponed_rq == NULL) {
669 tape->dsc_polling_start = jiffies; 662 tape->dsc_polling_start = jiffies;
670 tape->dsc_poll_freq = tape->best_dsc_rw_freq; 663 tape->dsc_poll_freq = tape->best_dsc_rw_freq;
@@ -684,7 +677,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
684 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; 677 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW;
685 idetape_postpone_request(drive); 678 idetape_postpone_request(drive);
686 return ide_stopped; 679 return ide_stopped;
687 } 680 } else
681 drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC;
682
688 if (rq->cmd[13] & REQ_IDETAPE_READ) { 683 if (rq->cmd[13] & REQ_IDETAPE_READ) {
689 pc = &tape->queued_pc; 684 pc = &tape->queued_pc;
690 ide_tape_create_rw_cmd(tape, pc, rq, READ_6); 685 ide_tape_create_rw_cmd(tape, pc, rq, READ_6);
@@ -744,7 +739,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
744 int load_attempted = 0; 739 int load_attempted = 0;
745 740
746 /* Wait for the tape to become ready */ 741 /* Wait for the tape to become ready */
747 set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); 742 set_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), &drive->atapi_flags);
748 timeout += jiffies; 743 timeout += jiffies;
749 while (time_before(jiffies, timeout)) { 744 while (time_before(jiffies, timeout)) {
750 if (ide_do_test_unit_ready(drive, disk) == 0) 745 if (ide_do_test_unit_ready(drive, disk) == 0)
@@ -820,7 +815,7 @@ static void __ide_tape_discard_merge_buffer(ide_drive_t *drive)
820 if (tape->chrdev_dir != IDETAPE_DIR_READ) 815 if (tape->chrdev_dir != IDETAPE_DIR_READ)
821 return; 816 return;
822 817
823 clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags); 818 clear_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags);
824 tape->valid = 0; 819 tape->valid = 0;
825 if (tape->buf != NULL) { 820 if (tape->buf != NULL) {
826 kfree(tape->buf); 821 kfree(tape->buf);
@@ -1113,7 +1108,8 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
1113 1108
1114 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 1109 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
1115 tape->valid = 0; 1110 tape->valid = 0;
1116 if (test_and_clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) 1111 if (test_and_clear_bit(ilog2(IDE_AFLAG_FILEMARK),
1112 &drive->atapi_flags))
1117 ++count; 1113 ++count;
1118 ide_tape_discard_merge_buffer(drive, 0); 1114 ide_tape_discard_merge_buffer(drive, 0);
1119 } 1115 }
@@ -1168,7 +1164,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
1168 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 1164 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
1169 1165
1170 if (tape->chrdev_dir != IDETAPE_DIR_READ) { 1166 if (tape->chrdev_dir != IDETAPE_DIR_READ) {
1171 if (test_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags)) 1167 if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags))
1172 if (count > tape->blk_size && 1168 if (count > tape->blk_size &&
1173 (count % tape->blk_size) == 0) 1169 (count % tape->blk_size) == 0)
1174 tape->user_bs_factor = count / tape->blk_size; 1170 tape->user_bs_factor = count / tape->blk_size;
@@ -1184,7 +1180,8 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
1184 /* refill if staging buffer is empty */ 1180 /* refill if staging buffer is empty */
1185 if (!tape->valid) { 1181 if (!tape->valid) {
1186 /* If we are at a filemark, nothing more to read */ 1182 /* If we are at a filemark, nothing more to read */
1187 if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) 1183 if (test_bit(ilog2(IDE_AFLAG_FILEMARK),
1184 &drive->atapi_flags))
1188 break; 1185 break;
1189 /* read */ 1186 /* read */
1190 if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, 1187 if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ,
@@ -1202,7 +1199,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
1202 done += todo; 1199 done += todo;
1203 } 1200 }
1204 1201
1205 if (!done && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) { 1202 if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) {
1206 debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); 1203 debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name);
1207 1204
1208 idetape_space_over_filemarks(drive, MTFSF, 1); 1205 idetape_space_over_filemarks(drive, MTFSF, 1);
@@ -1336,7 +1333,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1336 ide_tape_discard_merge_buffer(drive, 0); 1333 ide_tape_discard_merge_buffer(drive, 0);
1337 retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); 1334 retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK);
1338 if (!retval) 1335 if (!retval)
1339 clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); 1336 clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT),
1337 &drive->atapi_flags);
1340 return retval; 1338 return retval;
1341 case MTNOP: 1339 case MTNOP:
1342 ide_tape_discard_merge_buffer(drive, 0); 1340 ide_tape_discard_merge_buffer(drive, 0);
@@ -1358,9 +1356,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1358 mt_count % tape->blk_size) 1356 mt_count % tape->blk_size)
1359 return -EIO; 1357 return -EIO;
1360 tape->user_bs_factor = mt_count / tape->blk_size; 1358 tape->user_bs_factor = mt_count / tape->blk_size;
1361 clear_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); 1359 clear_bit(ilog2(IDE_AFLAG_DETECT_BS),
1360 &drive->atapi_flags);
1362 } else 1361 } else
1363 set_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); 1362 set_bit(ilog2(IDE_AFLAG_DETECT_BS),
1363 &drive->atapi_flags);
1364 return 0; 1364 return 0;
1365 case MTSEEK: 1365 case MTSEEK:
1366 ide_tape_discard_merge_buffer(drive, 0); 1366 ide_tape_discard_merge_buffer(drive, 0);
@@ -1486,7 +1486,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
1486 return -ENXIO; 1486 return -ENXIO;
1487 1487
1488 lock_kernel(); 1488 lock_kernel();
1489 tape = ide_tape_chrdev_get(i); 1489 tape = ide_tape_get(NULL, true, i);
1490 if (!tape) { 1490 if (!tape) {
1491 unlock_kernel(); 1491 unlock_kernel();
1492 return -ENXIO; 1492 return -ENXIO;
@@ -1505,20 +1505,20 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
1505 1505
1506 filp->private_data = tape; 1506 filp->private_data = tape;
1507 1507
1508 if (test_and_set_bit(IDE_AFLAG_BUSY, &drive->atapi_flags)) { 1508 if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) {
1509 retval = -EBUSY; 1509 retval = -EBUSY;
1510 goto out_put_tape; 1510 goto out_put_tape;
1511 } 1511 }
1512 1512
1513 retval = idetape_wait_ready(drive, 60 * HZ); 1513 retval = idetape_wait_ready(drive, 60 * HZ);
1514 if (retval) { 1514 if (retval) {
1515 clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); 1515 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags);
1516 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); 1516 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name);
1517 goto out_put_tape; 1517 goto out_put_tape;
1518 } 1518 }
1519 1519
1520 idetape_read_position(drive); 1520 idetape_read_position(drive);
1521 if (!test_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags)) 1521 if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags))
1522 (void)idetape_rewind_tape(drive); 1522 (void)idetape_rewind_tape(drive);
1523 1523
1524 /* Read block size and write protect status from drive. */ 1524 /* Read block size and write protect status from drive. */
@@ -1534,7 +1534,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
1534 if (tape->write_prot) { 1534 if (tape->write_prot) {
1535 if ((filp->f_flags & O_ACCMODE) == O_WRONLY || 1535 if ((filp->f_flags & O_ACCMODE) == O_WRONLY ||
1536 (filp->f_flags & O_ACCMODE) == O_RDWR) { 1536 (filp->f_flags & O_ACCMODE) == O_RDWR) {
1537 clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); 1537 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags);
1538 retval = -EROFS; 1538 retval = -EROFS;
1539 goto out_put_tape; 1539 goto out_put_tape;
1540 } 1540 }
@@ -1591,15 +1591,17 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp)
1591 ide_tape_discard_merge_buffer(drive, 1); 1591 ide_tape_discard_merge_buffer(drive, 1);
1592 } 1592 }
1593 1593
1594 if (minor < 128 && test_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags)) 1594 if (minor < 128 && test_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT),
1595 &drive->atapi_flags))
1595 (void) idetape_rewind_tape(drive); 1596 (void) idetape_rewind_tape(drive);
1597
1596 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 1598 if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
1597 if (tape->door_locked == DOOR_LOCKED) { 1599 if (tape->door_locked == DOOR_LOCKED) {
1598 if (!ide_set_media_lock(drive, tape->disk, 0)) 1600 if (!ide_set_media_lock(drive, tape->disk, 0))
1599 tape->door_locked = DOOR_UNLOCKED; 1601 tape->door_locked = DOOR_UNLOCKED;
1600 } 1602 }
1601 } 1603 }
1602 clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); 1604 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags);
1603 ide_tape_put(tape); 1605 ide_tape_put(tape);
1604 unlock_kernel(); 1606 unlock_kernel();
1605 return 0; 1607 return 0;
@@ -1905,7 +1907,7 @@ static const struct file_operations idetape_fops = {
1905 1907
1906static int idetape_open(struct block_device *bdev, fmode_t mode) 1908static int idetape_open(struct block_device *bdev, fmode_t mode)
1907{ 1909{
1908 struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk); 1910 struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk, false, 0);
1909 1911
1910 if (!tape) 1912 if (!tape)
1911 return -ENXIO; 1913 return -ENXIO;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index a0c3e1b2f73c..75b85a8cd2d4 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -98,7 +98,6 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
98 if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { 98 if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) {
99 ide_tf_dump(drive->name, cmd); 99 ide_tf_dump(drive->name, cmd);
100 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); 100 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);
101 SELECT_MASK(drive, 0);
102 101
103 if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) { 102 if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) {
104 u8 data[2] = { cmd->tf.data, cmd->hob.data }; 103 u8 data[2] = { cmd->tf.data, cmd->hob.data };
@@ -166,7 +165,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
166 if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { 165 if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) {
167 if (custom && tf->command == ATA_CMD_SET_MULTI) { 166 if (custom && tf->command == ATA_CMD_SET_MULTI) {
168 drive->mult_req = drive->mult_count = 0; 167 drive->mult_req = drive->mult_count = 0;
169 drive->special.b.recalibrate = 1; 168 drive->special_flags |= IDE_SFLAG_RECALIBRATE;
170 (void)ide_dump_status(drive, __func__, stat); 169 (void)ide_dump_status(drive, __func__, stat);
171 return ide_stopped; 170 return ide_stopped;
172 } else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) { 171 } else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) {
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 92c9b90931e7..16d056939f9f 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -211,6 +211,11 @@ static unsigned int ide_noflush;
211module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); 211module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0);
212MODULE_PARM_DESC(noflush, "disable flush requests for a device"); 212MODULE_PARM_DESC(noflush, "disable flush requests for a device");
213 213
214static unsigned int ide_nohpa;
215
216module_param_call(nohpa, ide_set_dev_param_mask, NULL, &ide_nohpa, 0);
217MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device");
218
214static unsigned int ide_noprobe; 219static unsigned int ide_noprobe;
215 220
216module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); 221module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0);
@@ -281,6 +286,11 @@ static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
281 drive->name); 286 drive->name);
282 drive->dev_flags |= IDE_DFLAG_NOFLUSH; 287 drive->dev_flags |= IDE_DFLAG_NOFLUSH;
283 } 288 }
289 if (ide_nohpa & (1 << i)) {
290 printk(KERN_INFO "ide: disabling Host Protected Area for %s\n",
291 drive->name);
292 drive->dev_flags |= IDE_DFLAG_NOHPA;
293 }
284 if (ide_noprobe & (1 << i)) { 294 if (ide_noprobe & (1 << i)) {
285 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); 295 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name);
286 drive->dev_flags |= IDE_DFLAG_NOPROBE; 296 drive->dev_flags |= IDE_DFLAG_NOPROBE;
diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c
index 051b4ab0f359..ee9b55ecc62b 100644
--- a/drivers/ide/ide_platform.c
+++ b/drivers/ide/ide_platform.c
@@ -21,7 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/io.h> 22#include <linux/io.h>
23 23
24static void __devinit plat_ide_setup_ports(hw_regs_t *hw, 24static void __devinit plat_ide_setup_ports(struct ide_hw *hw,
25 void __iomem *base, 25 void __iomem *base,
26 void __iomem *ctrl, 26 void __iomem *ctrl,
27 struct pata_platform_info *pdata, 27 struct pata_platform_info *pdata,
@@ -40,12 +40,11 @@ static void __devinit plat_ide_setup_ports(hw_regs_t *hw,
40 hw->io_ports.ctl_addr = (unsigned long)ctrl; 40 hw->io_ports.ctl_addr = (unsigned long)ctrl;
41 41
42 hw->irq = irq; 42 hw->irq = irq;
43
44 hw->chipset = ide_generic;
45} 43}
46 44
47static const struct ide_port_info platform_ide_port_info = { 45static const struct ide_port_info platform_ide_port_info = {
48 .host_flags = IDE_HFLAG_NO_DMA, 46 .host_flags = IDE_HFLAG_NO_DMA,
47 .chipset = ide_generic,
49}; 48};
50 49
51static int __devinit plat_ide_probe(struct platform_device *pdev) 50static int __devinit plat_ide_probe(struct platform_device *pdev)
@@ -55,7 +54,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
55 struct pata_platform_info *pdata; 54 struct pata_platform_info *pdata;
56 struct ide_host *host; 55 struct ide_host *host;
57 int ret = 0, mmio = 0; 56 int ret = 0, mmio = 0;
58 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 57 struct ide_hw hw, *hws[] = { &hw };
59 struct ide_port_info d = platform_ide_port_info; 58 struct ide_port_info d = platform_ide_port_info;
60 59
61 pdata = pdev->dev.platform_data; 60 pdata = pdev->dev.platform_data;
@@ -99,7 +98,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
99 if (mmio) 98 if (mmio)
100 d.host_flags |= IDE_HFLAG_MMIO; 99 d.host_flags |= IDE_HFLAG_MMIO;
101 100
102 ret = ide_host_add(&d, hws, &host); 101 ret = ide_host_add(&d, hws, 1, &host);
103 if (ret) 102 if (ret)
104 goto out; 103 goto out;
105 104
diff --git a/drivers/ide/macide.c b/drivers/ide/macide.c
index 4b1718e83283..1447c8c90565 100644
--- a/drivers/ide/macide.c
+++ b/drivers/ide/macide.c
@@ -62,7 +62,7 @@ int macide_ack_intr(ide_hwif_t* hwif)
62 return 0; 62 return 0;
63} 63}
64 64
65static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base, 65static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
66 int irq, ide_ack_intr_t *ack_intr) 66 int irq, ide_ack_intr_t *ack_intr)
67{ 67{
68 int i; 68 int i;
@@ -76,13 +76,12 @@ static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base,
76 76
77 hw->irq = irq; 77 hw->irq = irq;
78 hw->ack_intr = ack_intr; 78 hw->ack_intr = ack_intr;
79
80 hw->chipset = ide_generic;
81} 79}
82 80
83static const struct ide_port_info macide_port_info = { 81static const struct ide_port_info macide_port_info = {
84 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 82 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
85 .irq_flags = IRQF_SHARED, 83 .irq_flags = IRQF_SHARED,
84 .chipset = ide_generic,
86}; 85};
87 86
88static const char *mac_ide_name[] = 87static const char *mac_ide_name[] =
@@ -97,7 +96,7 @@ static int __init macide_init(void)
97 ide_ack_intr_t *ack_intr; 96 ide_ack_intr_t *ack_intr;
98 unsigned long base; 97 unsigned long base;
99 int irq; 98 int irq;
100 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 99 struct ide_hw hw, *hws[] = { &hw };
101 100
102 if (!MACH_IS_MAC) 101 if (!MACH_IS_MAC)
103 return -ENODEV; 102 return -ENODEV;
@@ -127,7 +126,7 @@ static int __init macide_init(void)
127 126
128 macide_setup_ports(&hw, base, irq, ack_intr); 127 macide_setup_ports(&hw, base, irq, ack_intr);
129 128
130 return ide_host_add(&macide_port_info, hws, NULL); 129 return ide_host_add(&macide_port_info, hws, 1, NULL);
131} 130}
132 131
133module_init(macide_init); 132module_init(macide_init);
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
index 09d813d313f4..3c1dc0152153 100644
--- a/drivers/ide/palm_bk3710.c
+++ b/drivers/ide/palm_bk3710.c
@@ -306,6 +306,7 @@ static struct ide_port_info __devinitdata palm_bk3710_port_info = {
306 .host_flags = IDE_HFLAG_MMIO, 306 .host_flags = IDE_HFLAG_MMIO,
307 .pio_mask = ATA_PIO4, 307 .pio_mask = ATA_PIO4,
308 .mwdma_mask = ATA_MWDMA2, 308 .mwdma_mask = ATA_MWDMA2,
309 .chipset = ide_palm3710,
309}; 310};
310 311
311static int __init palm_bk3710_probe(struct platform_device *pdev) 312static int __init palm_bk3710_probe(struct platform_device *pdev)
@@ -315,7 +316,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
315 void __iomem *base; 316 void __iomem *base;
316 unsigned long rate, mem_size; 317 unsigned long rate, mem_size;
317 int i, rc; 318 int i, rc;
318 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 319 struct ide_hw hw, *hws[] = { &hw };
319 320
320 clk = clk_get(&pdev->dev, "IDECLK"); 321 clk = clk_get(&pdev->dev, "IDECLK");
321 if (IS_ERR(clk)) 322 if (IS_ERR(clk))
@@ -363,13 +364,12 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
363 (base + IDE_PALM_ATA_PRI_CTL_OFFSET); 364 (base + IDE_PALM_ATA_PRI_CTL_OFFSET);
364 hw.irq = irq->start; 365 hw.irq = irq->start;
365 hw.dev = &pdev->dev; 366 hw.dev = &pdev->dev;
366 hw.chipset = ide_palm3710;
367 367
368 palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : 368 palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 :
369 ATA_UDMA5; 369 ATA_UDMA5;
370 370
371 /* Register the IDE interface with Linux */ 371 /* Register the IDE interface with Linux */
372 rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); 372 rc = ide_host_add(&palm_bk3710_port_info, hws, 1, NULL);
373 if (rc) 373 if (rc)
374 goto out; 374 goto out;
375 375
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
index b68906c3c17e..65ba8239e7b5 100644
--- a/drivers/ide/pdc202xx_new.c
+++ b/drivers/ide/pdc202xx_new.c
@@ -40,18 +40,6 @@
40#define DBG(fmt, args...) 40#define DBG(fmt, args...)
41#endif 41#endif
42 42
43static const char *pdc_quirk_drives[] = {
44 "QUANTUM FIREBALLlct08 08",
45 "QUANTUM FIREBALLP KA6.4",
46 "QUANTUM FIREBALLP KA9.1",
47 "QUANTUM FIREBALLP LM20.4",
48 "QUANTUM FIREBALLP KX13.6",
49 "QUANTUM FIREBALLP KX20.5",
50 "QUANTUM FIREBALLP KX27.3",
51 "QUANTUM FIREBALLP LM20.5",
52 NULL
53};
54
55static u8 max_dma_rate(struct pci_dev *pdev) 43static u8 max_dma_rate(struct pci_dev *pdev)
56{ 44{
57 u8 mode; 45 u8 mode;
@@ -200,19 +188,6 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
200 return ATA_CBL_PATA80; 188 return ATA_CBL_PATA80;
201} 189}
202 190
203static void pdcnew_quirkproc(ide_drive_t *drive)
204{
205 const char **list, *m = (char *)&drive->id[ATA_ID_PROD];
206
207 for (list = pdc_quirk_drives; *list != NULL; list++)
208 if (strstr(m, *list) != NULL) {
209 drive->quirk_list = 2;
210 return;
211 }
212
213 drive->quirk_list = 0;
214}
215
216static void pdcnew_reset(ide_drive_t *drive) 191static void pdcnew_reset(ide_drive_t *drive)
217{ 192{
218 /* 193 /*
@@ -473,7 +448,6 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
473static const struct ide_port_ops pdcnew_port_ops = { 448static const struct ide_port_ops pdcnew_port_ops = {
474 .set_pio_mode = pdcnew_set_pio_mode, 449 .set_pio_mode = pdcnew_set_pio_mode,
475 .set_dma_mode = pdcnew_set_dma_mode, 450 .set_dma_mode = pdcnew_set_dma_mode,
476 .quirkproc = pdcnew_quirkproc,
477 .resetproc = pdcnew_reset, 451 .resetproc = pdcnew_reset,
478 .cable_detect = pdcnew_cable_detect, 452 .cable_detect = pdcnew_cable_detect,
479}; 453};
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index e24ecc87a9b1..b6abf7e52cac 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -23,18 +23,6 @@
23 23
24#define PDC202XX_DEBUG_DRIVE_INFO 0 24#define PDC202XX_DEBUG_DRIVE_INFO 0
25 25
26static const char *pdc_quirk_drives[] = {
27 "QUANTUM FIREBALLlct08 08",
28 "QUANTUM FIREBALLP KA6.4",
29 "QUANTUM FIREBALLP KA9.1",
30 "QUANTUM FIREBALLP LM20.4",
31 "QUANTUM FIREBALLP KX13.6",
32 "QUANTUM FIREBALLP KX20.5",
33 "QUANTUM FIREBALLP KX27.3",
34 "QUANTUM FIREBALLP LM20.5",
35 NULL
36};
37
38static void pdc_old_disable_66MHz_clock(ide_hwif_t *); 26static void pdc_old_disable_66MHz_clock(ide_hwif_t *);
39 27
40static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) 28static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed)
@@ -151,19 +139,6 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
151 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); 139 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
152} 140}
153 141
154static void pdc202xx_quirkproc(ide_drive_t *drive)
155{
156 const char **list, *m = (char *)&drive->id[ATA_ID_PROD];
157
158 for (list = pdc_quirk_drives; *list != NULL; list++)
159 if (strstr(m, *list) != NULL) {
160 drive->quirk_list = 2;
161 return;
162 }
163
164 drive->quirk_list = 0;
165}
166
167static void pdc202xx_dma_start(ide_drive_t *drive) 142static void pdc202xx_dma_start(ide_drive_t *drive)
168{ 143{
169 if (drive->current_speed > XFER_UDMA_2) 144 if (drive->current_speed > XFER_UDMA_2)
@@ -203,52 +178,6 @@ static int pdc202xx_dma_end(ide_drive_t *drive)
203 return ide_dma_end(drive); 178 return ide_dma_end(drive);
204} 179}
205 180
206static int pdc202xx_dma_test_irq(ide_drive_t *drive)
207{
208 ide_hwif_t *hwif = drive->hwif;
209 unsigned long high_16 = hwif->extra_base - 16;
210 u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
211 u8 sc1d = inb(high_16 + 0x001d);
212
213 if (hwif->channel) {
214 /* bit7: Error, bit6: Interrupting, bit5: FIFO Full, bit4: FIFO Empty */
215 if ((sc1d & 0x50) == 0x50)
216 goto somebody_else;
217 else if ((sc1d & 0x40) == 0x40)
218 return (dma_stat & 4) == 4;
219 } else {
220 /* bit3: Error, bit2: Interrupting, bit1: FIFO Full, bit0: FIFO Empty */
221 if ((sc1d & 0x05) == 0x05)
222 goto somebody_else;
223 else if ((sc1d & 0x04) == 0x04)
224 return (dma_stat & 4) == 4;
225 }
226somebody_else:
227 return (dma_stat & 4) == 4; /* return 1 if INTR asserted */
228}
229
230static void pdc202xx_reset(ide_drive_t *drive)
231{
232 ide_hwif_t *hwif = drive->hwif;
233 unsigned long high_16 = hwif->extra_base - 16;
234 u8 udma_speed_flag = inb(high_16 | 0x001f);
235
236 printk(KERN_WARNING "PDC202xx: software reset...\n");
237
238 outb(udma_speed_flag | 0x10, high_16 | 0x001f);
239 mdelay(100);
240 outb(udma_speed_flag & ~0x10, high_16 | 0x001f);
241 mdelay(2000); /* 2 seconds ?! */
242
243 ide_set_max_pio(drive);
244}
245
246static void pdc202xx_dma_lost_irq(ide_drive_t *drive)
247{
248 pdc202xx_reset(drive);
249 ide_dma_lost_irq(drive);
250}
251
252static int init_chipset_pdc202xx(struct pci_dev *dev) 181static int init_chipset_pdc202xx(struct pci_dev *dev)
253{ 182{
254 unsigned long dmabase = pci_resource_start(dev, 4); 183 unsigned long dmabase = pci_resource_start(dev, 4);
@@ -302,37 +231,22 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
302static const struct ide_port_ops pdc20246_port_ops = { 231static const struct ide_port_ops pdc20246_port_ops = {
303 .set_pio_mode = pdc202xx_set_pio_mode, 232 .set_pio_mode = pdc202xx_set_pio_mode,
304 .set_dma_mode = pdc202xx_set_mode, 233 .set_dma_mode = pdc202xx_set_mode,
305 .quirkproc = pdc202xx_quirkproc,
306}; 234};
307 235
308static const struct ide_port_ops pdc2026x_port_ops = { 236static const struct ide_port_ops pdc2026x_port_ops = {
309 .set_pio_mode = pdc202xx_set_pio_mode, 237 .set_pio_mode = pdc202xx_set_pio_mode,
310 .set_dma_mode = pdc202xx_set_mode, 238 .set_dma_mode = pdc202xx_set_mode,
311 .quirkproc = pdc202xx_quirkproc,
312 .resetproc = pdc202xx_reset,
313 .cable_detect = pdc2026x_cable_detect, 239 .cable_detect = pdc2026x_cable_detect,
314}; 240};
315 241
316static const struct ide_dma_ops pdc20246_dma_ops = {
317 .dma_host_set = ide_dma_host_set,
318 .dma_setup = ide_dma_setup,
319 .dma_start = ide_dma_start,
320 .dma_end = ide_dma_end,
321 .dma_test_irq = pdc202xx_dma_test_irq,
322 .dma_lost_irq = ide_dma_lost_irq,
323 .dma_timer_expiry = ide_dma_sff_timer_expiry,
324 .dma_sff_read_status = ide_dma_sff_read_status,
325};
326
327static const struct ide_dma_ops pdc2026x_dma_ops = { 242static const struct ide_dma_ops pdc2026x_dma_ops = {
328 .dma_host_set = ide_dma_host_set, 243 .dma_host_set = ide_dma_host_set,
329 .dma_setup = ide_dma_setup, 244 .dma_setup = ide_dma_setup,
330 .dma_start = pdc202xx_dma_start, 245 .dma_start = pdc202xx_dma_start,
331 .dma_end = pdc202xx_dma_end, 246 .dma_end = pdc202xx_dma_end,
332 .dma_test_irq = pdc202xx_dma_test_irq, 247 .dma_test_irq = ide_dma_test_irq,
333 .dma_lost_irq = pdc202xx_dma_lost_irq, 248 .dma_lost_irq = ide_dma_lost_irq,
334 .dma_timer_expiry = ide_dma_sff_timer_expiry, 249 .dma_timer_expiry = ide_dma_sff_timer_expiry,
335 .dma_clear = pdc202xx_reset,
336 .dma_sff_read_status = ide_dma_sff_read_status, 250 .dma_sff_read_status = ide_dma_sff_read_status,
337}; 251};
338 252
@@ -354,7 +268,7 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = {
354 .name = DRV_NAME, 268 .name = DRV_NAME,
355 .init_chipset = init_chipset_pdc202xx, 269 .init_chipset = init_chipset_pdc202xx,
356 .port_ops = &pdc20246_port_ops, 270 .port_ops = &pdc20246_port_ops,
357 .dma_ops = &pdc20246_dma_ops, 271 .dma_ops = &sff_dma_ops,
358 .host_flags = IDE_HFLAGS_PDC202XX, 272 .host_flags = IDE_HFLAGS_PDC202XX,
359 .pio_mask = ATA_PIO4, 273 .pio_mask = ATA_PIO4,
360 .mwdma_mask = ATA_MWDMA2, 274 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index f76e4e6b408f..97642a7a79c4 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1023,13 +1023,14 @@ static const struct ide_port_info pmac_port_info = {
1023 * Setup, register & probe an IDE channel driven by this driver, this is 1023 * Setup, register & probe an IDE channel driven by this driver, this is
1024 * called by one of the 2 probe functions (macio or PCI). 1024 * called by one of the 2 probe functions (macio or PCI).
1025 */ 1025 */
1026static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) 1026static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif,
1027 struct ide_hw *hw)
1027{ 1028{
1028 struct device_node *np = pmif->node; 1029 struct device_node *np = pmif->node;
1029 const int *bidp; 1030 const int *bidp;
1030 struct ide_host *host; 1031 struct ide_host *host;
1031 ide_hwif_t *hwif; 1032 ide_hwif_t *hwif;
1032 hw_regs_t *hws[] = { hw, NULL, NULL, NULL }; 1033 struct ide_hw *hws[] = { hw };
1033 struct ide_port_info d = pmac_port_info; 1034 struct ide_port_info d = pmac_port_info;
1034 int rc; 1035 int rc;
1035 1036
@@ -1077,7 +1078,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
1077 /* Make sure we have sane timings */ 1078 /* Make sure we have sane timings */
1078 sanitize_timings(pmif); 1079 sanitize_timings(pmif);
1079 1080
1080 host = ide_host_alloc(&d, hws); 1081 host = ide_host_alloc(&d, hws, 1);
1081 if (host == NULL) 1082 if (host == NULL)
1082 return -ENOMEM; 1083 return -ENOMEM;
1083 hwif = host->ports[0]; 1084 hwif = host->ports[0];
@@ -1124,7 +1125,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
1124 return 0; 1125 return 0;
1125} 1126}
1126 1127
1127static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base) 1128static void __devinit pmac_ide_init_ports(struct ide_hw *hw, unsigned long base)
1128{ 1129{
1129 int i; 1130 int i;
1130 1131
@@ -1144,7 +1145,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1144 unsigned long regbase; 1145 unsigned long regbase;
1145 pmac_ide_hwif_t *pmif; 1146 pmac_ide_hwif_t *pmif;
1146 int irq, rc; 1147 int irq, rc;
1147 hw_regs_t hw; 1148 struct ide_hw hw;
1148 1149
1149 pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); 1150 pmif = kzalloc(sizeof(*pmif), GFP_KERNEL);
1150 if (pmif == NULL) 1151 if (pmif == NULL)
@@ -1268,7 +1269,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1268 void __iomem *base; 1269 void __iomem *base;
1269 unsigned long rbase, rlen; 1270 unsigned long rbase, rlen;
1270 int rc; 1271 int rc;
1271 hw_regs_t hw; 1272 struct ide_hw hw;
1272 1273
1273 np = pci_device_to_OF_node(pdev); 1274 np = pci_device_to_OF_node(pdev);
1274 if (np == NULL) { 1275 if (np == NULL) {
diff --git a/drivers/ide/q40ide.c b/drivers/ide/q40ide.c
index c79346679244..ab49a97023d9 100644
--- a/drivers/ide/q40ide.c
+++ b/drivers/ide/q40ide.c
@@ -51,11 +51,11 @@ static int q40ide_default_irq(unsigned long base)
51/* 51/*
52 * Addresses are pretranslated for Q40 ISA access. 52 * Addresses are pretranslated for Q40 ISA access.
53 */ 53 */
54static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base, 54static void q40_ide_setup_ports(struct ide_hw *hw, unsigned long base,
55 ide_ack_intr_t *ack_intr, 55 ide_ack_intr_t *ack_intr,
56 int irq) 56 int irq)
57{ 57{
58 memset(hw, 0, sizeof(hw_regs_t)); 58 memset(hw, 0, sizeof(*hw));
59 /* BIG FAT WARNING: 59 /* BIG FAT WARNING:
60 assumption: only DATA port is ever used in 16 bit mode */ 60 assumption: only DATA port is ever used in 16 bit mode */
61 hw->io_ports.data_addr = Q40_ISA_IO_W(base); 61 hw->io_ports.data_addr = Q40_ISA_IO_W(base);
@@ -70,8 +70,6 @@ static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base,
70 70
71 hw->irq = irq; 71 hw->irq = irq;
72 hw->ack_intr = ack_intr; 72 hw->ack_intr = ack_intr;
73
74 hw->chipset = ide_generic;
75} 73}
76 74
77static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, 75static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
@@ -119,6 +117,7 @@ static const struct ide_port_info q40ide_port_info = {
119 .tp_ops = &q40ide_tp_ops, 117 .tp_ops = &q40ide_tp_ops,
120 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 118 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
121 .irq_flags = IRQF_SHARED, 119 .irq_flags = IRQF_SHARED,
120 .chipset = ide_generic,
122}; 121};
123 122
124/* 123/*
@@ -136,7 +135,7 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={
136static int __init q40ide_init(void) 135static int __init q40ide_init(void)
137{ 136{
138 int i; 137 int i;
139 hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; 138 struct ide_hw hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL };
140 139
141 if (!MACH_IS_Q40) 140 if (!MACH_IS_Q40)
142 return -ENODEV; 141 return -ENODEV;
@@ -163,7 +162,7 @@ static int __init q40ide_init(void)
163 hws[i] = &hw[i]; 162 hws[i] = &hw[i];
164 } 163 }
165 164
166 return ide_host_add(&q40ide_port_info, hws, NULL); 165 return ide_host_add(&q40ide_port_info, hws, Q40IDE_NUM_HWIFS, NULL);
167} 166}
168 167
169module_init(q40ide_init); 168module_init(q40ide_init);
diff --git a/drivers/ide/rapide.c b/drivers/ide/rapide.c
index d5003ca69801..00f54248f41f 100644
--- a/drivers/ide/rapide.c
+++ b/drivers/ide/rapide.c
@@ -13,9 +13,10 @@
13 13
14static const struct ide_port_info rapide_port_info = { 14static const struct ide_port_info rapide_port_info = {
15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
16 .chipset = ide_generic,
16}; 17};
17 18
18static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, 19static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base,
19 void __iomem *ctrl, unsigned int sz, int irq) 20 void __iomem *ctrl, unsigned int sz, int irq)
20{ 21{
21 unsigned long port = (unsigned long)base; 22 unsigned long port = (unsigned long)base;
@@ -35,7 +36,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
35 void __iomem *base; 36 void __iomem *base;
36 struct ide_host *host; 37 struct ide_host *host;
37 int ret; 38 int ret;
38 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 39 struct ide_hw hw, *hws[] = { &hw };
39 40
40 ret = ecard_request_resources(ec); 41 ret = ecard_request_resources(ec);
41 if (ret) 42 if (ret)
@@ -49,10 +50,9 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
49 50
50 memset(&hw, 0, sizeof(hw)); 51 memset(&hw, 0, sizeof(hw));
51 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); 52 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
52 hw.chipset = ide_generic;
53 hw.dev = &ec->dev; 53 hw.dev = &ec->dev;
54 54
55 ret = ide_host_add(&rapide_port_info, hws, &host); 55 ret = ide_host_add(&rapide_port_info, hws, 1, &host);
56 if (ret) 56 if (ret)
57 goto release; 57 goto release;
58 58
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 5be41f25204f..1104bb301eb9 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -559,7 +559,7 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
559{ 559{
560 struct scc_ports *ports = pci_get_drvdata(dev); 560 struct scc_ports *ports = pci_get_drvdata(dev);
561 struct ide_host *host; 561 struct ide_host *host;
562 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 562 struct ide_hw hw, *hws[] = { &hw };
563 int i, rc; 563 int i, rc;
564 564
565 memset(&hw, 0, sizeof(hw)); 565 memset(&hw, 0, sizeof(hw));
@@ -567,9 +567,8 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
567 hw.io_ports_array[i] = ports->dma + 0x20 + i * 4; 567 hw.io_ports_array[i] = ports->dma + 0x20 + i * 4;
568 hw.irq = dev->irq; 568 hw.irq = dev->irq;
569 hw.dev = &dev->dev; 569 hw.dev = &dev->dev;
570 hw.chipset = ide_pci;
571 570
572 rc = ide_host_add(d, hws, &host); 571 rc = ide_host_add(d, hws, 1, &host);
573 if (rc) 572 if (rc)
574 return rc; 573 return rc;
575 574
@@ -823,6 +822,7 @@ static const struct ide_port_info scc_chipset __devinitdata = {
823 .host_flags = IDE_HFLAG_SINGLE, 822 .host_flags = IDE_HFLAG_SINGLE,
824 .irq_flags = IRQF_SHARED, 823 .irq_flags = IRQF_SHARED,
825 .pio_mask = ATA_PIO4, 824 .pio_mask = ATA_PIO4,
825 .chipset = ide_pci,
826}; 826};
827 827
828/** 828/**
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 7a3a12d6e638..ab3db61d2ba0 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 2 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
3 * Copyright (C) 1995-1998 Mark Lord 3 * Copyright (C) 1995-1998 Mark Lord
4 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 4 * Copyright (C) 2007-2009 Bartlomiej Zolnierkiewicz
5 * 5 *
6 * May be copied or modified under the terms of the GNU General Public License 6 * May be copied or modified under the terms of the GNU General Public License
7 */ 7 */
@@ -301,11 +301,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
301} 301}
302 302
303/** 303/**
304 * ide_hw_configure - configure a hw_regs_t instance 304 * ide_hw_configure - configure a struct ide_hw instance
305 * @dev: PCI device holding interface 305 * @dev: PCI device holding interface
306 * @d: IDE port info 306 * @d: IDE port info
307 * @port: port number 307 * @port: port number
308 * @hw: hw_regs_t instance corresponding to this port 308 * @hw: struct ide_hw instance corresponding to this port
309 * 309 *
310 * Perform the initial set up for the hardware interface structure. This 310 * Perform the initial set up for the hardware interface structure. This
311 * is done per interface port rather than per PCI device. There may be 311 * is done per interface port rather than per PCI device. There may be
@@ -315,7 +315,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
315 */ 315 */
316 316
317static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, 317static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
318 unsigned int port, hw_regs_t *hw) 318 unsigned int port, struct ide_hw *hw)
319{ 319{
320 unsigned long ctl = 0, base = 0; 320 unsigned long ctl = 0, base = 0;
321 321
@@ -344,7 +344,6 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
344 344
345 memset(hw, 0, sizeof(*hw)); 345 memset(hw, 0, sizeof(*hw));
346 hw->dev = &dev->dev; 346 hw->dev = &dev->dev;
347 hw->chipset = d->chipset ? d->chipset : ide_pci;
348 ide_std_init_ports(hw, base, ctl | 2); 347 ide_std_init_ports(hw, base, ctl | 2);
349 348
350 return 0; 349 return 0;
@@ -446,8 +445,8 @@ out:
446 * ide_pci_setup_ports - configure ports/devices on PCI IDE 445 * ide_pci_setup_ports - configure ports/devices on PCI IDE
447 * @dev: PCI device 446 * @dev: PCI device
448 * @d: IDE port info 447 * @d: IDE port info
449 * @hw: hw_regs_t instances corresponding to this PCI IDE device 448 * @hw: struct ide_hw instances corresponding to this PCI IDE device
450 * @hws: hw_regs_t pointers table to update 449 * @hws: struct ide_hw pointers table to update
451 * 450 *
452 * Scan the interfaces attached to this device and do any 451 * Scan the interfaces attached to this device and do any
453 * necessary per port setup. Attach the devices and ask the 452 * necessary per port setup. Attach the devices and ask the
@@ -459,7 +458,7 @@ out:
459 */ 458 */
460 459
461void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, 460void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
462 hw_regs_t *hw, hw_regs_t **hws) 461 struct ide_hw *hw, struct ide_hw **hws)
463{ 462{
464 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; 463 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
465 u8 tmp; 464 u8 tmp;
@@ -535,61 +534,15 @@ out:
535 return ret; 534 return ret;
536} 535}
537 536
538int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
539 void *priv)
540{
541 struct ide_host *host;
542 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
543 int ret;
544
545 ret = ide_setup_pci_controller(dev, d, 1);
546 if (ret < 0)
547 goto out;
548
549 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
550
551 host = ide_host_alloc(d, hws);
552 if (host == NULL) {
553 ret = -ENOMEM;
554 goto out;
555 }
556
557 host->dev[0] = &dev->dev;
558
559 host->host_priv = priv;
560
561 host->irq_flags = IRQF_SHARED;
562
563 pci_set_drvdata(dev, host);
564
565 ret = do_ide_setup_pci_device(dev, d, 1);
566 if (ret < 0)
567 goto out;
568
569 /* fixup IRQ */
570 if (ide_pci_is_in_compatibility_mode(dev)) {
571 hw[0].irq = pci_get_legacy_ide_irq(dev, 0);
572 hw[1].irq = pci_get_legacy_ide_irq(dev, 1);
573 } else
574 hw[1].irq = hw[0].irq = ret;
575
576 ret = ide_host_register(host, d, hws);
577 if (ret)
578 ide_host_free(host);
579out:
580 return ret;
581}
582EXPORT_SYMBOL_GPL(ide_pci_init_one);
583
584int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, 537int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
585 const struct ide_port_info *d, void *priv) 538 const struct ide_port_info *d, void *priv)
586{ 539{
587 struct pci_dev *pdev[] = { dev1, dev2 }; 540 struct pci_dev *pdev[] = { dev1, dev2 };
588 struct ide_host *host; 541 struct ide_host *host;
589 int ret, i; 542 int ret, i, n_ports = dev2 ? 4 : 2;
590 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 543 struct ide_hw hw[4], *hws[] = { NULL, NULL, NULL, NULL };
591 544
592 for (i = 0; i < 2; i++) { 545 for (i = 0; i < n_ports / 2; i++) {
593 ret = ide_setup_pci_controller(pdev[i], d, !i); 546 ret = ide_setup_pci_controller(pdev[i], d, !i);
594 if (ret < 0) 547 if (ret < 0)
595 goto out; 548 goto out;
@@ -597,23 +550,24 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
597 ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]); 550 ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]);
598 } 551 }
599 552
600 host = ide_host_alloc(d, hws); 553 host = ide_host_alloc(d, hws, n_ports);
601 if (host == NULL) { 554 if (host == NULL) {
602 ret = -ENOMEM; 555 ret = -ENOMEM;
603 goto out; 556 goto out;
604 } 557 }
605 558
606 host->dev[0] = &dev1->dev; 559 host->dev[0] = &dev1->dev;
607 host->dev[1] = &dev2->dev; 560 if (dev2)
561 host->dev[1] = &dev2->dev;
608 562
609 host->host_priv = priv; 563 host->host_priv = priv;
610
611 host->irq_flags = IRQF_SHARED; 564 host->irq_flags = IRQF_SHARED;
612 565
613 pci_set_drvdata(pdev[0], host); 566 pci_set_drvdata(pdev[0], host);
614 pci_set_drvdata(pdev[1], host); 567 if (dev2)
568 pci_set_drvdata(pdev[1], host);
615 569
616 for (i = 0; i < 2; i++) { 570 for (i = 0; i < n_ports / 2; i++) {
617 ret = do_ide_setup_pci_device(pdev[i], d, !i); 571 ret = do_ide_setup_pci_device(pdev[i], d, !i);
618 572
619 /* 573 /*
@@ -639,6 +593,13 @@ out:
639} 593}
640EXPORT_SYMBOL_GPL(ide_pci_init_two); 594EXPORT_SYMBOL_GPL(ide_pci_init_two);
641 595
596int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
597 void *priv)
598{
599 return ide_pci_init_two(dev, NULL, d, priv);
600}
601EXPORT_SYMBOL_GPL(ide_pci_init_one);
602
642void ide_pci_remove(struct pci_dev *dev) 603void ide_pci_remove(struct pci_dev *dev)
643{ 604{
644 struct ide_host *host = pci_get_drvdata(dev); 605 struct ide_host *host = pci_get_drvdata(dev);
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c
index e5d2a48a84de..5f37f168f944 100644
--- a/drivers/ide/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -91,7 +91,7 @@ typedef struct {
91 91
92 92
93static void 93static void
94sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port, 94sgiioc4_init_hwif_ports(struct ide_hw *hw, unsigned long data_port,
95 unsigned long ctrl_port, unsigned long irq_port) 95 unsigned long ctrl_port, unsigned long irq_port)
96{ 96{
97 unsigned long reg = data_port; 97 unsigned long reg = data_port;
@@ -546,7 +546,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
546 unsigned long cmd_base, irqport; 546 unsigned long cmd_base, irqport;
547 unsigned long bar0, cmd_phys_base, ctl; 547 unsigned long bar0, cmd_phys_base, ctl;
548 void __iomem *virt_base; 548 void __iomem *virt_base;
549 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 549 struct ide_hw hw, *hws[] = { &hw };
550 int rc; 550 int rc;
551 551
552 /* Get the CmdBlk and CtrlBlk Base Registers */ 552 /* Get the CmdBlk and CtrlBlk Base Registers */
@@ -575,13 +575,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
575 memset(&hw, 0, sizeof(hw)); 575 memset(&hw, 0, sizeof(hw));
576 sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport); 576 sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport);
577 hw.irq = dev->irq; 577 hw.irq = dev->irq;
578 hw.chipset = ide_pci;
579 hw.dev = &dev->dev; 578 hw.dev = &dev->dev;
580 579
581 /* Initializing chipset IRQ Registers */ 580 /* Initializing chipset IRQ Registers */
582 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 581 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
583 582
584 rc = ide_host_add(&sgiioc4_port_info, hws, NULL); 583 rc = ide_host_add(&sgiioc4_port_info, hws, 1, NULL);
585 if (!rc) 584 if (!rc)
586 return 0; 585 return 0;
587 586
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c
index e4973cd1fba9..bd82d228608c 100644
--- a/drivers/ide/siimage.c
+++ b/drivers/ide/siimage.c
@@ -451,8 +451,8 @@ static int sil_sata_reset_poll(ide_drive_t *drive)
451static void sil_sata_pre_reset(ide_drive_t *drive) 451static void sil_sata_pre_reset(ide_drive_t *drive)
452{ 452{
453 if (drive->media == ide_disk) { 453 if (drive->media == ide_disk) {
454 drive->special.b.set_geometry = 0; 454 drive->special_flags &=
455 drive->special.b.recalibrate = 0; 455 ~(IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE);
456 } 456 }
457} 457}
458 458
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
index b0a460625335..0924abff52ff 100644
--- a/drivers/ide/sl82c105.c
+++ b/drivers/ide/sl82c105.c
@@ -10,7 +10,7 @@
10 * with the timing registers setup. 10 * with the timing registers setup.
11 * -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org 11 * -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org
12 * 12 *
13 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> 13 * Copyright (C) 2006-2007,2009 MontaVista Software, Inc. <source@mvista.com>
14 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 14 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
15 */ 15 */
16 16
@@ -146,14 +146,15 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive)
146 u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; 146 u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA;
147 u8 dma_cmd; 147 u8 dma_cmd;
148 148
149 printk("sl82c105: lost IRQ, resetting host\n"); 149 printk(KERN_WARNING "sl82c105: lost IRQ, resetting host\n");
150 150
151 /* 151 /*
152 * Check the raw interrupt from the drive. 152 * Check the raw interrupt from the drive.
153 */ 153 */
154 pci_read_config_dword(dev, 0x40, &val); 154 pci_read_config_dword(dev, 0x40, &val);
155 if (val & mask) 155 if (val & mask)
156 printk("sl82c105: drive was requesting IRQ, but host lost it\n"); 156 printk(KERN_INFO "sl82c105: drive was requesting IRQ, "
157 "but host lost it\n");
157 158
158 /* 159 /*
159 * Was DMA enabled? If so, disable it - we're resetting the 160 * Was DMA enabled? If so, disable it - we're resetting the
@@ -162,7 +163,7 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive)
162 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 163 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
163 if (dma_cmd & 1) { 164 if (dma_cmd & 1) {
164 outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); 165 outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD);
165 printk("sl82c105: DMA was enabled\n"); 166 printk(KERN_INFO "sl82c105: DMA was enabled\n");
166 } 167 }
167 168
168 sl82c105_reset_host(dev); 169 sl82c105_reset_host(dev);
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index e33d764e2945..ea89fddeed91 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -130,8 +130,7 @@ static const struct ide_port_info tx4938ide_port_info __initdata = {
130 130
131static int __init tx4938ide_probe(struct platform_device *pdev) 131static int __init tx4938ide_probe(struct platform_device *pdev)
132{ 132{
133 hw_regs_t hw; 133 struct ide_hw hw, *hws[] = { &hw };
134 hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
135 struct ide_host *host; 134 struct ide_host *host;
136 struct resource *res; 135 struct resource *res;
137 struct tx4938ide_platform_info *pdata = pdev->dev.platform_data; 136 struct tx4938ide_platform_info *pdata = pdev->dev.platform_data;
@@ -183,7 +182,7 @@ static int __init tx4938ide_probe(struct platform_device *pdev)
183 tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0); 182 tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0);
184 else 183 else
185 d.port_ops = NULL; 184 d.port_ops = NULL;
186 ret = ide_host_add(&d, hws, &host); 185 ret = ide_host_add(&d, hws, 1, &host);
187 if (!ret) 186 if (!ret)
188 platform_set_drvdata(pdev, host); 187 platform_set_drvdata(pdev, host);
189 return ret; 188 return ret;
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 5ca76224f6d1..64b58ecc3f0e 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -537,8 +537,7 @@ static const struct ide_port_info tx4939ide_port_info __initdata = {
537 537
538static int __init tx4939ide_probe(struct platform_device *pdev) 538static int __init tx4939ide_probe(struct platform_device *pdev)
539{ 539{
540 hw_regs_t hw; 540 struct ide_hw hw, *hws[] = { &hw };
541 hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
542 struct ide_host *host; 541 struct ide_host *host;
543 struct resource *res; 542 struct resource *res;
544 int irq, ret; 543 int irq, ret;
@@ -581,7 +580,7 @@ static int __init tx4939ide_probe(struct platform_device *pdev)
581 hw.dev = &pdev->dev; 580 hw.dev = &pdev->dev;
582 581
583 pr_info("TX4939 IDE interface (base %#lx, irq %d)\n", mapbase, irq); 582 pr_info("TX4939 IDE interface (base %#lx, irq %d)\n", mapbase, irq);
584 host = ide_host_alloc(&tx4939ide_port_info, hws); 583 host = ide_host_alloc(&tx4939ide_port_info, hws, 1);
585 if (!host) 584 if (!host)
586 return -ENOMEM; 585 return -ENOMEM;
587 /* use extra_base for base address of the all registers */ 586 /* use extra_base for base address of the all registers */