Commit 578e99d6 authored by Libin Yang's avatar Libin Yang Committed by Mauro Carvalho Chehab

[media] marvell-ccic: switch to resource managed allocation and request

This patch switchs to resource managed allocation and request in mmp-driver.
It can remove free resource operations.
Signed-off-by: default avatarAlbert Wang <twang13@marvell.com>
Signed-off-by: default avatarLibin Yang <lbyang@marvell.com>
Acked-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 0a0b3fb4
...@@ -367,7 +367,7 @@ static int mmpcam_probe(struct platform_device *pdev) ...@@ -367,7 +367,7 @@ static int mmpcam_probe(struct platform_device *pdev)
if (!pdata) if (!pdata)
return -ENODEV; return -ENODEV;
cam = kzalloc(sizeof(*cam), GFP_KERNEL); cam = devm_kzalloc(&pdev->dev, sizeof(*cam), GFP_KERNEL);
if (cam == NULL) if (cam == NULL)
return -ENOMEM; return -ENOMEM;
cam->pdev = pdev; cam->pdev = pdev;
...@@ -398,15 +398,11 @@ static int mmpcam_probe(struct platform_device *pdev) ...@@ -398,15 +398,11 @@ static int mmpcam_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "no iomem resource!\n"); dev_err(&pdev->dev, "no iomem resource!\n");
ret = -ENODEV; return -ENODEV;
goto out_free;
}
mcam->regs = ioremap(res->start, resource_size(res));
if (mcam->regs == NULL) {
dev_err(&pdev->dev, "MMIO ioremap fail\n");
ret = -ENODEV;
goto out_free;
} }
mcam->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(mcam->regs))
return PTR_ERR(mcam->regs);
mcam->regs_size = resource_size(res); mcam->regs_size = resource_size(res);
/* /*
* Power/clock memory is elsewhere; get it too. Perhaps this * Power/clock memory is elsewhere; get it too. Perhaps this
...@@ -415,40 +411,37 @@ static int mmpcam_probe(struct platform_device *pdev) ...@@ -415,40 +411,37 @@ static int mmpcam_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "no power resource!\n"); dev_err(&pdev->dev, "no power resource!\n");
ret = -ENODEV; return -ENODEV;
goto out_unmap1;
}
cam->power_regs = ioremap(res->start, resource_size(res));
if (cam->power_regs == NULL) {
dev_err(&pdev->dev, "power MMIO ioremap fail\n");
ret = -ENODEV;
goto out_unmap1;
} }
cam->power_regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(cam->power_regs))
return PTR_ERR(cam->power_regs);
/* /*
* Find the i2c adapter. This assumes, of course, that the * Find the i2c adapter. This assumes, of course, that the
* i2c bus is already up and functioning. * i2c bus is already up and functioning.
*/ */
mcam->i2c_adapter = platform_get_drvdata(pdata->i2c_device); mcam->i2c_adapter = platform_get_drvdata(pdata->i2c_device);
if (mcam->i2c_adapter == NULL) { if (mcam->i2c_adapter == NULL) {
ret = -ENODEV;
dev_err(&pdev->dev, "No i2c adapter\n"); dev_err(&pdev->dev, "No i2c adapter\n");
goto out_unmap2; return -ENODEV;
} }
/* /*
* Sensor GPIO pins. * Sensor GPIO pins.
*/ */
ret = gpio_request(pdata->sensor_power_gpio, "cam-power"); ret = devm_gpio_request(&pdev->dev, pdata->sensor_power_gpio,
"cam-power");
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't get sensor power gpio %d", dev_err(&pdev->dev, "Can't get sensor power gpio %d",
pdata->sensor_power_gpio); pdata->sensor_power_gpio);
goto out_unmap2; return ret;
} }
gpio_direction_output(pdata->sensor_power_gpio, 0); gpio_direction_output(pdata->sensor_power_gpio, 0);
ret = gpio_request(pdata->sensor_reset_gpio, "cam-reset"); ret = devm_gpio_request(&pdev->dev, pdata->sensor_reset_gpio,
"cam-reset");
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't get sensor reset gpio %d", dev_err(&pdev->dev, "Can't get sensor reset gpio %d",
pdata->sensor_reset_gpio); pdata->sensor_reset_gpio);
goto out_gpio; return ret;
} }
gpio_direction_output(pdata->sensor_reset_gpio, 0); gpio_direction_output(pdata->sensor_reset_gpio, 0);
...@@ -459,10 +452,10 @@ static int mmpcam_probe(struct platform_device *pdev) ...@@ -459,10 +452,10 @@ static int mmpcam_probe(struct platform_device *pdev)
*/ */
ret = mmpcam_power_up(mcam); ret = mmpcam_power_up(mcam);
if (ret) if (ret)
goto out_gpio2; goto out_deinit_clk;
ret = mccic_register(mcam); ret = mccic_register(mcam);
if (ret) if (ret)
goto out_pwdn; goto out_power_down;
/* /*
* Finally, set up our IRQ now that the core is ready to * Finally, set up our IRQ now that the core is ready to
* deal with it. * deal with it.
...@@ -473,8 +466,8 @@ static int mmpcam_probe(struct platform_device *pdev) ...@@ -473,8 +466,8 @@ static int mmpcam_probe(struct platform_device *pdev)
goto out_unregister; goto out_unregister;
} }
cam->irq = res->start; cam->irq = res->start;
ret = request_irq(cam->irq, mmpcam_irq, IRQF_SHARED, ret = devm_request_irq(&pdev->dev, cam->irq, mmpcam_irq, IRQF_SHARED,
"mmp-camera", mcam); "mmp-camera", mcam);
if (ret == 0) { if (ret == 0) {
mmpcam_add_device(cam); mmpcam_add_device(cam);
return 0; return 0;
...@@ -482,19 +475,10 @@ static int mmpcam_probe(struct platform_device *pdev) ...@@ -482,19 +475,10 @@ static int mmpcam_probe(struct platform_device *pdev)
out_unregister: out_unregister:
mccic_shutdown(mcam); mccic_shutdown(mcam);
out_pwdn: out_power_down:
mmpcam_power_down(mcam); mmpcam_power_down(mcam);
out_gpio2: out_deinit_clk:
mcam_deinit_clk(mcam); mcam_deinit_clk(mcam);
gpio_free(pdata->sensor_reset_gpio);
out_gpio:
gpio_free(pdata->sensor_power_gpio);
out_unmap2:
iounmap(cam->power_regs);
out_unmap1:
iounmap(mcam->regs);
out_free:
kfree(cam);
return ret; return ret;
} }
......
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