diff options
author | Tejun Heo <htejun@gmail.com> | 2007-04-17 10:44:08 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 14:16:06 -0400 |
commit | 5d728824efeda61d304153bfcf1378a3c18b7d70 (patch) | |
tree | 8a3d4ba0c1c650da5c161f11155e7c19f0fe78aa /drivers/ata/pata_winbond.c | |
parent | 4447d35156169cf136e829eb6b5cac2d6370f2d9 (diff) |
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_winbond.c')
-rw-r--r-- | drivers/ata/pata_winbond.c | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c index 434f14f6f869..aa6d4bca2ea3 100644 --- a/drivers/ata/pata_winbond.c +++ b/drivers/ata/pata_winbond.c | |||
@@ -158,7 +158,6 @@ static struct ata_port_operations winbond_port_ops = { | |||
158 | 158 | ||
159 | .data_xfer = winbond_data_xfer, | 159 | .data_xfer = winbond_data_xfer, |
160 | 160 | ||
161 | .irq_handler = ata_interrupt, | ||
162 | .irq_clear = ata_bmdma_irq_clear, | 161 | .irq_clear = ata_bmdma_irq_clear, |
163 | .irq_on = ata_irq_on, | 162 | .irq_on = ata_irq_on, |
164 | .irq_ack = ata_irq_ack, | 163 | .irq_ack = ata_irq_ack, |
@@ -179,11 +178,9 @@ static struct ata_port_operations winbond_port_ops = { | |||
179 | 178 | ||
180 | static __init int winbond_init_one(unsigned long port) | 179 | static __init int winbond_init_one(unsigned long port) |
181 | { | 180 | { |
182 | struct ata_probe_ent ae; | ||
183 | struct platform_device *pdev; | 181 | struct platform_device *pdev; |
184 | int ret; | ||
185 | u8 reg; | 182 | u8 reg; |
186 | int i; | 183 | int i, rc; |
187 | 184 | ||
188 | reg = winbond_readcfg(port, 0x81); | 185 | reg = winbond_readcfg(port, 0x81); |
189 | reg |= 0x80; /* jumpered mode off */ | 186 | reg |= 0x80; /* jumpered mode off */ |
@@ -202,58 +199,56 @@ static __init int winbond_init_one(unsigned long port) | |||
202 | 199 | ||
203 | for (i = 0; i < 2 ; i ++) { | 200 | for (i = 0; i < 2 ; i ++) { |
204 | unsigned long cmd_port = 0x1F0 - (0x80 * i); | 201 | unsigned long cmd_port = 0x1F0 - (0x80 * i); |
202 | struct ata_host *host; | ||
203 | struct ata_port *ap; | ||
205 | void __iomem *cmd_addr, *ctl_addr; | 204 | void __iomem *cmd_addr, *ctl_addr; |
206 | 205 | ||
207 | if (reg & (1 << i)) { | 206 | if (!(reg & (1 << i))) |
208 | /* | 207 | continue; |
209 | * Fill in a probe structure first of all | 208 | |
210 | */ | 209 | pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0); |
211 | 210 | if (IS_ERR(pdev)) | |
212 | pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0); | 211 | return PTR_ERR(pdev); |
213 | if (IS_ERR(pdev)) | 212 | |
214 | return PTR_ERR(pdev); | 213 | rc = -ENOMEM; |
215 | 214 | host = ata_host_alloc(&pdev->dev, 1); | |
216 | cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8); | 215 | if (!host) |
217 | ctl_addr = devm_ioport_map(&pdev->dev, cmd_port + 0x0206, 1); | 216 | goto err_unregister; |
218 | if (!cmd_addr || !ctl_addr) { | 217 | |
219 | platform_device_unregister(pdev); | 218 | rc = -ENOMEM; |
220 | return -ENOMEM; | 219 | cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8); |
221 | } | 220 | ctl_addr = devm_ioport_map(&pdev->dev, cmd_port + 0x0206, 1); |
222 | 221 | if (!cmd_addr || !ctl_addr) | |
223 | memset(&ae, 0, sizeof(struct ata_probe_ent)); | 222 | goto err_unregister; |
224 | INIT_LIST_HEAD(&ae.node); | 223 | |
225 | ae.dev = &pdev->dev; | 224 | ap = host->ports[0]; |
226 | 225 | ap->ops = &winbond_port_ops; | |
227 | ae.port_ops = &winbond_port_ops; | 226 | ap->pio_mask = 0x1F; |
228 | ae.pio_mask = 0x1F; | 227 | ap->flags |= ATA_FLAG_SLAVE_POSS; |
229 | 228 | ap->ioaddr.cmd_addr = cmd_addr; | |
230 | ae.sht = &winbond_sht; | 229 | ap->ioaddr.altstatus_addr = ctl_addr; |
231 | 230 | ap->ioaddr.ctl_addr = ctl_addr; | |
232 | ae.n_ports = 1; | 231 | ata_std_ports(&ap->ioaddr); |
233 | ae.irq = 14 + i; | 232 | |
234 | ae.irq_flags = 0; | 233 | /* hook in a private data structure per channel */ |
235 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | 234 | host->private_data = &winbond_data[nr_winbond_host]; |
236 | ae.port[0].cmd_addr = cmd_addr; | 235 | winbond_data[nr_winbond_host].config = port; |
237 | ae.port[0].altstatus_addr = ctl_addr; | 236 | winbond_data[nr_winbond_host].platform_dev = pdev; |
238 | ae.port[0].ctl_addr = ctl_addr; | 237 | |
239 | ata_std_ports(&ae.port[0]); | 238 | /* activate */ |
240 | /* | 239 | rc = ata_host_activate(host, 14 + i, ata_interrupt, 0, |
241 | * Hook in a private data structure per channel | 240 | &winbond_sht); |
242 | */ | 241 | if (rc) |
243 | ae.private_data = &winbond_data[nr_winbond_host]; | 242 | goto err_unregister; |
244 | winbond_data[nr_winbond_host].config = port; | 243 | |
245 | winbond_data[nr_winbond_host].platform_dev = pdev; | 244 | winbond_host[nr_winbond_host++] = dev_get_drvdata(&pdev->dev); |
246 | |||
247 | ret = ata_device_add(&ae); | ||
248 | if (ret == 0) { | ||
249 | platform_device_unregister(pdev); | ||
250 | return -ENODEV; | ||
251 | } | ||
252 | winbond_host[nr_winbond_host++] = dev_get_drvdata(&pdev->dev); | ||
253 | } | ||
254 | } | 245 | } |
255 | 246 | ||
256 | return 0; | 247 | return 0; |
248 | |||
249 | err_unregister: | ||
250 | platform_device_unregister(pdev); | ||
251 | return rc; | ||
257 | } | 252 | } |
258 | 253 | ||
259 | /** | 254 | /** |