Re: [PATCH] drm/bridge: adv7511: Replace hardcoded number

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

 



On 12/02/2020 14:42, Fabio Estevam wrote:
> The hardcoded '12' means the number of elements in the
> adv7511_csc_ycbcr_to_rgb[] array, so use the ARRAY_SIZE() macro
> to let the code less error prone.
> 
> Signed-off-by: Fabio Estevam <festevam@xxxxxxxxx>
> ---
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> index 9e13e466e72c..568c6d52cdda 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -132,6 +132,13 @@ static const struct regmap_config adv7511_regmap_config = {
>   * Hardware configuration
>   */
>  
> +/* Coefficients for adv7511 color space conversion */
> +static const uint16_t adv7511_csc_ycbcr_to_rgb[] = {
> +	0x0734, 0x04ad, 0x0000, 0x1c1b,
> +	0x1ddc, 0x04ad, 0x1f24, 0x0135,
> +	0x0000, 0x04ad, 0x087c, 0x1b77,
> +};
> +
>  static void adv7511_set_colormap(struct adv7511 *adv7511, bool enable,
>  				 const uint16_t *coeff,
>  				 unsigned int scaling_factor)
> @@ -142,7 +149,7 @@ static void adv7511_set_colormap(struct adv7511 *adv7511, bool enable,
>  			   ADV7511_CSC_UPDATE_MODE, ADV7511_CSC_UPDATE_MODE);
>  
>  	if (enable) {
> -		for (i = 0; i < 12; ++i) {
> +		for (i = 0; i < ARRAY_SIZE(adv7511_csc_ycbcr_to_rgb); ++i) {
>  			regmap_update_bits(adv7511->regmap,
>  					   ADV7511_REG_CSC_UPPER(i),
>  					   0x1f, coeff[i] >> 8);
> @@ -193,13 +200,6 @@ static int adv7511_packet_disable(struct adv7511 *adv7511, unsigned int packet)
>  	return 0;
>  }
>  
> -/* Coefficients for adv7511 color space conversion */
> -static const uint16_t adv7511_csc_ycbcr_to_rgb[] = {
> -	0x0734, 0x04ad, 0x0000, 0x1c1b,
> -	0x1ddc, 0x04ad, 0x1f24, 0x0135,
> -	0x0000, 0x04ad, 0x087c, 0x1b77,
> -};
> -
>  static void adv7511_set_config_csc(struct adv7511 *adv7511,
>  				   struct drm_connector *connector,
>  				   bool rgb, bool hdmi_mode)
> 

Hmm, you replace an hardcoded number by an ARRAY_SIZE() of a maybe unrelated array,
maybe the size should be passed to adv7511_set_colormap() instead,

Neil
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://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