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, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 05/12] drm/edid: pass struct edid to connector_bad_edid()
Date: Thu, 7 Apr 2022 14:56:17 +0300	[thread overview]
Message-ID: <Yk7RYZxPWZTQbPjT@intel.com> (raw)
In-Reply-To: <13320766ab44588fa27755619fa3b9dc81e91836.1649322799.git.jani.nikula@intel.com>

On Thu, Apr 07, 2022 at 12:14:31PM +0300, Jani Nikula wrote:
> Avoid casting here and there, and make it const.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 8638e54e0879..ba54701f91f6 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1967,7 +1967,7 @@ drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len)
>  }
>  
>  static void connector_bad_edid(struct drm_connector *connector,
> -			       u8 *edid, int num_blocks)
> +			       const struct edid *edid, int num_blocks)
>  {
>  	int i;
>  	u8 last_block;
> @@ -1978,22 +1978,19 @@ static void connector_bad_edid(struct drm_connector *connector,
>  	 * of 0x7e in the EDID of the _index_ of the last block in the
>  	 * combined chunk of memory.
>  	 */
> -	last_block = edid[0x7e];
> +	last_block = edid->extensions;
>  
>  	/* Calculate real checksum for the last edid extension block data */
>  	if (last_block < num_blocks)
>  		connector->real_edid_checksum =
> -			edid_block_compute_checksum(edid + last_block * EDID_LENGTH);
> +			edid_block_compute_checksum(edid + last_block);
>  
>  	if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
>  		return;
>  
>  	drm_dbg_kms(connector->dev, "%s: EDID is invalid:\n", connector->name);
> -	for (i = 0; i < num_blocks; i++) {
> -		u8 *block = edid + i * EDID_LENGTH;
> -
> -		edid_block_dump(KERN_DEBUG, block, i);
> -	}
> +	for (i = 0; i < num_blocks; i++)
> +		edid_block_dump(KERN_DEBUG, edid + i, i);

nit: I'm not a big fan of pointer arithmetic in general. IMO it
makes it a bit too easy to miss the fact that it's not counting
bytes but rather potentially something much bigger. So I tend to
prefer array notation for such things. But looks like most of 
these go away at the end anyway with the block_data() stuff.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  }
>  
>  /* Get override or firmware EDID */
> @@ -2139,7 +2136,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>  	}
>  
>  	if (invalid_blocks) {
> -		connector_bad_edid(connector, (u8 *)edid, edid->extensions + 1);
> +		connector_bad_edid(connector, edid, edid->extensions + 1);
>  
>  		edid = edid_filter_invalid_blocks(edid, invalid_blocks);
>  	}
> -- 
> 2.30.2

-- 
Ville Syrjälä
Intel

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 05/12] drm/edid: pass struct edid to connector_bad_edid()
Date: Thu, 7 Apr 2022 14:56:17 +0300	[thread overview]
Message-ID: <Yk7RYZxPWZTQbPjT@intel.com> (raw)
In-Reply-To: <13320766ab44588fa27755619fa3b9dc81e91836.1649322799.git.jani.nikula@intel.com>

