Re: [PATCH v4 02/16] drm/dsi: Add DSI transfer helper

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

 



On 11/03/2014 10:13 AM, Thierry Reding wrote:
> From: Thierry Reding <treding@xxxxxxxxxx>
>
> A common pattern is starting to emerge for higher level transfer
> helpers. Create a new helper that encapsulates this pattern and avoids
> code duplication.
>
> Signed-off-by: Thierry Reding <treding@xxxxxxxxxx>
Acked-by: Andrzej Hajda <a.hajda@xxxxxxxxxxx>
--
Regards
Andrzej

> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 76e81aba8220..89a228b4eacc 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -198,6 +198,20 @@ int mipi_dsi_detach(struct mipi_dsi_device *dsi)
>  }
>  EXPORT_SYMBOL(mipi_dsi_detach);
>  
> +static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi,
> +					struct mipi_dsi_msg *msg)
> +{
> +	const struct mipi_dsi_host_ops *ops = dsi->host->ops;
> +
> +	if (!ops || !ops->transfer)
> +		return -ENOSYS;
> +
> +	if (dsi->mode_flags & MIPI_DSI_MODE_LPM)
> +		msg->flags |= MIPI_DSI_MSG_USE_LPM;
> +
> +	return ops->transfer(dsi->host, msg);
> +}
> +
>  /**
>   * mipi_dsi_create_packet - create a packet from a message according to the
>   *     DSI protocol
> @@ -252,16 +266,12 @@ EXPORT_SYMBOL(mipi_dsi_create_packet);
>  ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, const void *data,
>  			    size_t len)
>  {
> -	const struct mipi_dsi_host_ops *ops = dsi->host->ops;
>  	struct mipi_dsi_msg msg = {
>  		.channel = dsi->channel,
>  		.tx_buf = data,
>  		.tx_len = len
>  	};
>  
> -	if (!ops || !ops->transfer)
> -		return -ENOSYS;
> -
>  	switch (len) {
>  	case 0:
>  		return -EINVAL;
> @@ -276,10 +286,7 @@ ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, const void *data,
>  		break;
>  	}
>  
> -	if (dsi->mode_flags & MIPI_DSI_MODE_LPM)
> -		msg.flags = MIPI_DSI_MSG_USE_LPM;
> -
> -	return ops->transfer(dsi->host, &msg);
> +	return mipi_dsi_device_transfer(dsi, &msg);
>  }
>  EXPORT_SYMBOL(mipi_dsi_dcs_write);
>  
> @@ -295,7 +302,6 @@ EXPORT_SYMBOL(mipi_dsi_dcs_write);
>  ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
>  			  size_t len)
>  {
> -	const struct mipi_dsi_host_ops *ops = dsi->host->ops;
>  	struct mipi_dsi_msg msg = {
>  		.channel = dsi->channel,
>  		.type = MIPI_DSI_DCS_READ,
> @@ -305,13 +311,7 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
>  		.rx_len = len
>  	};
>  
> -	if (!ops || !ops->transfer)
> -		return -ENOSYS;
> -
> -	if (dsi->mode_flags & MIPI_DSI_MODE_LPM)
> -		msg.flags = MIPI_DSI_MSG_USE_LPM;
> -
> -	return ops->transfer(dsi->host, &msg);
> +	return mipi_dsi_device_transfer(dsi, &msg);
>  }
>  EXPORT_SYMBOL(mipi_dsi_dcs_read);
>  

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux