Yisheng Xie
2018-May-31 11:11 UTC
[Nouveau] [PATCH v2 11/21] drm/nouveau: use match_string() helper
match_string() returns the index of an array for a matching string, which can be used instead of open coded variant. Cc: Ben Skeggs <bskeggs at redhat.com> Cc: David Airlie <airlied at linux.ie> Cc: dri-devel at lists.freedesktop.org Cc: nouveau at lists.freedesktop.org Signed-off-by: Yisheng Xie <xieyisheng1 at huawei.com> --- v2: - handle err case before normal case - per Andy drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index 6d99f11..67ba2ac 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -644,16 +644,13 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder, int i; if (nouveau_tv_norm) { - for (i = 0; i < num_tv_norms; i++) { - if (!strcmp(nv17_tv_norm_names[i], nouveau_tv_norm)) { - tv_enc->tv_norm = i; - break; - } - } - - if (i == num_tv_norms) + i = match_string(nv17_tv_norm_names, + num_tv_norms, nouveau_tv_norm); + if (i < 0) NV_WARN(drm, "Invalid TV norm setting \"%s\"\n", nouveau_tv_norm); + else + tv_enc->tv_norm = i; } drm_mode_create_tv_properties(dev, num_tv_norms, nv17_tv_norm_names); -- 1.7.12.4
Andy Shevchenko
2018-Jun-05 13:20 UTC
[Nouveau] [PATCH v2 11/21] drm/nouveau: use match_string() helper
On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1 at 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 at gmail.com>> Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: David Airlie <airlied at linux.ie> > Cc: dri-devel at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Signed-off-by: Yisheng Xie <xieyisheng1 at huawei.com> > --- > v2: > - handle err case before normal case - per Andy > > drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c > index 6d99f11..67ba2ac 100644 > --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c > +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c > @@ -644,16 +644,13 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder, > int i; > > if (nouveau_tv_norm) { > - for (i = 0; i < num_tv_norms; i++) { > - if (!strcmp(nv17_tv_norm_names[i], nouveau_tv_norm)) { > - tv_enc->tv_norm = i; > - break; > - } > - } > - > - if (i == num_tv_norms) > + i = match_string(nv17_tv_norm_names, > + num_tv_norms, nouveau_tv_norm); > + if (i < 0) > NV_WARN(drm, "Invalid TV norm setting \"%s\"\n", > nouveau_tv_norm); > + else > + tv_enc->tv_norm = i; > } > > drm_mode_create_tv_properties(dev, num_tv_norms, nv17_tv_norm_names); > -- > 1.7.12.4 >-- With Best Regards, Andy Shevchenko
Apparently Analagous Threads
- [PATCH 21/33] drm/nouveau: use match_string() helper
- [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code
- [PATCH] drm: nouveau: use match_string() helper to simplify the code
- [PATCH 21/33] drm/nouveau: use match_string() helper
- [PATCH] mm balloon: umount balloon_mnt when remove vb device