On Thu, Apr 07, 2022 at 12:14:31PM +0300, Jani Nikula wrote:
> Avoid casting here and there, and make it const.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 8638e54e0879..ba54701f91f6 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1967,7 +1967,7 @@ drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len)
>  }
>  
>  static void connector_bad_edid(struct drm_connector *connector,
> -			       u8 *edid, int num_blocks)
> +			       const struct edid *edid, int num_blocks)
>  {
>  	int i;
>  	u8 last_block;
> @@ -1978,22 +1978,19 @@ static void connector_bad_edid(struct drm_connector *connector,
>  	 * of 0x7e in the EDID of the _index_ of the last block in the
>  	 * combined chunk of memory.
>  	 */
> -	last_block = edid[0x7e];
> +	last_block = edid->extensions;
>  
>  	/* Calculate real checksum for the last edid extension block data */
>  	if (last_block < num_blocks)
>  		connector->real_edid_checksum =
> -			edid_block_compute_checksum(edid + last_block * EDID_LENGTH);
> +			edid_block_compute_checksum(edid + last_block);
>  
>  	if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
>  		return;
>  
>  	drm_dbg_kms(connector->dev, "%s: EDID is invalid:\n", connector->name);
> -	for (i = 0; i < num_blocks; i++) {
> -		u8 *block = edid + i * EDID_LENGTH;
> -
> -		edid_block_dump(KERN_DEBUG, block, i);
> -	}
> +	for (i = 0; i < num_blocks; i++)
> +		edid_block_dump(KERN_DEBUG, edid + i, i);

nit: I'm not a big fan of pointer arithmetic in general. IMO it
makes it a bit too easy to miss the fact that it's not counting
bytes but rather potentially something much bigger. So I tend to
prefer array notation for such things. But looks like most of 
these go away at the end anyway with the block_data() stuff.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  }
>  
>  /* Get override or firmware EDID */
> @@ -2139,7 +2136,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>  	}
>  
>  	if (invalid_blocks) {
> -		connector_bad_edid(connector, (u8 *)edid, edid->extensions + 1);
> +		connector_bad_edid(connector, edid, edid->extensions + 1);
>  
>  		edid = edid_filter_invalid_blocks(edid, invalid_blocks);
>  	}
> -- 
> 2.30.2

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2022-04-07 11:56 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07  9:14 [Intel-gfx] [PATCH 00/12] drm/edid: low level EDID block read refactoring etc Jani Nikula
2022-04-07  9:14 ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 01/12] drm/edid: convert edid_is_zero() to edid_block_is_zero() for blocks Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 02/12] drm/edid: have edid_block_check() detect blocks that are all zero Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 03/12] drm/edid: refactor EDID block status printing Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07 11:54   ` [Intel-gfx] " Ville Syrjälä
2022-04-07 11:54     ` Ville Syrjälä
2022-04-11  9:49     ` [Intel-gfx] " Jani Nikula
2022-04-11  9:49       ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 04/12] drm/edid: add a helper to log dump an EDID block Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 05/12] drm/edid: pass struct edid to connector_bad_edid() Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07 11:56   ` Ville Syrjälä [this message]
2022-04-07 11:56     ` Ville Syrjälä
2022-04-07  9:14 ` [Intel-gfx] [PATCH 06/12] drm/edid: add typedef for block read function Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07 12:06   ` [Intel-gfx] " Ville Syrjälä
2022-04-07 12:06     ` Ville Syrjälä
2022-04-11  9:48     ` [Intel-gfx] " Jani Nikula
2022-04-11  9:48       ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 07/12] drm/edid: abstract an EDID block read helper Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 08/12] drm/edid: use EDID block read helper in drm_do_get_edid() Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 09/12] drm/edid: convert extension block read to EDID block read helper Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 10/12] drm/edid: drop extra local var Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 11/12] drm/edid: add single point of return to drm_do_get_edid() Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07  9:14 ` [Intel-gfx] [PATCH 12/12] drm/edid: add EDID block count and size helpers Jani Nikula
2022-04-07  9:14   ` Jani Nikula
2022-04-07 15:07   ` [Intel-gfx] [PATCH v2] " Jani Nikula
2022-04-07 15:07     ` Jani Nikula
2022-04-07 12:24 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/edid: low level EDID block read refactoring etc Patchwork
2022-04-07 12:41   ` Jani Nikula
2022-04-07 12:44 ` [Intel-gfx] [PATCH 00/12] " Ville Syrjälä
2022-04-07 12:44   ` Ville Syrjälä
2022-04-11  9:51   ` [Intel-gfx] " Jani Nikula
2022-04-11  9:51     ` Jani Nikula
2022-04-07 17:43 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/edid: low level EDID block read refactoring etc. (rev2) Patchwork
2022-04-07 23:17 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/edid: low level EDID block read refactoring etc. (rev3) 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=Yk7RYZxPWZTQbPjT@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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.