aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-12-25 15:27:31 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-05 11:49:17 -0500
commitcf2b4cf661bd183791ebc0a7ab091de77a1748b0 (patch)
treef46112fb67c7f8cca87abe7788bb4ff5d0d90bc0 /drivers/media/platform
parent3d5a71ef32742298f9022043160a2c6cbfdf30ac (diff)
[media] omap3isp: Use devm_* managed functions
Replace kzalloc, request_mem_region, ioremap, clk_get and regulator_get with their devm_* managed replacement. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/omap3isp/isp.c74
-rw-r--r--drivers/media/platform/omap3isp/ispccp2.c8
-rw-r--r--drivers/media/platform/omap3isp/isph3a_aewb.c27
-rw-r--r--drivers/media/platform/omap3isp/isph3a_af.c27
-rw-r--r--drivers/media/platform/omap3isp/isphist.c4
5 files changed, 27 insertions, 113 deletions
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index e4aaee91201d..383a727b8aa0 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1406,28 +1406,15 @@ static const char *isp_clocks[] = {
1406 "l3_ick", 1406 "l3_ick",
1407}; 1407};
1408 1408
1409static void isp_put_clocks(struct isp_device *isp)
1410{
1411 unsigned int i;
1412
1413 for (i = 0; i < ARRAY_SIZE(isp_clocks); ++i) {
1414 if (isp->clock[i]) {
1415 clk_put(isp->clock[i]);
1416 isp->clock[i] = NULL;
1417 }
1418 }
1419}
1420
1421static int isp_get_clocks(struct isp_device *isp) 1409static int isp_get_clocks(struct isp_device *isp)
1422{ 1410{
1423 struct clk *clk; 1411 struct clk *clk;
1424 unsigned int i; 1412 unsigned int i;
1425 1413
1426 for (i = 0; i < ARRAY_SIZE(isp_clocks); ++i) { 1414 for (i = 0; i < ARRAY_SIZE(isp_clocks); ++i) {
1427 clk = clk_get(isp->dev, isp_clocks[i]); 1415 clk = devm_clk_get(isp->dev, isp_clocks[i]);
1428 if (IS_ERR(clk)) { 1416 if (IS_ERR(clk)) {
1429 dev_err(isp->dev, "clk_get %s failed\n", isp_clocks[i]); 1417 dev_err(isp->dev, "clk_get %s failed\n", isp_clocks[i]);
1430 isp_put_clocks(isp);
1431 return PTR_ERR(clk); 1418 return PTR_ERR(clk);
1432 } 1419 }
1433 1420
@@ -1993,7 +1980,6 @@ error_csiphy:
1993static int isp_remove(struct platform_device *pdev) 1980static int isp_remove(struct platform_device *pdev)
1994{ 1981{
1995 struct isp_device *isp = platform_get_drvdata(pdev); 1982 struct isp_device *isp = platform_get_drvdata(pdev);
1996 int i;
1997 1983
1998 isp_unregister_entities(isp); 1984 isp_unregister_entities(isp);
1999 isp_cleanup_modules(isp); 1985 isp_cleanup_modules(isp);
@@ -2004,26 +1990,6 @@ static int isp_remove(struct platform_device *pdev)
2004 isp->domain = NULL; 1990 isp->domain = NULL;
2005 omap3isp_put(isp); 1991 omap3isp_put(isp);
2006 1992
2007 free_irq(isp->irq_num, isp);
2008 isp_put_clocks(isp);
2009
2010 for (i = 0; i < OMAP3_ISP_IOMEM_LAST; i++) {
2011 if (isp->mmio_base[i]) {
2012 iounmap(isp->mmio_base[i]);
2013 isp->mmio_base[i] = NULL;
2014 }
2015
2016 if (isp->mmio_base_phys[i]) {
2017 release_mem_region(isp->mmio_base_phys[i],
2018 isp->mmio_size[i]);
2019 isp->mmio_base_phys[i] = 0;
2020 }
2021 }
2022
2023 regulator_put(isp->isp_csiphy1.vdd);
2024 regulator_put(isp->isp_csiphy2.vdd);
2025 kfree(isp);
2026
2027 return 0; 1993 return 0;
2028} 1994}
2029 1995
@@ -2041,7 +2007,8 @@ static int isp_map_mem_resource(struct platform_device *pdev,
2041 return -ENODEV; 2007 return -ENODEV;
2042 } 2008 }
2043 2009
2044 if (!request_mem_region(mem->start, resource_size(mem), pdev->name)) { 2010 if (!devm_request_mem_region(isp->dev, mem->start, resource_size(mem),
2011 pdev->name)) {
2045 dev_err(isp->dev, 2012 dev_err(isp->dev,
2046 "cannot reserve camera register I/O region\n"); 2013 "cannot reserve camera register I/O region\n");
2047 return -ENODEV; 2014 return -ENODEV;
@@ -2050,8 +2017,9 @@ static int isp_map_mem_resource(struct platform_device *pdev,
2050 isp->mmio_size[res] = resource_size(mem); 2017 isp->mmio_size[res] = resource_size(mem);
2051 2018
2052 /* map the region */ 2019 /* map the region */
2053 isp->mmio_base[res] = ioremap_nocache(isp->mmio_base_phys[res], 2020 isp->mmio_base[res] = devm_ioremap_nocache(isp->dev,
2054 isp->mmio_size[res]); 2021 isp->mmio_base_phys[res],
2022 isp->mmio_size[res]);
2055 if (!isp->mmio_base[res]) { 2023 if (!isp->mmio_base[res]) {
2056 dev_err(isp->dev, "cannot map camera register I/O region\n"); 2024 dev_err(isp->dev, "cannot map camera register I/O region\n");
2057 return -ENODEV; 2025 return -ENODEV;
@@ -2081,7 +2049,7 @@ static int isp_probe(struct platform_device *pdev)
2081 if (pdata == NULL) 2049 if (pdata == NULL)
2082 return -EINVAL; 2050 return -EINVAL;
2083 2051
2084 isp = kzalloc(sizeof(*isp), GFP_KERNEL); 2052 isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
2085 if (!isp) { 2053 if (!isp) {
2086 dev_err(&pdev->dev, "could not allocate memory\n"); 2054 dev_err(&pdev->dev, "could not allocate memory\n");
2087 return -ENOMEM; 2055 return -ENOMEM;
@@ -2104,8 +2072,8 @@ static int isp_probe(struct platform_device *pdev)
2104 platform_set_drvdata(pdev, isp); 2072 platform_set_drvdata(pdev, isp);
2105 2073
2106 /* Regulators */ 2074 /* Regulators */
2107 isp->isp_csiphy1.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY1"); 2075 isp->isp_csiphy1.vdd = devm_regulator_get(&pdev->dev, "VDD_CSIPHY1");
2108 isp->isp_csiphy2.vdd = regulator_get(&pdev->dev, "VDD_CSIPHY2"); 2076 isp->isp_csiphy2.vdd = devm_regulator_get(&pdev->dev, "VDD_CSIPHY2");
2109 2077
2110 /* Clocks 2078 /* Clocks
2111 * 2079 *
@@ -2180,7 +2148,8 @@ static int isp_probe(struct platform_device *pdev)
2180 goto detach_dev; 2148 goto detach_dev;
2181 } 2149 }
2182 2150
2183 if (request_irq(isp->irq_num, isp_isr, IRQF_SHARED, "OMAP3 ISP", isp)) { 2151 if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED,
2152 "OMAP3 ISP", isp)) {
2184 dev_err(isp->dev, "Unable to request IRQ\n"); 2153 dev_err(isp->dev, "Unable to request IRQ\n");
2185 ret = -EINVAL; 2154 ret = -EINVAL;
2186 goto detach_dev; 2155 goto detach_dev;
@@ -2189,7 +2158,7 @@ static int isp_probe(struct platform_device *pdev)
2189 /* Entities */ 2158 /* Entities */
2190 ret = isp_initialize_modules(isp); 2159 ret = isp_initialize_modules(isp);
2191 if (ret < 0) 2160 if (ret < 0)
2192 goto error_irq; 2161 goto detach_dev;
2193 2162
2194 ret = isp_register_entities(isp); 2163 ret = isp_register_entities(isp);
2195 if (ret < 0) 2164 if (ret < 0)
@@ -2202,8 +2171,6 @@ static int isp_probe(struct platform_device *pdev)
2202 2171
2203error_modules: 2172error_modules:
2204 isp_cleanup_modules(isp); 2173 isp_cleanup_modules(isp);
2205error_irq:
2206 free_irq(isp->irq_num, isp);
2207detach_dev: 2174detach_dev:
2208 iommu_detach_device(isp->domain, &pdev->dev); 2175 iommu_detach_device(isp->domain, &pdev->dev);
2209free_domain: 2176free_domain:
@@ -2211,26 +2178,9 @@ free_domain:
2211error_isp: 2178error_isp:
2212 omap3isp_put(isp); 2179 omap3isp_put(isp);
2213error: 2180error:
2214 isp_put_clocks(isp);
2215
2216 for (i = 0; i < OMAP3_ISP_IOMEM_LAST; i++) {
2217 if (isp->mmio_base[i]) {
2218 iounmap(isp->mmio_base[i]);
2219 isp->mmio_base[i] = NULL;
2220 }
2221
2222 if (isp->mmio_base_phys[i]) {
2223 release_mem_region(isp->mmio_base_phys[i],
2224 isp->mmio_size[i]);
2225 isp->mmio_base_phys[i] = 0;
2226 }
2227 }
2228 regulator_put(isp->isp_csiphy2.vdd);
2229 regulator_put(isp->isp_csiphy1.vdd);
2230 platform_set_drvdata(pdev, NULL); 2181 platform_set_drvdata(pdev, NULL);
2231 2182
2232 mutex_destroy(&isp->isp_mutex); 2183 mutex_destroy(&isp->isp_mutex);
2233 kfree(isp);
2234 2184
2235 return ret; 2185 return ret;
2236} 2186}
diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c
index 85f0de85f37c..c5d84c977e29 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -1136,7 +1136,7 @@ int omap3isp_ccp2_init(struct isp_device *isp)
1136 * TODO: Don't hardcode the usage of PHY1 (shared with CSI2c). 1136 * TODO: Don't hardcode the usage of PHY1 (shared with CSI2c).
1137 */ 1137 */
1138 if (isp->revision == ISP_REVISION_2_0) { 1138 if (isp->revision == ISP_REVISION_2_0) {
1139 ccp2->vdds_csib = regulator_get(isp->dev, "vdds_csib"); 1139 ccp2->vdds_csib = devm_regulator_get(isp->dev, "vdds_csib");
1140 if (IS_ERR(ccp2->vdds_csib)) { 1140 if (IS_ERR(ccp2->vdds_csib)) {
1141 dev_dbg(isp->dev, 1141 dev_dbg(isp->dev,
1142 "Could not get regulator vdds_csib\n"); 1142 "Could not get regulator vdds_csib\n");
@@ -1147,10 +1147,8 @@ int omap3isp_ccp2_init(struct isp_device *isp)
1147 } 1147 }
1148 1148
1149 ret = ccp2_init_entities(ccp2); 1149 ret = ccp2_init_entities(ccp2);
1150 if (ret < 0) { 1150 if (ret < 0)
1151 regulator_put(ccp2->vdds_csib);
1152 return ret; 1151 return ret;
1153 }
1154 1152
1155 ccp2_reset(ccp2); 1153 ccp2_reset(ccp2);
1156 return 0; 1154 return 0;
@@ -1166,6 +1164,4 @@ void omap3isp_ccp2_cleanup(struct isp_device *isp)
1166 1164
1167 omap3isp_video_cleanup(&ccp2->video_in); 1165 omap3isp_video_cleanup(&ccp2->video_in);
1168 media_entity_cleanup(&ccp2->subdev.entity); 1166 media_entity_cleanup(&ccp2->subdev.entity);
1169
1170 regulator_put(ccp2->vdds_csib);
1171} 1167}
diff --git a/drivers/media/platform/omap3isp/isph3a_aewb.c b/drivers/media/platform/omap3isp/isph3a_aewb.c
index 1b908fd2e3cf..75fd82b152ba 100644
--- a/drivers/media/platform/omap3isp/isph3a_aewb.c
+++ b/drivers/media/platform/omap3isp/isph3a_aewb.c
@@ -300,9 +300,8 @@ int omap3isp_h3a_aewb_init(struct isp_device *isp)
300 struct ispstat *aewb = &isp->isp_aewb; 300 struct ispstat *aewb = &isp->isp_aewb;
301 struct omap3isp_h3a_aewb_config *aewb_cfg; 301 struct omap3isp_h3a_aewb_config *aewb_cfg;
302 struct omap3isp_h3a_aewb_config *aewb_recover_cfg; 302 struct omap3isp_h3a_aewb_config *aewb_recover_cfg;
303 int ret;
304 303
305 aewb_cfg = kzalloc(sizeof(*aewb_cfg), GFP_KERNEL); 304 aewb_cfg = devm_kzalloc(isp->dev, sizeof(*aewb_cfg), GFP_KERNEL);
306 if (!aewb_cfg) 305 if (!aewb_cfg)
307 return -ENOMEM; 306 return -ENOMEM;
308 307
@@ -313,12 +312,12 @@ int omap3isp_h3a_aewb_init(struct isp_device *isp)
313 aewb->isp = isp; 312 aewb->isp = isp;
314 313
315 /* Set recover state configuration */ 314 /* Set recover state configuration */
316 aewb_recover_cfg = kzalloc(sizeof(*aewb_recover_cfg), GFP_KERNEL); 315 aewb_recover_cfg = devm_kzalloc(isp->dev, sizeof(*aewb_recover_cfg),
316 GFP_KERNEL);
317 if (!aewb_recover_cfg) { 317 if (!aewb_recover_cfg) {
318 dev_err(aewb->isp->dev, "AEWB: cannot allocate memory for " 318 dev_err(aewb->isp->dev, "AEWB: cannot allocate memory for "
319 "recover configuration.\n"); 319 "recover configuration.\n");
320 ret = -ENOMEM; 320 return -ENOMEM;
321 goto err_recover_alloc;
322 } 321 }
323 322
324 aewb_recover_cfg->saturation_limit = OMAP3ISP_AEWB_MAX_SATURATION_LIM; 323 aewb_recover_cfg->saturation_limit = OMAP3ISP_AEWB_MAX_SATURATION_LIM;
@@ -335,25 +334,13 @@ int omap3isp_h3a_aewb_init(struct isp_device *isp)
335 if (h3a_aewb_validate_params(aewb, aewb_recover_cfg)) { 334 if (h3a_aewb_validate_params(aewb, aewb_recover_cfg)) {
336 dev_err(aewb->isp->dev, "AEWB: recover configuration is " 335 dev_err(aewb->isp->dev, "AEWB: recover configuration is "
337 "invalid.\n"); 336 "invalid.\n");
338 ret = -EINVAL; 337 return -EINVAL;
339 goto err_conf;
340 } 338 }
341 339
342 aewb_recover_cfg->buf_size = h3a_aewb_get_buf_size(aewb_recover_cfg); 340 aewb_recover_cfg->buf_size = h3a_aewb_get_buf_size(aewb_recover_cfg);
343 aewb->recover_priv = aewb_recover_cfg; 341 aewb->recover_priv = aewb_recover_cfg;
344 342
345 ret = omap3isp_stat_init(aewb, "AEWB", &h3a_aewb_subdev_ops); 343 return omap3isp_stat_init(aewb, "AEWB", &h3a_aewb_subdev_ops);
346 if (ret)
347 goto err_conf;
348
349 return 0;
350
351err_conf:
352 kfree(aewb_recover_cfg);
353err_recover_alloc:
354 kfree(aewb_cfg);
355
356 return ret;
357} 344}
358 345
359/* 346/*
@@ -361,7 +348,5 @@ err_recover_alloc:
361 */ 348 */
362void omap3isp_h3a_aewb_cleanup(struct isp_device *isp) 349void omap3isp_h3a_aewb_cleanup(struct isp_device *isp)
363{ 350{
364 kfree(isp->isp_aewb.priv);
365 kfree(isp->isp_aewb.recover_priv);
366 omap3isp_stat_cleanup(&isp->isp_aewb); 351 omap3isp_stat_cleanup(&isp->isp_aewb);
367} 352}
diff --git a/drivers/media/platform/omap3isp/isph3a_af.c b/drivers/media/platform/omap3isp/isph3a_af.c
index d645b418ca6a..a0bf5af32438 100644
--- a/drivers/media/platform/omap3isp/isph3a_af.c
+++ b/drivers/media/platform/omap3isp/isph3a_af.c
@@ -363,9 +363,8 @@ int omap3isp_h3a_af_init(struct isp_device *isp)
363 struct ispstat *af = &isp->isp_af; 363 struct ispstat *af = &isp->isp_af;
364 struct omap3isp_h3a_af_config *af_cfg; 364 struct omap3isp_h3a_af_config *af_cfg;
365 struct omap3isp_h3a_af_config *af_recover_cfg; 365 struct omap3isp_h3a_af_config *af_recover_cfg;
366 int ret;
367 366
368 af_cfg = kzalloc(sizeof(*af_cfg), GFP_KERNEL); 367 af_cfg = devm_kzalloc(isp->dev, sizeof(*af_cfg), GFP_KERNEL);
369 if (af_cfg == NULL) 368 if (af_cfg == NULL)
370 return -ENOMEM; 369 return -ENOMEM;
371 370
@@ -376,12 +375,12 @@ int omap3isp_h3a_af_init(struct isp_device *isp)
376 af->isp = isp; 375 af->isp = isp;
377 376
378 /* Set recover state configuration */ 377 /* Set recover state configuration */
379 af_recover_cfg = kzalloc(sizeof(*af_recover_cfg), GFP_KERNEL); 378 af_recover_cfg = devm_kzalloc(isp->dev, sizeof(*af_recover_cfg),
379 GFP_KERNEL);
380 if (!af_recover_cfg) { 380 if (!af_recover_cfg) {
381 dev_err(af->isp->dev, "AF: cannot allocate memory for recover " 381 dev_err(af->isp->dev, "AF: cannot allocate memory for recover "
382 "configuration.\n"); 382 "configuration.\n");
383 ret = -ENOMEM; 383 return -ENOMEM;
384 goto err_recover_alloc;
385 } 384 }
386 385
387 af_recover_cfg->paxel.h_start = OMAP3ISP_AF_PAXEL_HZSTART_MIN; 386 af_recover_cfg->paxel.h_start = OMAP3ISP_AF_PAXEL_HZSTART_MIN;
@@ -393,30 +392,16 @@ int omap3isp_h3a_af_init(struct isp_device *isp)
393 if (h3a_af_validate_params(af, af_recover_cfg)) { 392 if (h3a_af_validate_params(af, af_recover_cfg)) {
394 dev_err(af->isp->dev, "AF: recover configuration is " 393 dev_err(af->isp->dev, "AF: recover configuration is "
395 "invalid.\n"); 394 "invalid.\n");
396 ret = -EINVAL; 395 return -EINVAL;
397 goto err_conf;
398 } 396 }
399 397
400 af_recover_cfg->buf_size = h3a_af_get_buf_size(af_recover_cfg); 398 af_recover_cfg->buf_size = h3a_af_get_buf_size(af_recover_cfg);
401 af->recover_priv = af_recover_cfg; 399 af->recover_priv = af_recover_cfg;
402 400
403 ret = omap3isp_stat_init(af, "AF", &h3a_af_subdev_ops); 401 return omap3isp_stat_init(af, "AF", &h3a_af_subdev_ops);
404 if (ret)
405 goto err_conf;
406
407 return 0;
408
409err_conf:
410 kfree(af_recover_cfg);
411err_recover_alloc:
412 kfree(af_cfg);
413
414 return ret;
415} 402}
416 403
417void omap3isp_h3a_af_cleanup(struct isp_device *isp) 404void omap3isp_h3a_af_cleanup(struct isp_device *isp)
418{ 405{
419 kfree(isp->isp_af.priv);
420 kfree(isp->isp_af.recover_priv);
421 omap3isp_stat_cleanup(&isp->isp_af); 406 omap3isp_stat_cleanup(&isp->isp_af);
422} 407}
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c
index da2fa98b501a..2ccc4e5702b2 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -477,7 +477,7 @@ int omap3isp_hist_init(struct isp_device *isp)
477 struct omap3isp_hist_config *hist_cfg; 477 struct omap3isp_hist_config *hist_cfg;
478 int ret = -1; 478 int ret = -1;
479 479
480 hist_cfg = kzalloc(sizeof(*hist_cfg), GFP_KERNEL); 480 hist_cfg = devm_kzalloc(isp->dev, sizeof(*hist_cfg), GFP_KERNEL);
481 if (hist_cfg == NULL) 481 if (hist_cfg == NULL)
482 return -ENOMEM; 482 return -ENOMEM;
483 483
@@ -503,7 +503,6 @@ int omap3isp_hist_init(struct isp_device *isp)
503 503
504 ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops); 504 ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops);
505 if (ret) { 505 if (ret) {
506 kfree(hist_cfg);
507 if (HIST_USING_DMA(hist)) 506 if (HIST_USING_DMA(hist))
508 omap_free_dma(hist->dma_ch); 507 omap_free_dma(hist->dma_ch);
509 } 508 }
@@ -518,6 +517,5 @@ void omap3isp_hist_cleanup(struct isp_device *isp)
518{ 517{
519 if (HIST_USING_DMA(&isp->isp_hist)) 518 if (HIST_USING_DMA(&isp->isp_hist))
520 omap_free_dma(isp->isp_hist.dma_ch); 519 omap_free_dma(isp->isp_hist.dma_ch);
521 kfree(isp->isp_hist.priv);
522 omap3isp_stat_cleanup(&isp->isp_hist); 520 omap3isp_stat_cleanup(&isp->isp_hist);
523} 521}