Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+11 -5
-1
drivers/gpu/drm/i915/intel_drv.h
··· 974 974 struct intel_lspcon { 975 975 bool active; 976 976 enum drm_lspcon_mode mode; 977 - struct drm_dp_aux *aux; 978 977 }; 979 978 980 979 struct intel_digital_port {
+11 -4
drivers/gpu/drm/i915/intel_lspcon.c
··· 27 27 #include <drm/drm_dp_dual_mode_helper.h> 28 28 #include "intel_drv.h" 29 29 30 + static 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 + 30 38 static enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon) 31 39 { 32 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 43 if (drm_lspcon_get_mode(adapter, &current_mode)) 36 44 DRM_ERROR("Error reading LSPCON mode\n"); ··· 53 45 { 54 46 int err; 55 47 enum drm_lspcon_mode current_mode; 56 - struct i2c_adapter *adapter = &lspcon->aux->ddc; 48 + struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc; 57 49 58 50 err = drm_lspcon_get_mode(adapter, &current_mode); 59 51 if (err) { ··· 80 72 static bool lspcon_probe(struct intel_lspcon *lspcon) 81 73 { 82 74 enum drm_dp_dual_mode_type adaptor_type; 83 - struct i2c_adapter *adapter = &lspcon->aux->ddc; 75 + struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc; 84 76 85 77 /* Lets probe the adaptor and check its type */ 86 78 adaptor_type = drm_dp_dual_mode_detect(adapter); ··· 119 111 120 112 lspcon->active = false; 121 113 lspcon->mode = DRM_LSPCON_MODE_INVALID; 122 - lspcon->aux = &dp->aux; 123 114 124 115 if (!lspcon_probe(lspcon)) { 125 116 DRM_ERROR("Failed to probe lspcon\n");