drm/stm: ltdc: add devm_reset_control & platform_get_ressource
authorPhilippe CORNU <philippe.cornu@st.com>
Thu, 20 Jul 2017 12:05:55 +0000 (14:05 +0200)
committerBenjamin Gaignard <benjamin.gaignard@linaro.org>
Wed, 26 Jul 2017 13:02:00 +0000 (15:02 +0200)
Use devm_reset_control_get_exclusive to avoid resource leakage (based
on patch "Convert drivers to explicit reset API" from Philipp Zabel).

Also use platform_get_resource, which is more usual and
consistent with platform_get_irq called later.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Signed-off-by: Philippe CORNU <philippe.cornu@st.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1500552357-29487-6-git-send-email-philippe.cornu@st.com
drivers/gpu/drm/stm/ltdc.c

index 92e58ba542b6100dfe8083f5d3854708b9e37411..d826045130ff2f6070a940b78bbda4145edb5c64 100644 (file)
@@ -874,7 +874,7 @@ int ltdc_load(struct drm_device *ddev)
        struct drm_panel *panel;
        struct drm_crtc *crtc;
        struct reset_control *rstc;
-       struct resource res;
+       struct resource *res;
        int irq, ret, i;
 
        DRM_DEBUG_DRIVER("\n");
@@ -883,7 +883,7 @@ int ltdc_load(struct drm_device *ddev)
        if (ret)
                return ret;
 
-       rstc = of_reset_control_get(np, NULL);
+       rstc = devm_reset_control_get_exclusive(dev, NULL);
 
        mutex_init(&ldev->err_lock);
 
@@ -898,13 +898,14 @@ int ltdc_load(struct drm_device *ddev)
                return -ENODEV;
        }
 
-       if (of_address_to_resource(np, 0, &res)) {
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res) {
                DRM_ERROR("Unable to get resource\n");
                ret = -ENODEV;
                goto err;
        }
 
-       ldev->regs = devm_ioremap_resource(dev, &res);
+       ldev->regs = devm_ioremap_resource(dev, res);
        if (IS_ERR(ldev->regs)) {
                DRM_ERROR("Unable to get ltdc registers\n");
                ret = PTR_ERR(ldev->regs);