1 From 5b6257773b43e7a7b28f86359d2e9ebe15346b78 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Mon, 18 Nov 2019 16:51:26 +0100
4 Subject: [PATCH] drm/modes: parse_cmdline: Rework
5 drm_mode_parse_cmdline_options()
7 Commit 739b200c2edcaaa7a86f37b0c11db57956433dfb upstream.
9 Refactor drm_mode_parse_cmdline_options() so that it takes a pointer
10 to the first option, rather then a pointer to the ',' before the first
13 This is a preparation patch for allowing parsing of stand-alone options
14 without a mode before them, e.g.: video=HDMI-1:margin_right=14,...
16 Acked-by: Maxime Ripard <mripard@kernel.org>
17 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
18 Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-5-hdegoede@redhat.com
20 drivers/gpu/drm/drm_modes.c | 21 +++++++++------------
21 1 file changed, 9 insertions(+), 12 deletions(-)
23 --- a/drivers/gpu/drm/drm_modes.c
24 +++ b/drivers/gpu/drm/drm_modes.c
25 @@ -1591,23 +1591,21 @@ static int drm_mode_parse_cmdline_int(co
29 -static int drm_mode_parse_cmdline_options(const char *str, size_t len,
30 +static int drm_mode_parse_cmdline_options(const char *str,
31 const struct drm_connector *connector,
32 struct drm_cmdline_mode *mode)
34 unsigned int deg, margin, rotation = 0;
35 - const char *sep = str;
36 + const char *delim, *option, *sep;
38 - while ((sep = strchr(sep, ','))) {
39 - const char *delim, *option;
44 delim = strchr(option, '=');
46 delim = strchr(option, ',');
50 + delim = option + strlen(option);
53 if (!strncmp(option, "rotate", delim - option)) {
54 @@ -1661,8 +1659,9 @@ static int drm_mode_parse_cmdline_option
60 + sep = strchr(delim, ',');
64 mode->rotation_reflection = rotation;
66 @@ -1855,9 +1854,7 @@ bool drm_mode_parse_command_line_for_con
70 - int len = strlen(name) - (options_ptr - name);
72 - ret = drm_mode_parse_cmdline_options(options_ptr, len,
73 + ret = drm_mode_parse_cmdline_options(options_ptr + 1,