aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_mpc52xx.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-01-20 02:00:28 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:37 -0500
commit24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch)
treed76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/pata_mpc52xx.c
parentf0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (diff)
libata: update libata LLDs to use devres
Update libata LLDs to use devres. Core layer is already converted to support managed LLDs. This patch simplifies initialization and fixes many resource related bugs in init failure and detach path. For example, all converted drivers now handle ata_device_add() failure gracefully without excessive resource rollback code. As most resources are released automatically on driver detach, many drivers don't need or can do with much simpler ->{port|host}_stop(). In general, stop callbacks are need iff port or host needs to be given commands to shut it down. Note that freezing is enough in many cases and ports are automatically frozen before being detached. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_mpc52xx.c')
-rw-r--r--drivers/ata/pata_mpc52xx.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 8b7019a2f190..5320ea854365 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -17,7 +17,6 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/libata.h> 18#include <linux/libata.h>
19 19
20#include <asm/io.h>
21#include <asm/types.h> 20#include <asm/types.h>
22#include <asm/prom.h> 21#include <asm/prom.h>
23#include <asm/of_platform.h> 22#include <asm/of_platform.h>
@@ -300,8 +299,6 @@ static struct ata_port_operations mpc52xx_ata_port_ops = {
300 .irq_handler = ata_interrupt, 299 .irq_handler = ata_interrupt,
301 .irq_clear = ata_bmdma_irq_clear, 300 .irq_clear = ata_bmdma_irq_clear,
302 .port_start = ata_port_start, 301 .port_start = ata_port_start,
303 .port_stop = ata_port_stop,
304 .host_stop = ata_host_stop,
305}; 302};
306 303
307static struct ata_probe_ent mpc52xx_ata_probe_ent = { 304static struct ata_probe_ent mpc52xx_ata_probe_ent = {
@@ -353,7 +350,7 @@ mpc52xx_ata_remove_one(struct device *dev)
353 struct ata_host *host = dev_get_drvdata(dev); 350 struct ata_host *host = dev_get_drvdata(dev);
354 struct mpc52xx_ata_priv *priv = host->private_data; 351 struct mpc52xx_ata_priv *priv = host->private_data;
355 352
356 ata_host_remove(host); 353 ata_host_detach(host);
357 354
358 return priv; 355 return priv;
359} 356}
@@ -369,8 +366,8 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
369 unsigned int ipb_freq; 366 unsigned int ipb_freq;
370 struct resource res_mem; 367 struct resource res_mem;
371 int ata_irq = NO_IRQ; 368 int ata_irq = NO_IRQ;
372 struct mpc52xx_ata __iomem *ata_regs = NULL; 369 struct mpc52xx_ata __iomem *ata_regs;
373 struct mpc52xx_ata_priv *priv = NULL; 370 struct mpc52xx_ata_priv *priv;
374 int rv; 371 int rv;
375 372
376 /* Get ipb frequency */ 373 /* Get ipb frequency */
@@ -397,16 +394,17 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
397 } 394 }
398 395
399 /* Request mem region */ 396 /* Request mem region */
400 if (!request_mem_region(res_mem.start, 397 if (!devm_request_mem_region(&op->dev, res_mem.start,
401 sizeof(struct mpc52xx_ata), DRV_NAME)) { 398 sizeof(struct mpc52xx_ata), DRV_NAME)) {
402 printk(KERN_ERR DRV_NAME ": " 399 printk(KERN_ERR DRV_NAME ": "
403 "Error while requesting mem region\n"); 400 "Error while requesting mem region\n");
404 irq_dispose_mapping(ata_irq); 401 rv = -EBUSY;
405 return -EBUSY; 402 goto err;
406 } 403 }
407 404
408 /* Remap registers */ 405 /* Remap registers */
409 ata_regs = ioremap(res_mem.start, sizeof(struct mpc52xx_ata)); 406 ata_regs = devm_ioremap(&op->dev, res_mem.start,
407 sizeof(struct mpc52xx_ata));
410 if (!ata_regs) { 408 if (!ata_regs) {
411 printk(KERN_ERR DRV_NAME ": " 409 printk(KERN_ERR DRV_NAME ": "
412 "Error while mapping register set\n"); 410 "Error while mapping register set\n");
@@ -415,7 +413,8 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
415 } 413 }
416 414
417 /* Prepare our private structure */ 415 /* Prepare our private structure */
418 priv = kmalloc(sizeof(struct mpc52xx_ata_priv), GFP_ATOMIC); 416 priv = devm_kzalloc(&op->dev, sizeof(struct mpc52xx_ata_priv),
417 GFP_ATOMIC);
419 if (!priv) { 418 if (!priv) {
420 printk(KERN_ERR DRV_NAME ": " 419 printk(KERN_ERR DRV_NAME ": "
421 "Error while allocating private structure\n"); 420 "Error while allocating private structure\n");
@@ -448,15 +447,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
448 447
449 /* Error path */ 448 /* Error path */
450err: 449err:
451 kfree(priv);
452
453 if (ata_regs)
454 iounmap(ata_regs);
455
456 release_mem_region(res_mem.start, sizeof(struct mpc52xx_ata));
457
458 irq_dispose_mapping(ata_irq); 450 irq_dispose_mapping(ata_irq);
459
460 return rv; 451 return rv;
461} 452}
462 453
@@ -464,28 +455,10 @@ static int
464mpc52xx_ata_remove(struct of_device *op) 455mpc52xx_ata_remove(struct of_device *op)
465{ 456{
466 struct mpc52xx_ata_priv *priv; 457 struct mpc52xx_ata_priv *priv;
467 struct resource res_mem;
468 int rv;
469 458
470 /* Unregister */
471 priv = mpc52xx_ata_remove_one(&op->dev); 459 priv = mpc52xx_ata_remove_one(&op->dev);
472
473 /* Free everything */
474 iounmap(priv->ata_regs);
475
476 rv = of_address_to_resource(op->node, 0, &res_mem);
477 if (rv) {
478 printk(KERN_ERR DRV_NAME ": "
479 "Error while parsing device node resource\n");
480 printk(KERN_ERR DRV_NAME ": "
481 "Zone may not be properly released\n");
482 } else
483 release_mem_region(res_mem.start, sizeof(struct mpc52xx_ata));
484
485 irq_dispose_mapping(priv->ata_irq); 460 irq_dispose_mapping(priv->ata_irq);
486 461
487 kfree(priv);
488
489 return 0; 462 return 0;
490} 463}
491 464