Re: [PATCH v2 7/8] drm/i915/lspcon: Get DDC adapter via container_of() instead of cached ptr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 24 Oct 2016, Imre Deak <imre.deak@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>
> Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx>

SPOT FTW.

Reviewed-by: Jani Nikula <jani.nikula@xxxxxxxxx>


> ---
>  drivers/gpu/drm/i915/intel_drv.h    |  1 -
>  drivers/gpu/drm/i915/intel_lspcon.c | 15 +++++++++++----
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index a79cbad..45f55b5 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -974,7 +974,6 @@ struct intel_dp {
>  struct intel_lspcon {
>  	bool active;
>  	enum drm_lspcon_mode mode;
> -	struct drm_dp_aux *aux;
>  };
>  
>  struct intel_digital_port {
> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> index c5f278b..3dc5a0b 100644
> --- a/drivers/gpu/drm/i915/intel_lspcon.c
> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
> @@ -27,10 +27,18 @@
>  #include <drm/drm_dp_dual_mode_helper.h>
>  #include "intel_drv.h"
>  
> +static struct intel_dp *lspcon_to_intel_dp(struct intel_lspcon *lspcon)
> +{
> +	struct intel_digital_port *dig_port =
> +		container_of(lspcon, struct intel_digital_port, lspcon);
> +
> +	return &dig_port->dp;
> +}
> +
>  static enum drm_lspcon_mode lspcon_get_current_mode(struct intel_lspcon *lspcon)
>  {
>  	enum drm_lspcon_mode current_mode = DRM_LSPCON_MODE_INVALID;
> -	struct i2c_adapter *adapter = &lspcon->aux->ddc;
> +	struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc;
>  
>  	if (drm_lspcon_get_mode(adapter, &current_mode))
>  		DRM_ERROR("Error reading LSPCON mode\n");
> @@ -45,7 +53,7 @@ static int lspcon_change_mode(struct intel_lspcon *lspcon,
>  {
>  	int err;
>  	enum drm_lspcon_mode current_mode;
> -	struct i2c_adapter *adapter = &lspcon->aux->ddc;
> +	struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc;
>  
>  	err = drm_lspcon_get_mode(adapter, &current_mode);
>  	if (err) {
> @@ -72,7 +80,7 @@ static int lspcon_change_mode(struct intel_lspcon *lspcon,
>  static bool lspcon_probe(struct intel_lspcon *lspcon)
>  {
>  	enum drm_dp_dual_mode_type adaptor_type;
> -	struct i2c_adapter *adapter = &lspcon->aux->ddc;
> +	struct i2c_adapter *adapter = &lspcon_to_intel_dp(lspcon)->aux.ddc;
>  
>  	/* Lets probe the adaptor and check its type */
>  	adaptor_type = drm_dp_dual_mode_detect(adapter);
> @@ -111,7 +119,6 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
>  
>  	lspcon->active = false;
>  	lspcon->mode = DRM_LSPCON_MODE_INVALID;
> -	lspcon->aux = &dp->aux;
>  
>  	if (!lspcon_probe(lspcon)) {
>  		DRM_ERROR("Failed to probe lspcon\n");

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux