aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_winbond.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_winbond.c')
-rw-r--r--drivers/ata/pata_winbond.c101
1 files changed, 48 insertions, 53 deletions
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
index 6c111035fc84..cc4ad271afb5 100644
--- a/drivers/ata/pata_winbond.c
+++ b/drivers/ata/pata_winbond.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/pci.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/blkdev.h> 12#include <linux/blkdev.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
@@ -36,7 +35,7 @@ static int probe_winbond = 1;
36static int probe_winbond; 35static int probe_winbond;
37#endif 36#endif
38 37
39static spinlock_t winbond_lock = SPIN_LOCK_UNLOCKED; 38static DEFINE_SPINLOCK(winbond_lock);
40 39
41static void winbond_writecfg(unsigned long port, u8 reg, u8 val) 40static void winbond_writecfg(unsigned long port, u8 reg, u8 val)
42{ 41{
@@ -152,13 +151,13 @@ static struct ata_port_operations winbond_port_ops = {
152 .thaw = ata_bmdma_thaw, 151 .thaw = ata_bmdma_thaw,
153 .error_handler = ata_bmdma_error_handler, 152 .error_handler = ata_bmdma_error_handler,
154 .post_internal_cmd = ata_bmdma_post_internal_cmd, 153 .post_internal_cmd = ata_bmdma_post_internal_cmd,
154 .cable_detect = ata_cable_40wire,
155 155
156 .qc_prep = ata_qc_prep, 156 .qc_prep = ata_qc_prep,
157 .qc_issue = ata_qc_issue_prot, 157 .qc_issue = ata_qc_issue_prot,
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
180static __init int winbond_init_one(unsigned long port) 179static __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/**