1716ebd7be4d3b3361b30d5f61b6d8039560df72
[openwrt/openwrt.git] /
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()
6
7 Commit 739b200c2edcaaa7a86f37b0c11db57956433dfb upstream.
8
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
11 option.
12
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,...
15
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
19 ---
20 drivers/gpu/drm/drm_modes.c | 21 +++++++++------------
21 1 file changed, 9 insertions(+), 12 deletions(-)
22
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
26 return 0;
27 }
28
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)
33 {
34 unsigned int deg, margin, rotation = 0;
35 - const char *sep = str;
36 + const char *delim, *option, *sep;
37
38 - while ((sep = strchr(sep, ','))) {
39 - const char *delim, *option;
40 -
41 - option = sep + 1;
42 + option = str;
43 + do {
44 delim = strchr(option, '=');
45 if (!delim) {
46 delim = strchr(option, ',');
47
48 if (!delim)
49 - delim = str + len;
50 + delim = option + strlen(option);
51 }
52
53 if (!strncmp(option, "rotate", delim - option)) {
54 @@ -1661,8 +1659,9 @@ static int drm_mode_parse_cmdline_option
55 } else {
56 return -EINVAL;
57 }
58 - sep = delim;
59 - }
60 + sep = strchr(delim, ',');
61 + option = sep + 1;
62 + } while (sep);
63
64 if (!(rotation & DRM_MODE_ROTATE_MASK))
65 rotation |= DRM_MODE_ROTATE_0;
66 @@ -1862,9 +1861,7 @@ bool drm_mode_parse_command_line_for_con
67 }
68
69 if (options_ptr) {
70 - int len = strlen(name) - (options_ptr - name);
71 -
72 - ret = drm_mode_parse_cmdline_options(options_ptr, len,
73 + ret = drm_mode_parse_cmdline_options(options_ptr + 1,
74 connector, mode);
75 if (ret)
76 return false;