* [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code
@ 2019-12-30 2:46 YueHaibing
2020-01-06 1:06 ` [Nouveau] " Ben Skeggs
0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2019-12-30 2:46 UTC (permalink / raw)
To: bskeggs, airlied, daniel, sam, alexander.deucher, jani.nikula,
harry.wentland, yuehaibing
Cc: dri-devel, nouveau, linux-kernel
match_string() returns the array index of a matching string.
Use it instead of the open-coded implementation.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
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 03466f0..3a9489e 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);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Nouveau] [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code
2019-12-30 2:46 [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code YueHaibing
@ 2020-01-06 1:06 ` Ben Skeggs
0 siblings, 0 replies; 2+ messages in thread
From: Ben Skeggs @ 2020-01-06 1:06 UTC (permalink / raw)
To: YueHaibing
Cc: Ben Skeggs, Dave Airlie, Daniel Vetter, Sam Ravnborg,
Alex Deucher, Jani Nikula, Harry Wentland, ML nouveau, LKML,
ML dri-devel
On Mon, 30 Dec 2019 at 12:48, YueHaibing <yuehaibing@huawei.com> wrote:
>
> match_string() returns the array index of a matching string.
> Use it instead of the open-coded implementation.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Thanks!
> ---
> 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 03466f0..3a9489e 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);
> --
> 2.7.4
>
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-06 1:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-30 2:46 [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code YueHaibing
2020-01-06 1:06 ` [Nouveau] " Ben Skeggs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).