aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-11-23 03:43:27 -0500
committerInki Dae <inki.dae@samsung.com>2012-12-05 00:39:22 -0500
commit9f49d9fba35df369482ee39905f90372e86b4439 (patch)
tree97d9dffb0d87d977bd43199d1d933081938e9ed9
parent37f508614e04cfc4a7a2cc0f286efd5d4bde4d23 (diff)
drm/exynos: Use devm_* APIs in exynos_hdmi.c
devm_* functions are device managed and make error handling and exit code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c60
1 files changed, 13 insertions, 47 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index a4052271a1f6..9f017748e730 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2176,27 +2176,27 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
2176 memset(res, 0, sizeof(*res)); 2176 memset(res, 0, sizeof(*res));
2177 2177
2178 /* get clocks, power */ 2178 /* get clocks, power */
2179 res->hdmi = clk_get(dev, "hdmi"); 2179 res->hdmi = devm_clk_get(dev, "hdmi");
2180 if (IS_ERR_OR_NULL(res->hdmi)) { 2180 if (IS_ERR_OR_NULL(res->hdmi)) {
2181 DRM_ERROR("failed to get clock 'hdmi'\n"); 2181 DRM_ERROR("failed to get clock 'hdmi'\n");
2182 goto fail; 2182 goto fail;
2183 } 2183 }
2184 res->sclk_hdmi = clk_get(dev, "sclk_hdmi"); 2184 res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
2185 if (IS_ERR_OR_NULL(res->sclk_hdmi)) { 2185 if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
2186 DRM_ERROR("failed to get clock 'sclk_hdmi'\n"); 2186 DRM_ERROR("failed to get clock 'sclk_hdmi'\n");
2187 goto fail; 2187 goto fail;
2188 } 2188 }
2189 res->sclk_pixel = clk_get(dev, "sclk_pixel"); 2189 res->sclk_pixel = devm_clk_get(dev, "sclk_pixel");
2190 if (IS_ERR_OR_NULL(res->sclk_pixel)) { 2190 if (IS_ERR_OR_NULL(res->sclk_pixel)) {
2191 DRM_ERROR("failed to get clock 'sclk_pixel'\n"); 2191 DRM_ERROR("failed to get clock 'sclk_pixel'\n");
2192 goto fail; 2192 goto fail;
2193 } 2193 }
2194 res->sclk_hdmiphy = clk_get(dev, "sclk_hdmiphy"); 2194 res->sclk_hdmiphy = devm_clk_get(dev, "sclk_hdmiphy");
2195 if (IS_ERR_OR_NULL(res->sclk_hdmiphy)) { 2195 if (IS_ERR_OR_NULL(res->sclk_hdmiphy)) {
2196 DRM_ERROR("failed to get clock 'sclk_hdmiphy'\n"); 2196 DRM_ERROR("failed to get clock 'sclk_hdmiphy'\n");
2197 goto fail; 2197 goto fail;
2198 } 2198 }
2199 res->hdmiphy = clk_get(dev, "hdmiphy"); 2199 res->hdmiphy = devm_clk_get(dev, "hdmiphy");
2200 if (IS_ERR_OR_NULL(res->hdmiphy)) { 2200 if (IS_ERR_OR_NULL(res->hdmiphy)) {
2201 DRM_ERROR("failed to get clock 'hdmiphy'\n"); 2201 DRM_ERROR("failed to get clock 'hdmiphy'\n");
2202 goto fail; 2202 goto fail;
@@ -2204,7 +2204,7 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
2204 2204
2205 clk_set_parent(res->sclk_hdmi, res->sclk_pixel); 2205 clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
2206 2206
2207 res->regul_bulk = kzalloc(ARRAY_SIZE(supply) * 2207 res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) *
2208 sizeof(res->regul_bulk[0]), GFP_KERNEL); 2208 sizeof(res->regul_bulk[0]), GFP_KERNEL);
2209 if (!res->regul_bulk) { 2209 if (!res->regul_bulk) {
2210 DRM_ERROR("failed to get memory for regulators\n"); 2210 DRM_ERROR("failed to get memory for regulators\n");
@@ -2214,7 +2214,7 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
2214 res->regul_bulk[i].supply = supply[i]; 2214 res->regul_bulk[i].supply = supply[i];
2215 res->regul_bulk[i].consumer = NULL; 2215 res->regul_bulk[i].consumer = NULL;
2216 } 2216 }
2217 ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk); 2217 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
2218 if (ret) { 2218 if (ret) {
2219 DRM_ERROR("failed to get regulators\n"); 2219 DRM_ERROR("failed to get regulators\n");
2220 goto fail; 2220 goto fail;
@@ -2227,28 +2227,6 @@ fail:
2227 return -ENODEV; 2227 return -ENODEV;
2228} 2228}
2229 2229
2230static int hdmi_resources_cleanup(struct hdmi_context *hdata)
2231{
2232 struct hdmi_resources *res = &hdata->res;
2233
2234 regulator_bulk_free(res->regul_count, res->regul_bulk);
2235 /* kfree is NULL-safe */
2236 kfree(res->regul_bulk);
2237 if (!IS_ERR_OR_NULL(res->hdmiphy))
2238 clk_put(res->hdmiphy);
2239 if (!IS_ERR_OR_NULL(res->sclk_hdmiphy))
2240 clk_put(res->sclk_hdmiphy);
2241 if (!IS_ERR_OR_NULL(res->sclk_pixel))
2242 clk_put(res->sclk_pixel);
2243 if (!IS_ERR_OR_NULL(res->sclk_hdmi))
2244 clk_put(res->sclk_hdmi);
2245 if (!IS_ERR_OR_NULL(res->hdmi))
2246 clk_put(res->hdmi);
2247 memset(res, 0, sizeof(*res));
2248
2249 return 0;
2250}
2251
2252static struct i2c_client *hdmi_ddc, *hdmi_hdmiphy; 2230static struct i2c_client *hdmi_ddc, *hdmi_hdmiphy;
2253 2231
2254void hdmi_attach_ddc_client(struct i2c_client *ddc) 2232void hdmi_attach_ddc_client(struct i2c_client *ddc)
@@ -2388,36 +2366,32 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2388 ret = hdmi_resources_init(hdata); 2366 ret = hdmi_resources_init(hdata);
2389 2367
2390 if (ret) { 2368 if (ret) {
2391 ret = -EINVAL;
2392 DRM_ERROR("hdmi_resources_init failed\n"); 2369 DRM_ERROR("hdmi_resources_init failed\n");
2393 goto err_data; 2370 return -EINVAL;
2394 } 2371 }
2395 2372
2396 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2373 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2397 if (!res) { 2374 if (!res) {
2398 DRM_ERROR("failed to find registers\n"); 2375 DRM_ERROR("failed to find registers\n");
2399 ret = -ENOENT; 2376 return -ENOENT;
2400 goto err_resource;
2401 } 2377 }
2402 2378
2403 hdata->regs = devm_request_and_ioremap(&pdev->dev, res); 2379 hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
2404 if (!hdata->regs) { 2380 if (!hdata->regs) {
2405 DRM_ERROR("failed to map registers\n"); 2381 DRM_ERROR("failed to map registers\n");
2406 ret = -ENXIO; 2382 return -ENXIO;
2407 goto err_resource;
2408 } 2383 }
2409 2384
2410 ret = gpio_request(hdata->hpd_gpio, "HPD"); 2385 ret = devm_gpio_request(&pdev->dev, hdata->hpd_gpio, "HPD");
2411 if (ret) { 2386 if (ret) {
2412 DRM_ERROR("failed to request HPD gpio\n"); 2387 DRM_ERROR("failed to request HPD gpio\n");
2413 goto err_resource; 2388 return ret;
2414 } 2389 }
2415 2390
2416 /* DDC i2c driver */ 2391 /* DDC i2c driver */
2417 if (i2c_add_driver(&ddc_driver)) { 2392 if (i2c_add_driver(&ddc_driver)) {
2418 DRM_ERROR("failed to register ddc i2c driver\n"); 2393 DRM_ERROR("failed to register ddc i2c driver\n");
2419 ret = -ENOENT; 2394 return -ENOENT;
2420 goto err_gpio;
2421 } 2395 }
2422 2396
2423 hdata->ddc_port = hdmi_ddc; 2397 hdata->ddc_port = hdmi_ddc;
@@ -2480,11 +2454,6 @@ err_hdmiphy:
2480 i2c_del_driver(&hdmiphy_driver); 2454 i2c_del_driver(&hdmiphy_driver);
2481err_ddc: 2455err_ddc:
2482 i2c_del_driver(&ddc_driver); 2456 i2c_del_driver(&ddc_driver);
2483err_gpio:
2484 gpio_free(hdata->hpd_gpio);
2485err_resource:
2486 hdmi_resources_cleanup(hdata);
2487err_data:
2488 return ret; 2457 return ret;
2489} 2458}
2490 2459
@@ -2501,9 +2470,6 @@ static int __devexit hdmi_remove(struct platform_device *pdev)
2501 free_irq(hdata->internal_irq, hdata); 2470 free_irq(hdata->internal_irq, hdata);
2502 free_irq(hdata->external_irq, hdata); 2471 free_irq(hdata->external_irq, hdata);
2503 2472
2504 gpio_free(hdata->hpd_gpio);
2505
2506 hdmi_resources_cleanup(hdata);
2507 2473
2508 /* hdmiphy i2c driver */ 2474 /* hdmiphy i2c driver */
2509 i2c_del_driver(&hdmiphy_driver); 2475 i2c_del_driver(&hdmiphy_driver);