[PATCH 1/3] drm/edid: new drm_edid_block_checksum helper function V2

Jani Nikula jani.nikula at linux.intel.com
Sun Nov 23 23:50:20 PST 2014


On Sun, 23 Nov 2014, Stefan Brüns <stefan.bruens at rwth-aachen.de> wrote:
> The function will also be used by a later patch, so factor it out.
>
> V2: make raw_edid const, define/declare before first use
>
> Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
> Reviewed-by: Jani Nikula <jani.nikula at intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index a71ed93..f6c4a1d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1022,6 +1022,16 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length)
>  	return true;
>  }
>  
> +static u8 drm_edid_block_checksum(const u8 *raw_edid)
> +{
> +	int i;
> +	u8 csum = 0;
> +	for (i = 0; i < EDID_LENGTH; i++)
> +		csum += raw_edid[i];
> +
> +	return csum;
> +}
> +
>  /**
>   * drm_edid_block_valid - Sanity check the EDID block (base or extension)
>   * @raw_edid: pointer to raw EDID block
> @@ -1036,7 +1046,6 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length)
>  bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
>  {
>  	int i;
> -	u8 csum = 0;

I meant it's no longer necessary to initialize this to 0. You still need
the variable. Please try compiling the code you send and you'll see
why. ;)

BR,
Jani.

>  	struct edid *edid = (struct edid *)raw_edid;
>  
>  	if (WARN_ON(!raw_edid))
> @@ -1056,9 +1065,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
>  		}
>  	}
>  
> -	for (i = 0; i < EDID_LENGTH; i++)
> -		csum += raw_edid[i];
> -	if (csum) {
> +	if (drm_edid_block_checksum(raw_edid)) {
>  		if (print_bad_edid) {
>  			DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum);
>  		}
> -- 
> 2.1.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center


More information about the dri-devel mailing list