All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/audio: constify ELD pointers
Date: Tue, 19 Jun 2018 16:09:46 +0300	[thread overview]
Message-ID: <20180619130946.GH20518@intel.com> (raw)
In-Reply-To: <20180619124437.10982-1-jani.nikula@intel.com>

On Tue, Jun 19, 2018 at 03:44:37PM +0300, Jani Nikula wrote:
> The hooks aren't supposed to modify the ELD, so use const pointer. As a
> drive-by fix, use drm_eld_size() to log ELD size.
> 
> Suggested-by: Ville Syrjala <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_audio.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
> index a34aa66f28f8..bb94172ffc07 100644
> --- a/drivers/gpu/drm/i915/intel_audio.c
> +++ b/drivers/gpu/drm/i915/intel_audio.c
> @@ -213,7 +213,7 @@ static bool intel_eld_uptodate(struct drm_connector *connector,
>  			       i915_reg_t reg_edid)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(connector->dev);
> -	u8 *eld = connector->eld;
> +	const u8 *eld = connector->eld;
>  	u32 tmp;
>  	int i;
>  
> @@ -228,7 +228,7 @@ static bool intel_eld_uptodate(struct drm_connector *connector,
>  	I915_WRITE(reg_elda, tmp);
>  
>  	for (i = 0; i < drm_eld_size(eld) / 4; i++)
> -		if (I915_READ(reg_edid) != *((u32 *)eld + i))
> +		if (I915_READ(reg_edid) != *((const u32 *)eld + i))

I was hoping we could make it const u32* and kill these ugly casts.
But I suppose that would require more casts for the drm_eld_size() & co.,
or changing those to take a const void* instead.

Anyways, the const alone is an improvement so
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  			return false;
>  
>  	return true;
> @@ -261,12 +261,12 @@ static void g4x_audio_codec_enable(struct intel_encoder *encoder,
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>  	struct drm_connector *connector = conn_state->connector;
> -	u8 *eld = connector->eld;
> +	const u8 *eld = connector->eld;
>  	u32 eldv;
>  	u32 tmp;
>  	int len, i;
>  
> -	DRM_DEBUG_KMS("Enable audio codec, %u bytes ELD\n", eld[2]);
> +	DRM_DEBUG_KMS("Enable audio codec, %u bytes ELD\n", drm_eld_size(eld));
>  
>  	tmp = I915_READ(G4X_AUD_VID_DID);
>  	if (tmp == INTEL_AUDIO_DEVBLC || tmp == INTEL_AUDIO_DEVCL)
> @@ -288,7 +288,7 @@ static void g4x_audio_codec_enable(struct intel_encoder *encoder,
>  	len = min(drm_eld_size(eld) / 4, len);
>  	DRM_DEBUG_DRIVER("ELD size %d\n", len);
>  	for (i = 0; i < len; i++)
> -		I915_WRITE(G4X_HDMIW_HDMIEDID, *((u32 *)eld + i));
> +		I915_WRITE(G4X_HDMIW_HDMIEDID, *((const u32 *)eld + i));
>  
>  	tmp = I915_READ(G4X_AUD_CNTL_ST);
>  	tmp |= eldv;
> @@ -466,7 +466,7 @@ static void hsw_audio_codec_enable(struct intel_encoder *encoder,
>  	/* Up to 84 bytes of hw ELD buffer */
>  	len = min(drm_eld_size(eld), 84);
>  	for (i = 0; i < len / 4; i++)
> -		I915_WRITE(HSW_AUD_EDID_DATA(pipe), *((u32 *)eld + i));
> +		I915_WRITE(HSW_AUD_EDID_DATA(pipe), *((const u32 *)eld + i));
>  
>  	/* ELD valid */
>  	tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
> @@ -534,7 +534,7 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
>  	struct drm_connector *connector = conn_state->connector;
>  	enum pipe pipe = crtc->pipe;
>  	enum port port = encoder->port;
> -	u8 *eld = connector->eld;
> +	const u8 *eld = connector->eld;
>  	u32 tmp, eldv;
>  	int len, i;
>  	i915_reg_t hdmiw_hdmiedid, aud_config, aud_cntl_st, aud_cntrl_st2;
> @@ -585,7 +585,7 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
>  	/* Up to 84 bytes of hw ELD buffer */
>  	len = min(drm_eld_size(eld), 84);
>  	for (i = 0; i < len / 4; i++)
> -		I915_WRITE(hdmiw_hdmiedid, *((u32 *)eld + i));
> +		I915_WRITE(hdmiw_hdmiedid, *((const u32 *)eld + i));
>  
>  	/* ELD valid */
>  	tmp = I915_READ(aud_cntrl_st2);
> -- 
> 2.11.0

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-06-19 13:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 12:44 [PATCH] drm/i915/audio: constify ELD pointers Jani Nikula
2018-06-19 12:55 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2018-06-19 13:09 ` Ville Syrjälä [this message]
2018-06-19 13:14 ` ✓ Fi.CI.BAT: success " Patchwork
2018-06-19 14:06 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180619130946.GH20518@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.