drm/sun4i: Make sun4i_crtc_init return ERR_PTR style error codes
authorChen-Yu Tsai <wens@csie.org>
Fri, 17 Feb 2017 03:13:30 +0000 (11:13 +0800)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Tue, 7 Mar 2017 21:15:15 +0000 (22:15 +0100)
sun4i_crtc_init can fail for a number of reasons. Instead of returning
a NULL pointer when it fails, pass back the encountered error using
ERR_PTR.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
drivers/gpu/drm/sun4i/sun4i_crtc.c
drivers/gpu/drm/sun4i/sun4i_drv.c

index a5d546a..7d332fc 100644 (file)
@@ -145,7 +145,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
 
        scrtc = devm_kzalloc(drm->dev, sizeof(*scrtc), GFP_KERNEL);
        if (!scrtc)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        scrtc->drv = drv;
 
        ret = drm_crtc_init_with_planes(drm, &scrtc->crtc,
@@ -155,7 +155,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
                                        NULL);
        if (ret) {
                dev_err(drm->dev, "Couldn't init DRM CRTC\n");
-               return NULL;
+               return ERR_PTR(ret);
        }
 
        drm_crtc_helper_add(&scrtc->crtc, &sun4i_crtc_helper_funcs);
index 46887c3..9adf126 100644 (file)
@@ -125,9 +125,9 @@ static int sun4i_drv_bind(struct device *dev)
 
        /* Create our CRTC */
        drv->crtc = sun4i_crtc_init(drm);
-       if (!drv->crtc) {
+       if (IS_ERR(drv->crtc)) {
                dev_err(drm->dev, "Couldn't create the CRTC\n");
-               ret = -EINVAL;
+               ret = PTR_ERR(drv->crtc);
                goto cleanup_mode_config;
        }
        drm->irq_enabled = true;