Re: [PATCH v3 04/12] drm/edid: pass a timing pointer to is_detailed_timing_descriptor()

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

 



On Mon, Mar 28, 2022 at 05:34:25PM +0300, Jani Nikula wrote:
> Use struct member access instead of direct offsets to avoid a cast.
> 
> Use BUILD_BUG_ON() for sanity check.
> 
> Cc: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>

Reviewed-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

> ---
>  drivers/gpu/drm/drm_edid.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index ded1f019180d..10da6b9b14fb 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2342,9 +2342,11 @@ static bool is_display_descriptor(const struct detailed_timing *descriptor, u8 t
>  		descriptor->data.other_data.type == type;
>  }
>  
> -static bool is_detailed_timing_descriptor(const u8 d[18])
> +static bool is_detailed_timing_descriptor(const struct detailed_timing *descriptor)
>  {
> -	return d[0] != 0x00 || d[1] != 0x00;
> +	BUILD_BUG_ON(offsetof(typeof(*descriptor), pixel_clock) != 0);
> +
> +	return descriptor->pixel_clock != 0;
>  }
>  
>  typedef void detailed_cb(struct detailed_timing *timing, void *closure);
> @@ -3266,7 +3268,7 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
>  	struct detailed_mode_closure *closure = c;
>  	struct drm_display_mode *newmode;
>  
> -	if (!is_detailed_timing_descriptor((const u8 *)timing))
> +	if (!is_detailed_timing_descriptor(timing))
>  		return;
>  
>  	newmode = drm_mode_detailed(closure->connector->dev,
> -- 
> 2.30.2

-- 
Ville Syrjälä
Intel



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux