Commit 739b200c authored by Hans de Goede's avatar Hans de Goede

drm/modes: parse_cmdline: Rework drm_mode_parse_cmdline_options()

Refactor drm_mode_parse_cmdline_options() so that it takes a pointer
to the first option, rather then a pointer to the ',' before the first
option.

This is a preparation patch for allowing parsing of stand-alone options
without a mode before them, e.g.: video=HDMI-1:margin_right=14,...
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-5-hdegoede@redhat.com
parent cfb0881b
...@@ -1591,23 +1591,21 @@ static int drm_mode_parse_cmdline_int(const char *delim, unsigned int *int_ret) ...@@ -1591,23 +1591,21 @@ static int drm_mode_parse_cmdline_int(const char *delim, unsigned int *int_ret)
return 0; return 0;
} }
static int drm_mode_parse_cmdline_options(const char *str, size_t len, static int drm_mode_parse_cmdline_options(const char *str,
const struct drm_connector *connector, const struct drm_connector *connector,
struct drm_cmdline_mode *mode) struct drm_cmdline_mode *mode)
{ {
unsigned int deg, margin, rotation = 0; unsigned int deg, margin, rotation = 0;
const char *sep = str; const char *delim, *option, *sep;
while ((sep = strchr(sep, ','))) { option = str;
const char *delim, *option; do {
option = sep + 1;
delim = strchr(option, '='); delim = strchr(option, '=');
if (!delim) { if (!delim) {
delim = strchr(option, ','); delim = strchr(option, ',');
if (!delim) if (!delim)
delim = str + len; delim = option + strlen(option);
} }
if (!strncmp(option, "rotate", delim - option)) { if (!strncmp(option, "rotate", delim - option)) {
...@@ -1661,8 +1659,9 @@ static int drm_mode_parse_cmdline_options(const char *str, size_t len, ...@@ -1661,8 +1659,9 @@ static int drm_mode_parse_cmdline_options(const char *str, size_t len,
} else { } else {
return -EINVAL; return -EINVAL;
} }
sep = delim; sep = strchr(delim, ',');
} option = sep + 1;
} while (sep);
mode->rotation_reflection = rotation; mode->rotation_reflection = rotation;
...@@ -1855,9 +1854,7 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, ...@@ -1855,9 +1854,7 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
} }
if (options_ptr) { if (options_ptr) {
int len = strlen(name) - (options_ptr - name); ret = drm_mode_parse_cmdline_options(options_ptr + 1,
ret = drm_mode_parse_cmdline_options(options_ptr, len,
connector, mode); connector, mode);
if (ret) if (ret)
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment