gfx: drv: tc35876x: don't oops if functions are called before probe
authorJani Nikula <jani.nikula@intel.com>
Fri, 4 Nov 2011 13:32:39 +0000 (15:32 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:28:32 +0000 (12:28 +0300)
The whole driver has serious design issues due to the rest of the display
controller code calling the driver's functions directly. In some (typically
failure) circumstances the calls might come in before the driver has
probed. Don't oops in such cases, but emit a warning. The proper fix will
require some redesign and rework later on.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/staging/mrst/drv/tc35876x-dsi-lvds.c

index 727c9dd..9f8fd56 100644 (file)
@@ -286,7 +286,9 @@ void tc35876x_set_bridge_reset_state(int state)
 {
        struct tc35876x_platform_data *pdata;
 
-       WARN_ON(!tc35876x_client);
+       if (WARN(!tc35876x_client, "%s called before probe", __func__))
+               return;
+
        dev_dbg(&tc35876x_client->dev, "%s: state %d\n", __func__, state);
 
        pdata = dev_get_platdata(&tc35876x_client->dev);
@@ -315,7 +317,9 @@ void tc35876x_configure_lvds_bridge(struct drm_device *dev)
        u32 txtasurecnt;
        u32 id;
 
-       WARN_ON(!tc35876x_client);
+       if (WARN(!tc35876x_client, "%s called before probe", __func__))
+               return;
+
        dev_dbg(&tc35876x_client->dev, "%s\n", __func__);
 
        tc35876x_regr(i2c, IDREG, &id);
@@ -391,7 +395,9 @@ void tc35876x_toshiba_bridge_panel_off(void)
 {
        struct tc35876x_platform_data *pdata;
 
-       WARN_ON(!tc35876x_client);
+       if (WARN(!tc35876x_client, "%s called before probe", __func__))
+               return;
+
        dev_dbg(&tc35876x_client->dev, "%s\n", __func__);
 
        if (pdata->gpio_panel_bl_en != -1)
@@ -405,7 +411,9 @@ void tc35876x_toshiba_bridge_panel_on(void)
 {
        struct tc35876x_platform_data *pdata;
 
-       WARN_ON(!tc35876x_client);
+       if (WARN(!tc35876x_client, "%s called before probe", __func__))
+               return;
+
        dev_dbg(&tc35876x_client->dev, "%s\n", __func__);
 
        pdata = dev_get_platdata(&tc35876x_client->dev);
@@ -422,7 +430,9 @@ void tc35876x_toshiba_bridge_panel_on(void)
 
 void tc35876x_bridge_get_display_params(struct drm_display_mode *mode)
 {
-       WARN_ON(!tc35876x_client);
+       if (WARN(!tc35876x_client, "%s called before probe", __func__))
+               return;
+
        dev_dbg(&tc35876x_client->dev, "%s\n", __func__);
 
        /* FIXME: do this properly. */