提交 31d951e2 编写于 作者: L Linus Walleij

ARM: integrator: use managed resources for the IM-PD1

Switch the IM-PD1 driver to use managed resources and cut down
on boilerplate.
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 e641b987
...@@ -307,25 +307,23 @@ static struct impd1_device impd1_devs[] = { ...@@ -307,25 +307,23 @@ static struct impd1_device impd1_devs[] = {
static int impd1_probe(struct lm_device *dev) static int impd1_probe(struct lm_device *dev)
{ {
struct impd1_module *impd1; struct impd1_module *impd1;
int i, ret; int i;
if (dev->id != module_id) if (dev->id != module_id)
return -EINVAL; return -EINVAL;
if (!request_mem_region(dev->resource.start, SZ_4K, "LM registers")) if (!devm_request_mem_region(&dev->dev, dev->resource.start,
SZ_4K, "LM registers"))
return -EBUSY; return -EBUSY;
impd1 = kzalloc(sizeof(struct impd1_module), GFP_KERNEL); impd1 = devm_kzalloc(&dev->dev, sizeof(struct impd1_module),
if (!impd1) { GFP_KERNEL);
ret = -ENOMEM; if (!impd1)
goto release_lm; return -ENOMEM;
}
impd1->base = ioremap(dev->resource.start, SZ_4K); impd1->base = devm_ioremap(&dev->dev, dev->resource.start, SZ_4K);
if (!impd1->base) { if (!impd1->base)
ret = -ENOMEM; return -ENOMEM;
goto free_impd1;
}
lm_set_drvdata(dev, impd1); lm_set_drvdata(dev, impd1);
...@@ -353,14 +351,6 @@ static int impd1_probe(struct lm_device *dev) ...@@ -353,14 +351,6 @@ static int impd1_probe(struct lm_device *dev)
} }
return 0; return 0;
free_impd1:
if (impd1 && impd1->base)
iounmap(impd1->base);
kfree(impd1);
release_lm:
release_mem_region(dev->resource.start, SZ_4K);
return ret;
} }
static int impd1_remove_one(struct device *dev, void *data) static int impd1_remove_one(struct device *dev, void *data)
...@@ -371,16 +361,10 @@ static int impd1_remove_one(struct device *dev, void *data) ...@@ -371,16 +361,10 @@ static int impd1_remove_one(struct device *dev, void *data)
static void impd1_remove(struct lm_device *dev) static void impd1_remove(struct lm_device *dev)
{ {
struct impd1_module *impd1 = lm_get_drvdata(dev);
device_for_each_child(&dev->dev, NULL, impd1_remove_one); device_for_each_child(&dev->dev, NULL, impd1_remove_one);
integrator_impd1_clk_exit(dev->id); integrator_impd1_clk_exit(dev->id);
lm_set_drvdata(dev, NULL); lm_set_drvdata(dev, NULL);
iounmap(impd1->base);
kfree(impd1);
release_mem_region(dev->resource.start, SZ_4K);
} }
static struct lm_driver impd1_driver = { static struct lm_driver impd1_driver = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册