* [PATCH v1] i915: Convert to use match_string() helper
@ 2018-05-03 18:17 Andy Shevchenko
2018-05-04 7:29 ` Jani Nikula
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2018-05-03 18:17 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, intel-gfx,
David Airlie, dri-devel
Cc: Andy Shevchenko
The new helper returns index of the matching string in an array.
We are going to use it here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpu/drm/i915/intel_pipe_crc.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c
index 4f367c16e9e5..39a4e4edda07 100644
--- a/drivers/gpu/drm/i915/intel_pipe_crc.c
+++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
@@ -766,13 +766,12 @@ display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o)
{
int i;
- for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++)
- if (!strcmp(buf, pipe_crc_objects[i])) {
- *o = i;
- return 0;
- }
+ i = match_string(pipe_crc_objects, ARRAY_SIZE(pipe_crc_objects), buf);
+ if (i < 0)
+ return i;
- return -EINVAL;
+ *o = i;
+ return 0;
}
static int display_crc_ctl_parse_pipe(struct drm_i915_private *dev_priv,
@@ -798,13 +797,12 @@ display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
return 0;
}
- for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
- if (!strcmp(buf, pipe_crc_sources[i])) {
- *s = i;
- return 0;
- }
+ i = match_string(pipe_crc_sources, ARRAY_SIZE(pipe_crc_sources), buf);
+ if (i < 0)
+ return i;
- return -EINVAL;
+ *s = i;
+ return 0;
}
static int display_crc_ctl_parse(struct drm_i915_private *dev_priv,
--
2.17.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] i915: Convert to use match_string() helper
2018-05-03 18:17 [PATCH v1] i915: Convert to use match_string() helper Andy Shevchenko
@ 2018-05-04 7:29 ` Jani Nikula
0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2018-05-04 7:29 UTC (permalink / raw)
To: Joonas Lahtinen, Rodrigo Vivi, intel-gfx, David Airlie, dri-devel
Cc: Andy Shevchenko
On Thu, 03 May 2018, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> The new helper returns index of the matching string in an array.
> We are going to use it here.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Pushed to drm-intel-next-queued, thanks for the patch.
BR,
Jani.
> ---
> drivers/gpu/drm/i915/intel_pipe_crc.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c
> index 4f367c16e9e5..39a4e4edda07 100644
> --- a/drivers/gpu/drm/i915/intel_pipe_crc.c
> +++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
> @@ -766,13 +766,12 @@ display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o)
> {
> int i;
>
> - for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++)
> - if (!strcmp(buf, pipe_crc_objects[i])) {
> - *o = i;
> - return 0;
> - }
> + i = match_string(pipe_crc_objects, ARRAY_SIZE(pipe_crc_objects), buf);
> + if (i < 0)
> + return i;
>
> - return -EINVAL;
> + *o = i;
> + return 0;
> }
>
> static int display_crc_ctl_parse_pipe(struct drm_i915_private *dev_priv,
> @@ -798,13 +797,12 @@ display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
> return 0;
> }
>
> - for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
> - if (!strcmp(buf, pipe_crc_sources[i])) {
> - *s = i;
> - return 0;
> - }
> + i = match_string(pipe_crc_sources, ARRAY_SIZE(pipe_crc_sources), buf);
> + if (i < 0)
> + return i;
>
> - return -EINVAL;
> + *s = i;
> + return 0;
> }
>
> static int display_crc_ctl_parse(struct drm_i915_private *dev_priv,
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-04 7:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-03 18:17 [PATCH v1] i915: Convert to use match_string() helper Andy Shevchenko
2018-05-04 7:29 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox