linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@gmail.com, deller@gmx.de,
	javierm@redhat.com, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, geoff@infradead.org, mpe@ellerman.id.au,
	npiggin@gmail.com, christophe.leroy@csgroup.eu
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 07/11] fbdev: Move option-string lookup into helper
Date: Thu,  9 Feb 2023 14:55:05 +0100	[thread overview]
Message-ID: <20230209135509.7786-8-tzimmermann@suse.de> (raw)
In-Reply-To: <20230209135509.7786-1-tzimmermann@suse.de>

Move the lookup of the option string into an internal helper. No
functional changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/core/fb_cmdline.c | 60 ++++++++++++++++-----------
 1 file changed, 36 insertions(+), 24 deletions(-)

diff --git a/drivers/video/fbdev/core/fb_cmdline.c b/drivers/video/fbdev/core/fb_cmdline.c
index 512da89ff8b5..f811c7b679e1 100644
--- a/drivers/video/fbdev/core/fb_cmdline.c
+++ b/drivers/video/fbdev/core/fb_cmdline.c
@@ -21,6 +21,36 @@ static char *video_options[FB_MAX] __read_mostly;
 static const char *fb_mode_option __read_mostly;
 static int ofonly __read_mostly;
 
+static const char *__fb_get_options(const char *name)
+{
+	const char *options = NULL;
+	size_t name_len = 0;
+
+	if (name)
+		name_len = strlen(name);
+
+	if (name_len) {
+		unsigned int i;
+		const char *opt;
+
+		for (i = 0; i < ARRAY_SIZE(video_options); ++i) {
+			if (!video_options[i])
+				continue;
+			if (video_options[i][0] == '\0')
+				continue;
+			opt = video_options[i];
+			if (!strncmp(opt, name, name_len) && opt[name_len] == ':')
+				options = opt + name_len + 1;
+		}
+	}
+
+	/* No match, return global options */
+	if (!options)
+		options = fb_mode_option;
+
+	return options;
+}
+
 /**
  * fb_get_options - get kernel boot parameters
  * @name:   framebuffer name as it would appear in
@@ -35,36 +65,18 @@ static int ofonly __read_mostly;
  */
 int fb_get_options(const char *name, char **option)
 {
-	const char *options = NULL;
 	int retval = 0;
-	size_t name_len;
-	char *opt;
+	const char *options;
 
-	if (name)
-		name_len = strlen(name);
-
-	if (name_len && ofonly && strncmp(name, "offb", 4))
+	if (name && ofonly && strncmp(name, "offb", 4))
 		retval = 1;
 
-	if (name_len && !retval) {
-		unsigned int i;
+	options = __fb_get_options(name);
 
-		for (i = 0; i < FB_MAX; i++) {
-			if (video_options[i] == NULL)
-				continue;
-			if (!video_options[i][0])
-				continue;
-			opt = video_options[i];
-			if (!strncmp(name, opt, name_len) &&
-			    opt[name_len] == ':')
-				options = opt + name_len + 1;
-		}
+	if (options) {
+		if (!strncmp(options, "off", 3))
+			retval = 1;
 	}
-	/* No match, pass global option */
-	if (!options && option && fb_mode_option)
-		options = fb_mode_option;
-	if (options && !strncmp(options, "off", 3))
-		retval = 1;
 
 	if (option) {
 		if (options)
-- 
2.39.1


  parent reply	other threads:[~2023-02-09 13:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 13:54 [PATCH 00/11] drm,fbdev: Move video= option to drivers/video Thomas Zimmermann
2023-02-09 13:54 ` [PATCH 01/11] fbdev: Fix contact info in fb_cmdline.c Thomas Zimmermann
2023-02-17  8:17   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 02/11] fbdev: Transfer video= option strings to caller; clarify ownership Thomas Zimmermann
2023-02-17  8:37   ` Javier Martinez Canillas
2023-02-17  9:44     ` Thomas Zimmermann
2023-02-17 11:23       ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 03/11] fbdev: Support NULL for name in option-string lookup Thomas Zimmermann
2023-02-17  8:45   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option() Thomas Zimmermann
2023-02-12 16:53   ` Geoff Levand
2023-02-13 11:29     ` Thomas Zimmermann
2023-02-13 16:31       ` Geoff Levand
2023-02-17  8:46   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 05/11] fbdev: Read video= option with fb_get_option() in modedb Thomas Zimmermann
2023-02-17  8:47   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 06/11] fbdev: Unexport fb_mode_option Thomas Zimmermann
2023-02-17  8:48   ` Javier Martinez Canillas
2023-02-09 13:55 ` Thomas Zimmermann [this message]
2023-02-17  8:49   ` [PATCH 07/11] fbdev: Move option-string lookup into helper Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 08/11] fbdev: Handle video= parameter in video/cmdline.c Thomas Zimmermann
2023-02-17  9:00   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 09/11] driver/ps3: Include <video/cmdline.h> for mode parsing Thomas Zimmermann
2023-02-17  9:01   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 10/11] drm: " Thomas Zimmermann
2023-02-17  9:03   ` Javier Martinez Canillas
2023-02-09 13:55 ` [PATCH 11/11] drm: Fix comment on " Thomas Zimmermann
2023-02-17  9:04   ` Javier Martinez Canillas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230209135509.7786-8-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=daniel@ffwll.ch \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geoff@infradead.org \
    --cc=javierm@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mpe@ellerman.id.au \
    --cc=mripard@kernel.org \
    --cc=npiggin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).