Commit 174f2366 authored by Axel Lin's avatar Axel Lin Committed by Wolfram Sang

i2c: au1550: Convert to devm_kzalloc and devm_ioremap_resource

Use devm_* APIs to simplify the code.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Tested-by: default avatarManuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 9e685c84
...@@ -48,7 +48,6 @@ struct i2c_au1550_data { ...@@ -48,7 +48,6 @@ struct i2c_au1550_data {
void __iomem *psc_base; void __iomem *psc_base;
int xfer_timeout; int xfer_timeout;
struct i2c_adapter adap; struct i2c_adapter adap;
struct resource *ioarea;
}; };
static inline void WR(struct i2c_au1550_data *a, int r, unsigned long v) static inline void WR(struct i2c_au1550_data *a, int r, unsigned long v)
...@@ -315,30 +314,16 @@ i2c_au1550_probe(struct platform_device *pdev) ...@@ -315,30 +314,16 @@ i2c_au1550_probe(struct platform_device *pdev)
struct resource *r; struct resource *r;
int ret; int ret;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv = devm_kzalloc(&pdev->dev, sizeof(struct i2c_au1550_data),
if (!r) { GFP_KERNEL);
ret = -ENODEV; if (!priv)
goto out; return -ENOMEM;
}
priv = kzalloc(sizeof(struct i2c_au1550_data), GFP_KERNEL); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!priv) { priv->psc_base = devm_ioremap_resource(&pdev->dev, r);
ret = -ENOMEM; if (IS_ERR(priv->psc_base))
goto out; return PTR_ERR(priv->psc_base);
}
priv->ioarea = request_mem_region(r->start, resource_size(r),
pdev->name);
if (!priv->ioarea) {
ret = -EBUSY;
goto out_mem;
}
priv->psc_base = ioremap(r->start, resource_size(r));
if (!priv->psc_base) {
ret = -EIO;
goto out_map;
}
priv->xfer_timeout = 200; priv->xfer_timeout = 200;
priv->adap.nr = pdev->id; priv->adap.nr = pdev->id;
...@@ -351,20 +336,13 @@ i2c_au1550_probe(struct platform_device *pdev) ...@@ -351,20 +336,13 @@ i2c_au1550_probe(struct platform_device *pdev)
i2c_au1550_setup(priv); i2c_au1550_setup(priv);
ret = i2c_add_numbered_adapter(&priv->adap); ret = i2c_add_numbered_adapter(&priv->adap);
if (ret == 0) { if (ret) {
platform_set_drvdata(pdev, priv); i2c_au1550_disable(priv);
return 0; return ret;
} }
i2c_au1550_disable(priv); platform_set_drvdata(pdev, priv);
iounmap(priv->psc_base); return 0;
out_map:
release_resource(priv->ioarea);
kfree(priv->ioarea);
out_mem:
kfree(priv);
out:
return ret;
} }
static int i2c_au1550_remove(struct platform_device *pdev) static int i2c_au1550_remove(struct platform_device *pdev)
...@@ -373,10 +351,6 @@ static int i2c_au1550_remove(struct platform_device *pdev) ...@@ -373,10 +351,6 @@ static int i2c_au1550_remove(struct platform_device *pdev)
i2c_del_adapter(&priv->adap); i2c_del_adapter(&priv->adap);
i2c_au1550_disable(priv); i2c_au1550_disable(priv);
iounmap(priv->psc_base);
release_resource(priv->ioarea);
kfree(priv->ioarea);
kfree(priv);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment