#include "dp_audio.h"
 #include "dp_debug.h"
 
-static struct msm_dp *g_dp_display;
 #define HPD_STRING_SIZE 30
 
 enum {
        {}
 };
 
+static struct dp_display_private *dev_get_dp_display_private(struct device *dev)
+{
+       struct msm_dp *dp = dev_get_drvdata(dev);
+
+       return container_of(dp, struct dp_display_private, dp_display);
+}
+
 static int dp_add_event(struct dp_display_private *dp_priv, u32 event,
                                                u32 data, u32 delay)
 {
                           void *data)
 {
        int rc = 0;
-       struct dp_display_private *dp;
-       struct drm_device *drm;
+       struct dp_display_private *dp = dev_get_dp_display_private(dev);
        struct msm_drm_private *priv;
+       struct drm_device *drm;
 
        drm = dev_get_drvdata(master);
 
-       dp = container_of(g_dp_display,
-                       struct dp_display_private, dp_display);
-
        dp->dp_display.drm_dev = drm;
        priv = drm->dev_private;
        priv->dp = &(dp->dp_display);
 static void dp_display_unbind(struct device *dev, struct device *master,
                              void *data)
 {
-       struct dp_display_private *dp;
+       struct dp_display_private *dp = dev_get_dp_display_private(dev);
        struct drm_device *drm = dev_get_drvdata(master);
        struct msm_drm_private *priv = drm->dev_private;
 
-       dp = container_of(g_dp_display,
-                       struct dp_display_private, dp_display);
-
        dp_power_client_deinit(dp->power);
        dp_aux_unregister(dp->aux);
        priv->dp = NULL;
 
 static int dp_display_usbpd_configure_cb(struct device *dev)
 {
-       int rc = 0;
-       struct dp_display_private *dp;
-
-       if (!dev) {
-               DRM_ERROR("invalid dev\n");
-               rc = -EINVAL;
-               goto end;
-       }
-
-       dp = container_of(g_dp_display,
-                       struct dp_display_private, dp_display);
+       struct dp_display_private *dp = dev_get_dp_display_private(dev);
 
        dp_display_host_init(dp, false);
 
-       rc = dp_display_process_hpd_high(dp);
-end:
-       return rc;
+       return dp_display_process_hpd_high(dp);
 }
 
 static int dp_display_usbpd_disconnect_cb(struct device *dev)
 {
        int rc = 0;
-       struct dp_display_private *dp;
-
-       if (!dev) {
-               DRM_ERROR("invalid dev\n");
-               rc = -EINVAL;
-               return rc;
-       }
-
-       dp = container_of(g_dp_display,
-                       struct dp_display_private, dp_display);
+       struct dp_display_private *dp = dev_get_dp_display_private(dev);
 
        dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
 
 {
        int rc = 0;
        u32 sink_request;
-       struct dp_display_private *dp;
-
-       if (!dev) {
-               DRM_ERROR("invalid dev\n");
-               return -EINVAL;
-       }
-
-       dp = container_of(g_dp_display,
-                       struct dp_display_private, dp_display);
+       struct dp_display_private *dp = dev_get_dp_display_private(dev);
 
        /* check for any test request issued by sink */
        rc = dp_link_process_request(dp->link);
 
        DRM_DEBUG_DP("hpd_state=%d\n", state);
        /* signal the disconnect event early to ensure proper teardown */
-       dp_display_handle_plugged_change(g_dp_display, false);
+       dp_display_handle_plugged_change(&dp->dp_display, false);
 
        /* enable HDP plug interrupt to prepare for next plugin */
        dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_PLUG_INT_MASK, true);
 static int dp_display_enable(struct dp_display_private *dp, u32 data)
 {
        int rc = 0;
-       struct msm_dp *dp_display;
-
-       dp_display = g_dp_display;
+       struct msm_dp *dp_display = &dp->dp_display;
 
        DRM_DEBUG_DP("sink_count=%d\n", dp->link->sink_count);
        if (dp_display->power_on) {
 
 static int dp_display_disable(struct dp_display_private *dp, u32 data)
 {
-       struct msm_dp *dp_display;
-
-       dp_display = g_dp_display;
+       struct msm_dp *dp_display = &dp->dp_display;
 
        if (!dp_display->power_on)
                return 0;
        }
 
        mutex_init(&dp->event_mutex);
-       g_dp_display = &dp->dp_display;
 
        /* Store DP audio handle inside DP display */
-       g_dp_display->dp_audio = dp->audio;
+       dp->dp_display.dp_audio = dp->audio;
 
        init_completion(&dp->audio_comp);
 
-       platform_set_drvdata(pdev, g_dp_display);
+       platform_set_drvdata(pdev, &dp->dp_display);
 
        rc = component_add(&pdev->dev, &dp_display_comp_ops);
        if (rc) {
 
 static int dp_display_remove(struct platform_device *pdev)
 {
-       struct dp_display_private *dp;
-
-       dp = container_of(g_dp_display,
-                       struct dp_display_private, dp_display);
+       struct dp_display_private *dp = dev_get_dp_display_private(&pdev->dev);
 
        dp_display_deinit_sub_modules(dp);
 
                dp->dp_display.is_connected = true;
        } else {
                dp->dp_display.is_connected = false;
-               dp_display_handle_plugged_change(g_dp_display, false);
+               dp_display_handle_plugged_change(dp_display, false);
        }
 
        DRM_DEBUG_DP("After, sink_count=%d is_connected=%d core_inited=%d power_on=%d\n",