drm/tilcdc: Fix tilcdc_crtc_create() return value handling
authorJyri Sarha <jsarha@ti.com>
Tue, 15 Nov 2016 20:56:46 +0000 (22:56 +0200)
committerJyri Sarha <jsarha@ti.com>
Wed, 30 Nov 2016 12:18:53 +0000 (14:18 +0200)
Failed tilcdc_crtc_create() error handling was broken, this patch
should fix it.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/gpu/drm/tilcdc/tilcdc_crtc.c
drivers/gpu/drm/tilcdc/tilcdc_drv.c
drivers/gpu/drm/tilcdc/tilcdc_drv.h

index 7ea34c21c3840076f3503ad9f8168bddf417cfdc..4605942b0ab93508838f0bd648a75716a0666682 100644 (file)
@@ -957,7 +957,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
        return IRQ_HANDLED;
 }
 
-struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
+int tilcdc_crtc_create(struct drm_device *dev)
 {
        struct tilcdc_drm_private *priv = dev->dev_private;
        struct tilcdc_crtc *tilcdc_crtc;
@@ -967,7 +967,7 @@ struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
        tilcdc_crtc = devm_kzalloc(dev->dev, sizeof(*tilcdc_crtc), GFP_KERNEL);
        if (!tilcdc_crtc) {
                dev_err(dev->dev, "allocation failed\n");
-               return NULL;
+               return -ENOMEM;
        }
 
        if (priv->rev == 1) {
@@ -977,7 +977,7 @@ struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
                                        &tilcdc_crtc->palette_dma_handle,
                                        GFP_KERNEL | __GFP_ZERO);
                if (!tilcdc_crtc->palette_base)
-                       return ERR_PTR(-ENOMEM);
+                       return -ENOMEM;
        }
 
        crtc = &tilcdc_crtc->base;
@@ -1020,13 +1020,15 @@ struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
                if (!crtc->port) { /* This should never happen */
                        dev_err(dev->dev, "Port node not found in %s\n",
                                dev->dev->of_node->full_name);
+                       ret = -EINVAL;
                        goto fail;
                }
        }
 
-       return crtc;
+       priv->crtc = crtc;
+       return 0;
 
 fail:
        tilcdc_crtc_destroy(crtc);
-       return NULL;
+       return -ENOMEM;
 }
index 7f4d3bc7152f482a11d6d2876eab91d6703d0382..b1bbbfefa72871c49a0ee514a2e613dd3d0ab7ff 100644 (file)
@@ -153,13 +153,11 @@ static const struct drm_mode_config_funcs mode_config_funcs = {
        .atomic_commit = tilcdc_commit,
 };
 
-static int modeset_init(struct drm_device *dev)
+static void modeset_init(struct drm_device *dev)
 {
        struct tilcdc_drm_private *priv = dev->dev_private;
        struct tilcdc_module *mod;
 
-       priv->crtc = tilcdc_crtc_create(dev);
-
        list_for_each_entry(mod, &module_list, list) {
                DBG("loading module: %s", mod->name);
                mod->funcs->modeset_init(mod, dev);
@@ -170,8 +168,6 @@ static int modeset_init(struct drm_device *dev)
        dev->mode_config.max_width = tilcdc_crtc_max_width(priv->crtc);
        dev->mode_config.max_height = 2048;
        dev->mode_config.funcs = &mode_config_funcs;
-
-       return 0;
 }
 
 #ifdef CONFIG_CPU_FREQ
@@ -370,11 +366,12 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
                }
        }
 
-       ret = modeset_init(ddev);
+       ret = tilcdc_crtc_create(ddev);
        if (ret < 0) {
-               dev_err(dev, "failed to initialize mode setting\n");
+               dev_err(dev, "failed to create crtc\n");
                goto init_failed;
        }
+       modeset_init(ddev);
 
        if (priv->is_componentized) {
                ret = component_bind_all(dev, ddev);
index 411f8a8d815898de36406f16a128305c05b4f4b0..0e71daf5b5cb30ec2dfa756ece83156122e4f2b9 100644 (file)
@@ -168,7 +168,7 @@ struct tilcdc_panel_info {
 
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 
-struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
+int tilcdc_crtc_create(struct drm_device *dev);
 irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
 void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
 void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,