aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_pcmcia.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_pcmcia.c')
-rw-r--r--drivers/ata/pata_pcmcia.c47
1 files changed, 8 insertions, 39 deletions
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index d94b8f0bd743..aa39bda6441a 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -45,16 +45,6 @@
45#define DRV_NAME "pata_pcmcia" 45#define DRV_NAME "pata_pcmcia"
46#define DRV_VERSION "0.3.5" 46#define DRV_VERSION "0.3.5"
47 47
48/*
49 * Private data structure to glue stuff together
50 */
51
52struct ata_pcmcia_info {
53 struct pcmcia_device *pdev;
54 int ndev;
55 dev_node_t node;
56};
57
58/** 48/**
59 * pcmcia_set_mode - PCMCIA specific mode setup 49 * pcmcia_set_mode - PCMCIA specific mode setup
60 * @link: link 50 * @link: link
@@ -248,7 +238,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
248{ 238{
249 struct ata_host *host; 239 struct ata_host *host;
250 struct ata_port *ap; 240 struct ata_port *ap;
251 struct ata_pcmcia_info *info;
252 struct pcmcia_config_check *stk = NULL; 241 struct pcmcia_config_check *stk = NULL;
253 int is_kme = 0, ret = -ENOMEM, p; 242 int is_kme = 0, ret = -ENOMEM, p;
254 unsigned long io_base, ctl_base; 243 unsigned long io_base, ctl_base;
@@ -256,19 +245,10 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
256 int n_ports = 1; 245 int n_ports = 1;
257 struct ata_port_operations *ops = &pcmcia_port_ops; 246 struct ata_port_operations *ops = &pcmcia_port_ops;
258 247
259 info = kzalloc(sizeof(*info), GFP_KERNEL);
260 if (info == NULL)
261 return -ENOMEM;
262
263 /* Glue stuff together. FIXME: We may be able to get rid of info with care */
264 info->pdev = pdev;
265 pdev->priv = info;
266
267 /* Set up attributes in order to probe card and get resources */ 248 /* Set up attributes in order to probe card and get resources */
268 pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 249 pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
269 pdev->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 250 pdev->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
270 pdev->io.IOAddrLines = 3; 251 pdev->io.IOAddrLines = 3;
271 pdev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
272 pdev->conf.Attributes = CONF_ENABLE_IRQ; 252 pdev->conf.Attributes = CONF_ENABLE_IRQ;
273 pdev->conf.IntType = INT_MEMORY_AND_IO; 253 pdev->conf.IntType = INT_MEMORY_AND_IO;
274 254
@@ -293,8 +273,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
293 } 273 }
294 io_base = pdev->io.BasePort1; 274 io_base = pdev->io.BasePort1;
295 ctl_base = stk->ctl_base; 275 ctl_base = stk->ctl_base;
296 ret = pcmcia_request_irq(pdev, &pdev->irq); 276 if (!pdev->irq)
297 if (ret)
298 goto failed; 277 goto failed;
299 278
300 ret = pcmcia_request_configuration(pdev, &pdev->conf); 279 ret = pcmcia_request_configuration(pdev, &pdev->conf);
@@ -344,21 +323,19 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
344 } 323 }
345 324
346 /* activate */ 325 /* activate */
347 ret = ata_host_activate(host, pdev->irq.AssignedIRQ, ata_sff_interrupt, 326 ret = ata_host_activate(host, pdev->irq, ata_sff_interrupt,
348 IRQF_SHARED, &pcmcia_sht); 327 IRQF_SHARED, &pcmcia_sht);
349 if (ret) 328 if (ret)
350 goto failed; 329 goto failed;
351 330
352 info->ndev = 1; 331 pdev->priv = host;
353 kfree(stk); 332 kfree(stk);
354 return 0; 333 return 0;
355 334
356failed: 335failed:
357 kfree(stk); 336 kfree(stk);
358 info->ndev = 0;
359 pcmcia_disable_device(pdev); 337 pcmcia_disable_device(pdev);
360out1: 338out1:
361 kfree(info);
362 return ret; 339 return ret;
363} 340}
364 341
@@ -372,20 +349,12 @@ out1:
372 349
373static void pcmcia_remove_one(struct pcmcia_device *pdev) 350static void pcmcia_remove_one(struct pcmcia_device *pdev)
374{ 351{
375 struct ata_pcmcia_info *info = pdev->priv; 352 struct ata_host *host = pdev->priv;
376 struct device *dev = &pdev->dev; 353
377 354 if (host)
378 if (info != NULL) { 355 ata_host_detach(host);
379 /* If we have attached the device to the ATA layer, detach it */ 356
380 if (info->ndev) {
381 struct ata_host *host = dev_get_drvdata(dev);
382 ata_host_detach(host);
383 }
384 info->ndev = 0;
385 pdev->priv = NULL;
386 }
387 pcmcia_disable_device(pdev); 357 pcmcia_disable_device(pdev);
388 kfree(info);
389} 358}
390 359
391static struct pcmcia_device_id pcmcia_devices[] = { 360static struct pcmcia_device_id pcmcia_devices[] = {