aboutsummaryrefslogtreecommitdiff
path: root/drivers/ata/pata_mpc52xx.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-01-20 16:00:28 +0900
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 8b7019a2f19..5320ea85436 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -17,7 +17,6 @@
#include <linux/delay.h>
#include <linux/libata.h>
-#include <asm/io.h>
#include <asm/types.h>
#include <asm/prom.h>
#include <asm/of_platform.h>
@@ -300,8 +299,6 @@ static struct ata_port_operations mpc52xx_ata_port_ops = {
.irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear,
.port_start = ata_port_start,
- .port_stop = ata_port_stop,
- .host_stop = ata_host_stop,
};
static struct ata_probe_ent mpc52xx_ata_probe_ent = {
@@ -353,7 +350,7 @@ mpc52xx_ata_remove_one(struct device *dev)
struct ata_host *host = dev_get_drvdata(dev);
struct mpc52xx_ata_priv *priv = host->private_data;
- ata_host_remove(host);
+ ata_host_detach(host);
return priv;
}
@@ -369,8 +366,8 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
unsigned int ipb_freq;
struct resource res_mem;
int ata_irq = NO_IRQ;
- struct mpc52xx_ata __iomem *ata_regs = NULL;
- struct mpc52xx_ata_priv *priv = NULL;
+ struct mpc52xx_ata __iomem *ata_regs;
+ struct mpc52xx_ata_priv *priv;
int rv;
/* Get ipb frequency */
@@ -397,16 +394,17 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
}
/* Request mem region */
- if (!request_mem_region(res_mem.start,
- sizeof(struct mpc52xx_ata), DRV_NAME)) {
+ if (!devm_request_mem_region(&op->dev, res_mem.start,
+ sizeof(struct mpc52xx_ata), DRV_NAME)) {
printk(KERN_ERR DRV_NAME ": "
"Error while requesting mem region\n");
- irq_dispose_mapping(ata_irq);
- return -EBUSY;
+ rv = -EBUSY;
+ goto err;
}
/* Remap registers */
- ata_regs = ioremap(res_mem.start, sizeof(struct mpc52xx_ata));
+ ata_regs = devm_ioremap(&op->dev, res_mem.start,
+ sizeof(struct mpc52xx_ata));
if (!ata_regs) {
printk(KERN_ERR DRV_NAME ": "
"Error while mapping register set\n");
@@ -415,7 +413,8 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
}
/* Prepare our private structure */
- priv = kmalloc(sizeof(struct mpc52xx_ata_priv), GFP_ATOMIC);
+ priv = devm_kzalloc(&op->dev, sizeof(struct mpc52xx_ata_priv),
+ GFP_ATOMIC);
if (!priv) {
printk(KERN_ERR DRV_NAME ": "
"Error while allocating private structure\n");
@@ -448,15 +447,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
/* Error path */
err:
- kfree(priv);
-
- if (ata_regs)
- iounmap(ata_regs);
-
- release_mem_region(res_mem.start, sizeof(struct mpc52xx_ata));
-
irq_dispose_mapping(ata_irq);
-
return rv;
}
@@ -464,28 +455,10 @@ static int
mpc52xx_ata_remove(struct of_device *op)
{
struct mpc52xx_ata_priv *priv;
- struct resource res_mem;
- int rv;
- /* Unregister */
priv = mpc52xx_ata_remove_one(&op->dev);
-
- /* Free everything */
- iounmap(priv->ata_regs);
-
- rv = of_address_to_resource(op->node, 0, &res_mem);
- if (rv) {
- printk(KERN_ERR DRV_NAME ": "
- "Error while parsing device node resource\n");
- printk(KERN_ERR DRV_NAME ": "
- "Zone may not be properly released\n");
- } else
- release_mem_region(res_mem.start, sizeof(struct mpc52xx_ata));
-
irq_dispose_mapping(priv->ata_irq);
- kfree(priv);
-
return 0;
}