lkml.org 
[lkml]   [2018]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 12/21] drm: i2c: ch7006: use match_string() helper
On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.
>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Cc: David Airlie <airlied@linux.ie>
> Cc: Yisheng Xie <xieyisheng1@huawei.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
> v2:
> - handle err case before normal case.
>
> drivers/gpu/drm/i2c/ch7006_drv.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c
> index 544a8a2..9eefdfe 100644
> --- a/drivers/gpu/drm/i2c/ch7006_drv.c
> +++ b/drivers/gpu/drm/i2c/ch7006_drv.c
> @@ -464,16 +464,13 @@ static int ch7006_encoder_init(struct i2c_client *client,
> priv->chip_version = ch7006_read(client, CH7006_VERSION_ID);
>
> if (ch7006_tv_norm) {
> - for (i = 0; i < NUM_TV_NORMS; i++) {
> - if (!strcmp(ch7006_tv_norm_names[i], ch7006_tv_norm)) {
> - priv->norm = i;
> - break;
> - }
> - }
> -
> - if (i == NUM_TV_NORMS)
> + i = match_string(ch7006_tv_norm_names,
> + NUM_TV_NORMS, ch7006_tv_norm);
> + if (i < 0)
> ch7006_err(client, "Invalid TV norm setting \"%s\".\n",
> ch7006_tv_norm);
> + else
> + priv->norm = i;
> }
>
> if (ch7006_scale >= 0 && ch7006_scale <= 2)
> --
> 1.7.12.4
>



--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2018-06-05 15:22    [W:0.192 / U:11.016 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site