aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_lspcon.c
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2016-10-24 12:33:30 -0400
committerImre Deak <imre.deak@intel.com>2016-10-26 05:41:01 -0400
commita5d94b83ec709dbd90f17cba79142fde123d3869 (patch)
tree3e8bf393d99a22c4b83a03577472774929acd6d6 /drivers/gpu/drm/i915/intel_lspcon.c
parent12a47a422862214d3a715a0bd93140b8176dcdc9 (diff)
drm/i915/lspcon: Get DDC adapter via container_of() instead of cached ptr
We can use the container_of() magic to get to the DDC adapter, so no need for caching a pointer to it. We'll also need to get at the intel_dp ptr in the following patch, so add a helper that can be used for both purposes. Cc: Shashank Sharma <shashank.sharma@intel.com> Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1477326811-30431-8-git-send-email-imre.deak@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/intel_lspcon.c')
-rw-r--r--drivers/gpu/drm/i915/intel_lspcon.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
index c5f278b250a7..3dc5a0be7857 100644
--- a/drivers/gpu/drm/i915/intel_lspcon.c
+++ b/drivers/gpu/drm/i915/intel_lspcon.c
@@ -27,10 +27,18 @@
27#include <drm/drm_dp_dual_mode_helper.h> 27#include <drm/drm_dp_dual_mode_helper.h>
28#include "intel_drv.h" 28#include "intel_drv.h"
29 29
30static struct intel_dp *lspcon_to_intel_dp(struct intel_lspcon *lspcon)
31{
32 struct intel_digital_port *dig_port =
33 container_of(lspcon, struct intel_digital_port, lspcon);
34
35 return &dig_port->dp;
36}
37
30static enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon) 38static enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon)
31{ 39{
32 enum drm_lspcon_mode current_mode = DRM_LSPCON_MODE_INVALID; 40 enum drm_lspcon_mode current_mode = DRM_LSPCON_MODE_INVALID;
33 struct i2c_adapter *adapter = &lspcon->aux->ddc; 41 struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc;
34 42
35 if (drm_lspcon_get_mode(adapter, &current_mode)) 43 if (drm_lspcon_get_mode(adapter, &current_mode))
36 DRM_ERROR("Error reading LSPCON mode\n"); 44 DRM_ERROR("Error reading LSPCON mode\n");
@@ -45,7 +53,7 @@ static int lspcon_change_mode(struct intel_lspcon *lspcon,
45{ 53{
46 int err; 54 int err;
47 enum drm_lspcon_mode current_mode; 55 enum drm_lspcon_mode current_mode;
48 struct i2c_adapter *adapter = &lspcon->aux->ddc; 56 struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc;
49 57
50 err = drm_lspcon_get_mode(adapter, &current_mode); 58 err = drm_lspcon_get_mode(adapter, &current_mode);
51 if (err) { 59 if (err) {
@@ -72,7 +80,7 @@ static int lspcon_change_mode(struct intel_lspcon *lspcon,
72static bool lspcon_probe(struct intel_lspcon *lspcon) 80static bool lspcon_probe(struct intel_lspcon *lspcon)
73{ 81{
74 enum drm_dp_dual_mode_type adaptor_type; 82 enum drm_dp_dual_mode_type adaptor_type;
75 struct i2c_adapter *adapter = &lspcon->aux->ddc; 83 struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc;
76 84
77 /* Lets probe the adaptor and check its type */ 85 /* Lets probe the adaptor and check its type */
78 adaptor_type = drm_dp_dual_mode_detect(adapter); 86 adaptor_type = drm_dp_dual_mode_detect(adapter);
@@ -111,7 +119,6 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
111 119
112 lspcon->active = false; 120 lspcon->active = false;
113 lspcon->mode = DRM_LSPCON_MODE_INVALID; 121 lspcon->mode = DRM_LSPCON_MODE_INVALID;
114 lspcon->aux = &dp->aux;
115 122
116 if (!lspcon_probe(lspcon)) { 123 if (!lspcon_probe(lspcon)) {
117 DRM_ERROR("Failed to probe lspcon\n"); 124 DRM_ERROR("Failed to probe lspcon\n");