From patchwork Mon Mar 6 15:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B34DFC6FA99 for ; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbjCFQAh (ORCPT ); Mon, 6 Mar 2023 11:00:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbjCFQA1 (ORCPT ); Mon, 6 Mar 2023 11:00:27 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4661F25E09; Mon, 6 Mar 2023 08:00:26 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D8AA72236F; Mon, 6 Mar 2023 16:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118424; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RzHUCgyDVd1/vFJIVF/yHXdWWow6tO5+rSrZEBgBa/c=; b=VyetxvZ3ORexkxsuy9ptjw4e5iKIRS6AtzM3owyFLAQtiKrEKVQ9OG/cR6tK3PRgu1sNRe 2i3fZa2NJQBfLehZT3TKF3vcS32wpe219jE6y7l2fYNtJL+CviITlg2rD8ml+KodbdSuUd J1rNF4avXuY8yMuQ5WLGlmqgrbGFNjg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118424; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RzHUCgyDVd1/vFJIVF/yHXdWWow6tO5+rSrZEBgBa/c=; b=GVWq0zHJQbDPUNtYod/JQRKJmUcCoDbJRr7rn6i6IULWpMZKZlGML5Vr/quQhC851qTigA zZ/vYCslR9zsLOCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8332F13A6A; Mon, 6 Mar 2023 16:00:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EA9EHxgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:24 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 01/99] lib: Add option iterator Date: Mon, 6 Mar 2023 16:58:38 +0100 Message-Id: <20230306160016.4459-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Add struct option_iter and helpers that walk over individual options of an option string. Add documentation. Kernel parameters often have the format of param=opt1,opt2:val,opt3 where the option string contains a number of comma-separated options. Drivers usually use strsep() in a loop to extract individual options from the string. Each call to strsep() modifies the given string, so callers have to duplicate kernel parameters that are to be parsed multiple times. The new struct option_iter and its helpers wrap this code behind a clean interface. Drivers can iterate over the options without having to know the details of the option-string format. The iterator handles string memory internally without modifying the original options. Signed-off-by: Thomas Zimmermann --- Documentation/core-api/kernel-api.rst | 9 +++ include/linux/cmdline.h | 29 ++++++++ lib/Makefile | 2 +- lib/cmdline_iter.c | 97 +++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 include/linux/cmdline.h create mode 100644 lib/cmdline_iter.c diff --git a/Documentation/core-api/kernel-api.rst b/Documentation/core-api/kernel-api.rst index 62f961610773..cdc7ba8decf9 100644 --- a/Documentation/core-api/kernel-api.rst +++ b/Documentation/core-api/kernel-api.rst @@ -93,9 +93,18 @@ Bitmap Operations Command-line Parsing -------------------- +.. kernel-doc:: lib/cmdline_iter.c + :doc: overview + .. kernel-doc:: lib/cmdline.c :export: +.. kernel-doc:: lib/cmdline_iter.c + :export: + +.. kernel-doc:: include/linux/cmdline.h + :internal: + Sorting ------- diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h new file mode 100644 index 000000000000..5d7e648e98a5 --- /dev/null +++ b/include/linux/cmdline.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef LINUX_CMDLINE_H +#define LINUX_CMDLINE_H + +/** + * struct option_iter - Iterates over string of kernel or module options + */ +struct option_iter { + char *optbuf; + char *next_opt; +}; + +void option_iter_init(struct option_iter *iter, const char *options); +void option_iter_release(struct option_iter *iter); +const char *option_iter_incr(struct option_iter *iter); + +/** + * option_iter_next - Loop condition to move over options + * @iter_: the iterator + * @opt_: the name of the option variable + * + * Iterates over option strings as part of a while loop and + * stores the current option in opt_. + */ +#define option_iter_next(iter_, opt_) \ + (((opt_) = option_iter_incr(iter_)) != NULL) + +#endif diff --git a/lib/Makefile b/lib/Makefile index 4d9461bfea42..829ea6647d7a 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -27,7 +27,7 @@ KASAN_SANITIZE_string.o := n CFLAGS_string.o += -fno-stack-protector endif -lib-y := ctype.o string.o vsprintf.o cmdline.o \ +lib-y := ctype.o string.o vsprintf.o cmdline.o cmdline_iter.o \ rbtree.o radix-tree.o timerqueue.o xarray.o \ maple_tree.o idr.o extable.o irq_regs.o argv_split.o \ flex_proportions.o ratelimit.o show_mem.o \ diff --git a/lib/cmdline_iter.c b/lib/cmdline_iter.c new file mode 100644 index 000000000000..d9371dfea08b --- /dev/null +++ b/lib/cmdline_iter.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include + +/** + * DOC: overview + * + * A kernel parameter's option string can contain multiple comma-separated + * options. Modules can parse an option string with struct &option_iter and + * its helpers. After obtaining the string, initialize and instance of the + * option iterator and loop iver its content as show below. + * + * .. code-block:: c + * + * const char *options = ...; // provided option string + * + * struct option_iter iter; + * const char *opt; + * + * option_iter_init(&iter, options); + * + * while (option_iter_next(&iter, &opt)) { + * if (!strcmp(opt, "foo")) + * ... + * else (strcmp(opt, "bar")) + * ... + * else + * pr_warn("unknown option %s\n", opt); + * } + * + * option_iter_release(&iter); + * + * The call to option_iter_init() initializes the iterator instance + * from the option string. The while loop walks over the individual + * options in the sting and returns each in the second argument. The + * returned memory is owned by the iterator instance and callers may + * not modify or free it. The call to option_iter_release() frees all + * resources of the iterator. This process does not modify the original + * option string. If the option string contains an empty option (i.e., + * two commas next to each other), option_iter_next() skips the empty + * option automatically. + */ + +/** + * option_iter_init - Initializes an option iterator + * @iter: the iterator to initialize + * @options: the options string + */ +void option_iter_init(struct option_iter *iter, const char *options) +{ + if (options && *options) + iter->optbuf = kstrdup(options, GFP_KERNEL); // can be NULL + else + iter->optbuf = NULL; + iter->next_opt = iter->optbuf; +} +EXPORT_SYMBOL(option_iter_init); + +/** + * option_iter_release - Releases an option iterator's resources + * @iter: the iterator + */ +void option_iter_release(struct option_iter *iter) +{ + kfree(iter->optbuf); + iter->next_opt = NULL; +} +EXPORT_SYMBOL(option_iter_release); + +/** + * option_iter_incr - Return current option and advance to the next + * @iter: the iterator + * + * Returns: + * The current option string, or NULL if there are no more options. + */ +const char *option_iter_incr(struct option_iter *iter) +{ + char *opt; + + if (!iter->next_opt) { // can be OK if kstrdup failed + if (iter->optbuf) // iter has already been released; logic error + pr_err("Incrementing option iterator without string\n"); + return NULL; + } + + do { + opt = strsep(&iter->next_opt, ","); + if (!opt) + return NULL; + } while (!*opt); // found empty option string, try next + + return opt; +} +EXPORT_SYMBOL(option_iter_incr); From patchwork Mon Mar 6 15:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7470CC7619A for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231328AbjCFQAw (ORCPT ); Mon, 6 Mar 2023 11:00:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbjCFQA2 (ORCPT ); Mon, 6 Mar 2023 11:00:28 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B241C2E0D3; Mon, 6 Mar 2023 08:00:26 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 38BFA22373; Mon, 6 Mar 2023 16:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118425; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b6D8FQBTb2yaZRkjP/3Zmj8yOkLU5mYNE2Q1swliLUA=; b=q8ROvjUcrSXURP4NQC4Zg3u4Gw4+An+KGI1Kz4tT1+pf8x6qL8wrC00mYNJwkdWcszbg5g tX72pAJlWDzpAc3ZuKEDcoSMaLFrSB4WMxkUhjCTS+K/hDHXwL/pU/Y0dOgZhUUlsZLJPi COMOQEwJ1WdVegCTBs0GtRQXm5JvkPg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118425; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b6D8FQBTb2yaZRkjP/3Zmj8yOkLU5mYNE2Q1swliLUA=; b=qnWYoxjTuASWAY95x+RCGYYuVtszvqtS7n4BHovqz0pZaA2P3xj7tUmgp0+ovDNZcGaSto nst+SnyK6AarT9AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DC4DB13513; Mon, 6 Mar 2023 16:00:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UBMDNRgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:24 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 02/99] fbdev/68328fb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 16:58:39 +0100 Message-Id: <20230306160016.4459-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/68328fb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/68328fb.c b/drivers/video/fbdev/68328fb.c index 7db03ed77c76..7fe56ecbe4e6 100644 --- a/drivers/video/fbdev/68328fb.c +++ b/drivers/video/fbdev/68328fb.c @@ -123,7 +123,7 @@ static u_long get_line_length(int xres_virtual, int bpp) * First part, xxxfb_check_var, must not write anything * to hardware, it should only verify and adjust var. * This means it doesn't alter par but it does use hardware - * data from it to check this var. + * data from it to check this var. */ static int mc68x328fb_check_var(struct fb_var_screeninfo *var, @@ -181,7 +181,7 @@ static int mc68x328fb_check_var(struct fb_var_screeninfo *var, /* * Now that we checked it we alter var. The reason being is that the video - * mode passed in might not work but slight changes to it might make it + * mode passed in might not work but slight changes to it might make it * work. This way we let the user know what is acceptable. */ switch (var->bits_per_pixel) { @@ -256,8 +256,8 @@ static int mc68x328fb_check_var(struct fb_var_screeninfo *var, } /* This routine actually sets the video mode. It's in here where we - * the hardware state info->par and fix which can be affected by the - * change in par. For this driver it doesn't do much. + * the hardware state info->par and fix which can be affected by the + * change in par. For this driver it doesn't do much. */ static int mc68x328fb_set_par(struct fb_info *info) { @@ -294,7 +294,7 @@ static int mc68x328fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, * {hardwarespecific} contains width of RAMDAC * cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset) * RAMDAC[X] is programmed to (red, green, blue) - * + * * Pseudocolor: * uses offset = 0 && length = RAMDAC register width. * var->{color}.offset is 0 @@ -383,7 +383,7 @@ static int mc68x328fb_pan_display(struct fb_var_screeninfo *var, } /* - * Most drivers don't need their own mmap function + * Most drivers don't need their own mmap function */ static int mc68x328fb_mmap(struct fb_info *info, struct vm_area_struct *vma) From patchwork Mon Mar 6 15:58:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C914FC7618A for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231265AbjCFQAt (ORCPT ); Mon, 6 Mar 2023 11:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbjCFQA3 (ORCPT ); Mon, 6 Mar 2023 11:00:29 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 167B42E807; Mon, 6 Mar 2023 08:00:27 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8DEB21FDEC; Mon, 6 Mar 2023 16:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118425; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=orZgFs2QhwCWX9f0KA+V1/nLVg0I8YGwHRr+Xo7enX4=; b=PjMJpakJyWjNdOrVTyPj2whm1Q33z1V9wUnZWqwkUtjHSLFErYtTgTH2SHx5DFdTpOL8xh 6U9/pIC8C4gADDBCoL+OsiNYP2whZbl/yPCwxtP12ni0FEa5VlS+mDYeO1SguNBXEe9un4 RUVVb3a1EKcTEJz4P+MuOTPRCOXbNYU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118425; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=orZgFs2QhwCWX9f0KA+V1/nLVg0I8YGwHRr+Xo7enX4=; b=OmtTWYs01MYMpYFXZYpM+67wyYIDNpyh+TL9PhTnDhkL7aGA62VtvQqKMH7Uj5yneuLI6Q OusXg2kuAvcWbfCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3C91913A6A; Mon, 6 Mar 2023 16:00:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0FAIDhkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:25 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 03/99] fbdev/68328fb: Remove unused option string Date: Mon, 6 Mar 2023 16:58:40 +0100 Message-Id: <20230306160016.4459-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The option string is unused. Remove the variable and a related helper function. No functional change. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/68328fb.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/video/fbdev/68328fb.c b/drivers/video/fbdev/68328fb.c index 7fe56ecbe4e6..f2d70df4104b 100644 --- a/drivers/video/fbdev/68328fb.c +++ b/drivers/video/fbdev/68328fb.c @@ -400,13 +400,6 @@ static int mc68x328fb_mmap(struct fb_info *info, struct vm_area_struct *vma) #endif } -static int __init mc68x328fb_setup(char *options) -{ - if (!options || !*options) - return 1; - return 1; -} - /* * Initialisation */ @@ -414,11 +407,8 @@ static int __init mc68x328fb_setup(char *options) static int __init mc68x328fb_init(void) { #ifndef MODULE - char *option = NULL; - - if (fb_get_options("68328fb", &option)) + if (fb_get_options("68328fb", NULL)) return -ENODEV; - mc68x328fb_setup(option); #endif /* * initialize the default mode from the LCD controller registers From patchwork Mon Mar 6 15:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 363D6C678D4 for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbjCFQAo (ORCPT ); Mon, 6 Mar 2023 11:00:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbjCFQAa (ORCPT ); Mon, 6 Mar 2023 11:00:30 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9055E2E820; Mon, 6 Mar 2023 08:00:27 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E49BA22374; Mon, 6 Mar 2023 16:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118425; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zjVYDbqjwwkw2fXJsfJw/E5OA0vR4qLTqrFh9CEDVls=; b=ZLVSod84jRFbPAgwcB/rSvYcuZWfcsxYuav+FTZqNFxsvnSfLRLU5huBmNGYVcvI8yno3A LA6pDjPT9aLuYAnnxhNodGwZ0RQ01ADMXbwahNoCcOCLwr3EeuDzjnOQEDy0IJnIyWT0tF 87OwqsKqf6RZr2exDvFhk8cgBNc17fg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118425; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zjVYDbqjwwkw2fXJsfJw/E5OA0vR4qLTqrFh9CEDVls=; b=1qLnPhqDZxTWyF1Se8kIFwwbvl09iQB96aeANdlPfciPamDkNnuZwA/St9n7mOre6S3RgJ L7j9zubiyqevDiAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9116313513; Mon, 6 Mar 2023 16:00:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uF6yIhkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:25 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 04/99] fbdev/acornfb: Only init fb_info once Date: Mon, 6 Mar 2023 16:58:41 +0100 Message-Id: <20230306160016.4459-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Init the fb_info instance once before parsing options. The current code initializes the instance once again after parsing options, which clears any resolution settings that have been given in the options string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/acornfb.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/video/fbdev/acornfb.c b/drivers/video/fbdev/acornfb.c index 1b72edc01cfb..8642136a6bdc 100644 --- a/drivers/video/fbdev/acornfb.c +++ b/drivers/video/fbdev/acornfb.c @@ -887,8 +887,6 @@ static int acornfb_setup(char *options) if (!options || !*options) return 0; - acornfb_init_fbinfo(); - while ((opt = strsep(&options, ",")) != NULL) { if (!*opt) continue; @@ -930,9 +928,8 @@ static int acornfb_probe(struct platform_device *dev) if (fb_get_options("acornfb", &option)) return -ENODEV; - acornfb_setup(option); - acornfb_init_fbinfo(); + acornfb_setup(option); current_par.dev = &dev->dev; From patchwork Mon Mar 6 15:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34BECC6FD1C for ; Mon, 6 Mar 2023 16:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbjCFQAz (ORCPT ); Mon, 6 Mar 2023 11:00:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbjCFQAb (ORCPT ); Mon, 6 Mar 2023 11:00:31 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 378492ED70; Mon, 6 Mar 2023 08:00:28 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 423AB1FDEE; Mon, 6 Mar 2023 16:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118426; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gKnsmkdajV5dwt0y63rKnWXciLaSNmTMATxql+kzlXQ=; b=m/l2WRz8+uGG7iRStMefAjKhRxVuhaUygsjz3Yr8sqUk+llkmsgNcoUOr66mqRK+5Ffkrt X0yxS7twf85QTr3a/ZmX8cKQ+6QS1/xdTM3DNOtaXz8u16xa4X1ssc5vx8I9QlzPbsMHfY OsnBJJWZsL+XR+YFy85KHEXB5nOE5uI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118426; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gKnsmkdajV5dwt0y63rKnWXciLaSNmTMATxql+kzlXQ=; b=RofdsvmIu4jmtpHMXRhMHrAiFIEazlA7oJ28EW/eNK35pX+FTLAl33+toZbUJ1oprN/cFn LaxWe+nxW4VMXOAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E7E0313A6A; Mon, 6 Mar 2023 16:00:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EAHaNxkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:25 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 05/99] fbdev/acornfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:42 +0100 Message-Id: <20230306160016.4459-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/acornfb.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/acornfb.c b/drivers/video/fbdev/acornfb.c index 8642136a6bdc..1d6dec45615c 100644 --- a/drivers/video/fbdev/acornfb.c +++ b/drivers/video/fbdev/acornfb.c @@ -14,6 +14,7 @@ * - Blanking 8bpp displays with VIDC */ +#include #include #include #include @@ -879,17 +880,15 @@ static struct options { { NULL, NULL } }; -static int acornfb_setup(char *options) +static int acornfb_setup(const char *options) { - struct options *optp; - char *opt; + struct option_iter iter; + const char *opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + while (option_iter_next(&iter, opt)) { + struct options *optp; for (optp = opt_table; optp->name; optp++) { int optlen; @@ -907,6 +906,9 @@ static int acornfb_setup(char *options) printk(KERN_ERR "acornfb: unknown parameter: %s\n", opt); } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:58:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE3EEC6FD1D for ; Mon, 6 Mar 2023 16:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbjCFQAm (ORCPT ); Mon, 6 Mar 2023 11:00:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbjCFQAa (ORCPT ); Mon, 6 Mar 2023 11:00:30 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 377E12ED62; Mon, 6 Mar 2023 08:00:28 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9959F1FDEF; Mon, 6 Mar 2023 16:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118426; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0LyrWAXBcaqIUsj+JpnvVhponNuq5N/GHJf5/1Zskc=; b=sRubLDkOMsxNVGYssaZlwo/BYs6XzZaphNc5/c7DfdygOCJjhsGN44Zj4byY8BuhI9nQF2 XGWgPmzab1L01Z4s1qEJZ2rhDrJqwJB6tdzfRc4DgFJY4Vv+tpmGQWchuL+NdAJhBChR58 JUYjg8WsmBAsyFf4IPa7CmZlaPOxjn8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118426; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0LyrWAXBcaqIUsj+JpnvVhponNuq5N/GHJf5/1Zskc=; b=nRE3HFpumOqB5NZ7Zrgf0wJnUJDtOCZoOG+o4LZEDlHVYiIW+7wOSM+yq7uMHCOs+np/8+ Vvy/8MKRmeQIWJBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4641913513; Mon, 6 Mar 2023 16:00:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oNBlEBoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:26 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 06/99] fbdev/amifb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:58:43 +0100 Message-Id: <20230306160016.4459-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically free the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/amifb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index d88265dbebf4..6edfd0bfdd57 100644 --- a/drivers/video/fbdev/amifb.c +++ b/drivers/video/fbdev/amifb.c @@ -2363,8 +2363,17 @@ static int __init amifb_setup(char *options) amifb_setup_mcap(this_opt + 11); else if (!strncmp(this_opt, "fstart:", 7)) min_fstrt = simple_strtoul(this_opt + 7, NULL, 0); - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "amifb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "amifb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } if (min_fstrt < 48) From patchwork Mon Mar 6 15:58:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9990CC6FA99 for ; Mon, 6 Mar 2023 16:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230181AbjCFQAl (ORCPT ); Mon, 6 Mar 2023 11:00:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbjCFQAb (ORCPT ); Mon, 6 Mar 2023 11:00:31 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E9A92410D; Mon, 6 Mar 2023 08:00:28 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F113D1FDF0; Mon, 6 Mar 2023 16:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118426; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IujpHsvYb7Uda7mxy1jpF8KsxacycfakNIzbr9SKPvg=; b=bOgy5TV20uAfVbzo/qdl86u2VuyvpkhF1LmcWEzydBkKPBn3chTE5bL/iFWKfvX/tMG7P7 feWqVZ7MK26L8LyFlI/MNCCo8/X9XV3DkWbEj3qf/4n8smtFfIZfs1dHYtorICMivGSuzL 69XNQE0xdEZtcFDluSp78pFLLvvFk0Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118426; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IujpHsvYb7Uda7mxy1jpF8KsxacycfakNIzbr9SKPvg=; b=sA5YID+zbQGa1Bz+s+ar3uRMccrx/oDUs12FLgVmEaCALDW1qDi/sIHPCMuz5qsYhS0Wmd jAxO/V1+mGe+gPCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9DE5013A6A; Mon, 6 Mar 2023 16:00:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MKqlJRoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:26 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 07/99] fbdev/amifb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:44 +0100 Message-Id: <20230306160016.4459-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/amifb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index 6edfd0bfdd57..b968cf2c5f06 100644 --- a/drivers/video/fbdev/amifb.c +++ b/drivers/video/fbdev/amifb.c @@ -40,6 +40,7 @@ * for more details. */ +#include #include #include #include @@ -2345,16 +2346,14 @@ static void __init amifb_setup_mcap(char *spec) amifb_vfmax = vmax; } -static int __init amifb_setup(char *options) +static int __init amifb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "inverse")) { fb_invert_cmaps(); } else if (!strcmp(this_opt, "ilbm")) @@ -2376,6 +2375,8 @@ static int __init amifb_setup(char *options) } } + option_iter_release(&iter); + if (min_fstrt < 48) min_fstrt = 48; From patchwork Mon Mar 6 15:58:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB269C761AF for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231346AbjCFQAy (ORCPT ); Mon, 6 Mar 2023 11:00:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjCFQAb (ORCPT ); Mon, 6 Mar 2023 11:00:31 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E66D28879; Mon, 6 Mar 2023 08:00:29 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 582BD1FDF2; Mon, 6 Mar 2023 16:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118427; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eakX9A1d2cL4JJsysk9bsXBTplb66PKOYwFwVUy7Prk=; b=NSZ3kfbaNFcSXTo+rqXNolhBFGsO47x8A18lNRu8ko1zfE4Ha2wzTO5rJV9vZFt+gOhjPJ QZU5NfSvsHLeHmAAvOnJhSKcsJzBQ2WzTOSBVH2x3cjJCtlP8w3ba7HTxRgLzeUmPAeT2O +Z18bN8KdGZ4NwY3xZhLWoZ14qRgQeY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118427; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eakX9A1d2cL4JJsysk9bsXBTplb66PKOYwFwVUy7Prk=; b=s+jFgKokFJJBBjICEuIXOMPa2srozkEi7v2eNk1Dm986GXURegWRkr5Di6ht2i1aeJ8UTf jNuNyfE6VhcOFVAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 011F413513; Mon, 6 Mar 2023 16:00:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eD8cOxoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:26 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 08/99] fbdev/arkfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:58:45 +0100 Message-Id: <20230306160016.4459-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/arkfb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c index 60a96fdb5dd8..f83fcdaec7a0 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -1196,8 +1196,17 @@ static int __init arkfb_init(void) if (fb_get_options("arkfb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + if (option && *option) { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", option); + if (WARN(ret < 0, "arkfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "arkfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } #endif pr_debug("arkfb: initializing\n"); From patchwork Mon Mar 6 15:58:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E8B8C76195 for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231299AbjCFQAv (ORCPT ); Mon, 6 Mar 2023 11:00:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjCFQAb (ORCPT ); Mon, 6 Mar 2023 11:00:31 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C65D25E09; Mon, 6 Mar 2023 08:00:29 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B7D4B1FDF4; Mon, 6 Mar 2023 16:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118427; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vdfHPhTBCGbkD8dn/FGrM9tZFQ/JKKvg+W2ZUY5fZ2k=; b=Y8eRGE5qfFP9QU7xFr7LAvCJIrNz6/6y759KGnQNVZgmDZNHY9/CDhS4NJLxexvfvxzZSY lonRvO8DMU0qj4y9gqVh8tHqTHa2d7Gaqp+Jvn0bSDS609BNahN0scaARk8dAbF9di0GWv g7FhWsd6nytTlo5pq1TpuR5O+e7sYQc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118427; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vdfHPhTBCGbkD8dn/FGrM9tZFQ/JKKvg+W2ZUY5fZ2k=; b=MUijP6g30XGyMBYKa57zr7ttsIjAdWwhQhtNrUpaG/lICac5ZXQVViKi7T60QzZhnLIEAc klT8c3AfpwLBU9Dw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5E07613513; Mon, 6 Mar 2023 16:00:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MAggFhsOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:27 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 09/99] fbdev/atafb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:58:46 +0100 Message-Id: <20230306160016.4459-10-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/atafb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index 2bc4089865e6..331e72096ebb 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -2946,8 +2946,16 @@ static int __init atafb_setup(char *options) if (!*this_opt) continue; if ((temp = get_video_mode(this_opt))) { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "atafb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "atafb: option too long\n")) + continue; + mode_option = mode_option_buf; default_par = temp; - mode_option = this_opt; } else if (!strcmp(this_opt, "inverse")) fb_invert_cmaps(); else if (!strncmp(this_opt, "hwscroll_", 9)) { From patchwork Mon Mar 6 15:58:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79078C77B62 for ; Mon, 6 Mar 2023 16:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjCFQAb (ORCPT ); Mon, 6 Mar 2023 11:00:31 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECE12E0D3; Mon, 6 Mar 2023 08:00:29 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2149C22384; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vW0Ol4SV/VF9Oy6zvE1dkGppBSF1ye6q+ZpyZhscWGg=; b=s2t6HZxNp2vyhC92hpPPuy5KnMNHVjZUkvHxsdoE9ro2sw1Jt+S4kGZPAZDGYA2+P8ZG/3 We+YjqMKQydkpiwakk7or+c9HgB6BfqI3jiAGBh7DXSL0/apIIw1mN/0YUQaRqnPg0y7Mb yQrB5SUrakfUCCHEZCDLufdlaD2eKYE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vW0Ol4SV/VF9Oy6zvE1dkGppBSF1ye6q+ZpyZhscWGg=; b=IJz+A+PqwW/VxnAl/Xw9sr3jtwXAyRnqxXipfpVfJp1kPa3tUf0/XrKlu3ZctUZe0jOvfH YpWKCZ6hV7jeO0BA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BC84613A6A; Mon, 6 Mar 2023 16:00:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iAsXLRsOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:27 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 10/99] fbdev/atafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:47 +0100 Message-Id: <20230306160016.4459-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/atafb.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index 331e72096ebb..82d5567f2ffb 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -47,6 +47,7 @@ #define ATAFB_EXT #define ATAFB_FALCON +#include #include #include #include @@ -2934,17 +2935,16 @@ static void __init atafb_setup_user(char *spec) } } -static int __init atafb_setup(char *options) +static int __init atafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; int temp; if (!options || !*options) return 0; - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if ((temp = get_video_mode(this_opt))) { static char mode_option_buf[256]; int ret; @@ -2988,6 +2988,9 @@ static int __init atafb_setup(char *options) else if (!strncmp(this_opt, "R", 1)) atafb_setup_user(this_opt + 1); } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:58:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F5B0C6FD20 for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230497AbjCFQAp (ORCPT ); Mon, 6 Mar 2023 11:00:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbjCFQAd (ORCPT ); Mon, 6 Mar 2023 11:00:33 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1751A2E820; Mon, 6 Mar 2023 08:00:31 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 824C71FDF5; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R1ax0gZCP5GAWPA9U/Rv1SWExQ5i1ifVmYzOBqHKJsU=; b=w8UTEzg3lOOZmlhZteJlDzIx7UNBzvedcr9T95EDZ7Y/lam6gJgF+xkLAFS6aEwT09PXoC oRRaOpEUVqV5KL8hv9Deu3rbo1zZAkQ2oyCvAvX/KkOrS4FVFhwJCIIUDOsK/O0Akdso33 qvalyQ4JuHK2W2kcMiNhTwBGe9r9EUs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R1ax0gZCP5GAWPA9U/Rv1SWExQ5i1ifVmYzOBqHKJsU=; b=8UHpl8Y7J9eEYZewQAqwQZ3O9M9Unph16qWNEYZOXqwsOgaOLscIn7V5hsjaMrd1ahtkco 4tbN42mNTR6bURAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 26CD513513; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YI6GCBwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:28 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 11/99] fbdev/aty: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:58:48 +0100 Message-Id: <20230306160016.4459-12-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/aty/aty128fb.c | 12 +++++++++++- drivers/video/fbdev/aty/atyfb_base.c | 13 +++++++++++-- drivers/video/fbdev/aty/radeon_base.c | 13 +++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index 36a9ac05a340..3c08904a107f 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -1723,7 +1723,17 @@ static int aty128fb_setup(char *options) continue; } #endif /* CONFIG_PPC_PMAC */ - mode_option = this_opt; + { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "aty128: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "aty128fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c index b02e4e645035..5e6e83472c30 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c @@ -3896,8 +3896,17 @@ static int __init atyfb_setup(char *options) } } #endif - else - mode = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "atyfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "atyfb: option too long\n")) + continue; + mode = mode_option_buf; + } } return 0; } diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 657064227de8..b885a7cc2424 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -2596,8 +2596,17 @@ static int __init radeonfb_setup (char *options) } else if (!strncmp(this_opt, "ignore_devlist", 14)) { ignore_devlist = 1; #endif - } else - mode_option = this_opt; + } else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "radeonfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "radeonfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F338C76188 for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbjCFQAt (ORCPT ); Mon, 6 Mar 2023 11:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbjCFQAc (ORCPT ); Mon, 6 Mar 2023 11:00:32 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 434622E0FB; Mon, 6 Mar 2023 08:00:30 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E6AC12238C; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bnhNpr1q6ynVgPdSq73n4KSY0p/YpyM8o7Xonnxl/Dg=; b=jUtNUaJ8dnpR1xVBjfP0lm3GvmxAswBIAVdLmqDMWNENAQjSa5c4+/7w9uc4zu0b8HPusq i0wmWN9WqontNr9E+IvlGlDEsLhtogd7cc/AsPODgQuyElyt4dOxcnFLiMyHiJD8ewNUpd znO1EbINjG2n8+qhZfuKPz8sQbCR8KU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bnhNpr1q6ynVgPdSq73n4KSY0p/YpyM8o7Xonnxl/Dg=; b=XSjb+z2ygn50wCcA1il3EK/j/icQ8Q6qbc45L1LzAgBEzRZnpSRLooMacpIFj+TNPalcm+ peVzwBPFe5NI60BA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8817C13A6A; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8NFPIBwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:28 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 12/99] fbdev/aty: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:49 +0100 Message-Id: <20230306160016.4459-13-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/aty/aty128fb.c | 14 +++++++++----- drivers/video/fbdev/aty/atyfb_base.c | 14 +++++++++----- drivers/video/fbdev/aty/radeon_base.c | 17 +++++++++-------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index 3c08904a107f..4a200eabe80b 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -48,6 +48,7 @@ #include +#include #include #include #include @@ -1673,14 +1674,14 @@ static int aty128fb_sync(struct fb_info *info) } #ifndef MODULE -static int aty128fb_setup(char *options) +static int aty128fb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "lcd:", 4)) { default_lcd_on = simple_strtoul(this_opt+4, NULL, 0); continue; @@ -1735,6 +1736,9 @@ static int aty128fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c index 5e6e83472c30..1920ee5c9a2a 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c @@ -49,6 +49,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -3831,14 +3832,14 @@ static struct pci_driver atyfb_driver = { #endif /* CONFIG_PCI */ #ifndef MODULE -static int __init atyfb_setup(char *options) +static int __init atyfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "noaccel", 7)) { noaccel = true; } else if (!strncmp(this_opt, "nomtrr", 6)) { @@ -3908,6 +3909,9 @@ static int __init atyfb_setup(char *options) mode = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index b885a7cc2424..185cd98ad59d 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -55,6 +55,7 @@ #include "radeonfb.h" #include +#include #include #include #include @@ -2561,17 +2562,14 @@ static struct pci_driver radeonfb_driver = { }; #ifndef MODULE -static int __init radeonfb_setup (char *options) +static int __init radeonfb_setup (const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; - - while ((this_opt = strsep (&options, ",")) != NULL) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "noaccel", 7)) { noaccel = 1; } else if (!strncmp(this_opt, "mirror", 6)) { @@ -2608,6 +2606,9 @@ static int __init radeonfb_setup (char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Mon Mar 6 15:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8B04C64EC4 for ; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbjCFQAj (ORCPT ); Mon, 6 Mar 2023 11:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbjCFQAc (ORCPT ); Mon, 6 Mar 2023 11:00:32 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173D72E813; Mon, 6 Mar 2023 08:00:31 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4E8131FDF6; Mon, 6 Mar 2023 16:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uk7crcnOtaYz5lnPu5nHcEno5CdLWKHT+UBXQhxUl8A=; b=GZXdKU6aEL7CBeCsklgVkmVkIEMmxg5dvY4rPpZZXFYp5mNWFe6RiZvl5BDYpi9UN0DtI5 qIpUhIkwDwylSmmVcPaCadPGfdUOkn6ll8RQNrWmsRbDF7PD9OcGXq9lrwoh5b9/9ROyIa rtiCyUhaVcaIId6N1XHJOnubTk2Uzfs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uk7crcnOtaYz5lnPu5nHcEno5CdLWKHT+UBXQhxUl8A=; b=Mc7IPHSQBqfzl2cZHYrUjQsreYZzMHsizsnW9xXH+s5PvhaOf8ELhUtJec5g5JKlJ0vnXg 7t9+6B2a9vT14HBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EB6DA13513; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uB6MOBwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:28 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 13/99] fbdev/au1100fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:50 +0100 Message-Id: <20230306160016.4459-14-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/au1100fb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c index 519313b8bb00..17dae92ac53f 100644 --- a/drivers/video/fbdev/au1100fb.c +++ b/drivers/video/fbdev/au1100fb.c @@ -42,6 +42,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include +#include #include #include #include @@ -365,7 +366,9 @@ static const struct fb_ops au1100fb_ops = static int au1100fb_setup(struct au1100fb_device *fbdev) { - char *this_opt, *options; + char *options; + struct option_iter iter; + const char *this_opt; int num_panels = ARRAY_SIZE(known_lcd_panels); if (num_panels <= 0) { @@ -375,10 +378,10 @@ static int au1100fb_setup(struct au1100fb_device *fbdev) if (fb_get_options(DRIVER_NAME, &options)) return -ENODEV; - if (!options) - return -ENODEV; - while ((this_opt = strsep(&options, ",")) != NULL) { + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { /* Panel option */ if (!strncmp(this_opt, "panel:", 6)) { int i; @@ -401,6 +404,8 @@ static int au1100fb_setup(struct au1100fb_device *fbdev) print_warn("Unsupported option \"%s\"", this_opt); } + option_iter_release(&iter); + print_info("Panel=%s", fbdev->panel->name); return 0; From patchwork Mon Mar 6 15:58:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 316BAC76196 for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjCFQAu (ORCPT ); Mon, 6 Mar 2023 11:00:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230344AbjCFQAc (ORCPT ); Mon, 6 Mar 2023 11:00:32 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0275C2E807; Mon, 6 Mar 2023 08:00:31 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A2985223A0; Mon, 6 Mar 2023 16:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RWjL74/OQnkYsQeBKz+W/Sdt0NW8X9eOoOaYmGq20ZE=; b=vHmpKEBQ90w+/BT1zxBEOj2D77zpxSMvpvdq+0mohTN7y8DSDx1vPqH/FA5O5IELosojyc Pbsgf6BoBUtWK8CtryNMO8YbmaJ0kjXKwQ5NJtqufnKhjViihsh5+jRyPpIjSgmkGwnfkU kOUBJ2jwseUqN8N2vshQgaytk+I3Q0w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RWjL74/OQnkYsQeBKz+W/Sdt0NW8X9eOoOaYmGq20ZE=; b=5xdvoayhMf1/lx6ek8bk0QKqS1TSIdVuKhQIbFTzLgx+/0efMZXjXRnKC35b5kA4O0I6NT H4zWj9KQFA7creBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5234D13A6A; Mon, 6 Mar 2023 16:00:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id INpHEx0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:29 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 14/99] fbdev/au1200fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:51 +0100 Message-Id: <20230306160016.4459-15-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/au1200fb.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c index 81c315454428..31a3f6afd8aa 100644 --- a/drivers/video/fbdev/au1200fb.c +++ b/drivers/video/fbdev/au1200fb.c @@ -31,6 +31,7 @@ */ #include +#include #include #include #include @@ -1578,16 +1579,17 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev) static int au1200fb_setup(struct au1200fb_platdata *pd) { char *options = NULL; - char *this_opt, *endptr; + struct option_iter iter; + const char *this_opt; + char *endptr; int num_panels = ARRAY_SIZE(known_lcd_panels); int panel_idx = -1; fb_get_options(DRIVER_NAME, &options); - if (!options) - goto out; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { /* Panel option - can be panel name, * "bs" for board-switch, or number/index */ if (!strncmp(this_opt, "panel:", 6)) { @@ -1636,7 +1638,8 @@ static int au1200fb_setup(struct au1200fb_platdata *pd) print_warn("Unsupported option \"%s\"", this_opt); } -out: + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:58:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C425C74A4B for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbjCFQAr (ORCPT ); Mon, 6 Mar 2023 11:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbjCFQAd (ORCPT ); Mon, 6 Mar 2023 11:00:33 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A8C2410D; Mon, 6 Mar 2023 08:00:32 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 05B181FDF9; Mon, 6 Mar 2023 16:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118430; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7NWpiNTTADv8jaNfklTWFL4Y9dqUHmm40DnGgzqtQYo=; b=CxbOhQdM0DmSSvSs4ws3YFEGRCq95427JdDIkqGjr3JXPgm8LNMlSjJzWXVjv7RdiUXlDg 3xK0HI3EBMbwz8QuyLjlRQ85o4TAIKmKFAm2V/3eU6fgvqyTKI34739C/DlpLYlhzJiCk6 fBRiMqqfb+mKNtoN4pn4MOJppqx0ZJU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118430; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7NWpiNTTADv8jaNfklTWFL4Y9dqUHmm40DnGgzqtQYo=; b=7ML7Gw2ReccPA0qqrfpdz0dm1kcgFqlbmBv2/WjBRkT6jfoGv9mWpQ59x49OFr1eCw3raH jSq1pImIDYAqu8Dg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A6A4413513; Mon, 6 Mar 2023 16:00:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oPnjJx0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:29 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 15/99] fbdev/cirrusfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:58:52 +0100 Message-Id: <20230306160016.4459-16-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/cirrusfb.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index ba45e2147c52..fbf9281a7004 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -2336,10 +2336,20 @@ static int __init cirrusfb_setup(char *options) if (!strcmp(this_opt, "noaccel")) noaccel = 1; - else if (!strncmp(this_opt, "mode:", 5)) - mode_option = this_opt + 5; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + if (!strncmp(this_opt, "mode:", 5)) + this_opt += 5; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "cirrusfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "cirrusfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:58:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A81DEC61DA4 for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbjCFQAy (ORCPT ); Mon, 6 Mar 2023 11:00:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjCFQAd (ORCPT ); Mon, 6 Mar 2023 11:00:33 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CD5E25E09; Mon, 6 Mar 2023 08:00:32 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 61EDA1FDFA; Mon, 6 Mar 2023 16:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118430; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A8MiP+VX4JXynIvzGoNsVlxZWAdkD76B2oWa0k5ktfw=; b=OxNyYdqNzGt/BVK1X2/BktdC9q8eovUASC6X7w7whA3TeiSQ1Eg67THvnHT6z3TpjtKSdK 39eYnVhldukJR1QK46DlFH0wkgeMKSTaFOsQas69ZsH+NSrBnO9kKWMqAnR9ay3jjSCRTv O8oxHWZ90sVmZi5m/9c8N9QbqhpEehY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118430; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A8MiP+VX4JXynIvzGoNsVlxZWAdkD76B2oWa0k5ktfw=; b=ejH6bE6q/ijYlEpllX4MbYOZUgI01BzIBJJpB1eRZecRHFOKTTUsb92a3CP5cNJHfyao9R /uVKyDuRc0jba+DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0948713A6A; Mon, 6 Mar 2023 16:00:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MGN6AR4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:30 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 16/99] fbdev/cirrusfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:53 +0100 Message-Id: <20230306160016.4459-17-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/cirrusfb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index fbf9281a7004..c6882bff3862 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -35,6 +35,7 @@ */ #include +#include #include #include #include @@ -2323,17 +2324,14 @@ static struct zorro_driver cirrusfb_zorro_driver = { #endif /* CONFIG_ZORRO */ #ifndef MODULE -static int __init cirrusfb_setup(char *options) +static int __init cirrusfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "noaccel")) noaccel = 1; else { @@ -2351,6 +2349,9 @@ static int __init cirrusfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:58:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C85AFC6FD1B for ; Mon, 6 Mar 2023 16:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbjCFQAn (ORCPT ); Mon, 6 Mar 2023 11:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjCFQAe (ORCPT ); Mon, 6 Mar 2023 11:00:34 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96D302ED62; Mon, 6 Mar 2023 08:00:32 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BA1491FDFB; Mon, 6 Mar 2023 16:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118430; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JQIsIu55QrbMD+roUSu/pu2hXLgdTGeDRwRmg1SZaxQ=; b=uN9so4BIslIye3gBaH19j80T8CD1IdD9LG3gCXj0ID52cAM0cYf7tj77QLgToEH0tkobLG xM5Vv3cMGY6vRUfSqgeT8UByO3EAfREoVKqGTnrvJxOLhDL1f//JyD45uBvYhL2FxwHSlA pB+ySH0mjQbf6fRENPbicqBe/pARPtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118430; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JQIsIu55QrbMD+roUSu/pu2hXLgdTGeDRwRmg1SZaxQ=; b=gioW6i5JjpU/EEtlKhgasZGROXwm8elWxVS7AWSnms3A9mxBeNoeZImnD6FtNLU93II74L 2PWN55iPhYPPoDCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 65C2B13513; Mon, 6 Mar 2023 16:00:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GDf4Fx4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:30 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 17/99] fbdev/controlfb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 16:58:54 +0100 Message-Id: <20230306160016.4459-18-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/controlfb.c | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c index 77dbf94aae5f..82eeb139c4eb 100644 --- a/drivers/video/fbdev/controlfb.c +++ b/drivers/video/fbdev/controlfb.c @@ -113,14 +113,14 @@ struct fb_info_control { struct fb_info info; struct fb_par_control par; u32 pseudo_palette[16]; - + struct cmap_regs __iomem *cmap_regs; unsigned long cmap_regs_phys; - + struct control_regs __iomem *control_regs; unsigned long control_regs_phys; unsigned long control_regs_size; - + __u8 __iomem *frame_buffer; unsigned long frame_buffer_phys; unsigned long fb_orig_base; @@ -196,7 +196,7 @@ static void set_control_clock(unsigned char *params) while (!req.complete) cuda_poll(); } -#endif +#endif } /* @@ -233,19 +233,19 @@ static void control_set_hardware(struct fb_info_control *p, struct fb_par_contro if (p->par.xoffset != par->xoffset || p->par.yoffset != par->yoffset) set_screen_start(par->xoffset, par->yoffset, p); - + return; } - + p->par = *par; cmode = p->par.cmode; r = &par->regvals; - + /* Turn off display */ out_le32(CNTRL_REG(p,ctrl), 0x400 | par->ctrl); - + set_control_clock(r->clock_params); - + RADACAL_WRITE(0x20, r->radacal_ctrl); RADACAL_WRITE(0x21, p->control_use_bank2 ? 0 : 1); RADACAL_WRITE(0x10, 0); @@ -254,7 +254,7 @@ static void control_set_hardware(struct fb_info_control *p, struct fb_par_contro rp = &p->control_regs->vswin; for (i = 0; i < 16; ++i, ++rp) out_le32(&rp->r, r->regs[i]); - + out_le32(CNTRL_REG(p,pitch), par->pitch); out_le32(CNTRL_REG(p,mode), r->mode); out_le32(CNTRL_REG(p,vram_attr), p->vram_attr); @@ -366,7 +366,7 @@ static int read_control_sense(struct fb_info_control *p) sense |= (in_le32(CNTRL_REG(p,mon_sense)) & 0x180) >> 7; out_le32(CNTRL_REG(p,mon_sense), 077); /* turn off drivers */ - + return sense; } @@ -558,9 +558,9 @@ static int control_var_to_par(struct fb_var_screeninfo *var, static void control_par_to_var(struct fb_par_control *par, struct fb_var_screeninfo *var) { struct control_regints *rv; - + rv = (struct control_regints *) par->regvals.regs; - + memset(var, 0, sizeof(*var)); var->xres = par->xres; var->yres = par->yres; @@ -568,7 +568,7 @@ static void control_par_to_var(struct fb_par_control *par, struct fb_var_screeni var->yres_virtual = par->vyres; var->xoffset = par->xoffset; var->yoffset = par->yoffset; - + switch(par->cmode) { default: case CMODE_8: @@ -634,7 +634,7 @@ static int controlfb_check_var (struct fb_var_screeninfo *var, struct fb_info *i err = control_var_to_par(var, &par, info); if (err) - return err; + return err; control_par_to_var(&par, var); return 0; @@ -655,7 +655,7 @@ static int controlfb_set_par (struct fb_info *info) " control_var_to_par: %d.\n", err); return err; } - + control_set_hardware(p, &par); info->fix.visual = (p->par.cmode == CMODE_8) ? @@ -840,7 +840,7 @@ static int __init init_control(struct fb_info_control *p) int full, sense, vmode, cmode, vyres; struct fb_var_screeninfo var; int rc; - + printk(KERN_INFO "controlfb: "); full = p->total_vram == 0x400000; From patchwork Mon Mar 6 15:58:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92645C61DA4 for ; Mon, 6 Mar 2023 16:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbjCFQAk (ORCPT ); Mon, 6 Mar 2023 11:00:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbjCFQAe (ORCPT ); Mon, 6 Mar 2023 11:00:34 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C712ED45; Mon, 6 Mar 2023 08:00:32 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1D9CB1FDFC; Mon, 6 Mar 2023 16:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AjH3WVe5o94jDkM7yEZsxRS+3f7/RHj2F55b95q4x1E=; b=foyarjqhUwYfzJLI9Rk+vgkn/vSwG+NV6ux+FotAEWdmUhdlM9tupYI+o4kueRMO3oqT8A 5bU3P4WHTc50auhSKvHrMWopUXzDOfphYwllkUF7ofaItyqkuOG/ZqZUxtJbMbna6sZc00 8GvJDcv0kOdiV4VcfCwdQjm+Iw5Azyg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AjH3WVe5o94jDkM7yEZsxRS+3f7/RHj2F55b95q4x1E=; b=KCcIWV4lZmGZdaGSl/yhE03Jn3uBMbf7nPposO/l7vqj9PzWGM8fMKHJJcsoa4NmRKA4R5 +5PZOMCODOdQaLAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BE9BA13A6A; Mon, 6 Mar 2023 16:00:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mCTALR4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:30 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 18/99] fbdev/controlfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:55 +0100 Message-Id: <20230306160016.4459-19-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/controlfb.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c index 82eeb139c4eb..3633e874ab2e 100644 --- a/drivers/video/fbdev/controlfb.c +++ b/drivers/video/fbdev/controlfb.c @@ -31,6 +31,7 @@ * more details. */ +#include #include #include #include @@ -795,14 +796,14 @@ static void __init control_init_info(struct fb_info *info, struct fb_info_contro /* * Parse user specified options (`video=controlfb:') */ -static void __init control_setup(char *options) +static void __init control_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "vmode:", 6)) { int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX && @@ -830,6 +831,8 @@ static void __init control_setup(char *options) } } } + + option_iter_release(&iter); } /* From patchwork Mon Mar 6 15:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8315DC77B60 for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231332AbjCFQAx (ORCPT ); Mon, 6 Mar 2023 11:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjCFQAe (ORCPT ); Mon, 6 Mar 2023 11:00:34 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B560728879; Mon, 6 Mar 2023 08:00:32 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7515C223B5; Mon, 6 Mar 2023 16:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Maka02GpjBPu0U5NCBjoSssgaATU0MBLIYe2pP3DK5E=; b=Q61VwCzNyrn+qGYMP0+l+bsNoqXWXFAjijkCeqXJH+UtFBh5a2z2vFY3Bbw0558Qrorcev GWAF/0Kl5vmydFmQzb3ohGQX16qUH/UXXWsHLZ8zS8FDLbE5+Cy6lZiUOTd3rfpL92cifD 4ggP7sccGpFAk9OFQmdQ260I4MWMjzk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Maka02GpjBPu0U5NCBjoSssgaATU0MBLIYe2pP3DK5E=; b=CnNrnz6CzTUIsFppWTdn4lA6p5yBImUwgrHMKjHqNWv8/0nXDqPQH6l/fTtC+bzkuwD1BC JXcnfnYoS2EPMkAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 223B813513; Mon, 6 Mar 2023 16:00:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0EdyBx8OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:31 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 19/99] fbdev/cyber2000fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:56 +0100 Message-Id: <20230306160016.4459-20-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/cyber2000fb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/cyber2000fb.c b/drivers/video/fbdev/cyber2000fb.c index 38c0a6866d76..939dde664b53 100644 --- a/drivers/video/fbdev/cyber2000fb.c +++ b/drivers/video/fbdev/cyber2000fb.c @@ -34,6 +34,7 @@ * entering standby mode.) */ #include +#include #include #include #include @@ -1486,17 +1487,14 @@ static void cyberpro_free_fb_info(struct cfb_info *cfb) * video=cyber2000:font:fontname */ #ifndef MODULE -static int cyber2000fb_setup(char *options) +static int cyber2000fb_setup(const char *options) { - char *opt; + struct option_iter iter; + const char *opt; - if (!options || !*options) - return 0; - - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, opt)) { if (strncmp(opt, "font:", 5) == 0) { static char default_font_storage[40]; @@ -1508,6 +1506,9 @@ static int cyber2000fb_setup(char *options) printk(KERN_ERR "CyberPro20x0: unknown parameter: %s\n", opt); } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Mon Mar 6 15:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12E48C7618D for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbjCFQAv (ORCPT ); Mon, 6 Mar 2023 11:00:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbjCFQAe (ORCPT ); Mon, 6 Mar 2023 11:00:34 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456C12E0FB; Mon, 6 Mar 2023 08:00:33 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C9BCE223B8; Mon, 6 Mar 2023 16:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pEiS628a+gvdqwiq6tmn4mXS8MTIkCO8G82VtcnGElY=; b=dX8GA3Zmo6YD1+zNtueih3J4rETzzjRTqyuUkOb20PDnlUGLN4RJ/+tZwKpMK95QRQE4j+ NXO6UypxHvk7HsFEzmEOSbs5j24wY63bfvLbAt9GcjpqN5Qgf/aQhDDe+v2o6SQ68xQib8 shvm9dSkb3Hr8vyE9WpCjeKjFRZRZ+U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pEiS628a+gvdqwiq6tmn4mXS8MTIkCO8G82VtcnGElY=; b=E5EiM8xHnCfGfy0KnDuv0lmlhGhpYGyaq8BYXqQSyMOwo1p3meL38IVFDFCSGpg934Mac0 kUw28k6uge0wrmCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 797E313A6A; Mon, 6 Mar 2023 16:00:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IHHeHB8OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:31 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 20/99] fbdev/efifb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:57 +0100 Message-Id: <20230306160016.4459-21-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/efifb.c | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index a5779fb453a2..1ae7574aaa82 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -284,31 +285,32 @@ static const struct fb_ops efifb_ops = { .fb_imageblit = cfb_imageblit, }; -static int efifb_setup(char *options) +static int efifb_setup(const char *options) { - char *this_opt; - - if (options && *options) { - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; - - efifb_setup_from_dmi(&screen_info, this_opt); - - if (!strncmp(this_opt, "base:", 5)) - screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0); - else if (!strncmp(this_opt, "stride:", 7)) - screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4; - else if (!strncmp(this_opt, "height:", 7)) - screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0); - else if (!strncmp(this_opt, "width:", 6)) - screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0); - else if (!strcmp(this_opt, "nowc")) - mem_flags &= ~EFI_MEMORY_WC; - else if (!strcmp(this_opt, "nobgrt")) - use_bgrt = false; - } + struct option_iter iter; + const char *this_opt; + + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { + efifb_setup_from_dmi(&screen_info, this_opt); + + if (!strncmp(this_opt, "base:", 5)) + screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0); + else if (!strncmp(this_opt, "stride:", 7)) + screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4; + else if (!strncmp(this_opt, "height:", 7)) + screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0); + else if (!strncmp(this_opt, "width:", 6)) + screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0); + else if (!strcmp(this_opt, "nowc")) + mem_flags &= ~EFI_MEMORY_WC; + else if (!strcmp(this_opt, "nobgrt")) + use_bgrt = false; } + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FCFBC74A5B for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjCFQAr (ORCPT ); Mon, 6 Mar 2023 11:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjCFQAe (ORCPT ); Mon, 6 Mar 2023 11:00:34 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81CEC2E807; Mon, 6 Mar 2023 08:00:33 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2E2E71FDFD; Mon, 6 Mar 2023 16:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hsuNbEK5cNmZjtgh1jaEOO+2lStJSQ63BaMSP5TbTBI=; b=W2PtrhU1XtZoY5lNfGpPaFoDKzYTgeSj0tRyxawWRZFmHKBgaDg+/0Z4pK5mGYuQFunVtu Htxk23bxQqOpWmNW00yB0ANDJ/uweL0hrNzNO/j4epDPNU6DVv6GZsW/VoiWK/d6XBr/94 xTdRdjBYU3hl9eOsa6GCceO0d5YyDlo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hsuNbEK5cNmZjtgh1jaEOO+2lStJSQ63BaMSP5TbTBI=; b=9upyelIWdwPa7ZTceN9DS1Kjn3gRjR5M82D42y4WtXTc67HpEhqQD0/PceNo9sVLe9Di5t okM2DzMj5QT4nkCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CDC0F13513; Mon, 6 Mar 2023 16:00:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mOtyMR8OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:31 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 21/99] fbdev/fm2fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:58 +0100 Message-Id: <20230306160016.4459-22-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/fm2fb.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/fm2fb.c b/drivers/video/fbdev/fm2fb.c index 942e382cf1cf..4f17bc8e6c1d 100644 --- a/drivers/video/fbdev/fm2fb.c +++ b/drivers/video/fbdev/fm2fb.c @@ -14,6 +14,7 @@ * more details. */ +#include #include #include #include @@ -293,19 +294,22 @@ static int fm2fb_probe(struct zorro_dev *z, const struct zorro_device_id *id) return 0; } -static int __init fm2fb_setup(char *options) +static int __init fm2fb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "pal", 3)) fm2fb_mode = FM2FB_MODE_PAL; else if (!strncmp(this_opt, "ntsc", 4)) fm2fb_mode = FM2FB_MODE_NTSC; } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46858C742A7 for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjCFQAq (ORCPT ); Mon, 6 Mar 2023 11:00:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbjCFQAe (ORCPT ); Mon, 6 Mar 2023 11:00:34 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCB992410D; Mon, 6 Mar 2023 08:00:33 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 885E41FE00; Mon, 6 Mar 2023 16:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ePH+vsZYxu4JG+mfGZow29tKllWJJQzJ3bWyonsD+Gs=; b=L/dTGMFtUOLj0kNeAJwfnmKNsHsRs6k76a4WAHVkbosYY/HwD13HOMmCZYC0boybuM+PWS IocjSC69fha5rCaQB7Fvfh0AKtrmtoRsZfCy3NJJnMW78f08QXssu2yqtTmVdOsO7yK49l QjbLXsfJj4qAqhoGJWenec7c/ggIpKM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ePH+vsZYxu4JG+mfGZow29tKllWJJQzJ3bWyonsD+Gs=; b=Hla2Rb1vfU+0FJJXUzcnNBAPpJeQUqG4Lit3v0jNDQG/gcO2vlN1BTesMdyY6GQw9mB6Iy amza4IBQ+Zear9CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 35DE513513; Mon, 6 Mar 2023 16:00:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0GP8CyAOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:32 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 22/99] fbdev/fsl-diu-fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:58:59 +0100 Message-Id: <20230306160016.4459-23-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/fsl-diu-fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index e332017c6af6..e01281959062 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -1858,8 +1858,17 @@ static int __init fsl_diu_setup(char *options) } else if (!strncmp(opt, "bpp=", 4)) { if (!kstrtoul(opt + 4, 10, &val)) default_bpp = val; - } else - fb_mode = opt; + } else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "fsl-diu-fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "fsl-diu-fb: option too long\n")) + continue; + fb_mode = mode_option_buf; + } } return 0; From patchwork Mon Mar 6 15:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8F92C6FD1C for ; Mon, 6 Mar 2023 16:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230257AbjCFQAl (ORCPT ); Mon, 6 Mar 2023 11:00:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbjCFQAf (ORCPT ); Mon, 6 Mar 2023 11:00:35 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DFF525E09; Mon, 6 Mar 2023 08:00:34 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DF6D91FE01; Mon, 6 Mar 2023 16:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8sbSKETRLyIrPUgNrj8HYfSUccLKJ5NVTrzj8qYXps=; b=1V3izje4UBdT6eEdvZTPXwzHuwokTbT+U0fr0VrjrdSwWbxaKVWHDYk+o8xsJbl0wulD55 EgkJKztSllacJmvcww+t+uH8wu/Hu0y9CIs9Hau7lg7xOSBHqEC21BEaa0ZhU3DUCq/PGJ +xSevhZ8p/IxUWgHYZUEHc1ERvRHS+Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8sbSKETRLyIrPUgNrj8HYfSUccLKJ5NVTrzj8qYXps=; b=+zCRk8lSuN7WS5wkErelCbWaXjLRHj17SEHNV7V/M/Vvv4IeD5Q1Dgnbm7mNzYFDgmfAVS h/5CUkpuGXCvwiBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8C52D13A6A; Mon, 6 Mar 2023 16:00:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wJt9ISAOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:32 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 23/99] fbdev/fsl-diu-fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:00 +0100 Message-Id: <20230306160016.4459-24-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/fsl-diu-fb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index e01281959062..c97a9c04e8e8 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -12,6 +12,7 @@ * Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix */ +#include #include #include #include @@ -1842,17 +1843,15 @@ static int fsl_diu_remove(struct platform_device *pdev) } #ifndef MODULE -static int __init fsl_diu_setup(char *options) +static int __init fsl_diu_setup(const char *options) { - char *opt; + struct option_iter iter; + const char *opt; unsigned long val; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + while (option_iter_next(&iter, opt)) { if (!strncmp(opt, "monitor=", 8)) { monitor_port = fsl_diu_name_to_port(opt + 8); } else if (!strncmp(opt, "bpp=", 4)) { @@ -1871,6 +1870,8 @@ static int __init fsl_diu_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B734BC76186 for ; Mon, 6 Mar 2023 16:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbjCFQAs (ORCPT ); Mon, 6 Mar 2023 11:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbjCFQAf (ORCPT ); Mon, 6 Mar 2023 11:00:35 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5D7A28879; Mon, 6 Mar 2023 08:00:34 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3E68A1FDEB; Mon, 6 Mar 2023 16:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118433; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rlw6Y9HytpkB3h8X3sYp9Q/5dj2jl9fyg6laIqBFHmA=; b=UA0AU+8JNLwhTqGrlpZIn9kcDz7Pgg2tC5sBRfYuOum/1ZRLNPGUgOobCxgPjF/b49X92m X6VesbrhU3/K1VgbkEemX3jDIq9pyokGPfsW+8+AmMpIowBtz9z2WUGydPYIgwFjEXX6hx QryOCn3keLR0ITMjl5mQKPsguZo2B4I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118433; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rlw6Y9HytpkB3h8X3sYp9Q/5dj2jl9fyg6laIqBFHmA=; b=b8tJbPSYaNtJ/8Uk5mCRRx6gPRMZLLKvfcW2ZfPdtD11XP/hPD5110toEAPpfNQjnjhchb JJZWioCGPKdTbxDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E36AC13513; Mon, 6 Mar 2023 16:00:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EKPFNiAOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:32 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 24/99] fbdev/gbefb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:01 +0100 Message-Id: <20230306160016.4459-25-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. Allocate the copy's memory with devm_kstrdup(), as the driver parses the option string once per probed device. Linux will automatically free the memory upon releasing the device. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/gbefb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 000b4aa44241..5330aa6029ca 100644 --- a/drivers/video/fbdev/gbefb.c +++ b/drivers/video/fbdev/gbefb.c @@ -1083,7 +1083,7 @@ ATTRIBUTE_GROUPS(gbefb); * Initialization */ -static int gbefb_setup(char *options) +static int gbefb_setup(char *options, struct device *dev) { char *this_opt; @@ -1108,8 +1108,9 @@ static int gbefb_setup(char *options) gbe_mem_size = CONFIG_FB_GBE_MEM * 1024 * 1024; if (gbe_mem_size < TILE_SIZE) gbe_mem_size = TILE_SIZE; - } else - mode_option = this_opt; + } else { + mode_option = devm_kstrdup(dev, this_opt, GFP_KERNEL); + } } return 0; } @@ -1132,7 +1133,7 @@ static int gbefb_probe(struct platform_device *p_dev) ret = -ENODEV; goto out_release_framebuffer; } - gbefb_setup(options); + gbefb_setup(options, &p_dev->dev); #endif if (!request_mem_region(GBE_BASE, sizeof(struct sgi_gbe), "GBE")) { From patchwork Mon Mar 6 15:59:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0ADBC77B6C for ; Mon, 6 Mar 2023 16:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbjCFQAf (ORCPT ); Mon, 6 Mar 2023 11:00:35 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E08342E0D3; Mon, 6 Mar 2023 08:00:34 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9462F1FE05; Mon, 6 Mar 2023 16:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118433; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxTnA/4g2gQ8QoHWKF4602AiCImq3uJcQGAx0xAZhD0=; b=R1JJfkm/Po0LNM1CAqRrM/YR42o67MYbo5KaZKOGJfLcTEyLBZ9ZsaP7wsOhttSMjHMGYp 20bx9U5hifW5XESEpB9lAN8xFuPNFIkwKuAFbmm8H5OfZmbj30JcqLLpRxfhtYVUDTjyHh f6d0E+pRl6FtacyKvH7UGcim1QXyQWs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118433; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxTnA/4g2gQ8QoHWKF4602AiCImq3uJcQGAx0xAZhD0=; b=ZH/y6rh99TWEiPVSauQR7+ZZYGNj4Hb9vv9syDGW1/KxBZrdHZuv5l2oWN2YvtL9VhImrN 1xHXKFEjthqY+QAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 429C013A6A; Mon, 6 Mar 2023 16:00:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WOd+DyEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:33 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 25/99] fbdev/gbefb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:02 +0100 Message-Id: <20230306160016.4459-26-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/gbefb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 5330aa6029ca..36651bb6006d 100644 --- a/drivers/video/fbdev/gbefb.c +++ b/drivers/video/fbdev/gbefb.c @@ -9,6 +9,7 @@ * more details. */ +#include #include #include #include @@ -1083,14 +1084,14 @@ ATTRIBUTE_GROUPS(gbefb); * Initialization */ -static int gbefb_setup(char *options, struct device *dev) +static int gbefb_setup(const char *options, struct device *dev) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "monitor:", 8)) { if (!strncmp(this_opt + 8, "crt", 3)) { flat_panel_enabled = 0; @@ -1103,7 +1104,7 @@ static int gbefb_setup(char *options, struct device *dev) default_mode = &default_mode_LCD; } } else if (!strncmp(this_opt, "mem:", 4)) { - gbe_mem_size = memparse(this_opt + 4, &this_opt); + gbe_mem_size = memparse(this_opt + 4, NULL); if (gbe_mem_size > CONFIG_FB_GBE_MEM * 1024 * 1024) gbe_mem_size = CONFIG_FB_GBE_MEM * 1024 * 1024; if (gbe_mem_size < TILE_SIZE) @@ -1112,6 +1113,9 @@ static int gbefb_setup(char *options, struct device *dev) mode_option = devm_kstrdup(dev, this_opt, GFP_KERNEL); } } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81F28C6FD1B for ; Mon, 6 Mar 2023 16:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230070AbjCFQAi (ORCPT ); Mon, 6 Mar 2023 11:00:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbjCFQAg (ORCPT ); Mon, 6 Mar 2023 11:00:36 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D1A42410D; Mon, 6 Mar 2023 08:00:35 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E9BAC1FE0A; Mon, 6 Mar 2023 16:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118433; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=78fsQ7KT7qSrtly2mvkXihDfcDaUcc6ompl2U420mus=; b=tosgSDfD6XMO3Va3mwPRHkyncOiDlsB4YwZjvuAM9a2eQcv49zFwQPqIWijD+fZItv7UqU K+TEdhaAo4Wwess8SSTG7yMZThLrNY49EeBuYDJieAGWDL7LnlGSb3Hi8w6VKoI1cdrGxw bni037Ofyf4I70A8PbimHW/I4lGucIM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118433; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=78fsQ7KT7qSrtly2mvkXihDfcDaUcc6ompl2U420mus=; b=NTrKWFJjsWKC/O5zJGz9yrkMpb/bE0Hi3mLTuId/tAF0i7p/Fc3p2uJWGa07avfn9UCEJ9 8ZiuIlLAWM1kvLCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9909013513; Mon, 6 Mar 2023 16:00:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IAGXJCEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:33 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 26/99] fbdev/geode: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:03 +0100 Message-Id: <20230306160016.4459-27-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/geode/gxfb_core.c | 10 +++++++++- drivers/video/fbdev/geode/lxfb_core.c | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c index 8e05e76de075..3ed85d2d53e9 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -497,10 +497,18 @@ static int __init gxfb_setup(char *options) return 0; while ((opt = strsep(&options, ",")) != NULL) { + static char mode_option_buf[256]; + int ret; + if (!*opt) continue; - mode_option = opt; + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "gxfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "gxfb: option too long\n")) + continue; + mode_option = mode_option_buf; } return 0; diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c index 8130e9eee2b4..6e1e73a21bdb 100644 --- a/drivers/video/fbdev/geode/lxfb_core.c +++ b/drivers/video/fbdev/geode/lxfb_core.c @@ -635,8 +635,17 @@ static int __init lxfb_setup(char *options) nopanel = 1; else if (!strcmp(opt, "nocrt")) nocrt = 1; - else - mode_option = opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "lxfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "lxfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; From patchwork Mon Mar 6 15:59:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B8D7C77B6E for ; Mon, 6 Mar 2023 16:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjCFQA5 (ORCPT ); Mon, 6 Mar 2023 11:00:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230417AbjCFQAg (ORCPT ); Mon, 6 Mar 2023 11:00:36 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A02DA2E0FB; Mon, 6 Mar 2023 08:00:35 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 567171FE0B; Mon, 6 Mar 2023 16:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118434; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ACmxitiOteI6mi9z0BgBQ/16D1s/Eul8G7DwC8i4fUY=; b=agFGvjCcIAnoCBZPbPcoRWKEeBcQjj4jGbuaZWlzGXf7CeQ/K/b8KZ5BXf1UvGDvQgTA0W II2Q/E2hv3CAMmY4wNlgUi390KReXar+ihBinjwMPuKWLCL2GwQmKj4mgMMBYMRN/0x5FU Td76lF0lEWkmjgOIzqo2tYja9ScHbGA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118434; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ACmxitiOteI6mi9z0BgBQ/16D1s/Eul8G7DwC8i4fUY=; b=zGQGSCh49AibU4o0tE11q5r6bDGen1nUV0vNfXlzFWtgegrLutSY7a9TMGIdOI2+EuhTHD p7OKwUQ9GOpcqvBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EEA5813513; Mon, 6 Mar 2023 16:00:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +OtpOSEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:33 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 27/99] fbdev/geode: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:04 +0100 Message-Id: <20230306160016.4459-28-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/geode/gx1fb_core.c | 16 ++++++++-------- drivers/video/fbdev/geode/gxfb_core.c | 17 ++++++++--------- drivers/video/fbdev/geode/lxfb_core.c | 14 ++++++-------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/video/fbdev/geode/gx1fb_core.c b/drivers/video/fbdev/geode/gx1fb_core.c index 9c942001ac10..dd1dc7ee7f83 100644 --- a/drivers/video/fbdev/geode/gx1fb_core.c +++ b/drivers/video/fbdev/geode/gx1fb_core.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -403,17 +404,14 @@ static void gx1fb_remove(struct pci_dev *pdev) } #ifndef MODULE -static void __init gx1fb_setup(char *options) +static void __init gx1fb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return; - - while ((this_opt = strsep(&options, ","))) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "mode:", 5)) strscpy(mode_option, this_opt + 5, sizeof(mode_option)); else if (!strncmp(this_opt, "crt:", 4)) @@ -423,6 +421,8 @@ static void __init gx1fb_setup(char *options) else strscpy(mode_option, this_opt, sizeof(mode_option)); } + + option_iter_release(&iter); } #endif diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c index 3ed85d2d53e9..f5e88e92ba16 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -16,6 +16,7 @@ * 16 MiB of framebuffer memory is assumed to be available. */ #include +#include #include #include #include @@ -488,21 +489,17 @@ static struct pci_driver gxfb_driver = { }; #ifndef MODULE -static int __init gxfb_setup(char *options) +static int __init gxfb_setup(const char *options) { + struct option_iter iter; + const char *opt; - char *opt; + option_iter_init(&iter, options); - if (!options || !*options) - return 0; - - while ((opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, opt)) { static char mode_option_buf[256]; int ret; - if (!*opt) - continue; - ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); if (WARN(ret < 0, "gxfb: ignoring invalid option, ret=%d\n", ret)) continue; @@ -511,6 +508,8 @@ static int __init gxfb_setup(char *options) mode_option = mode_option_buf; } + option_iter_release(&iter); + return 0; } #endif diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c index 6e1e73a21bdb..d687054cdb09 100644 --- a/drivers/video/fbdev/geode/lxfb_core.c +++ b/drivers/video/fbdev/geode/lxfb_core.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -618,17 +619,14 @@ static struct pci_driver lxfb_driver = { }; #ifndef MODULE -static int __init lxfb_setup(char *options) +static int __init lxfb_setup(const char *options) { - char *opt; + struct option_iter iter; + const char *opt; - if (!options || !*options) - return 0; - - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, opt)) { if (!strcmp(opt, "noclear")) noclear = 1; else if (!strcmp(opt, "nopanel")) From patchwork Mon Mar 6 15:59:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A789C6FA99 for ; Mon, 6 Mar 2023 16:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbjCFQA7 (ORCPT ); Mon, 6 Mar 2023 11:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbjCFQAg (ORCPT ); Mon, 6 Mar 2023 11:00:36 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0724F25E09; Mon, 6 Mar 2023 08:00:36 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B82F0223C6; Mon, 6 Mar 2023 16:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118434; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Daegt13aj+W//lZr8jRyusQkz8W6ZntxWFk0xss/ois=; b=RoZqQo9seqyRZSsMcMTj/mNrzws/HA+1pN+gEO5r7iEuL326SSnDJJeu0bHUQhse3wVIqB pDiOHA1W2gC7HuAplCqAhd+mBFrUxIiK+I6kgoOJ1h36GrAEX3KSZCnlCiyZpg4ADN1bJ+ 0i+AhTYYlBhjLTSIvu3b9kxeq+TIUPM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118434; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Daegt13aj+W//lZr8jRyusQkz8W6ZntxWFk0xss/ois=; b=7YBoKzPFjp0NPDLv2F5FLa4z2un3YEve6Vg729kDl9fy6lwL8pN6cE2xgWFIb4CLy0DYt7 HbFYK42ELFUVQxAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5BE8413513; Mon, 6 Mar 2023 16:00:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uJOPFSIOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:34 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 28/99] fbdev/grvga: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:05 +0100 Message-Id: <20230306160016.4459-29-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/grvga.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/grvga.c b/drivers/video/fbdev/grvga.c index 24818b276241..bb4baec2eccc 100644 --- a/drivers/video/fbdev/grvga.c +++ b/drivers/video/fbdev/grvga.c @@ -369,8 +369,20 @@ static int grvga_probe(struct platform_device *dev) grvga_fix_addr = simple_strtoul(this_opt + 5, NULL, 16); else if (!strncmp(this_opt, "size", 4)) grvga_mem_size = simple_strtoul(this_opt + 5, NULL, 0); - else - mode_opt = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, + "grlib-svgactrl: ignoring invalid option, ret=%d\n", + ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), + "grlib-svgactrl: option too long\n")) + continue; + mode_opt = mode_option_buf; + } } par = info->par; From patchwork Mon Mar 6 15:59:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D516AC77B70 for ; Mon, 6 Mar 2023 16:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231435AbjCFQA6 (ORCPT ); Mon, 6 Mar 2023 11:00:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbjCFQAh (ORCPT ); Mon, 6 Mar 2023 11:00:37 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ACCF26853; Mon, 6 Mar 2023 08:00:36 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 29555223CC; Mon, 6 Mar 2023 16:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=slMylKd0o1pIzeZMW4EsaSmRliq1ZmGtsXfkeJQfBhI=; b=nWYRCxcpSw24XPnQhN6bsR7WDZgM5apHXp8qLJ8oOubE1YwShKqdO5TsIDKOMtJ3FPFb6N EZxbONNv0/77cheKLv9YZW6HrNa7N9p2dN+u8ZRCH6c/NY1jDBriNp7vIecSSHruZY/N9R zEcCu0I151s7ETsZ4rKWTZQfYb4sRPg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=slMylKd0o1pIzeZMW4EsaSmRliq1ZmGtsXfkeJQfBhI=; b=4kKE/MQinGXqJrRY+pyR3GyijdpoQkzvzi4uId+nsbVwA3X0bWWFnbwzB5QDn590hlGa6x yiJ+B/TIhTZCXFDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BDA8D13A6A; Mon, 6 Mar 2023 16:00:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iONwLSIOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:34 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 29/99] fbdev/grvga: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:06 +0100 Message-Id: <20230306160016.4459-30-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/grvga.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/grvga.c b/drivers/video/fbdev/grvga.c index bb4baec2eccc..f803dc37c891 100644 --- a/drivers/video/fbdev/grvga.c +++ b/drivers/video/fbdev/grvga.c @@ -10,6 +10,7 @@ * Contributors: Kristoffer Glembo */ +#include #include #include #include @@ -334,6 +335,8 @@ static int grvga_probe(struct platform_device *dev) unsigned long grvga_mem_size = 0; struct grvga_par *par = NULL; char *options = NULL, *mode_opt = NULL; + struct option_iter iter; + const char *this_opt; info = framebuffer_alloc(sizeof(struct grvga_par), &dev->dev); if (!info) @@ -353,15 +356,13 @@ static int grvga_probe(struct platform_device *dev) if (!options || !*options) options = "640x480-8@60"; - while (1) { - char *this_opt = strsep(&options, ","); - - if (!this_opt) - break; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "custom", 6)) { if (grvga_parse_custom(this_opt, &info->var) < 0) { dev_err(&dev->dev, "Failed to parse custom mode (%s).\n", this_opt); + option_iter_release(&iter); retval = -EINVAL; goto free_fb; } @@ -385,6 +386,8 @@ static int grvga_probe(struct platform_device *dev) } } + option_iter_release(&iter); + par = info->par; info->fbops = &grvga_ops; info->fix = grvga_fix; From patchwork Mon Mar 6 15:59:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1B2FC77B6F for ; Mon, 6 Mar 2023 16:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbjCFQA7 (ORCPT ); Mon, 6 Mar 2023 11:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjCFQAh (ORCPT ); Mon, 6 Mar 2023 11:00:37 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40E92E0D3; Mon, 6 Mar 2023 08:00:36 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8A86A1FE0E; Mon, 6 Mar 2023 16:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cbqgFJuuPg76i7Tnxrt6nBFhBok7n+TE7fgC7SU4OZ0=; b=Da0ENzwyFBTDsMLo3AswyCJ9nQ9MmJnvXIiRNIlgJMp8QxpKUpzomHhERtz7loGmLfN9/p nF6oWsvZzIka7u2mWeUEC8hxpWZrWylGj5N2SlgXnao2CDocmqTHpMBB59YQh5B76luBMI cE9fKUckWZT87SJ2zppW3J4HWEH8f04= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cbqgFJuuPg76i7Tnxrt6nBFhBok7n+TE7fgC7SU4OZ0=; b=YH3fqQmGKJmw+1YRRJcCgP64iONty98Zbul4QvaYMSkTYTluCtSrVH4Kb5bWog113QORMV IJ9+FtaoXxj4QoDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2D16013513; Mon, 6 Mar 2023 16:00:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wO0pCiMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:35 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 30/99] fbdev/gxt4500: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:07 +0100 Message-Id: <20230306160016.4459-31-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/gxt4500.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/gxt4500.c b/drivers/video/fbdev/gxt4500.c index 5f42d3d9d6ce..61bc714693f5 100644 --- a/drivers/video/fbdev/gxt4500.c +++ b/drivers/video/fbdev/gxt4500.c @@ -779,12 +779,28 @@ static struct pci_driver gxt4500_driver = { static int gxt4500_init(void) { +#ifndef MODULE + char *options; +#endif + if (fb_modesetting_disabled("gxt4500")) return -ENODEV; #ifndef MODULE - if (fb_get_options("gxt4500", &mode_option)) + if (fb_get_options("gxt4500", &options)) return -ENODEV; + + do { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", options); + if (WARN(ret < 0, "gxt4500: ignoring invalid option, ret=%d\n", ret)) + break; + if (WARN(ret >= sizeof(mode_option_buf), "gxt4500: option too long\n")) + break; + mode_option = mode_option_buf; + } while (0); #endif return pci_register_driver(&gxt4500_driver); From patchwork Mon Mar 6 15:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6713BC77B74 for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231489AbjCFQBD (ORCPT ); Mon, 6 Mar 2023 11:01:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbjCFQAi (ORCPT ); Mon, 6 Mar 2023 11:00:38 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498F62E813; Mon, 6 Mar 2023 08:00:37 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EAF0A223CD; Mon, 6 Mar 2023 16:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8TOK4HErI/2h/odaJ3yQPBqDv7GClK8xHBQXOXIADoU=; b=j2oGZGmRcaFV4sOEfUtQD63SjvnKYDpLXdmiKny/eUdB8X3MerkbRpoduPUwFuOII6rYzy ylz/c4M+1109Jzoe8AcG4X9xugu9U4k8q/to5ONmkPmRsBau/iGr+OdeMmIkeqII7Yi3Yq qEn1v2R4sz4XTPsnkx5sOrX8rtbv1Ok= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8TOK4HErI/2h/odaJ3yQPBqDv7GClK8xHBQXOXIADoU=; b=B22qWvL6Z85SpiqMWFw+V0uhYhQ49REUShk3qyvO2UXPkep+f20mR5bso4tLc4mruF8h4W 7ZuV47ng/Et9K2CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8D8DB13A6A; Mon, 6 Mar 2023 16:00:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MI2tISMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:35 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 31/99] fbdev/hyperv_fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:08 +0100 Message-Id: <20230306160016.4459-32-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. As the driver implements a very simple mode parser in a fairly unstructured way, just duplicate the option string and parse the duplicated memory buffer. Free the buffer afterwards. Done in preparation of constifying the option string and switching the driver to struct option_iter. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/hyperv_fb.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index 4a6a3303b6b4..edb0555239c6 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -903,17 +903,23 @@ static const struct fb_ops hvfb_ops = { static void hvfb_get_option(struct fb_info *info) { struct hvfb_par *par = info->par; - char *opt = NULL, *p; + char *options = NULL; + char *optbuf, *opt, *p; uint x = 0, y = 0; - if (fb_get_options(KBUILD_MODNAME, &opt) || !opt || !*opt) + if (fb_get_options(KBUILD_MODNAME, &options) || !options || !*options) return; + optbuf = kstrdup(options, GFP_KERNEL); + if (!optbuf) + return; + opt = optbuf; + p = strsep(&opt, "x"); if (!*p || kstrtouint(p, 0, &x) || !opt || !*opt || kstrtouint(opt, 0, &y)) { pr_err("Screen option is invalid: skipped\n"); - return; + goto out; } if (x < HVFB_WIDTH_MIN || y < HVFB_HEIGHT_MIN || @@ -922,12 +928,14 @@ static void hvfb_get_option(struct fb_info *info) (par->synthvid_version == SYNTHVID_VERSION_WIN8 && x * y * screen_depth / 8 > SYNTHVID_FB_SIZE_WIN8)) { pr_err("Screen resolution option is out of range: skipped\n"); - return; + goto out; } screen_width = x; screen_height = y; - return; + +out: + kfree(optbuf); } /* From patchwork Mon Mar 6 15:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5852AC77B75 for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbjCFQBB (ORCPT ); Mon, 6 Mar 2023 11:01:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjCFQAi (ORCPT ); Mon, 6 Mar 2023 11:00:38 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A905C25E09; Mon, 6 Mar 2023 08:00:37 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 580411FE10; Mon, 6 Mar 2023 16:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GGy0uoU2mZrL5vxS4nkKabnlKfDbjtCt8Qt8KHG9Q+4=; b=iUJ1re8mOZl0ZwMPuyJXPQm7R25NyRs3Xv7I/zoLVT9WSJXAXPRcLmjoWYkNrvCln2WKfw sCJdMJZUdkc25z7vkQC/3dKonItI9In7lbYau2HF0gx9Kn8GvIBNj95wqy80VqeMxdCvQ9 hmZgFoL69g+w/Y2HeQ3gEkIDinom/8w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GGy0uoU2mZrL5vxS4nkKabnlKfDbjtCt8Qt8KHG9Q+4=; b=mvRPARJ/Z8R3NhG7HdrFbmhrhL9ejvzLWreZJLkkO5+ESUf2/bckHr8SDClSrjsyySfarr h33hEYyTP3J6e9Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F052413513; Mon, 6 Mar 2023 16:00:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iBfHOSMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:35 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 32/99] fbdev/i740fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:09 +0100 Message-Id: <20230306160016.4459-33-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/i740fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index 3860b137b86a..dd4b5c717e8e 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -1273,8 +1273,17 @@ static int __init i740fb_setup(char *options) continue; else if (!strncmp(opt, "mtrr:", 5)) mtrr = simple_strtoul(opt + 5, NULL, 0); - else - mode_option = opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "i740fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "i740fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; From patchwork Mon Mar 6 15:59:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157BBC77B72 for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbjCFQBA (ORCPT ); Mon, 6 Mar 2023 11:01:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbjCFQAj (ORCPT ); Mon, 6 Mar 2023 11:00:39 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24EDD26853; Mon, 6 Mar 2023 08:00:38 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C3B5D223D2; Mon, 6 Mar 2023 16:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=szSIj9mGfnEj6DDhBSYI3vEveuuHtykqw5SPVzp1w74=; b=HVUdyJKw0cu6nbedGmwrMqy+SYtNj+Gaeh+x9sV5x7Zyl0M9X8vrlogM1Ey8i6J8gIRYT+ e3VfbolRpmR10UdcWcCc37ZcR6O2V/SyThnLoqFB2PKS33hSKerC43zBQKU8THJYEz7s+Y g68DTqs0NtkEjScViYka6L9A5zbMjuA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=szSIj9mGfnEj6DDhBSYI3vEveuuHtykqw5SPVzp1w74=; b=00q1Pc/34je/Cyfz+4Bo7JXAAx+YIpUxKAuk1hjz0DxlMHkexGWiEpOvYuW1pI/v5iFZ0x H9I3LGMxVjxSwIBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5F98513513; Mon, 6 Mar 2023 16:00:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eDDEFSQOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:36 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 33/99] fbdev/i740fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:10 +0100 Message-Id: <20230306160016.4459-34-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/i740fb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index dd4b5c717e8e..cf45d6280f38 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -1261,17 +1262,15 @@ static struct pci_driver i740fb_driver = { }; #ifndef MODULE -static int __init i740fb_setup(char *options) +static int __init i740fb_setup(const char *options) { - char *opt; + struct option_iter iter; + const char *opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; - else if (!strncmp(opt, "mtrr:", 5)) + while (option_iter_next(&iter, opt)) { + if (!strncmp(opt, "mtrr:", 5)) mtrr = simple_strtoul(opt + 5, NULL, 0); else { static char mode_option_buf[256]; @@ -1286,6 +1285,8 @@ static int __init i740fb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48B55C77B73 for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231478AbjCFQBC (ORCPT ); Mon, 6 Mar 2023 11:01:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbjCFQAj (ORCPT ); Mon, 6 Mar 2023 11:00:39 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A95F2E0FB; Mon, 6 Mar 2023 08:00:38 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 38EA41FE11; Mon, 6 Mar 2023 16:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118437; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lukZcQyFgWDteguAf6aIzOi0pRoWXRBd9Sx3zg4LSys=; b=j334/7t8UKv88xr97Eho1ZNBsOoW8d/8AFnIxgGVPVLesvgg6veWoTc+DLTKmYuaQY7/Om yJ8TKde/4H5rSdEbU11fCpuMWanbrTlYDkYYm5U/5noD5PTjL6aD0GfdoS3VWkYJsyjsrw Y8JET6LHyuCk2jOtryMcII/88pTRKEM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118437; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lukZcQyFgWDteguAf6aIzOi0pRoWXRBd9Sx3zg4LSys=; b=AHFf8BXnpzkFU+mWXgBDdQ4KlD2Qqm4TCyLgAwt38K7Y6EVQdiK4botq9+WaP1DEHJVbAv /Btqmrowjt+yp+AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C757D13A6A; Mon, 6 Mar 2023 16:00:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6M+4LyQOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:36 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 34/99] fbdev/i810: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:11 +0100 Message-Id: <20230306160016.4459-35-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/i810/i810_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/i810/i810_main.c b/drivers/video/fbdev/i810/i810_main.c index 85abb65f07d7..66f94dfaef16 100644 --- a/drivers/video/fbdev/i810/i810_main.c +++ b/drivers/video/fbdev/i810/i810_main.c @@ -2002,8 +2002,17 @@ static int i810fb_setup(char *options) dcolor = true; else if (!strncmp(this_opt, "ddc3", 4)) ddc3 = true; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "i810fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "i810fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:59:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4EC4C77B79 for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbjCFQBF (ORCPT ); Mon, 6 Mar 2023 11:01:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjCFQAk (ORCPT ); Mon, 6 Mar 2023 11:00:40 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23082ED7E; Mon, 6 Mar 2023 08:00:38 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9702F1FE12; Mon, 6 Mar 2023 16:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118437; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N4+KAj7O++Yi5vpFwEv8UDUdYndu+GaxZcmBs3XLVsE=; b=MrrOCooNoOqiaDI3UBCDwQqRxu3KrZ8Xsu4FCuqHqFzGzItpU9rPmy5vAqKreZ94PyobG8 9JISjYQgvab3QMCF23iM2n03F+YpGq50XYQVx+cySGutUKX9YhXW/7Hb8GUw5KuDKGAaZO ufQ8j2kDuJMP9TciQE3jZPSoAOTnTpU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118437; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N4+KAj7O++Yi5vpFwEv8UDUdYndu+GaxZcmBs3XLVsE=; b=6B4wSnDCF8D3W0DJ/OHeovnr378np44tRR49XRk1NaRoCsVMj9txmnXfuy1IThDxLyCHSF ozR+mQmTatZbKwDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3D96913513; Mon, 6 Mar 2023 16:00:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2DUvDiUOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:37 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 35/99] fbdev/i810: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:12 +0100 Message-Id: <20230306160016.4459-36-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/i810/i810_main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/i810/i810_main.c b/drivers/video/fbdev/i810/i810_main.c index 66f94dfaef16..3e624522fe7a 100644 --- a/drivers/video/fbdev/i810/i810_main.c +++ b/drivers/video/fbdev/i810/i810_main.c @@ -29,6 +29,7 @@ */ #include +#include #include #include #include @@ -1958,14 +1959,15 @@ static void i810fb_find_init_mode(struct fb_info *info) } #ifndef MODULE -static int i810fb_setup(char *options) +static int i810fb_setup(const char *options) { - char *this_opt, *suffix = NULL; + char *suffix = NULL; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "mtrr", 4)) mtrr = true; else if (!strncmp(this_opt, "accel", 5)) @@ -2014,6 +2016,9 @@ static int i810fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95441C77B76 for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231497AbjCFQBE (ORCPT ); Mon, 6 Mar 2023 11:01:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbjCFQAk (ORCPT ); Mon, 6 Mar 2023 11:00:40 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5922E820; Mon, 6 Mar 2023 08:00:39 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 04C031FE14; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u1Vj2hdFriPuAq6eu7C8YZHRTaIjSTKM0OUYtVPbUzk=; b=NVJcM5+tIjVKP36P2s61a81geLBT2XVpk0f49JGUpN36gKTy2EJ9npfGm04wJi6oNyABMQ bOhMpWxD8/HPl7I1+8n3/+4XfiUd87dBUrEYjiShSTB0DDjVwb6hbnlpxrTokTc9mqxDhO 5pFEn7NRrp51TH6y5EEhomLOiPfnclc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u1Vj2hdFriPuAq6eu7C8YZHRTaIjSTKM0OUYtVPbUzk=; b=oUyTvCb7JB9J08x2nUAGyuDJaMojsQtB+ZHQlyLEJYFCPGhkHFN+qOwbnWxxDefF0hD8O8 uAfuSfArup44SOBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9C43313A6A; Mon, 6 Mar 2023 16:00:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gA4kJSUOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:37 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 36/99] fbdev/imsttfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:13 +0100 Message-Id: <20230306160016.4459-37-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/imsttfb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index bea45647184e..fc046886599c 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -1560,16 +1561,16 @@ static void imsttfb_remove(struct pci_dev *pdev) #ifndef MODULE static int __init -imsttfb_setup(char *options) +imsttfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "font:", 5)) { - char *p; + const char *p; int i; p = this_opt + 5; @@ -1608,6 +1609,9 @@ imsttfb_setup(char *options) } #endif } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED528C77B7C for ; Mon, 6 Mar 2023 16:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231530AbjCFQBJ (ORCPT ); Mon, 6 Mar 2023 11:01:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbjCFQAk (ORCPT ); Mon, 6 Mar 2023 11:00:40 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF172E813; Mon, 6 Mar 2023 08:00:39 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 642A01FE65; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7iMEfuN9WtWV+W8GDub6mP4KQ3dzlvXhpj7NWAmQU0E=; b=jI5U4bYHQERQJ5zYLmjEBr6kHAGSynAx4GUKy1XmqHWtu1EhmY49M44UTE3CObvlKGu5y9 yo+RM5cR00zj5iKH2RnVxb3o2kbhY7t29sJO1Ld1SnC8pxkneuYI01bG3HXrTe6qgWg6TV RSuj5PYrQZQYKqGazTtobw2W3QpoR5k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7iMEfuN9WtWV+W8GDub6mP4KQ3dzlvXhpj7NWAmQU0E=; b=lc2R0HRkewYJnPi639Ts7hGbCxPIXrVBltySd2DcbFrKvdj+cu4UzMqJDj3yZShsR0OzHE tAXWoeCZnooPaNBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 08D9C13513; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ILY8ASYOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:38 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 37/99] fbdev/intelfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:14 +0100 Message-Id: <20230306160016.4459-38-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/intelfb/intelfbdrv.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 0a9e5067b201..896c2646e2ae 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -365,8 +365,17 @@ static int __init intelfb_setup(char *options) noinit = !noinit; else if (OPT_EQUAL(this_opt, "mode=")) mode = get_opt_string(this_opt, "mode="); - else - mode = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "intelfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "intelfb: option too long\n")) + continue; + mode = mode_option_buf; + } } return 0; From patchwork Mon Mar 6 15:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659544 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA586C6FD1B for ; Mon, 6 Mar 2023 16:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbjCFQBM (ORCPT ); Mon, 6 Mar 2023 11:01:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbjCFQAl (ORCPT ); Mon, 6 Mar 2023 11:00:41 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C232FCFD; Mon, 6 Mar 2023 08:00:40 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C62271FE6A; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0mI5hxY6oQ2Q0qWcdERaw/gENN4eL71qVG14XGIWDCI=; b=YDxqQDsMAp2UjoBTYs3dheGgn2s0QrRmSahZQmc9b99QUFQtkLLjYzwCOza3atJg8P3qNH w0p6UElS0n3VFUx3Qw0xcRTINa4XFbhhnSkOQbG15WBIJN6z3330ZLNnhx1PQfov3Csx+Y QIC3KuEFK1l+ee/LUE9ck4iOV+mqMRA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0mI5hxY6oQ2Q0qWcdERaw/gENN4eL71qVG14XGIWDCI=; b=G5QYY12iSeLUPhHPCh0//gAizWQw49VWoI4CZAvAG0KKVWPuNaDPYGe5vDkb9S29FvhGE9 mPj6MjKM7bBIv6CQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 68A7613A6A; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OO23GCYOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:38 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 38/99] fbdev/intelfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:15 +0100 Message-Id: <20230306160016.4459-39-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/intelfb/intelfbdrv.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 896c2646e2ae..2d4e03b9e7fd 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -108,6 +108,7 @@ */ #include +#include #include #include #include @@ -323,9 +324,10 @@ static __inline__ int get_opt_bool(const char *this_opt, const char *name, return 1; } -static int __init intelfb_setup(char *options) +static int __init intelfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; DBG_MSG("intelfb_setup\n"); @@ -348,9 +350,9 @@ static int __init intelfb_setup(char *options) * video=intelfb:1024x768-16@75,accel=0 */ - while ((this_opt = strsep(&options, ","))) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { if (get_opt_bool(this_opt, "accel", &accel)) ; else if (get_opt_int(this_opt, "vram", &vram)) @@ -378,6 +380,8 @@ static int __init intelfb_setup(char *options) } } + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95088C678D4 for ; Mon, 6 Mar 2023 16:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjCFQBN (ORCPT ); Mon, 6 Mar 2023 11:01:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjCFQAm (ORCPT ); Mon, 6 Mar 2023 11:00:42 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907AE30195; Mon, 6 Mar 2023 08:00:40 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 35D451FE7A; Mon, 6 Mar 2023 16:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118439; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VI7czhrNpM2s9K222rNz4O6xPKZ6jdVhFOSUUaE2lw0=; b=QrF8kA+C8XcomNE0zqN8N9/n5oBvjDYcFmcsZLk194PjlTIBh6z4pccrzaFTd3+upMUVyj 3/1n7f/8g7tEJ5iwjJ1H2hM3YKanxaop251MJBNIVCnOLQxMRgfPKpL548ofc2auWbh4HC t/VQvDrfiVFZ+dSidmNRideJ8LWSG70= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118439; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VI7czhrNpM2s9K222rNz4O6xPKZ6jdVhFOSUUaE2lw0=; b=CLVk59UClN2YcyneRzaq1MZ5QoxJ6OE2CJTZOcLwygMr7D84MCr8seqKhFTfbboX5ZtbG9 rq6UDfbwMH4AM4Cg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CB41B13513; Mon, 6 Mar 2023 16:00:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gLmBMCYOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:38 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 39/99] fbdev/imxfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:16 +0100 Message-Id: <20230306160016.4459-40-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/imxfb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index 51fde1b2a793..34cd4d4fd137 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -854,10 +854,18 @@ static int imxfb_setup(void) return 0; while ((opt = strsep(&options, ",")) != NULL) { + static char mode_option_buf[256]; + int ret; + if (!*opt) continue; - else - fb_mode = opt; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "imxfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "imxfb: option too long\n")) + continue; + fb_mode = mode_option_buf; } return 0; From patchwork Mon Mar 6 15:59:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54ECBC74A44 for ; Mon, 6 Mar 2023 16:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbjCFQBN (ORCPT ); Mon, 6 Mar 2023 11:01:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjCFQAm (ORCPT ); Mon, 6 Mar 2023 11:00:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 040C2311E5; Mon, 6 Mar 2023 08:00:40 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 99953223DA; Mon, 6 Mar 2023 16:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118439; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JtbWzX++GGWbJi+6VWECCdUUEYcE0hx5AMmoDw+mBo0=; b=hoAdTAlSWRWIS8eldmOwiIJ4f+Vg2uQDTsTusRwTAWOkeI47A15NIY23hQXLlTxTFXQduQ 0EI58wO/yiBVJ7VKAWVfYaGJwum1Jv6wOtcpXtBdidtKpgLQra+J7LDiopldk04/9TNyBs K4USCU4wP15UtxQ7BcbrGiJDNadof1Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118439; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JtbWzX++GGWbJi+6VWECCdUUEYcE0hx5AMmoDw+mBo0=; b=wIOz3uCCPRIotkqVBq+Ci4zHjt/k9eTmMhFPLMa6TYXNtnli4Ws8apt9RgJBaliprd9pwj /CE8LaWXXsUf0uCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3A52B13A6A; Mon, 6 Mar 2023 16:00:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uG5dDScOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:39 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 40/99] fbdev/imxfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:17 +0100 Message-Id: <20230306160016.4459-41-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/imxfb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index 34cd4d4fd137..950df484e5be 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -14,6 +14,7 @@ * linux-arm-kernel@lists.arm.linux.org.uk */ +#include #include #include #include @@ -845,21 +846,19 @@ static struct lcd_ops imxfb_lcd_ops = { static int imxfb_setup(void) { - char *opt, *options = NULL; + char *options = NULL; + struct option_iter iter; + const char *opt; if (fb_get_options("imxfb", &options)) return -ENODEV; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, opt)) { static char mode_option_buf[256]; int ret; - if (!*opt) - continue; - ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); if (WARN(ret < 0, "imxfb: ignoring invalid option, ret=%d\n", ret)) continue; @@ -868,6 +867,8 @@ static int imxfb_setup(void) fb_mode = mode_option_buf; } + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659542 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97F24C74A4B for ; Mon, 6 Mar 2023 16:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbjCFQBQ (ORCPT ); Mon, 6 Mar 2023 11:01:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjCFQAm (ORCPT ); Mon, 6 Mar 2023 11:00:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CDDD2FCDE; Mon, 6 Mar 2023 08:00:41 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 10025223DC; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K0gGAw7ZqBoMZQQEk3RoG354RK+dTClSMJKbERgVuz8=; b=QvMmCKNwXDv+cSg00PFI22+IxUxHLK5DLRZbbuZ7Jz3xMDPN8olle+TigcBeEyicia25DD Jut0LD6tq+fjFP8aNsGs29r3vtZbGeOuaOD/G343DAf+MB7w9ZbH1ZAFFlMuQo+YOVd0RW pIPAjIXHfM27OBAyk49NBjnyuUkE8M4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K0gGAw7ZqBoMZQQEk3RoG354RK+dTClSMJKbERgVuz8=; b=5CRCQQCEKlKMirs1zh8B4JrZ1nWQZbgPPGMJJ3GDYDKTYcECCiXaqRdIMIsCZw4+V6toOx V7/iz9RnNDnWfACw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9E85413513; Mon, 6 Mar 2023 16:00:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cFzMJScOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:39 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 41/99] fbdev/kyrofb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:18 +0100 Message-Id: <20230306160016.4459-42-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/kyro/fbdev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index 0596573ef140..a171f1119e4d 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -579,7 +579,15 @@ static int __init kyrofb_setup(char *options) } else if (strcmp(this_opt, "nomtrr") == 0) { nomtrr = 1; } else { - mode_option = this_opt; + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "kyrofb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "kyrofb: option too long\n")) + continue; + mode_option = mode_option_buf; } } From patchwork Mon Mar 6 15:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659540 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B9FFC742A7 for ; Mon, 6 Mar 2023 16:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbjCFQBP (ORCPT ); Mon, 6 Mar 2023 11:01:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbjCFQAo (ORCPT ); Mon, 6 Mar 2023 11:00:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC5C333463; Mon, 6 Mar 2023 08:00:41 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 67624223DD; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cwqVqLpgUlWI9lNPI1evG9ZIvx/rxfSu6w7hLxHEO1M=; b=BOCKi3DJGxCVb2eTSqE2gWoeQ2DRsbUuoQ5zZ6KOjaVNuQ+W5wYpTfst1/IZGMEEFupZy9 sN3lAiH3I7nA4iMMB4pv7ekKWOX9SHpTdB98kH7aAeEL+eDGkAX0GO7TssiLNONbE4f6JG YZlN7rjJmGl5LuLxwySw/HCt3j9EfOs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cwqVqLpgUlWI9lNPI1evG9ZIvx/rxfSu6w7hLxHEO1M=; b=mpoJNTk5aCW4ze/v/oWDZzIHjLV2fF3Kxpku3QGa19Xe35RhJ2pc/Jc9ncZkH9ZjUgXVY7 PLJj2S+tgBw3V+CQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 09D1E13A6A; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EKR3ASgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:40 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 42/99] fbdev/kyrofb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:19 +0100 Message-Id: <20230306160016.4459-43-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/kyro/fbdev.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index a171f1119e4d..c2c6e1bba3a0 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -562,16 +563,14 @@ static int kyrofb_setcolreg(u_int regno, u_int red, u_int green, } #ifndef MODULE -static int __init kyrofb_setup(char *options) +static int __init kyrofb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ","))) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if (strcmp(this_opt, "nopan") == 0) { nopan = 1; } else if (strcmp(this_opt, "nowrap") == 0) { @@ -591,6 +590,8 @@ static int __init kyrofb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660174 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40421C6FD1F for ; Mon, 6 Mar 2023 16:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230308AbjCFQBO (ORCPT ); Mon, 6 Mar 2023 11:01:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjCFQAo (ORCPT ); Mon, 6 Mar 2023 11:00:44 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208893400A; Mon, 6 Mar 2023 08:00:42 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CA1981FE85; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tdQ9Z0pKhccY3nAxYeCZXdxmClNrcqOqv/uxdQRKhl8=; b=dDysJK5IsCuhM1q2UWLb5Ii5to5sS5Q4BZGGCGE2pS/9vfUfk8TWhygJI3GxRCBxiQXwPA 14gNMuSkMQG14LLNsdA/Oxqko5ax+4zmtSA0/fi4DV59JBXJsFyyl+NotQSNh+ym6cMPAn I1rrLDYRDERoY5W5mLEBXXWyycCB4rE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tdQ9Z0pKhccY3nAxYeCZXdxmClNrcqOqv/uxdQRKhl8=; b=Dv4YwkluAuGRzM30rb8v2sbxU0FROOq1braDVs1pbDI8FImUyWqXz/rnLm9cufyF5noEbq XFU41H4GOayQQYAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6C54A13513; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4MCfGSgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:40 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 43/99] fbdev/macfb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 16:59:20 +0100 Message-Id: <20230306160016.4459-44-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/macfb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/macfb.c b/drivers/video/fbdev/macfb.c index 312e35c9aa6c..44ff860a3f37 100644 --- a/drivers/video/fbdev/macfb.c +++ b/drivers/video/fbdev/macfb.c @@ -339,7 +339,7 @@ static int civic_setpalette(unsigned int regno, unsigned int red, { unsigned long flags; int clut_status; - + local_irq_save(flags); /* Set the register address */ @@ -439,7 +439,7 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, * (according to the entries in the `var' structure). * Return non-zero for invalid regno. */ - + if (regno >= fb_info->cmap.len) return 1; @@ -548,7 +548,7 @@ static int __init macfb_init(void) return -ENODEV; macfb_setup(option); - if (!MACH_IS_MAC) + if (!MACH_IS_MAC) return -ENODEV; if (mac_bi_data.id == MAC_MODEL_Q630 || @@ -644,7 +644,7 @@ static int __init macfb_init(void) err = -EINVAL; goto fail_unmap; } - + /* * We take a wild guess that if the video physical address is * in nubus slot space, that the nubus card is driving video. @@ -774,7 +774,7 @@ static int __init macfb_init(void) civic_cmap_regs = ioremap(CIVIC_BASE, 0x1000); break; - + /* * Assorted weirdos * We think this may be like the LC II From patchwork Mon Mar 6 15:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27A82C7618B for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjCFQBS (ORCPT ); Mon, 6 Mar 2023 11:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbjCFQAp (ORCPT ); Mon, 6 Mar 2023 11:00:45 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FCF34F7E; Mon, 6 Mar 2023 08:00:42 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 338261FE82; Mon, 6 Mar 2023 16:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118441; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zGLBLBg3pdJVJ0Ef7zMg0fUWatn8Nn9plsu006L4xGY=; b=rGbS6q1dbhX3Pk7dNvUjpg8lilOZjgiJHNpUw5nxdDRrKvdHY+/1hEn/lLOTcJ6k5cF4v2 1QgMMBPb3bfiOLBqVpLPk9Ln3fenHy2+Vcv9IcDgd0730zb6rUqU5gQRsbWMoKq+Anxajh gig1RRPHv+C7TEa8m2U4BfSYTfIPZzw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118441; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zGLBLBg3pdJVJ0Ef7zMg0fUWatn8Nn9plsu006L4xGY=; b=tImxUNXWmu7wTyC7umHvV5pt6XrboNN+O93DgzWYN/JyZLxSNY1wixlU1hhBMVcr+jm1/R 8Jg2dPER5jD8+MDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CD79113A6A; Mon, 6 Mar 2023 16:00:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CDtAMSgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:40 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 44/99] fbdev/macfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:21 +0100 Message-Id: <20230306160016.4459-45-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/macfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/macfb.c b/drivers/video/fbdev/macfb.c index 44ff860a3f37..a72edb98b170 100644 --- a/drivers/video/fbdev/macfb.c +++ b/drivers/video/fbdev/macfb.c @@ -20,6 +20,7 @@ * http://rajsky.psych.nyu.edu/Tips/VideoBugs.html */ +#include #include #include #include @@ -504,23 +505,22 @@ static const struct fb_ops macfb_ops = { .fb_imageblit = cfb_imageblit, }; -static void __init macfb_setup(char *options) +static void __init macfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "inverse")) fb_invert_cmaps(); else if (!strcmp(this_opt, "vidtest")) vidtest = 1; /* enable experimental CLUT code */ } + + option_iter_release(&iter); } static void __init iounmap_macfb(void) From patchwork Mon Mar 6 15:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6057C76188 for ; Mon, 6 Mar 2023 16:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbjCFQBS (ORCPT ); Mon, 6 Mar 2023 11:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbjCFQAo (ORCPT ); Mon, 6 Mar 2023 11:00:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3072125E09; Mon, 6 Mar 2023 08:00:42 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 95A25223E5; Mon, 6 Mar 2023 16:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118441; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZkQXjan0jowROvGRC5u3ioDg+jvgH6ZrVreFgORBrsc=; b=p4dSG4UN0SvOYm7f+Ini5G3JxYDXizo15S+ZES2hM8gMpQ+3h0fPW1c3+zc8LfsqJ5uOAa OFPVScXTSW0J1TU/x2+ApALnnvxl1elZCtpmtFZIlmXmV7n746WZB7lcdKoDAc/dsQotHo JYY02IhBpZi7DNJVPKZmos1RkATJ2OQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118441; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZkQXjan0jowROvGRC5u3ioDg+jvgH6ZrVreFgORBrsc=; b=x+GPpd14JqLOBkBEeV+nlMqiuF81+O1WMnDaNkbDHairiMyBGsocqbASU5EH4OxvOuXOwO C+wXHNWgKrawJdBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 388EA13513; Mon, 6 Mar 2023 16:00:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EDztDCkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:41 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 45/99] fbdev/matroxfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:22 +0100 Message-Id: <20230306160016.4459-46-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/matrox/matroxfb_base.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c index a043a737ea9f..f690ee0c9b1f 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.c +++ b/drivers/video/fbdev/matrox/matroxfb_base.c @@ -101,6 +101,7 @@ */ #include +#include #include #include "matroxfb_base.h" @@ -2333,17 +2334,14 @@ static void __exit matrox_done(void) { /* ************************* init in-kernel code ************************** */ -static int __init matroxfb_setup(char *options) { - char *this_opt; - - DBG(__func__) - - if (!options || !*options) - return 0; +static int __init matroxfb_setup(const char *options) +{ + struct option_iter iter; + const char *this_opt; - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { dprintk("matroxfb_setup: option %s\n", this_opt); if (!strncmp(this_opt, "dev:", 4)) @@ -2467,6 +2465,9 @@ static int __init matroxfb_setup(char *options) { } } } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE346C7618A for ; Mon, 6 Mar 2023 16:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbjCFQBQ (ORCPT ); Mon, 6 Mar 2023 11:01:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbjCFQAo (ORCPT ); Mon, 6 Mar 2023 11:00:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B67DC2FCCF; Mon, 6 Mar 2023 08:00:43 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 03BB7223EA; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0MbXmAED/WWG0mr/2DOyHWFGxo5EmitjWc+reW8upDI=; b=S+97CIg0q3c5K+TuqxSZD3t/TtccVwdfs7BL2vx8JV40xHQlOnCT44nOPNxZWms+wafw6u 2KYAPYVGczXFRWC+FFmrY0tlNcE7oZm1DXH7FVNd0qn9U5/TMZ2NUH3qKnUzQfKthwQBuR rlUPfNLrEr4OsxfDp6S+hS7751t++rw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0MbXmAED/WWG0mr/2DOyHWFGxo5EmitjWc+reW8upDI=; b=ELgqy9L5zAtaBO082optXPQ1Go7QxZOM/JFvRhDK1o5pe0ouXouJ993gNcvsu+4o/H+ESh nx7es1PAg0CQSADA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9C37313513; Mon, 6 Mar 2023 16:00:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KG5OJSkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:41 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 46/99] fbdev/mx3fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:23 +0100 Message-Id: <20230306160016.4459-47-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/mx3fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c index 76771e126d0a..cf14fe08567a 100644 --- a/drivers/video/fbdev/mx3fb.c +++ b/drivers/video/fbdev/mx3fb.c @@ -1666,8 +1666,17 @@ static int __init mx3fb_setup(void) continue; if (!strncmp(opt, "bpp=", 4)) default_bpp = simple_strtoul(opt + 4, NULL, 0); - else - fb_mode = opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "mx3fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "mx3fb: option too long\n")) + continue; + fb_mode = mode_option_buf; + } } #endif From patchwork Mon Mar 6 15:59:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0955C76196 for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbjCFQBW (ORCPT ); Mon, 6 Mar 2023 11:01:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230504AbjCFQAq (ORCPT ); Mon, 6 Mar 2023 11:00:46 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E16B305DA; Mon, 6 Mar 2023 08:00:44 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 62216223EB; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VWHGHzW+q4kH1KH9xY8JJ8/Ps4LWtbKGrYcEV4O06cw=; b=VJph/50tpYWpeD5xSouwPdd5N+UgrC9A0PWexq0Z93ZLQnDO2jbNMZSbhMebV1wmOD8h6k CJjdO30HSXkjqa4QnBJ0Z1tNVCg1oQx7RwF/3Fku3u4BotRgPjPlTmRl25vB6oA8Pk6vzC fWhWMr9eTu1T22A7hxkhHbuNuNCHMpQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VWHGHzW+q4kH1KH9xY8JJ8/Ps4LWtbKGrYcEV4O06cw=; b=ynBpFxaUvUoYCB9hqyNEKRepUHFWDhchenuy25Fur3iMNFndKFcoS3PED9ofZDOeY8woPN 6SplZdPzWJzn5iDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0873613A6A; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CPYyASoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:42 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 47/99] fbdev/mx3fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:24 +0100 Message-Id: <20230306160016.4459-48-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/mx3fb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c index cf14fe08567a..cb9f5ac69e79 100644 --- a/drivers/video/fbdev/mx3fb.c +++ b/drivers/video/fbdev/mx3fb.c @@ -6,6 +6,7 @@ * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. */ +#include #include #include #include @@ -1653,17 +1654,16 @@ static struct platform_driver mx3fb_driver = { static int __init mx3fb_setup(void) { #ifndef MODULE - char *opt, *options = NULL; + char *options = NULL; + struct option_iter iter; + const char *opt; if (fb_get_options("mx3fb", &options)) return -ENODEV; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + while (option_iter_next(&iter, opt)) { if (!strncmp(opt, "bpp=", 4)) default_bpp = simple_strtoul(opt + 4, NULL, 0); else { @@ -1678,6 +1678,8 @@ static int __init mx3fb_setup(void) fb_mode = mode_option_buf; } } + + option_iter_release(&iter); #endif return 0; From patchwork Mon Mar 6 15:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74E07C76195 for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbjCFQBV (ORCPT ); Mon, 6 Mar 2023 11:01:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230508AbjCFQAq (ORCPT ); Mon, 6 Mar 2023 11:00:46 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1F530B34; Mon, 6 Mar 2023 08:00:44 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C37991FE8E; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RY3kXDB5O3B2dKeL06A7y/2N+B8soo0q40s9lvLV3c0=; b=dFdmq7Maqv9IBxfXjOtZJbinxuRrLnLdsPdKXYEl1qQi/wrhQxu8yr+8McekkWAH/2SmlB 7zKf6taB7830jBxci9VS5tTnFIAKMID+oBDHDZjBQENwb5N42q/gyz69EriiuWzzmYdH8S 7Ry3BWyWak5Iq5j43eCCPntiOLDl5qY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RY3kXDB5O3B2dKeL06A7y/2N+B8soo0q40s9lvLV3c0=; b=GbyCBA84a/aaAPVwSDmwul2Q+inOSugQYvcb0HUNAJvn/QXdaVWrRao+yY5sfTedrTiO1F EYEYAT8cItDj8+Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6679113513; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ENcjGCoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:42 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 48/99] fbdev/neofb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:25 +0100 Message-Id: <20230306160016.4459-49-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/neofb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 39d8cdef5c97..958111f7d63c 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -2198,8 +2198,17 @@ static int __init neofb_setup(char *options) nopciburst = 1; else if (!strncmp(this_opt, "libretto", 8)) libretto = 1; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "neofb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "neofb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:59:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09B3AC64EC4 for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230510AbjCFQBT (ORCPT ); Mon, 6 Mar 2023 11:01:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230516AbjCFQAq (ORCPT ); Mon, 6 Mar 2023 11:00:46 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 863512E0D3; Mon, 6 Mar 2023 08:00:44 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 30B48223F0; Mon, 6 Mar 2023 16:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118443; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gYmDAktYqSKk16Nt3SCIyrh7JuKwp4gqEgQeRQha4rE=; b=jGqD8OG7NA+zxUIBZpS607qu9LoqogwbziuEQ7wE8IsvXasOWQ8sk5113lM4Y+Aoai1VjK V1zbFNmtoIOBi7CARgZrmLNEkMCwEljbaHEMS7NXihNFU4UAWiycDcf+QMzBR3/zfVURv9 emwhEoGxwTySfU/TsMKcZ+nfow8VtMs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118443; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gYmDAktYqSKk16Nt3SCIyrh7JuKwp4gqEgQeRQha4rE=; b=Yx9jMAbSCp9f9Fq3RNrZI9vyCIxqTNcX1eE2f3Ejd1rnk0M/TQNXaucXHpCnuLtVijIOGY R5buLDvH1HKHS+Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C8F1713513; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uMAkMCoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:42 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 49/99] fbdev/neofb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:26 +0100 Message-Id: <20230306160016.4459-50-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/neofb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 958111f7d63c..e9b132d660ab 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -55,6 +55,7 @@ */ #include +#include #include #include #include @@ -2175,19 +2176,16 @@ static struct pci_driver neofb_driver = { /* ************************* init in-kernel code ************************** */ #ifndef MODULE -static int __init neofb_setup(char *options) +static int __init neofb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; DBG("neofb_setup"); - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "internal", 8)) internal = 1; else if (!strncmp(this_opt, "external", 8)) @@ -2210,6 +2208,9 @@ static int __init neofb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Mon Mar 6 15:59:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D86DC7618D for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbjCFQBU (ORCPT ); Mon, 6 Mar 2023 11:01:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbjCFQAq (ORCPT ); Mon, 6 Mar 2023 11:00:46 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D82122FCEF; Mon, 6 Mar 2023 08:00:44 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 902811FE9D; Mon, 6 Mar 2023 16:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118443; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bNt7g7qk3sNz1zHUSaStHnUvLckbyLDyTgt+yojcOaU=; b=sSn5L16MpIhjidLvMNCBDr4FRRQm/jwbp6ove7mwcqJnV62ScS4M1M4j7CBVp9L2gmTHfu sql+Kb67O68OSpxuTInrxN+65Qbam2Q97DctYwxoweaACPcYMQ61dv/qIzeSUnA8o0nvWm nlb5c0L67GkGSY/iUvxsJv9e53HZTj0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118443; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bNt7g7qk3sNz1zHUSaStHnUvLckbyLDyTgt+yojcOaU=; b=2bcIZLSAwIvktfikfJeQXEEUi+WahZFzsbEkYrkLuT6pYFhDjMKNq2HYVeV9VKd8XIv68Z 0gzvebfe1cw4VUCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3376313A6A; Mon, 6 Mar 2023 16:00:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6Ou7CysOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:43 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 50/99] fbdev/nvidiafb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:27 +0100 Message-Id: <20230306160016.4459-51-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/nvidia/nvidia.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index e60a276b4855..eb91201babd4 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -1498,8 +1498,17 @@ static int nvidiafb_setup(char *options) fpdither = simple_strtol(this_opt+9, NULL, 0); } else if (!strncmp(this_opt, "bpp:", 4)) { bpp = simple_strtoul(this_opt+4, NULL, 0); - } else - mode_option = this_opt; + } else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "nvidiafb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "nvidiafb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } NVTRACE_LEAVE(); return 0; From patchwork Mon Mar 6 15:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C394C7619A for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbjCFQBW (ORCPT ); Mon, 6 Mar 2023 11:01:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbjCFQAr (ORCPT ); Mon, 6 Mar 2023 11:00:47 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91462E813; Mon, 6 Mar 2023 08:00:45 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F0CE8223F5; Mon, 6 Mar 2023 16:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118443; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GdlBvpQCtFANkdgtqm8ATrYFTI/ql2Egv02ZUyDqJ8o=; b=HCZQ0kRDvWLtfqeDNYrYdSQ5fA3xEzhdgqLwHl+t6jQxmCQDXXqqHRjZnVdQq7GmTqRPi6 eclrzaKX4l4SdJ2lQRmRd39SCd1aouKWj1l5/LyVC38Ca1AGZ3HQWxQQDgg3QDtZeUuqvC 9dRlhbPiwqT9LvKb+Vnxac5h4MDMNQc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118443; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GdlBvpQCtFANkdgtqm8ATrYFTI/ql2Egv02ZUyDqJ8o=; b=Hd+sMIb0Mlk7afi9BKsvEL4L3ph/cRvshwvmOsYdJEdvckMpsdPLTwcceaEJrWqc+tzWxG rHEKgviagQh1ZLDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 94A3613513; Mon, 6 Mar 2023 16:00:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gO9JIysOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:43 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 51/99] fbdev/nvidiafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:28 +0100 Message-Id: <20230306160016.4459-52-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/nvidia/nvidia.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index eb91201babd4..58b1b13f09dd 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -1458,17 +1459,18 @@ static void nvidiafb_remove(struct pci_dev *pd) * ------------------------------------------------------------------------- */ #ifndef MODULE -static int nvidiafb_setup(char *options) +static int nvidiafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; NVTRACE_ENTER(); - if (!options || !*options) - return 0; - while ((this_opt = strsep(&options, ",")) != NULL) { + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "forceCRTC", 9)) { - char *p; + const char *p; p = this_opt + 9; if (!*p || !*(++p)) @@ -1510,6 +1512,9 @@ static int nvidiafb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + NVTRACE_LEAVE(); return 0; } From patchwork Mon Mar 6 15:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1B16C77B61 for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjCFQBY (ORCPT ); Mon, 6 Mar 2023 11:01:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbjCFQAr (ORCPT ); Mon, 6 Mar 2023 11:00:47 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF54F30195; Mon, 6 Mar 2023 08:00:45 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5973E223F9; Mon, 6 Mar 2023 16:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5xZuWufF0BKBnJgqnmUzO92Agzss6jwSfAKczEAHKgw=; b=Ri+OkwPppiCoGP9RFfeKBJINJh8GGPK6sO/aql/OWm+N8e38md54yG1eM8FoghdD0HGk4u 98L3izBlLDXHA0Fkb9m1lGhvHOU9rH+lV2sURp1LZLRPC8osURiIGBD14qdloYQD/O9oew ZaOjvQeKFDdzqG5HgOkl2SqHrxtvyOw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5xZuWufF0BKBnJgqnmUzO92Agzss6jwSfAKczEAHKgw=; b=aqrGuidrSFqrQf7eR1g3H2MBDl0S41CbUCmCHHRkWYuQ5h3+tMTkJShxYePoVy3k1lhxoG itYNAd1KxDdLOyDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 00BD513A6A; Mon, 6 Mar 2023 16:00:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WPrbOisOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:43 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 52/99] fbdev/ocfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:29 +0100 Message-Id: <20230306160016.4459-53-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ocfb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c index da7e1457e58f..34684191f2f0 100644 --- a/drivers/video/fbdev/ocfb.c +++ b/drivers/video/fbdev/ocfb.c @@ -75,9 +75,18 @@ static int __init ocfb_setup(char *options) return 0; while ((curr_opt = strsep(&options, ",")) != NULL) { + static char mode_option_buf[256]; + int ret; + if (!*curr_opt) continue; - mode_option = curr_opt; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", curr_opt); + if (WARN(ret < 0, "ocfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "ocfb: option too long\n")) + continue; + mode_option = mode_option_buf; } return 0; From patchwork Mon Mar 6 15:59:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDE27C761A6 for ; Mon, 6 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229579AbjCFQBX (ORCPT ); Mon, 6 Mar 2023 11:01:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbjCFQAs (ORCPT ); Mon, 6 Mar 2023 11:00:48 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B97E30E8A; Mon, 6 Mar 2023 08:00:46 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BBAAF223FC; Mon, 6 Mar 2023 16:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lkt2t6TbCzJeoqPND2yFcyB59V0QgGNbu9SOcmgKnwk=; b=NHhEcmv9tsTiLJnQPH2ETHxCXkscjljCidCHPH+0jJoMKrFPIlw13weJEQ/uR4kiHi1+No 7B21Wmn0iT8sijfvKnK85CFFQGL5peTP18PtRSlTBJxiQfxOyXGaiTTMQLlPREW9dNHE24 2kZd+BUHqz1lzgrPvbopotGkchivvcs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lkt2t6TbCzJeoqPND2yFcyB59V0QgGNbu9SOcmgKnwk=; b=qfqauMl2cTtJd+0wi1cHAGPk6rCgs4b1+BCspicy+N2lDVf+4nioAOvim68MP+hMiNqD+K bMKzDjfBg/QZouDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5EF3A13513; Mon, 6 Mar 2023 16:00:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CPVGFiwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:44 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 53/99] fbdev/ocfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:30 +0100 Message-Id: <20230306160016.4459-54-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ocfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c index 34684191f2f0..546230483f53 100644 --- a/drivers/video/fbdev/ocfb.c +++ b/drivers/video/fbdev/ocfb.c @@ -8,6 +8,7 @@ * kind, whether express or implied. */ +#include #include #include #include @@ -67,20 +68,17 @@ struct ocfb_dev { }; #ifndef MODULE -static int __init ocfb_setup(char *options) +static int __init ocfb_setup(const char *options) { - char *curr_opt; + struct option_iter iter; + const char *curr_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((curr_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, curr_opt)) { static char mode_option_buf[256]; int ret; - if (!*curr_opt) - continue; - ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", curr_opt); if (WARN(ret < 0, "ocfb: ignoring invalid option, ret=%d\n", ret)) continue; @@ -89,6 +87,8 @@ static int __init ocfb_setup(char *options) mode_option = mode_option_buf; } + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FCBC77B71 for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230377AbjCFQB3 (ORCPT ); Mon, 6 Mar 2023 11:01:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbjCFQAs (ORCPT ); Mon, 6 Mar 2023 11:00:48 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 917142A6D2; Mon, 6 Mar 2023 08:00:46 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 21A321FEAA; Mon, 6 Mar 2023 16:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118445; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FDbqWv5400a+VKgJzOqfkAd4hlorIAaEh2nSCFtvtGc=; b=d8KWB8grReTsp7EdFmF1dYuc7UjFEFWkdMlnYuY3q2xkxJZiertWS7uNdwfQaags6RMf0m hIRTXaU7d0pcafaAP8un9ei5EufYbVz7YHEw77NlEjgDyBsaOw6K6OIGXT5Wp639lViXXu cAn90eUDM/SN/l3mUnvBpUVwIJAIh/U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118445; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FDbqWv5400a+VKgJzOqfkAd4hlorIAaEh2nSCFtvtGc=; b=FEvtDlKDZcdcwsYwN+k/oUaPR0pEpgvBHhrlbpfb/7RX4YyApBKHEby7n2RI1regyZHYuq KTvN+Em66oNmBjDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BE3F913A6A; Mon, 6 Mar 2023 16:00:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OPWLLSwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:44 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 54/99] fbdev/omapfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:31 +0100 Message-Id: <20230306160016.4459-55-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/omap/omapfb_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c index 1f3df2055ff0..464a667708db 100644 --- a/drivers/video/fbdev/omap/omapfb_main.c +++ b/drivers/video/fbdev/omap/omapfb_main.c @@ -11,6 +11,7 @@ * Dirk Behme - changes for 2.6 kernel API * Texas Instruments - H3 support */ +#include #include #include #include @@ -1842,17 +1843,17 @@ static struct platform_driver omapfb_driver = { #ifndef MODULE /* Process kernel command line parameters */ -static int __init omapfb_setup(char *options) +static int __init omapfb_setup(const char *options) { - char *this_opt = NULL; + struct option_iter iter; + const char *this_opt; int r = 0; pr_debug("omapfb: options %s\n", options); - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while (!r && (this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "accel", 5)) def_accel = 1; else if (!strncmp(this_opt, "vram:", 5)) { @@ -1893,6 +1894,8 @@ static int __init omapfb_setup(char *options) } } + option_iter_release(&iter); + return r; } From patchwork Mon Mar 6 15:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB9DBC77B73 for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjCFQBb (ORCPT ); Mon, 6 Mar 2023 11:01:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbjCFQAs (ORCPT ); Mon, 6 Mar 2023 11:00:48 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50742ED53; Mon, 6 Mar 2023 08:00:46 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8406022401; Mon, 6 Mar 2023 16:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118445; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X5AyqMEb/dcQWrJZGyOdvA+a4qQMQbwFfZc6UsGJ8JQ=; b=dVFyUP2baBGf9dvkncsVlo9MYCWDNFG8nv4glDhW5tyv5c1l0SjKbjM+FjMOKBGjKzvXDy jweZm0u6aG5G07WS9UYXGJSNRBXgBZoVYPSOfyGiYMO4fYhrHEkjh/frYiRznSvOJtYBhj zUGTakJjpUYEdzuqiLmyi/so6lgsLBs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118445; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X5AyqMEb/dcQWrJZGyOdvA+a4qQMQbwFfZc6UsGJ8JQ=; b=GlZsmHoIHEMsPv5KnPss40JCrUMMeKcNWxpjxNgeEhiq6g7kiJkUvutwGy962jW7c/A738 +EuUu6pvHsU/agBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 27D0513513; Mon, 6 Mar 2023 16:00:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wH6GCC0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:45 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 55/99] fbdev/platinumfb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 16:59:32 +0100 Message-Id: <20230306160016.4459-56-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/platinumfb.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c index 5b9e26ea6449..c7172174c1b7 100644 --- a/drivers/video/fbdev/platinumfb.c +++ b/drivers/video/fbdev/platinumfb.c @@ -52,17 +52,17 @@ struct fb_info_platinum { __u8 red, green, blue; } palette[256]; u32 pseudo_palette[16]; - + volatile struct cmap_regs __iomem *cmap_regs; unsigned long cmap_regs_phys; - + volatile struct platinum_regs __iomem *platinum_regs; unsigned long platinum_regs_phys; - + __u8 __iomem *frame_buffer; volatile __u8 __iomem *base_frame_buffer; unsigned long frame_buffer_phys; - + unsigned long total_vram; int clktype; int dactype; @@ -133,7 +133,7 @@ static int platinumfb_set_par (struct fb_info *info) platinum_set_hardware(pinfo); init = platinum_reg_init[pinfo->vmode-1]; - + if ((pinfo->vmode == VMODE_832_624_75) && (pinfo->cmode > CMODE_8)) offset = 0x10; @@ -214,7 +214,7 @@ static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, break; } } - + return 0; } @@ -269,7 +269,7 @@ static void platinum_set_hardware(struct fb_info_platinum *pinfo) struct platinum_regvals *init; int i; int vmode, cmode; - + vmode = pinfo->vmode; cmode = pinfo->cmode; @@ -436,7 +436,7 @@ static int read_platinum_sense(struct fb_info_platinum *info) * This routine takes a user-supplied var, and picks the best vmode/cmode from it. * It also updates the var structure to the actual mode data obtained */ -static int platinum_var_to_par(struct fb_var_screeninfo *var, +static int platinum_var_to_par(struct fb_var_screeninfo *var, struct fb_info_platinum *pinfo, int check_only) { @@ -478,12 +478,12 @@ static int platinum_var_to_par(struct fb_var_screeninfo *var, pinfo->yoffset = 0; pinfo->vxres = pinfo->xres; pinfo->vyres = pinfo->yres; - + return 0; } -/* +/* * Parse user specified options (`video=platinumfb:') */ static int __init platinumfb_setup(char *options) @@ -624,7 +624,7 @@ static int platinumfb_probe(struct platform_device* odev) break; } dev_set_drvdata(&odev->dev, info); - + rc = platinum_init_fb(info); if (rc != 0) { iounmap(pinfo->frame_buffer); @@ -640,9 +640,9 @@ static int platinumfb_remove(struct platform_device* odev) { struct fb_info *info = dev_get_drvdata(&odev->dev); struct fb_info_platinum *pinfo = info->par; - + unregister_framebuffer (info); - + /* Unmap frame buffer and registers */ iounmap(pinfo->frame_buffer); iounmap(pinfo->platinum_regs); @@ -658,7 +658,7 @@ static int platinumfb_remove(struct platform_device* odev) return 0; } -static struct of_device_id platinumfb_match[] = +static struct of_device_id platinumfb_match[] = { { .name = "platinum", @@ -666,7 +666,7 @@ static struct of_device_id platinumfb_match[] = {}, }; -static struct platform_driver platinum_driver = +static struct platform_driver platinum_driver = { .driver = { .name = "platinumfb", From patchwork Mon Mar 6 15:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7392C61DA4 for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231387AbjCFQBa (ORCPT ); Mon, 6 Mar 2023 11:01:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbjCFQAs (ORCPT ); Mon, 6 Mar 2023 11:00:48 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413CB25E09; Mon, 6 Mar 2023 08:00:47 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E6C4222402; Mon, 6 Mar 2023 16:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118445; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S9aOCeHqZlZesioi37B2NVNrU0985XVnrbCXRalDe94=; b=B7MGPgkgov5u7qATe+/yiN/dQr13NYhlaJ9FfNoDPe7PD782it2Y6MrJ+fFt+5QlhICHFo hnNdbx0inQS6diZWdefspyz3oeON+AfmrHiWdK9omvZVGOc8GRYZSNllaw0mlNCie2VA/g E7dnWxbbXf5ADMqM8JSMTWH3fAoC1Xc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118445; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S9aOCeHqZlZesioi37B2NVNrU0985XVnrbCXRalDe94=; b=y/FCJC70+qCLgBSyVm+GkBzzHpZaGORydb8TdcBUe6COteZgoSOHJmM2FDM/vfuhmY1zcZ 9D6pBD1L487QYwCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 875E813A6A; Mon, 6 Mar 2023 16:00:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GAkjIC0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:45 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 56/99] fbdev/platinumfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:33 +0100 Message-Id: <20230306160016.4459-57-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/platinumfb.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c index c7172174c1b7..71d5b7c169e7 100644 --- a/drivers/video/fbdev/platinumfb.c +++ b/drivers/video/fbdev/platinumfb.c @@ -19,6 +19,7 @@ #undef DEBUG +#include #include #include #include @@ -486,14 +487,14 @@ static int platinum_var_to_par(struct fb_var_screeninfo *var, /* * Parse user specified options (`video=platinumfb:') */ -static int __init platinumfb_setup(char *options) +static int __init platinumfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "vmode:", 6)) { int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX) @@ -516,6 +517,9 @@ static int __init platinumfb_setup(char *options) } } } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9009AC77B70 for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231355AbjCFQB2 (ORCPT ); Mon, 6 Mar 2023 11:01:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231258AbjCFQAt (ORCPT ); Mon, 6 Mar 2023 11:00:49 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 949A32ED45; Mon, 6 Mar 2023 08:00:47 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 51E3922406; Mon, 6 Mar 2023 16:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gUS+ZW/pjIEoipwKswrnCLU1MrAzI/P20Inh2a0F+bs=; b=CrcpXfMqJqc6ae5p1CI7DFt9MvHFl/3jAsSDDKr4YE4Crfttt0VQMXO3em4fR6/mwjYaSC 5AAK2BMKVxhwNWtOTOvkY+YWuVamVp+774vDPWeEYys4QthyAMMX5LsBq5gt1bD72KtU/a l0j9Y9yFx2PFxHYOOajRAtwDZ9q+h3c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gUS+ZW/pjIEoipwKswrnCLU1MrAzI/P20Inh2a0F+bs=; b=uHf5iErwd5ElSU4O3kj+nz1dVxQnF35JZOdp/SzwZk0Ql0HgPNSv3Crx/bL96+CL+Zn3x3 sw4BB30WF57qMQBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EB9F213513; Mon, 6 Mar 2023 16:00:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WHFsOC0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:45 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 57/99] fbdev/pm2fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:34 +0100 Message-Id: <20230306160016.4459-58-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pm2fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c index 47d212944f30..c6a117538fd8 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -1792,8 +1792,17 @@ static int __init pm2fb_setup(char *options) nomtrr = 1; else if (!strncmp(this_opt, "noaccel", 7)) noaccel = 1; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "pm2fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "pm2fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:59:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 596BDC77B6F for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231349AbjCFQB1 (ORCPT ); Mon, 6 Mar 2023 11:01:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbjCFQAt (ORCPT ); Mon, 6 Mar 2023 11:00:49 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E762ED79; Mon, 6 Mar 2023 08:00:48 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B48B71FEB2; Mon, 6 Mar 2023 16:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19VpuBm70vNXnliD8T8K9oFn9HFUwo8rA5qbZ2DfN+A=; b=rineVMVSwgL0pJkgvD7v14B+v8/s4iidysofQdfX4Cb7Y6ElVbD2yxJf9R/DmY1MYGVds0 gBv8l8PpL9bIjpdckt9oeXD+CmygyvvgEGswoLRoRduIT7oTRRJXO63r1+TdfvvHx6jhhh UYQrGM1o6yrDESqG2ViT92nlkO8AsXc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118446; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19VpuBm70vNXnliD8T8K9oFn9HFUwo8rA5qbZ2DfN+A=; b=brI7szavTzuLuj45bTppKinf8IxIal5TwelwYUJG2hsFok28choJKmfUrd/0sgxmoH1M67 o1XqPFLWOrt7B/CQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 56E9C13A6A; Mon, 6 Mar 2023 16:00:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cE9PFC4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:46 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 58/99] fbdev/pm2fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:35 +0100 Message-Id: <20230306160016.4459-59-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pm2fb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c index c6a117538fd8..a6a793efb0fe 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include @@ -1772,16 +1773,14 @@ MODULE_DEVICE_TABLE(pci, pm2fb_id_table); * * This is, comma-separated options following `video=pm2fb:'. */ -static int __init pm2fb_setup(char *options) +static int __init pm2fb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "lowhsync")) lowhsync = 1; else if (!strcmp(this_opt, "lowvsync")) @@ -1804,6 +1803,9 @@ static int __init pm2fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EAA7C77B6C for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbjCFQB0 (ORCPT ); Mon, 6 Mar 2023 11:01:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231263AbjCFQAt (ORCPT ); Mon, 6 Mar 2023 11:00:49 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65FD32E0D3; Mon, 6 Mar 2023 08:00:48 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 218AB1FEB6; Mon, 6 Mar 2023 16:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MS+PFmaqiOmf95A5S5Zq6/GUizF4f5fYETWFaMoxpps=; b=eyAcjdzDglmtF4oh1f0MNlaik2bGJgNkrgTFv1LJfMo4v1hE2CKxGYM9r1k5sOmX1luf0b Pt6wK2chtkXQCnXhJq+hJN4v3enn9riFmiEEq9S+7RuJSjKCBFMXzAvoC6vT205OWvaiJ0 1Ln1Nod3dTOz4yy9dnVEH86cOCkZLaw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MS+PFmaqiOmf95A5S5Zq6/GUizF4f5fYETWFaMoxpps=; b=nuUXLk2Pj692pTF+R3MQ78A7dHt9zUtyxTUn/qqQKTI7goCHVs9q8w74qYk1XVpRrUC1dB OGeaL7bNptKdhkAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B846313513; Mon, 6 Mar 2023 16:00:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cIAfLC4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:46 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 59/99] fbdev/pm3fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:36 +0100 Message-Id: <20230306160016.4459-60-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pm3fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c index b46a471df9ae..d0a2cf623c60 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -1526,8 +1526,17 @@ static int __init pm3fb_setup(char *options) hwcursor = simple_strtoul(this_opt + 9, NULL, 0); else if (!strncmp(this_opt, "nomtrr", 6)) nomtrr = 1; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "pm3fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "pm3fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:59:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15C04C761AF for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbjCFQBZ (ORCPT ); Mon, 6 Mar 2023 11:01:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjCFQAu (ORCPT ); Mon, 6 Mar 2023 11:00:50 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18062FCF9; Mon, 6 Mar 2023 08:00:48 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 84D802240C; Mon, 6 Mar 2023 16:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5yPnSkbz5tA4uAxISnCkR1RSi8OF61H7RsXEqS6C5Nk=; b=w+n+ch+QtZ/PrnUkjqkuUkxbbK4eWiCtDZ1wwhbOhcw/lecYrodPTBgW7kprX3fl9w7gqK V6WByqkcEfh1aYAT2LWCRovEHtzzp/c71upUeUG4gBOzSZ2C5FTzDvZxuH2sUzDnqc1n5d 7vtIHZuwTeZjhAHQiyp9wJ3l03/5zts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5yPnSkbz5tA4uAxISnCkR1RSi8OF61H7RsXEqS6C5Nk=; b=AkGWwV+A7HRbMxnQAQxcJsFEy1RoWlLDfYJASmlbsqLlTzVl+9PsMt7D1AaoKTwf7WSrA1 3YjAu9z42XtbYVCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2718C13A6A; Mon, 6 Mar 2023 16:00:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6K5vCC8OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:47 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 60/99] fbdev/pm3fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:37 +0100 Message-Id: <20230306160016.4459-61-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pm3fb.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c index d0a2cf623c60..4eec0ad1e984 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -1509,18 +1510,16 @@ MODULE_DEVICE_TABLE(pci, pm3fb_id_table); * Only necessary if your driver takes special options, * otherwise we fall back on the generic fb_setup(). */ -static int __init pm3fb_setup(char *options) +static int __init pm3fb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; /* Parse user specified options (`video=pm3fb:') */ - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; - else if (!strncmp(this_opt, "noaccel", 7)) + while (option_iter_next(&iter, this_opt)) { + if (!strncmp(this_opt, "noaccel", 7)) noaccel = 1; else if (!strncmp(this_opt, "hwcursor=", 9)) hwcursor = simple_strtoul(this_opt + 9, NULL, 0); @@ -1538,6 +1537,9 @@ static int __init pm3fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Mon Mar 6 15:59:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9A35C77B74 for ; Mon, 6 Mar 2023 16:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbjCFQBc (ORCPT ); Mon, 6 Mar 2023 11:01:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231317AbjCFQAw (ORCPT ); Mon, 6 Mar 2023 11:00:52 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 515EB30B34; Mon, 6 Mar 2023 08:00:49 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E68AC2240D; Mon, 6 Mar 2023 16:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VDfFDt7NYTyK2aPKtVVQx73vE1xW7+lyU5Y/t6YH1Aw=; b=YCuoZH5vrb88dmhkcqHeZwWnsWN/9hDNUqsa7M8Ff78pvzJm19ixcxoq6iMaEbPkLjRC2U nBkdlkoaeWveE+xVbr8Sc1jWYLfHKnncw6sWNMzbM0C/7m8bNAiN9LaP/bbabLHfqkw9B1 7U4VdUDKy7jzq73QM0RO6/4xsmDhs1o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118447; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VDfFDt7NYTyK2aPKtVVQx73vE1xW7+lyU5Y/t6YH1Aw=; b=77pBNYDAw+nlLWdiXpinb/K3eDqjxZK9WUBGDc+n/WoOeThXp7xrRC9z44+IFXnTcu9TuI nmSt6x9g42iD/xDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8882513513; Mon, 6 Mar 2023 16:00:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sDl4IC8OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:47 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 61/99] fbdev/ps3fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:38 +0100 Message-Id: <20230306160016.4459-62-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ps3fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c index 2fe08b67eda7..87543411acaf 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -1276,8 +1276,17 @@ static int __init ps3fb_setup(void) continue; if (!strncmp(this_opt, "mode:", 5)) ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0); - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "ps3fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "ps3fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:59:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21B83C77B75 for ; Mon, 6 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjCFQBd (ORCPT ); Mon, 6 Mar 2023 11:01:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbjCFQAw (ORCPT ); Mon, 6 Mar 2023 11:00:52 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97DA02E813; Mon, 6 Mar 2023 08:00:49 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 484A222416; Mon, 6 Mar 2023 16:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118448; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A7YnDe3aCf50AqpJp4Wzplaha6UCPWu6xjvmVT/66wY=; b=pNSDKF5CwThjpxHh8R7ZQhSpo/AvfxIKHq5OEd8Qk+xplhSzry3Hx8QFuPy0nRxzBXWEUe nwbR1ImnVbQ4DVg7B66GymLb8dQ+m9Awm0Gjlwj71gKTzsBJmW4AvicvWgi+Gw8kmu9JU3 wE8fXZGLnHo7RAPLNivnVttYiIiVO2o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118448; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A7YnDe3aCf50AqpJp4Wzplaha6UCPWu6xjvmVT/66wY=; b=Z+wSpFHGB7tPNNCT3v3Vqym6j7FeA5YkKZRG3Q0koRWhkmZMOjcVdJoTBgRgbiAciWG3bW wxWkXVKXwp5lTQAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EA1A513A6A; Mon, 6 Mar 2023 16:00:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cM1cOC8OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:47 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 62/99] fbdev/ps3fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:39 +0100 Message-Id: <20230306160016.4459-63-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ps3fb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c index 87543411acaf..d7c287089c64 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -17,6 +17,7 @@ * more details. */ +#include #include #include #include @@ -1256,6 +1257,8 @@ static struct ps3_system_bus_driver ps3fb_driver = { static int __init ps3fb_setup(void) { char *options; + struct option_iter iter; + const char *this_opt; #ifdef MODULE return 0; @@ -1264,16 +1267,9 @@ static int __init ps3fb_setup(void) if (fb_get_options(DEVICE_NAME, &options)) return -ENXIO; - if (!options || !*options) - return 0; - - while (1) { - char *this_opt = strsep(&options, ","); + option_iter_init(&iter, options); - if (!this_opt) - break; - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "mode:", 5)) ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0); else { @@ -1288,6 +1284,9 @@ static int __init ps3fb_setup(void) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB64C77B79 for ; Mon, 6 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjCFQBg (ORCPT ); Mon, 6 Mar 2023 11:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231330AbjCFQAx (ORCPT ); Mon, 6 Mar 2023 11:00:53 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FD052A6D2; Mon, 6 Mar 2023 08:00:50 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A129322417; Mon, 6 Mar 2023 16:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118448; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yk8NEEFyYFz7QCOnrJy+3UNVzVnSkFF9rUK/rTVstVw=; b=ipn1oNoL8qgLXjs4f4GtU9f/Ri4YDt73X0/TvFnJ79CtWu9n8/hVZ440v9W1mRlrMiJY0m ZaKok8Kf9WW9HIlqjzJnAy1fgeoNTaMoYA5kSIO1mxHfdyxUaObCQYCwdElfxm8sTp+Nrm RIBwLREtIjf+l2gADtz4zYDiixiSOSo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118448; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yk8NEEFyYFz7QCOnrJy+3UNVzVnSkFF9rUK/rTVstVw=; b=iC4cIbwtW1r3WfnatTA5zG+AxJ5q1hiAvjhOthUj8zVJkV1RQje56jvLmm06CSUTaLYgih i8qNrh7K62zv6OCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4CC8513513; Mon, 6 Mar 2023 16:00:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iJjmETAOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:48 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 63/99] fbdev/pvr2fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:40 +0100 Message-Id: <20230306160016.4459-64-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pvr2fb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index 6888127a5eb8..cd778f8753f1 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -1049,7 +1049,15 @@ static int __init pvr2fb_setup(char *options) } else if (!strncmp(this_opt, "nowrap", 6)) { nowrap = 1; } else { - mode_option = this_opt; + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "pvr2fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "pvr2fb: option too long\n")) + continue; + mode_option = mode_option_buf; } } From patchwork Mon Mar 6 15:59:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3802AC77B78 for ; Mon, 6 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231439AbjCFQBf (ORCPT ); Mon, 6 Mar 2023 11:01:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjCFQAx (ORCPT ); Mon, 6 Mar 2023 11:00:53 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B692ED53; Mon, 6 Mar 2023 08:00:50 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 05A501FEC1; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OWrkdVSEPMMK9cPjOGgBoOtcewGCxhSWSIMFGqazRc0=; b=Goz1yKKxJT0Jr6x5BTkNtJr6vgGDw0pko1sUEqMhorQVy2CEnmdo7IqfwSwLtXzBLOUJIp KYly7cott6YArzFVQmwOxKMS9p1NhLrSHepl2UshUvVyLflqPepjrn5BhayjT2rZJ0y3cj YaXXA0liKLJl2aiOY4JoBKtgtYuxkjU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OWrkdVSEPMMK9cPjOGgBoOtcewGCxhSWSIMFGqazRc0=; b=pfbJlJtyzM0O5KIBaoENIeDlueFBFEhTDijAwxcEZJivTdx6S7jlRDIgw2aPl4T9brVWH1 nwuXTIV2jya25RCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3C1213A6A; Mon, 6 Mar 2023 16:00:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cG8rJzAOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:48 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 64/99] fbdev/pvr2fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:41 +0100 Message-Id: <20230306160016.4459-65-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pvr2fb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index cd778f8753f1..9255b3506b81 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -46,6 +46,7 @@ #undef DEBUG #include +#include #include #include #include @@ -1024,20 +1025,18 @@ static void pvr2fb_pci_exit(void) */ #ifndef MODULE -static int __init pvr2fb_setup(char *options) +static int __init pvr2fb_setup(const char *options) { - char *this_opt; char cable_arg[80]; char output_arg[80]; - - if (!options || !*options) - return 0; + struct option_iter iter; + const char *this_opt; cable_arg[0] = output_arg[0] = 0; - while ((this_opt = strsep(&options, ","))) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "inverse")) { fb_invert_cmaps(); } else if (!strncmp(this_opt, "cable:", 6)) { @@ -1061,6 +1060,8 @@ static int __init pvr2fb_setup(char *options) } } + option_iter_release(&iter); + if (*cable_arg) cable_type = pvr2_get_param_val(cables, cable_arg, 3); if (*output_arg) From patchwork Mon Mar 6 15:59:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57160C77B77 for ; Mon, 6 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbjCFQBi (ORCPT ); Mon, 6 Mar 2023 11:01:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjCFQAy (ORCPT ); Mon, 6 Mar 2023 11:00:54 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6DC832E58; Mon, 6 Mar 2023 08:00:50 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5D4CF2240E; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snfxViy/qdBZ7vPsSIH131CJdLXFxu4HUqdQ8e37Ud8=; b=Zxi4arKwI8LyGIiT6qDZFplx3WjAiVUTv64MwpmZ9zxfKO2wmAhKEnjpYvUDQcFUOYsPpz 79g2AKWBjzNEcYzymVXnX3ZyyToxLMr3os4tWtGA2qZuuQaYffVeJBJ8ByIOe0rYo0jp43 KNjeH6YAaZrm7NZSGapCW32CwYAL5BI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snfxViy/qdBZ7vPsSIH131CJdLXFxu4HUqdQ8e37Ud8=; b=0/WTUCL0oPb9lqiQxJDQsko4JelX3Bjrotl1dZNLTd3+caezJol+RQJp3BDWng0sZId3yg R3hbR7MLNBJtrQAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 09EFD13513; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AF2mATEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:49 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 65/99] fbdev/pxafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:42 +0100 Message-Id: <20230306160016.4459-66-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pxafb.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c index c46ed78298ae..1937a58e47a1 100644 --- a/drivers/video/fbdev/pxafb.c +++ b/drivers/video/fbdev/pxafb.c @@ -32,6 +32,7 @@ * All Rights Reserved */ +#include #include #include #include @@ -2011,23 +2012,26 @@ static int parse_opt(struct device *dev, char *this_opt, return 0; } -static int pxafb_parse_options(struct device *dev, char *options, +static int pxafb_parse_options(struct device *dev, const char *options, struct pxafb_mach_info *inf) { - char *this_opt; + struct option_iter iter; + const char *this_opt; int ret; - if (!options || !*options) - return 0; - dev_dbg(dev, "options are \"%s\"\n", options ? options : "null"); - /* could be made table driven or similar?... */ - while ((this_opt = strsep(&options, ",")) != NULL) { + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { + /* could be made table driven or similar?... */ ret = parse_opt(dev, this_opt, inf); if (ret) return ret; } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FBE2C678D4 for ; Mon, 6 Mar 2023 16:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231542AbjCFQBj (ORCPT ); Mon, 6 Mar 2023 11:01:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbjCFQAz (ORCPT ); Mon, 6 Mar 2023 11:00:55 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22DDA2E0D3; Mon, 6 Mar 2023 08:00:51 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BC6DB2241C; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KeAlevCWeWePabJAji9QriWw1Xre+Z3oHUn0cc9BQIk=; b=YuTMjqOVPPTdnqtMm4Gjk1woVSERAG+XGK8+BhA2SIt+oqeiS5AnDwsmUkYc/oDXMLyscX Xe1pwVJLCxD2lIVwLri1KFCvflZOgyQWJ4bMPxaLWn620+NNq/A/mNVztNMzFuOFk6h62B F75u0lxPL1fwlfLAotKGkrQHBPUgHlg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KeAlevCWeWePabJAji9QriWw1Xre+Z3oHUn0cc9BQIk=; b=YbA/aSwezIiBCjAunUVSJQ9NmgQHQe2ttWpY9f+fGgvNk+79sYaAdYcIGtIw64N39e6hb0 W+Vjk8omi9rcJeAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 61B3213A6A; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iKEFFzEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:49 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 66/99] fbdev/rivafb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:43 +0100 Message-Id: <20230306160016.4459-67-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/riva/fbdev.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index 41edc6e79460..affb7c5ef69c 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -2132,8 +2132,17 @@ static int rivafb_setup(char *options) strictmode = 1; } else if (!strncmp(this_opt, "noaccel", 7)) { noaccel = 1; - } else - mode_option = this_opt; + } else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "rivafb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "rivafb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } NVTRACE_LEAVE(); return 0; From patchwork Mon Mar 6 15:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 831D6C77B7B for ; Mon, 6 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230368AbjCFQBi (ORCPT ); Mon, 6 Mar 2023 11:01:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8096D2E807; Mon, 6 Mar 2023 08:00:51 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2C50C22420; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WSh0HckrJ14YnHwX8ou8Ih8C9aC0FM64D7FA3t8uE60=; b=QneuH2XZ6Xs+drSTkA4ph3R2sAoTuAW3CggI3eegmR3uKEN2BcOB9D2md7FPav27gZsC4i N2dtuydW9qAIwtaK31qTu4b3ppxUXkKao9UsWKfQNBQr4LmjyoVgvoYeCbdyq+hhGCeXK3 MK2I2COBaOpjZNJGsrevr3MrsEOeUoE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WSh0HckrJ14YnHwX8ou8Ih8C9aC0FM64D7FA3t8uE60=; b=bp7IKviDrEyrrsnS0ceS6wdtj23PO79q69MreIKf7f5OkJkEJEbrbJ/lgUMhywPF7jBIkF wMEzF2Z7xEC/zkAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C10F813513; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uMnwLTEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:49 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 67/99] fbdev/rivafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:44 +0100 Message-Id: <20230306160016.4459-68-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/riva/fbdev.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index affb7c5ef69c..d95319bb93cc 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -30,6 +30,7 @@ */ #include +#include #include #include #include @@ -2105,17 +2106,18 @@ static void rivafb_remove(struct pci_dev *pd) * ------------------------------------------------------------------------- */ #ifndef MODULE -static int rivafb_setup(char *options) +static int rivafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; NVTRACE_ENTER(); - if (!options || !*options) - return 0; - while ((this_opt = strsep(&options, ",")) != NULL) { + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "forceCRTC", 9)) { - char *p; + const char *p; p = this_opt + 9; if (!*p || !*(++p)) continue; @@ -2144,6 +2146,9 @@ static int rivafb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + NVTRACE_LEAVE(); return 0; } From patchwork Mon Mar 6 15:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1775EC64EC4 for ; Mon, 6 Mar 2023 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbjCFQBm (ORCPT ); Mon, 6 Mar 2023 11:01:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38A63018E; Mon, 6 Mar 2023 08:00:51 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 812C81FEC4; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=63rAnMx2YP20dq4CbrataKJRbeisc0iZL+E03N9wrcE=; b=ffSxHVH/UnJx5Egi7/w50TwVwbInrgMDZVnUV6n6xvFhZd/ZKjD/Nn19p0jZeed2mD+nzh uZepI7NEZzh/ttgCN9b9JMgAXD7Ly1KZ8yM3Q4ZqGsK89P0G+yaL19NWxvd1H2Oh0UNrZ4 apcWF0BFGsSiKK4xC1YspRYZMoNsH7c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=63rAnMx2YP20dq4CbrataKJRbeisc0iZL+E03N9wrcE=; b=8bMnB9nt/h9VK9qBKZ7klkW+QDw7629xsahXkHDZyKTbqpJ7z4j0HVP6zzDqgKIqMATyAf dAP//9UNASp6DYAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2E32E13A6A; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yDt+CjIOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:50 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 68/99] fbdev/s3fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:45 +0100 Message-Id: <20230306160016.4459-69-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/s3fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 7d257489edcc..70aefd7224a1 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1535,8 +1535,17 @@ static int __init s3fb_setup(char *options) mtrr = simple_strtoul(opt + 5, NULL, 0); else if (!strncmp(opt, "fasttext:", 9)) fasttext = simple_strtoul(opt + 9, NULL, 0); - else - mode_option = opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "s3fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "s3fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; From patchwork Mon Mar 6 15:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11852C74A4B for ; Mon, 6 Mar 2023 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbjCFQCC (ORCPT ); Mon, 6 Mar 2023 11:02:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 497713344C; Mon, 6 Mar 2023 08:00:52 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D3B331FEBD; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1oaOTqhLqj27vSdh0cq11LIl0EI69h40CbQa7yd1/0g=; b=ta6oVjgZxW6t2uTHz1oo+mZ03l6ueNVF5e+5aa9/k8MBRNjWrAYEgwvEWpIj/OsI/IkBIn tsunLcrtobwQL0xw+96gozhnNAUOX2hBV4aZEIQCXKnrsPoEMj8bsL+mqsgtuhTGYWaN9F qwuUTPTmR/C2/8XSTKprIb820NCcXX4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1oaOTqhLqj27vSdh0cq11LIl0EI69h40CbQa7yd1/0g=; b=L2UEvQOAkMesIGHLeKLp4JKRZPvuryBcCgJrdGiA/UW2xhuo43BLKKYDJpp7n6USvStaHM c8Cg00NSdKVL+oDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 83FBF13513; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6MtyHzIOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:50 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 69/99] fbdev/s3fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:46 +0100 Message-Id: <20230306160016.4459-70-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/s3fb.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 70aefd7224a1..f3bd7b1c2c9a 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -1520,18 +1521,15 @@ static struct pci_driver s3fb_pci_driver = { /* Parse user specified options */ #ifndef MODULE -static int __init s3fb_setup(char *options) +static int __init s3fb_setup(const char *options) { - char *opt; + struct option_iter iter; + const char *opt; - if (!options || !*options) - return 0; - - while ((opt = strsep(&options, ",")) != NULL) { + option_iter_init(&iter, options); - if (!*opt) - continue; - else if (!strncmp(opt, "mtrr:", 5)) + while (option_iter_next(&iter, opt)) { + if (!strncmp(opt, "mtrr:", 5)) mtrr = simple_strtoul(opt + 5, NULL, 0); else if (!strncmp(opt, "fasttext:", 9)) fasttext = simple_strtoul(opt + 9, NULL, 0); @@ -1548,6 +1546,8 @@ static int __init s3fb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF1A4C61DA4 for ; Mon, 6 Mar 2023 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjCFQCE (ORCPT ); Mon, 6 Mar 2023 11:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231411AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D3892FCDE; Mon, 6 Mar 2023 08:00:52 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3A6591FECB; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zIcCTHOdlnmOrevNPvQ6R5cfRaWzMuURTLQ3rJVomJ0=; b=wakMHB6YSWHElv0eseFqAQJHSUDEpOKBQ2zXWLIvvfR4rSj30bH5MoLOUQ95H6yt3gKYuE jwm6e1dhQNTPh4J37ezH7yIJ+7galbWoGDGi+1I24cwiHoqJSk/RKdQzHqfHqQBzSausPT 4gWnC37kChwr67oK+eeaciSpVvJbTEs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zIcCTHOdlnmOrevNPvQ6R5cfRaWzMuURTLQ3rJVomJ0=; b=E6gREROODWoRv7Ps324DQe5AXbef2Hfx+MAaoNEyCdB+xYdSRcvobbwsjkMYjR7SypeMWz rmH5CWOnl6qVUlDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D6D6913A6A; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kHKrMzIOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:50 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 70/99] fbdev/savagefb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:47 +0100 Message-Id: <20230306160016.4459-71-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/savage/savagefb_driver.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 4a27b68798bf..19fffe0b6cdd 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -2544,7 +2544,15 @@ static int __init savagefb_setup(char *options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { - mode_option = this_opt; + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "savagefb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "savagefb: option too long\n")) + continue; + mode_option = mode_option_buf; } #endif /* !MODULE */ return 0; From patchwork Mon Mar 6 15:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA823C742A7 for ; Mon, 6 Mar 2023 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbjCFQCB (ORCPT ); Mon, 6 Mar 2023 11:02:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbjCFQA5 (ORCPT ); Mon, 6 Mar 2023 11:00:57 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E976B2ED7E; Mon, 6 Mar 2023 08:00:52 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 98CCE2242A; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0DwH9PbkOKEqD3wmCjB0TQMZNUTuSApTKev00H3660E=; b=Lk+8+JhT/+B3f0AwSzmLvFmEfURRKyVzWUrzHFGKzJ+mhJ98TLoYKnbcsJFoQp5T1KByW+ N47ktubG4HpzVPVQlOKinz0XONa5lwU3J3I7+rZKdK2y3PeTfS6UKzYuCfUywj/uJlh3fi W0Y+RRvd7RnHuwWrANQ1KFIaAn0NiLk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0DwH9PbkOKEqD3wmCjB0TQMZNUTuSApTKev00H3660E=; b=Sd8cn0Wty4HjwI7jXy8sDdskYz0sboQCIYBR22NrZ+XNj8yXkNNQOUqcan8o6sLDrqABUp 17idD2saMikjCrBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3E30D13513; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qB1eDjMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:51 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 71/99] fbdev/savagefb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:48 +0100 Message-Id: <20230306160016.4459-72-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/savage/savagefb_driver.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 19fffe0b6cdd..94026848d67d 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -42,6 +42,7 @@ */ #include +#include #include #include #include @@ -2535,15 +2536,15 @@ static void __exit savage_done(void) /* ************************* init in-kernel code ************************** */ -static int __init savagefb_setup(char *options) +static int __init savagefb_setup(const char *options) { #ifndef MODULE - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { static char mode_option_buf[256]; int ret; @@ -2554,6 +2555,9 @@ static int __init savagefb_setup(char *options) continue; mode_option = mode_option_buf; } + + option_iter_release(&iter); + #endif /* !MODULE */ return 0; } From patchwork Mon Mar 6 15:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B268C6FD1E for ; Mon, 6 Mar 2023 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjCFQCA (ORCPT ); Mon, 6 Mar 2023 11:02:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbjCFQA5 (ORCPT ); Mon, 6 Mar 2023 11:00:57 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 402102E813; Mon, 6 Mar 2023 08:00:53 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F17472242C; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FHsw9G40HD12yWMfW+3kaONrrrxFvi6OorhBwRazvNw=; b=jaLHBd2ZnCEawg3As+bdVniBuW//6UdlJDPreseZw6KPB5jjYCo604b2XU3tfyAff5vpfN 8ukpj6sTWj8zQN/fDtjdBHUBt4Vku22YPBNa/wlRkSLqpGeqevGiB+3EbCbR+pn/DI7n1+ lXD4UbfcWIw0ppSmyiXrmep2077pRDc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FHsw9G40HD12yWMfW+3kaONrrrxFvi6OorhBwRazvNw=; b=KoS8rLuFGGdDvRtgrX+jMTdBEh8GGfYNXVX0wj4gReGH1MfoyEZflEAyErznczRPIxhS+N eVvjme4RGvyY9RAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9C20913A6A; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KIVfJTMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:51 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 72/99] fbdev/sisfb: Constify mode string Date: Mon, 6 Mar 2023 16:59:49 +0100 Message-Id: <20230306160016.4459-73-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Constify the intenal video-mode string that is passed around among functions. The caller owns the memory and callees do not modify its content. This change will later allow to constify the option string. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sis/sis_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c index cfba776afcea..c16493d3ac4f 100644 --- a/drivers/video/fbdev/sis/sis_main.c +++ b/drivers/video/fbdev/sis/sis_main.c @@ -73,7 +73,7 @@ static int sisfb_blank(int blank, static void sisfb_handle_command(struct sis_video_info *ivideo, struct sisfb_cmd *sisfb_command); -static void sisfb_search_mode(char *name, bool quiet); +static void sisfb_search_mode(const char *name, bool quiet); static int sisfb_validate_mode(struct sis_video_info *ivideo, int modeindex, u32 vbflags); static u8 sisfb_search_refresh_rate(struct sis_video_info *ivideo, unsigned int rate, int index); @@ -180,12 +180,12 @@ static void sisfb_search_vesamode(unsigned int vesamode, bool quiet) printk(KERN_ERR "sisfb: Invalid VESA mode 0x%x'\n", vesamode); } -static void sisfb_search_mode(char *name, bool quiet) +static void sisfb_search_mode(const char *name, bool quiet) { unsigned int j = 0, xres = 0, yres = 0, depth = 0, rate = 0; int i = 0; char strbuf[16], strbuf1[20]; - char *nameptr = name; + const char *nameptr = name; /* We don't know the hardware specs yet and there is no ivideo */ From patchwork Mon Mar 6 15:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96DA2C678D4 for ; Mon, 6 Mar 2023 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229950AbjCFQCF (ORCPT ); Mon, 6 Mar 2023 11:02:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbjCFQA5 (ORCPT ); Mon, 6 Mar 2023 11:00:57 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A208E2A6D2; Mon, 6 Mar 2023 08:00:53 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 55AA11FECE; Mon, 6 Mar 2023 16:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118452; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IgDfEiZ+lqWxemBwjnD++85rG8ImLkOXixDWmH7+Qvc=; b=06PWyrPnlY2PpvcduLC6hbRXrvAvLmhUJlODGem3cz4jKBYELZ+f9NbVP76wM7kZ3QPPRY qNTwvZ0OEz0/lLBb0UXT1tskGCw/CTJ8dtiKQXi5KywfTUhAGQ2at3aZ4d2K5UggA8Gmsq 4aEmOSbzo82FTMGKXQIQ0LwqoZ+SDnk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118452; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IgDfEiZ+lqWxemBwjnD++85rG8ImLkOXixDWmH7+Qvc=; b=zvxwEXIh7ySAzyLjW3NPaZW3m2hiBd3qGLTIqzgWMTYF/FYIP+HxtzZt89w4O7BNJbtyLx p42uU1SMNbeS5FDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 014AC13513; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mLYqOzMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:51 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 73/99] fbdev/sisfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:50 +0100 Message-Id: <20230306160016.4459-74-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sis/sis_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c index c16493d3ac4f..7e6e2251e62f 100644 --- a/drivers/video/fbdev/sis/sis_main.c +++ b/drivers/video/fbdev/sis/sis_main.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -54,7 +55,7 @@ /* Interface used by the world */ #ifndef MODULE -static int sisfb_setup(char *options); +static int sisfb_setup(const char *options); #endif /* Interface to the low level console driver */ @@ -3987,19 +3988,16 @@ sisfb_handle_command(struct sis_video_info *ivideo, struct sisfb_cmd *sisfb_comm } #ifndef MODULE -static int __init sisfb_setup(char *options) +static int __init sisfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; sisfb_setdefaultparms(); - if(!options || !(*options)) - return 0; - - while((this_opt = strsep(&options, ",")) != NULL) { - - if(!(*this_opt)) continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if(!strncasecmp(this_opt, "off", 3)) { sisfb_off = 1; } else if(!strncasecmp(this_opt, "forcecrt2type:", 14)) { @@ -4081,6 +4079,8 @@ static int __init sisfb_setup(char *options) } + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 15:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B685C6FD1D for ; Mon, 6 Mar 2023 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbjCFQBr (ORCPT ); Mon, 6 Mar 2023 11:01:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231423AbjCFQA5 (ORCPT ); Mon, 6 Mar 2023 11:00:57 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A3DB2FCCF; Mon, 6 Mar 2023 08:00:54 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B04CA2242E; Mon, 6 Mar 2023 16:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118452; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4pYlnhHsXehvuEXAaE7vZAg0+RcAOHve8GXvNQPf9tw=; b=qiEx02SdzApw3jnhZTQdIYKA9xXDDK49JbJWa87PpbhsOYS1FLqtq4IVvlAX7A7bzrnkOy KwEjaf67XVJKVYzXjacFtyEd4ZpKmNt+UXX8vy1nkgttGmtfleXA3kJUFGuyQskXvNFbQq K+Kom1HqiDvYkR4QjqLj6l3Cz/Bfj0Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118452; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4pYlnhHsXehvuEXAaE7vZAg0+RcAOHve8GXvNQPf9tw=; b=bOA6jqmIa4PpO2pBUmZjmKn6flKLX0KA9+92wC+3LlLVKDgBpMpxkCY7q6gXfsNkxAnscA bl/5kOjJYN77+VBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 58E5513A6A; Mon, 6 Mar 2023 16:00:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eKbgFDQOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:52 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 74/99] fbdev/skeletonfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:51 +0100 Message-Id: <20230306160016.4459-75-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/skeletonfb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/skeletonfb.c b/drivers/video/fbdev/skeletonfb.c index 40c130ab6b38..1e876ad2a261 100644 --- a/drivers/video/fbdev/skeletonfb.c +++ b/drivers/video/fbdev/skeletonfb.c @@ -43,6 +43,7 @@ */ #include +#include #include #include #include @@ -973,9 +974,19 @@ static struct platform_device *xxxfb_device; * Only necessary if your driver takes special options, * otherwise we fall back on the generic fb_setup(). */ -static int __init xxxfb_setup(char *options) +static int __init xxxfb_setup(const char *options) { - /* Parse user specified options (`video=xxxfb:') */ + /* Parse user-specified options (`video=xxxfb:') */ + + struct option_iter iter; + const char *this_opt; + + option_iter_init(&iter, options); + + while (option_iter_next(&iter, this_opt)) { + } + + option_iter_release(&iter); } #endif /* MODULE */ From patchwork Mon Mar 6 15:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 380B7C74A5B for ; Mon, 6 Mar 2023 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjCFQCE (ORCPT ); Mon, 6 Mar 2023 11:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbjCFQA6 (ORCPT ); Mon, 6 Mar 2023 11:00:58 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F83533463; Mon, 6 Mar 2023 08:00:54 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 159A022426; Mon, 6 Mar 2023 16:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/mD4G4g5PKVnWJeJOlK/9atHL+s+VwLsA1DXPQcRuS8=; b=QhmoVNA0HCmkwRTmuQWbJUa22zmn0hw9Tvp4xOZrt+mF/Jy3ccartVIqL+C736yGOoZCQJ v8+/FKlprNw7JpxQ/4ewuXTd+DuZIf9ORq1J6l2zYKVh8/fF5z7Ib+lqhXF9lJT5SiJa4D lIgNBXAcRXFIizXSk7eIFTULyflzKt0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/mD4G4g5PKVnWJeJOlK/9atHL+s+VwLsA1DXPQcRuS8=; b=H6wjNmwq5kd9ML242yT/QOwXzkWG02v2KIZmiwsDi2TYAtNKEzdajdKN/N1p7FaTKrlaht /VxpZsRL6ja619AQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B3ACE13513; Mon, 6 Mar 2023 16:00:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EG0WKzQOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:52 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 75/99] fbdev/sm712fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:52 +0100 Message-Id: <20230306160016.4459-76-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sm712fb.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index b528776c7612..b0f3898125f4 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1761,8 +1761,21 @@ static int __init sm712fb_init(void) if (fb_get_options("sm712fb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + + if (option && *option) { + do { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", option); + if (WARN(ret < 0, "sm712fb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "sm712fb: option too long\n")) + continue; + mode_option = mode_option_buf; + } while (0); + } + sm7xx_vga_setup(mode_option); return pci_register_driver(&smtcfb_driver); From patchwork Mon Mar 6 15:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A0C6C74A44 for ; Mon, 6 Mar 2023 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjCFQCG (ORCPT ); Mon, 6 Mar 2023 11:02:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbjCFQBA (ORCPT ); Mon, 6 Mar 2023 11:01:00 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3DD634333; Mon, 6 Mar 2023 08:00:54 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6D26422433; Mon, 6 Mar 2023 16:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ljuuhqpOqDDWmpDnbCdmNaVjarJVcwoFXmhAbwHgMNg=; b=GRYYeHFR+sXD4ucrs0CM8OonsIBECWGTFKP2zZ+ycPeiKN/Mjah8nkUfPVbQagTR5VjTxn NvQdjtxy9CNE4KgWeie9HnUJoGq3+5KZh33kSfFmpFDD/piEkEb4UP4j0rd1gXBPJsjdN8 fsJUR/F5KvsdurHBf/qC8d3xrMZtSpI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ljuuhqpOqDDWmpDnbCdmNaVjarJVcwoFXmhAbwHgMNg=; b=uyjMas/nXWwFncG/VqAI8UJM1TBdDYgFItMI4x6cTLqCultdpbHnEf/R5jekOrCfQ5Nazj 7K66MR5r8FFEeVAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 16F3513A6A; Mon, 6 Mar 2023 16:00:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0H/OBDUOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:53 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 76/99] fbdev/sstfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:53 +0100 Message-Id: <20230306160016.4459-77-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sstfb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c index da296b2ab54a..7cd65f924b08 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -1301,8 +1301,17 @@ static int sstfb_setup(char *options) mem = simple_strtoul (this_opt+4, NULL, 0); else if (!strncmp(this_opt, "gfxclk:",7)) gfxclk = simple_strtoul (this_opt+7, NULL, 0); - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "sstfb: Ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "sstfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 15:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE7E9C7618B for ; Mon, 6 Mar 2023 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbjCFQCH (ORCPT ); Mon, 6 Mar 2023 11:02:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231473AbjCFQBB (ORCPT ); Mon, 6 Mar 2023 11:01:01 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ADE432E58; Mon, 6 Mar 2023 08:00:55 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C037E22438; Mon, 6 Mar 2023 16:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8zqlhoySL/+Cl4DvCGVN1/4X2sxUzQQxUz8kG5dII7Y=; b=f3AHmAS0i4v505wvstRJfF7KcB995UCtX/Tp2H5HSPoejkWBwL+VPVGi2CxhDStbrGxfX6 PSThBx/uMoguCfpuTCpi1JiBgDzmWsNcSkvmLXBVQ5S0RqmWh2iX1mFb/r//0vST76wj8p dmxQ38Iw+ieOBoAbZGf1FzszhmrtGdQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8zqlhoySL/+Cl4DvCGVN1/4X2sxUzQQxUz8kG5dII7Y=; b=uLhNIq46LztfPeQewB+IzQzo955ubK9udVOMjNXR7+N9apmDvXK/1MzHC9ADAXXBJ2Vnk0 F/P4V6oXhMTjP3Dw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6FB1113513; Mon, 6 Mar 2023 16:00:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sOd/GjUOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:53 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 77/99] fbdev/sstfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:54 +0100 Message-Id: <20230306160016.4459-78-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sstfb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c index 7cd65f924b08..6c3769062d50 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -81,6 +81,7 @@ */ #include +#include #include #include #include @@ -1273,16 +1274,14 @@ static void sst_shutdown(struct fb_info *info) /* * Interface to the world */ -static int sstfb_setup(char *options) +static int sstfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { f_ddprintk("option %s\n", this_opt); if (!strcmp(this_opt, "vganopass")) @@ -1313,6 +1312,9 @@ static int sstfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 15:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C26DC7619A for ; Mon, 6 Mar 2023 16:02:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbjCFQCL (ORCPT ); Mon, 6 Mar 2023 11:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjCFQBD (ORCPT ); Mon, 6 Mar 2023 11:01:03 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2CA32536; Mon, 6 Mar 2023 08:00:55 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2F29C1FED3; Mon, 6 Mar 2023 16:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ux309O9TgXMG2iCBc1Nlc/YxhMdiiSbk+pPPbR4+wSE=; b=cHlFCGgJRl+TL9ujL2GCiY/0xCP8fnBUYJtSh+N5u85Rey0kAdvey/59LQWamzYXr5LbQ9 64remF5e5rxpYVPk1VHlnqHwlhn5OYxcOY0ne2fZY9gIYuzjgWwzdbtApSif+ojT+vYyeL PAC4E+rYNLhR52VmHMnE9TRvMHvm/Ug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ux309O9TgXMG2iCBc1Nlc/YxhMdiiSbk+pPPbR4+wSE=; b=KwHPi0tLBMnCHIKI6wKS+3sFnrFfSJTY51Wd8T5PNQHKE2QBOm4LbnGGKiwdeSedYi2hid eaoDeD+BL09No/AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C620613513; Mon, 6 Mar 2023 16:00:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SA+XLzUOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:53 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 78/99] fbdev/stifb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 16:59:55 +0100 Message-Id: <20230306160016.4459-79-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/stifb.c | 156 ++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c index 3feb6e40d56d..a151377f5b45 100644 --- a/drivers/video/fbdev/stifb.c +++ b/drivers/video/fbdev/stifb.c @@ -1,11 +1,11 @@ /* - * linux/drivers/video/stifb.c - - * Low level Frame buffer driver for HP workstations with + * linux/drivers/video/stifb.c - + * Low level Frame buffer driver for HP workstations with * STI (standard text interface) video firmware. * * Copyright (C) 2001-2006 Helge Deller * Portions Copyright (C) 2001 Thomas Bogendoerfer - * + * * Based on: * - linux/drivers/video/artistfb.c -- Artist frame buffer driver * Copyright (C) 2000 Philipp Rumpf @@ -14,7 +14,7 @@ * - HP Xhp cfb-based X11 window driver for XFree86 * (c)Copyright 1992 Hewlett-Packard Co. * - * + * * The following graphics display devices (NGLE family) are supported by this driver: * * HPA4070A known as "HCRX", a 1280x1024 color device with 8 planes @@ -30,7 +30,7 @@ * supports 1280x1024 color displays with 8 planes. * HP710G same as HP710C, 1280x1024 grayscale only * HP710L same as HP710C, 1024x768 color only - * HP712 internal graphics support on HP9000s712 SPU, supports 640x480, + * HP712 internal graphics support on HP9000s712 SPU, supports 640x480, * 1024x768 or 1280x1024 color displays on 8 planes (Artist) * * This file is subject to the terms and conditions of the GNU General Public @@ -92,7 +92,7 @@ typedef struct { __s32 misc_video_end; } video_setup_t; -typedef struct { +typedef struct { __s16 sizeof_ngle_data; __s16 x_size_visible; /* visible screen dim in pixels */ __s16 y_size_visible; @@ -177,10 +177,10 @@ static int __initdata stifb_bpp_pref[MAX_STI_ROMS]; #endif /* DEBUG_STIFB_REGS */ -#define ENABLE 1 /* for enabling/disabling screen */ +#define ENABLE 1 /* for enabling/disabling screen */ #define DISABLE 0 -#define NGLE_LOCK(fb_info) do { } while (0) +#define NGLE_LOCK(fb_info) do { } while (0) #define NGLE_UNLOCK(fb_info) do { } while (0) static void @@ -198,9 +198,9 @@ SETUP_HW(struct stifb_info *fb) static void SETUP_FB(struct stifb_info *fb) -{ +{ unsigned int reg10_value = 0; - + SETUP_HW(fb); switch (fb->id) { @@ -210,15 +210,15 @@ SETUP_FB(struct stifb_info *fb) reg10_value = 0x13601000; break; case S9000_ID_A1439A: - if (fb->info.var.bits_per_pixel == 32) + if (fb->info.var.bits_per_pixel == 32) reg10_value = 0xBBA0A000; - else + else reg10_value = 0x13601000; break; case S9000_ID_HCRX: if (fb->info.var.bits_per_pixel == 32) reg10_value = 0xBBA0A000; - else + else reg10_value = 0x13602000; break; case S9000_ID_TIMBER: @@ -243,7 +243,7 @@ START_IMAGE_COLORMAP_ACCESS(struct stifb_info *fb) } static void -WRITE_IMAGE_COLOR(struct stifb_info *fb, int index, int color) +WRITE_IMAGE_COLOR(struct stifb_info *fb, int index, int color) { SETUP_HW(fb); WRITE_WORD(((0x100+index)<<2), fb, REG_3); @@ -251,30 +251,30 @@ WRITE_IMAGE_COLOR(struct stifb_info *fb, int index, int color) } static void -FINISH_IMAGE_COLORMAP_ACCESS(struct stifb_info *fb) -{ +FINISH_IMAGE_COLORMAP_ACCESS(struct stifb_info *fb) +{ WRITE_WORD(0x400, fb, REG_2); if (fb->info.var.bits_per_pixel == 32) { WRITE_WORD(0x83000100, fb, REG_1); } else { if (fb->id == S9000_ID_ARTIST || fb->id == CRT_ID_VISUALIZE_EG) WRITE_WORD(0x80000100, fb, REG_26); - else + else WRITE_WORD(0x80000100, fb, REG_1); } SETUP_FB(fb); } static void -SETUP_RAMDAC(struct stifb_info *fb) +SETUP_RAMDAC(struct stifb_info *fb) { SETUP_HW(fb); WRITE_WORD(0x04000000, fb, 0x1020); WRITE_WORD(0xff000000, fb, 0x1028); } -static void -CRX24_SETUP_RAMDAC(struct stifb_info *fb) +static void +CRX24_SETUP_RAMDAC(struct stifb_info *fb) { SETUP_HW(fb); WRITE_WORD(0x04000000, fb, 0x1000); @@ -286,14 +286,14 @@ CRX24_SETUP_RAMDAC(struct stifb_info *fb) } #if 0 -static void +static void HCRX_SETUP_RAMDAC(struct stifb_info *fb) { WRITE_WORD(0xffffffff, fb, REG_32); } #endif -static void +static void CRX24_SET_OVLY_MASK(struct stifb_info *fb) { SETUP_HW(fb); @@ -314,7 +314,7 @@ ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) WRITE_WORD(value, fb, 0x1038); } -static void +static void CRX24_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) { unsigned int value = enable ? 0x10000000 : 0x30000000; @@ -325,11 +325,11 @@ CRX24_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) } static void -ARTIST_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) +ARTIST_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) { u32 DregsMiscVideo = REG_21; u32 DregsMiscCtl = REG_27; - + SETUP_HW(fb); if (enable) { WRITE_WORD(READ_WORD(fb, DregsMiscVideo) | 0x0A000000, fb, DregsMiscVideo); @@ -344,7 +344,7 @@ ARTIST_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) (READ_BYTE(fb, REG_16b3) - 1) #define HYPER_CONFIG_PLANES_24 0x00000100 - + #define IS_24_DEVICE(fb) \ (fb->deviceSpecificConfig & HYPER_CONFIG_PLANES_24) @@ -470,15 +470,15 @@ SETUP_ATTR_ACCESS(struct stifb_info *fb, unsigned BufferNumber) } static void -SET_ATTR_SIZE(struct stifb_info *fb, int width, int height) +SET_ATTR_SIZE(struct stifb_info *fb, int width, int height) { - /* REG_6 seems to have special values when run on a + /* REG_6 seems to have special values when run on a RDI precisionbook parisc laptop (INTERNAL_EG_DX1024 or INTERNAL_EG_X1024). The values are: 0x2f0: internal (LCD) & external display enabled 0x2a0: external display only 0x000: zero on standard artist graphic cards - */ + */ WRITE_WORD(0x00000000, fb, REG_6); WRITE_WORD((width<<16) | height, fb, REG_9); WRITE_WORD(0x05000000, fb, REG_6); @@ -486,7 +486,7 @@ SET_ATTR_SIZE(struct stifb_info *fb, int width, int height) } static void -FINISH_ATTR_ACCESS(struct stifb_info *fb) +FINISH_ATTR_ACCESS(struct stifb_info *fb) { SETUP_HW(fb); WRITE_WORD(0x00000000, fb, REG_12); @@ -499,7 +499,7 @@ elkSetupPlanes(struct stifb_info *fb) SETUP_FB(fb); } -static void +static void ngleSetupAttrPlanes(struct stifb_info *fb, int BufferNumber) { SETUP_ATTR_ACCESS(fb, BufferNumber); @@ -519,7 +519,7 @@ rattlerSetupPlanes(struct stifb_info *fb) * read mask register for overlay planes, not image planes). */ CRX24_SETUP_RAMDAC(fb); - + /* change fb->id temporarily to fool SETUP_FB() */ saved_id = fb->id; fb->id = CRX24_OVERLAY_PLANES; @@ -565,7 +565,7 @@ setNgleLutBltCtl(struct stifb_info *fb, int offsetWithinLut, int length) lutBltCtl.all = 0x80000000; lutBltCtl.fields.length = length; - switch (fb->id) + switch (fb->id) { case S9000_ID_A1439A: /* CRX24 */ if (fb->var.bits_per_pixel == 8) { @@ -576,12 +576,12 @@ setNgleLutBltCtl(struct stifb_info *fb, int offsetWithinLut, int length) lutBltCtl.fields.lutOffset = 0 * 256; } break; - + case S9000_ID_ARTIST: lutBltCtl.fields.lutType = NGLE_CMAP_INDEXED0_TYPE; lutBltCtl.fields.lutOffset = 0 * 256; break; - + default: lutBltCtl.fields.lutType = NGLE_CMAP_INDEXED0_TYPE; lutBltCtl.fields.lutOffset = 0; @@ -596,7 +596,7 @@ setNgleLutBltCtl(struct stifb_info *fb, int offsetWithinLut, int length) #endif static NgleLutBltCtl -setHyperLutBltCtl(struct stifb_info *fb, int offsetWithinLut, int length) +setHyperLutBltCtl(struct stifb_info *fb, int offsetWithinLut, int length) { NgleLutBltCtl lutBltCtl; @@ -633,7 +633,7 @@ static void hyperUndoITE(struct stifb_info *fb) /* Hardware setup for full-depth write to "magic" location */ GET_FIFO_SLOTS(fb, nFreeFifoSlots, 7); - NGLE_QUICK_SET_DST_BM_ACCESS(fb, + NGLE_QUICK_SET_DST_BM_ACCESS(fb, BA(IndexedDcd, Otc04, Ots08, AddrLong, BAJustPoint(0), BINovly, BAIndexBase(0))); NGLE_QUICK_SET_IMAGE_BITMAP_OP(fb, @@ -653,13 +653,13 @@ static void hyperUndoITE(struct stifb_info *fb) NGLE_UNLOCK(fb); } -static void +static void ngleDepth8_ClearImagePlanes(struct stifb_info *fb) { /* FIXME! */ } -static void +static void ngleDepth24_ClearImagePlanes(struct stifb_info *fb) { /* FIXME! */ @@ -675,7 +675,7 @@ ngleResetAttrPlanes(struct stifb_info *fb, unsigned int ctlPlaneReg) NGLE_LOCK(fb); GET_FIFO_SLOTS(fb, nFreeFifoSlots, 4); - NGLE_QUICK_SET_DST_BM_ACCESS(fb, + NGLE_QUICK_SET_DST_BM_ACCESS(fb, BA(IndexedDcd, Otc32, OtsIndirect, AddrLong, BAJustPoint(0), BINattr, BAIndexBase(0))); @@ -713,22 +713,22 @@ ngleResetAttrPlanes(struct stifb_info *fb, unsigned int ctlPlaneReg) /**** Finally, set the Control Plane Register back to zero: ****/ GET_FIFO_SLOTS(fb, nFreeFifoSlots, 1); NGLE_QUICK_SET_CTL_PLN_REG(fb, 0); - + NGLE_UNLOCK(fb); } - + static void ngleClearOverlayPlanes(struct stifb_info *fb, int mask, int data) { int nFreeFifoSlots = 0; u32 packed_dst; u32 packed_len; - + NGLE_LOCK(fb); /* Hardware setup */ GET_FIFO_SLOTS(fb, nFreeFifoSlots, 8); - NGLE_QUICK_SET_DST_BM_ACCESS(fb, + NGLE_QUICK_SET_DST_BM_ACCESS(fb, BA(IndexedDcd, Otc04, Ots08, AddrLong, BAJustPoint(0), BINovly, BAIndexBase(0))); @@ -736,23 +736,23 @@ ngleClearOverlayPlanes(struct stifb_info *fb, int mask, int data) NGLE_REALLY_SET_IMAGE_FG_COLOR(fb, data); NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, mask); - + packed_dst = 0; packed_len = (fb->info.var.xres << 16) | fb->info.var.yres; NGLE_SET_DSTXY(fb, packed_dst); - - /* Write zeroes to overlay planes */ + + /* Write zeroes to overlay planes */ NGLE_QUICK_SET_IMAGE_BITMAP_OP(fb, IBOvals(RopSrc, MaskAddrOffset(0), BitmapExtent08, StaticReg(0), DataDynamic, MaskOtc, BGx(0), FGx(0))); - + SET_LENXY_START_RECFILL(fb, packed_len); NGLE_UNLOCK(fb); } -static void +static void hyperResetPlanes(struct stifb_info *fb, int enable) { unsigned int controlPlaneReg; @@ -783,7 +783,7 @@ hyperResetPlanes(struct stifb_info *fb, int enable) ngleClearOverlayPlanes(fb, 0xff, 255); /************************************************** - ** Also need to counteract ITE settings + ** Also need to counteract ITE settings **************************************************/ hyperUndoITE(fb); break; @@ -803,13 +803,13 @@ hyperResetPlanes(struct stifb_info *fb, int enable) ngleResetAttrPlanes(fb, controlPlaneReg); break; } - + NGLE_UNLOCK(fb); } /* Return pointer to in-memory structure holding ELK device-dependent ROM values. */ -static void +static void ngleGetDeviceRomData(struct stifb_info *fb) { #if 0 @@ -821,7 +821,7 @@ XXX: FIXME: !!! char *pCard8; int i; char *mapOrigin = NULL; - + int romTableIdx; pPackedDevRomData = fb->ngle_rom; @@ -888,7 +888,7 @@ SETUP_HCRX(struct stifb_info *fb) /* Initialize Hyperbowl registers */ GET_FIFO_SLOTS(fb, nFreeFifoSlots, 7); - + if (IS_24_DEVICE(fb)) { hyperbowl = (fb->info.var.bits_per_pixel == 32) ? HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE : @@ -897,9 +897,9 @@ SETUP_HCRX(struct stifb_info *fb) /* First write to Hyperbowl must happen twice (bug) */ WRITE_WORD(hyperbowl, fb, REG_40); WRITE_WORD(hyperbowl, fb, REG_40); - + WRITE_WORD(HYPERBOWL_MODE2_8_24, fb, REG_39); - + WRITE_WORD(0x014c0148, fb, REG_42); /* Set lut 0 to be the direct color */ WRITE_WORD(0x404c4048, fb, REG_43); WRITE_WORD(0x034c0348, fb, REG_44); @@ -968,7 +968,7 @@ stifb_setcolreg(u_int regno, u_int red, u_int green, 0, /* Offset w/i LUT */ 256); /* Load entire LUT */ NGLE_BINC_SET_SRCADDR(fb, - NGLE_LONG_FB_ADDRESS(0, 0x100, 0)); + NGLE_LONG_FB_ADDRESS(0, 0x100, 0)); /* 0x100 is same as used in WRITE_IMAGE_COLOR() */ START_COLORMAPLOAD(fb, lutBltCtl.all); SETUP_FB(fb); @@ -1006,7 +1006,7 @@ stifb_blank(int blank_mode, struct fb_info *info) ENABLE_DISABLE_DISPLAY(fb, enable); break; } - + SETUP_FB(fb); return 0; } @@ -1092,15 +1092,15 @@ stifb_init_display(struct stifb_info *fb) /* HCRX specific initialization */ SETUP_HCRX(fb); - + /* if (id == S9000_ID_HCRX) hyperInitSprite(fb); else ngleInitSprite(fb); */ - - /* Initialize the image planes. */ + + /* Initialize the image planes. */ switch (id) { case S9000_ID_HCRX: hyperResetPlanes(fb, ENABLE); @@ -1170,7 +1170,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) fb = kzalloc(sizeof(*fb), GFP_ATOMIC); if (!fb) return -ENOMEM; - + info = &fb->info; /* set struct to a known state */ @@ -1211,7 +1211,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) dev_name, fb->id); goto out_err0; } - + /* default to 8 bpp on most graphic chips */ bpp = 8; xres = sti_onscreen_x(fb->sti); @@ -1232,7 +1232,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) fb->id = S9000_ID_A1659A; break; case S9000_ID_TIMBER: /* HP9000/710 Any (may be a grayscale device) */ - if (strstr(dev_name, "GRAYSCALE") || + if (strstr(dev_name, "GRAYSCALE") || strstr(dev_name, "Grayscale") || strstr(dev_name, "grayscale")) var->grayscale = 1; @@ -1271,16 +1271,16 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) case CRT_ID_VISUALIZE_EG: case S9000_ID_ARTIST: /* Artist */ break; - default: + default: #ifdef FALLBACK_TO_1BPP - printk(KERN_WARNING + printk(KERN_WARNING "stifb: Unsupported graphics card (id=0x%08x) " "- now trying 1bpp mode instead\n", fb->id); bpp = 1; /* default to 1 bpp */ break; #else - printk(KERN_WARNING + printk(KERN_WARNING "stifb: Unsupported graphics card (id=0x%08x) " "- skipping.\n", fb->id); @@ -1296,11 +1296,11 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) fix->line_length = (fb->sti->glob_cfg->total_x * bpp) / 8; if (!fix->line_length) fix->line_length = 2048; /* default */ - + /* limit fbsize to max visible screen size */ if (fix->smem_len > yres*fix->line_length) fix->smem_len = ALIGN(yres*fix->line_length, 4*1024*1024); - + fix->accel = FB_ACCEL_NONE; switch (bpp) { @@ -1326,7 +1326,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) default: break; } - + var->xres = var->xres_virtual = xres; var->yres = var->yres_virtual = yres; var->bits_per_pixel = bpp; @@ -1352,7 +1352,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) fix->smem_start, fix->smem_start+fix->smem_len); goto out_err2; } - + if (!request_mem_region(fix->mmio_start, fix->mmio_len, "stifb mmio")) { printk(KERN_ERR "stifb: cannot reserve sti mmio region 0x%04lx-0x%04lx\n", fix->mmio_start, fix->mmio_start+fix->mmio_len); @@ -1366,11 +1366,11 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) fb_info(&fb->info, "%s %dx%d-%d frame buffer device, %s, id: %04x, mmio: 0x%04lx\n", fix->id, - var->xres, + var->xres, var->yres, var->bits_per_pixel, dev_name, - fb->id, + fb->id, fix->mmio_start); return 0; @@ -1399,7 +1399,7 @@ static int __init stifb_init(void) struct sti_struct *sti; struct sti_struct *def_sti; int i; - + #ifndef MODULE char *option = NULL; @@ -1411,7 +1411,7 @@ static int __init stifb_init(void) printk(KERN_INFO "stifb: disabled by \"stifb=off\" kernel parameter\n"); return -ENXIO; } - + def_sti = sti_get_rom(0); if (def_sti) { for (i = 1; i <= MAX_STI_ROMS; i++) { @@ -1445,7 +1445,7 @@ stifb_cleanup(void) { struct sti_struct *sti; int i; - + for (i = 1; i <= MAX_STI_ROMS; i++) { sti = sti_get_rom(i); if (!sti) @@ -1468,10 +1468,10 @@ int __init stifb_setup(char *options) { int i; - + if (!options || !*options) return 1; - + if (strncmp(options, "off", 3) == 0) { stifb_disabled = 1; options += 3; From patchwork Mon Mar 6 15:59:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB918C76188 for ; Mon, 6 Mar 2023 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjCFQCI (ORCPT ); Mon, 6 Mar 2023 11:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbjCFQBC (ORCPT ); Mon, 6 Mar 2023 11:01:02 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D54722E0D3; Mon, 6 Mar 2023 08:00:55 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 865161FED6; Mon, 6 Mar 2023 16:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yOhrk3uETM+pHr/QFHdYcLngL83sbtfH5kDoWLgLZZs=; b=cFfY9u/UJ9aeaeawMWvOIzzsUb2kja3lMv3D49+urNNE3uH2w/XNPP31AOfVbPYw+apfuz E+v2B2ef6C6EVKycL6hcLfNrfKzeTelxJmikHnrTiOkshtUSyLXdOE2qebKIwdxDYHitK7 BrkWHLcxy7juDYaVrluJ7tUkT1H5LEc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yOhrk3uETM+pHr/QFHdYcLngL83sbtfH5kDoWLgLZZs=; b=4R7PA0tHfHRSIED4nXwUYPe0ntH8GGEBrmTNrAlv1QSvnXF8YKhVZZcIpQlRdUpfeaa4aE 2EeMjt/WWPzsjDAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 32C2313A6A; Mon, 6 Mar 2023 16:00:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WHCVCzYOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:54 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 79/99] fbdev/sti: Constify option string Date: Mon, 6 Mar 2023 16:59:56 +0100 Message-Id: <20230306160016.4459-80-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Constify the intenal option string that is passed around among functions. The caller owns the memory and callees do not modify its content. This change will later allow to constify the caller's option string as well. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/stifb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c index a151377f5b45..304ce8fcb9f8 100644 --- a/drivers/video/fbdev/stifb.c +++ b/drivers/video/fbdev/stifb.c @@ -1392,7 +1392,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) static int stifb_disabled __initdata; int __init -stifb_setup(char *options); +stifb_setup(const char *options); static int __init stifb_init(void) { @@ -1465,7 +1465,7 @@ stifb_cleanup(void) } int __init -stifb_setup(char *options) +stifb_setup(const char *options) { int i; From patchwork Mon Mar 6 15:59:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A9A3C76195 for ; Mon, 6 Mar 2023 16:02:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbjCFQCK (ORCPT ); Mon, 6 Mar 2023 11:02:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjCFQBD (ORCPT ); Mon, 6 Mar 2023 11:01:03 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A7934C39; Mon, 6 Mar 2023 08:00:56 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EC2961FED8; Mon, 6 Mar 2023 16:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4CTiBWCUsSzOh1iLUcC+NpZPt+whzLfG50MTmUnIlMg=; b=P2PiTpZvGnfq2wqnAXUK7WniO3UNETfvcMcNJIAOiG/NMxPqrNH0HCDyrpDlHFjzFsKoJB qeoWv5tTsxRqWhVeKrOQDuwhad6PcPKffMHTGwU91L9ldvzyGl5jf89DZKsWYsCck57E4R QzeCPLqHkwcO+VyxhU38q+uhnA0raSY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4CTiBWCUsSzOh1iLUcC+NpZPt+whzLfG50MTmUnIlMg=; b=PhP4C6vlnz9G4m2ojHstR0sRP9FOMkoiUnThczLryuI0RnRGr45EjGnIMmswtWGZpuutKM nr5uPv4MbkG+s2Cg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8A52F13513; Mon, 6 Mar 2023 16:00:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SFb6IDYOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:54 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 80/99] fbdev/tdfxfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:57 +0100 Message-Id: <20230306160016.4459-81-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tdfxfb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index d17e5e1472aa..ed3d8491e724 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -1589,7 +1589,15 @@ static void __init tdfxfb_setup(char *options) } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; } else { - mode_option = this_opt; + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "tdfxfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "tdfxfb: option too long\n")) + continue; + mode_option = mode_option_buf; } } } From patchwork Mon Mar 6 15:59:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07C17C7618D for ; Mon, 6 Mar 2023 16:02:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbjCFQCJ (ORCPT ); Mon, 6 Mar 2023 11:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbjCFQBD (ORCPT ); Mon, 6 Mar 2023 11:01:03 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43C4311E5; Mon, 6 Mar 2023 08:00:56 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6248D22441; Mon, 6 Mar 2023 16:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ls2zpWNQwKyUd6c7jGCzHsXipZg/epgyes0ZWs+tOkQ=; b=cNab8bW1wtB1J/f7O9PqZI22+q4ZVQsMV4pMe7hlvQRnFEf2FPr9BV5rNnBMSNkw87suyy zii8gpql9YZdZrPq0vHjPUBKJZOFrodN/3euKsE4QkBQaCEfJzeDTYSfXQ9Mr5fufwi6mE hDzCrw90Q8EyEOCzGxOODTOVBUrhLjo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ls2zpWNQwKyUd6c7jGCzHsXipZg/epgyes0ZWs+tOkQ=; b=xpghlH3ap6xUl4eeycZ5M7CETfUlMyor5LQYwbIo+fkm9wcHjWroPP4metLpnX9FGP8sO6 vjEcTfbEu+BbryCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F090713A6A; Mon, 6 Mar 2023 16:00:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2OXaOTYOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:54 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 81/99] fbdev/tdfxfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:58 +0100 Message-Id: <20230306160016.4459-82-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tdfxfb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index ed3d8491e724..54b19ce40bff 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -65,6 +65,7 @@ */ #include +#include #include #include #include @@ -1570,16 +1571,14 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) } #ifndef MODULE -static void __init tdfxfb_setup(char *options) +static void __init tdfxfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "nopan")) { nopan = 1; } else if (!strcmp(this_opt, "nowrap")) { @@ -1600,6 +1599,8 @@ static void __init tdfxfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); } #endif From patchwork Mon Mar 6 15:59:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E81B8C678D4 for ; Mon, 6 Mar 2023 16:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbjCFQCQ (ORCPT ); Mon, 6 Mar 2023 11:02:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231496AbjCFQBE (ORCPT ); Mon, 6 Mar 2023 11:01:04 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B37625E09; Mon, 6 Mar 2023 08:00:57 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C4A3422443; Mon, 6 Mar 2023 16:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aGY7Fu+FjH5ebrEemOkXLczvoMTp1L2oXB861qWkvNU=; b=jO+jFE6XviH+PxwP2JyPoLSjnYyEpIn34E2rFOJkcRr0M7X98vcXTCiZDd8uzD5T6ZRojH 6StEZ5ATSm4FgKja60Gp2u7FGnLZ5DDftD7PBHiCxseMbiGZEgD6ZkHe80NVcSMKkD0M79 Gm2x2+2UOPr3prtpTjKJgh8IlQFG4mg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aGY7Fu+FjH5ebrEemOkXLczvoMTp1L2oXB861qWkvNU=; b=VlJjJiIUs+oHeU8hDVVlqsE2CfYsTGg62x/mWIFG5U/Zh94oDrhdW8CkvrHNvrfjokCm16 N6nRW7LywKCIABBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6655F13513; Mon, 6 Mar 2023 16:00:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gOr6FzcOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:55 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 82/99] fbdev/tgafb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:59 +0100 Message-Id: <20230306160016.4459-83-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tgafb.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c index 14d37c49633c..a412fdddfd8c 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -1579,9 +1579,21 @@ static int tgafb_setup(char *arg) while ((this_opt = strsep(&arg, ","))) { if (!*this_opt) continue; - if (!strncmp(this_opt, "mode:", 5)) - mode_option = this_opt+5; - else + if (!strncmp(this_opt, "mode:", 5)) { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", + this_opt + 5); + if (WARN(ret < 0, + "tgafb: ignoring invalid option, ret=%d\n", + ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), + "tgafb: option too long\n")) + continue; + mode_option = mode_option_buf; + } else printk(KERN_ERR "tgafb: unknown parameter %s\n", this_opt); From patchwork Mon Mar 6 16:00:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 153D6C6FD1D for ; Mon, 6 Mar 2023 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjCFQCP (ORCPT ); Mon, 6 Mar 2023 11:02:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231501AbjCFQBE (ORCPT ); Mon, 6 Mar 2023 11:01:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83EDF34F44; Mon, 6 Mar 2023 08:00:57 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 43F5D1FEE3; Mon, 6 Mar 2023 16:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118456; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GGmlkKUitP/mPaJwo4DVCYrRiGQzK8ly7VqVkEk13o=; b=LHeaDUuqcFLT7mvfjL3Oe2/1UgmRJHfKInYcEKlnvYt4gTrcecvGEXnoNnAJqb35G/SlDv nPl1lofsiQ/GLHtiJ6rgy5havdpCwU9WJxddivM0PSECOADY2BIrzW1W45EhJu3rDUdSeL XkPTWdMb62Vr0KLMHhq8iLyaxGuyRzs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118456; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GGmlkKUitP/mPaJwo4DVCYrRiGQzK8ly7VqVkEk13o=; b=CgsnbGbmnWvItotHj0adFz0sUs6nZ/rNAfneC3yL5yga7kw0lmaeTHogJ5Fs4t7PAfUWVw IZvSo6EYQ983jqAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C9EF613513; Mon, 6 Mar 2023 16:00:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cNVhMDcOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:55 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 83/99] fbdev/tgafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:00 +0100 Message-Id: <20230306160016.4459-84-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tgafb.c | 45 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c index a412fdddfd8c..704909edf89d 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -1571,35 +1572,31 @@ static void tgafb_exit(void) } #ifndef MODULE -static int tgafb_setup(char *arg) +static int tgafb_setup(const char *arg) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (arg && *arg) { - while ((this_opt = strsep(&arg, ","))) { - if (!*this_opt) + option_iter_init(&iter, arg); + + while (option_iter_next(&iter, this_opt)) { + if (!strncmp(this_opt, "mode:", 5)) { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", + this_opt + 5); + if (WARN(ret < 0, "tgafb: ignoring invalid option, ret=%d\n", ret)) continue; - if (!strncmp(this_opt, "mode:", 5)) { - static char mode_option_buf[256]; - int ret; - - ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", - this_opt + 5); - if (WARN(ret < 0, - "tgafb: ignoring invalid option, ret=%d\n", - ret)) - continue; - if (WARN(ret >= sizeof(mode_option_buf), - "tgafb: option too long\n")) - continue; - mode_option = mode_option_buf; - } else - printk(KERN_ERR - "tgafb: unknown parameter %s\n", - this_opt); - } + if (WARN(ret >= sizeof(mode_option_buf), "tgafb: option too long\n")) + continue; + mode_option = mode_option_buf; + } else + printk(KERN_ERR "tgafb: unknown parameter %s\n", this_opt); } + option_iter_release(&iter); + return 0; } #endif /* !MODULE */ From patchwork Mon Mar 6 16:00:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7208C6FA99 for ; Mon, 6 Mar 2023 16:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjCFQCO (ORCPT ); Mon, 6 Mar 2023 11:02:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjCFQBF (ORCPT ); Mon, 6 Mar 2023 11:01:05 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05F2334C3B; Mon, 6 Mar 2023 08:00:58 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AFFB31FEE6; Mon, 6 Mar 2023 16:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118456; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OEolRl7Gtp6eBSHcZORJIpDzJ5v2DCmOHbu1CyAwA3Y=; b=nSAPDps7b4eyqBSFBGX40iycf64sF9/x7zewiXbBXIgAwzGfjnbPkMl7H2bVusG+ypnnkQ 09gZjxZA1bTyL+96HyqwGXH5nBzyBnV3iyb4kTnylRUbHh/vqFqjrN5JhjY/thXIzgoWwV hrmhdXkj6pM1gB8vff2/qhblJ37W5O4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118456; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OEolRl7Gtp6eBSHcZORJIpDzJ5v2DCmOHbu1CyAwA3Y=; b=MieZldQrprtTBsfNXL0KzOsqbmwfoQDjj+0/IPsyDelLittK1mvKIo3Odip4IXy8GCTDxc 7k+7tkeTmpW2x9CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3A63413A6A; Mon, 6 Mar 2023 16:00:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oHFyDTgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:56 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 84/99] fbdev/tmiofb: Remove unused option string Date: Mon, 6 Mar 2023 17:00:01 +0100 Message-Id: <20230306160016.4459-85-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The option string is unused. Remove the variable and a related helper function. No functional change. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tmiofb.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/video/fbdev/tmiofb.c b/drivers/video/fbdev/tmiofb.c index 50111966c981..8920cee52d7f 100644 --- a/drivers/video/fbdev/tmiofb.c +++ b/drivers/video/fbdev/tmiofb.c @@ -11,6 +11,7 @@ * code written by Sharp/Lineo for 2.4 kernels */ +#include #include #include #include @@ -997,32 +998,11 @@ static struct platform_driver tmiofb_driver = { /*--------------------------------------------------------------------------*/ -#ifndef MODULE -static void __init tmiofb_setup(char *options) -{ - char *this_opt; - - if (!options || !*options) - return; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; - /* - * FIXME - */ - } -} -#endif - static int __init tmiofb_init(void) { #ifndef MODULE - char *option = NULL; - - if (fb_get_options("tmiofb", &option)) + if (fb_get_options("tmiofb", NULL)) return -ENODEV; - tmiofb_setup(option); #endif return platform_driver_register(&tmiofb_driver); } From patchwork Mon Mar 6 16:00:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C37E7C6FD20 for ; Mon, 6 Mar 2023 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbjCFQCS (ORCPT ); Mon, 6 Mar 2023 11:02:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbjCFQBF (ORCPT ); Mon, 6 Mar 2023 11:01:05 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6358735279; Mon, 6 Mar 2023 08:00:58 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2104A1FEE8; Mon, 6 Mar 2023 16:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118457; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NRH8FDBlUenGi6t3vADvmnZXBzAlyd1DOo5qbgN/AjE=; b=FcmR5Ilu2FyZ0aLZLBjI89PfVeogAgi8Mj3NX5fDD6u8EnA92IzM/KZ9RUvIFMIYffMmFF ttlyLQCdemVx47Xa+brtK/X9Wh6quLpVYb+bi6gx0DfVvACXPIetiiUzl4s++i38cXFW12 9ulDrdY5EcKxarL+MWNJ4DKzGUtOXPI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118457; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NRH8FDBlUenGi6t3vADvmnZXBzAlyd1DOo5qbgN/AjE=; b=wY5srk6jZqqWfP4NxccbClrm872HRKp9pzYLQDFdEis3ybVZ+2xKQmslhC1gIsFyykRMs+ IPUbHcSbEW1RVMAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AF5ED13513; Mon, 6 Mar 2023 16:00:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eDDJKTgOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:56 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 85/99] fbdev/tridentfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 17:00:02 +0100 Message-Id: <20230306160016.4459-86-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tridentfb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c index 6099b9768ba1..21cee678047b 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -1800,8 +1800,17 @@ static int __init tridentfb_setup(char *options) memdiff = simple_strtoul(opt + 8, NULL, 0); else if (!strncmp(opt, "nativex=", 8)) nativex = simple_strtoul(opt + 8, NULL, 0); - else - mode_option = opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt); + if (WARN(ret < 0, "tridentfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "tridentfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; } From patchwork Mon Mar 6 16:00:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659522 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2316AC6FD1C for ; Mon, 6 Mar 2023 16:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbjCFQCN (ORCPT ); Mon, 6 Mar 2023 11:02:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231503AbjCFQBF (ORCPT ); Mon, 6 Mar 2023 11:01:05 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF56536088; Mon, 6 Mar 2023 08:00:58 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A29D51FEEB; Mon, 6 Mar 2023 16:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118457; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mGQE+ZcGyuVNRtdwYQbikR9YEbMLrF150xmpu0jqFzU=; b=DYymHttlVRncjdxkjgOcd/RypvLPIwkCs4865i0fRblDr+sWZVWwyhdQohkYcoFeyoHeZh bVJQYnEx+cyBP6EcUYK8GFgBLnJjKRFVnat6u/EkAVO8V+lxFuh5CmiFuN9CTcIOyIM2hB kbnlY0nueRouXYoypO7HF0o7UX8910A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118457; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mGQE+ZcGyuVNRtdwYQbikR9YEbMLrF150xmpu0jqFzU=; b=ncqaOhvDFT5fGJedOnieNRBQbXIgs8+ET12Fjq4Ckcj34fqN8R/Wln1EFgyXtrCXwYOepx 1Eb/9CH5SBfvtnDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2107913A6A; Mon, 6 Mar 2023 16:00:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0DI3BzkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:57 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 86/99] fbdev/tridentfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:03 +0100 Message-Id: <20230306160016.4459-87-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tridentfb.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c index 21cee678047b..0b8d4bc514e2 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -1774,14 +1775,14 @@ static struct pci_driver tridentfb_pci_driver = { * video=trident:800x600,bpp=16,noaccel */ #ifndef MODULE -static int __init tridentfb_setup(char *options) +static int __init tridentfb_setup(const char *options) { - char *opt; - if (!options || !*options) - return 0; - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + struct option_iter iter; + const char *opt; + + option_iter_init(&iter, options); + + while (option_iter_next(&iter, opt)) { if (!strncmp(opt, "noaccel", 7)) noaccel = 1; else if (!strncmp(opt, "fp", 2)) @@ -1812,6 +1813,9 @@ static int __init tridentfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 16:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A7DDC6FD1E for ; Mon, 6 Mar 2023 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbjCFQCS (ORCPT ); Mon, 6 Mar 2023 11:02:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231506AbjCFQBF (ORCPT ); Mon, 6 Mar 2023 11:01:05 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 662672FCDE; Mon, 6 Mar 2023 08:00:59 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1D2AF2244B; Mon, 6 Mar 2023 16:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fY7la/uDAaobcBLaIZ85iqzUSoMyQj9cvO6BCel8NIQ=; b=qHsDy5eO9yrSPhK/XQhdzCtKRVRbSQHLTxCxG18+IDzTMh8CZ/Vuuv+NuczfuH7Rg11B9/ 2/OFGiLzeVo/8kZ1fp2DMrdVqng0F/j1gM+goEH9eW9sp1MPyL9Toy1pj09pKAi4lwj9SL bfYMqJ0daIYn3j97bdHKWJXWxywDHcY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fY7la/uDAaobcBLaIZ85iqzUSoMyQj9cvO6BCel8NIQ=; b=Pr6Z2vZDZym0ebLFiDPvT4FgSkTzx0WnJoMOBBUvEdY3QZfMNkQjugC3D3WckrE6A8xouS CEHlxlU9EiPP3OCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A819513513; Mon, 6 Mar 2023 16:00:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UBf9JzkOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:57 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 87/99] fbdev/uvesafb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 17:00:04 +0100 Message-Id: <20230306160016.4459-88-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/uvesafb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c index f09f483c219b..201f6bba0763 100644 --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c @@ -1851,7 +1851,15 @@ static int uvesafb_setup(char *options) else if (!strncmp(this_opt, "vbemode:", 8)) vbemode = simple_strtoul(this_opt + 8, NULL, 0); else if (this_opt[0] >= '0' && this_opt[0] <= '9') { - mode_option = this_opt; + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "uvesafb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "uvesafb: option too long\n")) + continue; + mode_option = mode_option_buf; } else { pr_warn("unrecognized option %s\n", this_opt); } From patchwork Mon Mar 6 16:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7274CC742A7 for ; Mon, 6 Mar 2023 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbjCFQCR (ORCPT ); Mon, 6 Mar 2023 11:02:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbjCFQBG (ORCPT ); Mon, 6 Mar 2023 11:01:06 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044F42E813; Mon, 6 Mar 2023 08:01:00 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9145522285; Mon, 6 Mar 2023 16:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mEhBpN6twqC93ccGiwa5lzYv6YauDqAwC362BxH6GVI=; b=Ut4v9Yp+wjwadONFNsyMBXo+mZuvnX1hNTwxN5+cjhS2okVvDS88iMnL9ULbLKMeJBvbqt 9uPkKM/Pj80pMIbKiwu3v9dwwEkSx29N8JQPI+tDGeSzwzGd6BCYfpIcBn4A+tYbHFTWsL ai2eg21TdqQA0G3W6G7X1eyn9O4/yqI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mEhBpN6twqC93ccGiwa5lzYv6YauDqAwC362BxH6GVI=; b=YimuZxKPDn8Mnu7nQeQbXeW4UjY4rPWmFD3/5m6LKna2JANBJ2sb8WycuUXUQuRAk+NEBT JM1YQiGjrwFc3XDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1EA8B13A6A; Mon, 6 Mar 2023 16:00:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aP94BjoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:58 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 88/99] fbdev/uvesafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:05 +0100 Message-Id: <20230306160016.4459-89-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/uvesafb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c index 201f6bba0763..aada6a44380c 100644 --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -1808,16 +1809,14 @@ static struct platform_driver uvesafb_driver = { static struct platform_device *uvesafb_device; #ifndef MODULE -static int uvesafb_setup(char *options) +static int uvesafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strcmp(this_opt, "redraw")) ypan = 0; else if (!strcmp(this_opt, "ypan")) @@ -1865,6 +1864,8 @@ static int uvesafb_setup(char *options) } } + option_iter_release(&iter); + if (mtrr != 3 && mtrr != 0) pr_warn("uvesafb: mtrr should be set to 0 or 3; %d is unsupported", mtrr); From patchwork Mon Mar 6 16:00:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 925BAC74A44 for ; Mon, 6 Mar 2023 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbjCFQCT (ORCPT ); Mon, 6 Mar 2023 11:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231514AbjCFQBH (ORCPT ); Mon, 6 Mar 2023 11:01:07 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF222FCCF; Mon, 6 Mar 2023 08:01:00 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 05B3022453; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zyH/0IPG9qUaFYsN9w/QwcLQQulAY9+Gu12kUrvFX8w=; b=nzzELS/KQ0f6PvEQbk7fKZU3Y+4WfDd83yEc40+/ngpNxQpZOIm8c5q0e8Cj4WzSlC/rtB uw4l5bT1ZzAH/W2ck1C5xYGw/vv1Zfe+pwLWUfn/ih3ntES1D8BEkrl3g3Y38s5KPBw9sM 9bd6s35PfzhrKiiEMKaWgNAuvN2l/7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zyH/0IPG9qUaFYsN9w/QwcLQQulAY9+Gu12kUrvFX8w=; b=Q+mU012QejaFFGb/sGL0VqoWftCSR5rJZ4XsoEL6CYGcoC32Igf/Yo/D4rZtN56zwXJPa0 +1o+Jy6gZqy4IFAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8BA7913513; Mon, 6 Mar 2023 16:00:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aM/eIDoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:58 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 89/99] fbdev/valkyriefb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 17:00:06 +0100 Message-Id: <20230306160016.4459-90-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/valkyriefb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c index 1007023a5e88..b166b7cfe0e5 100644 --- a/drivers/video/fbdev/valkyriefb.c +++ b/drivers/video/fbdev/valkyriefb.c @@ -1,7 +1,7 @@ /* * valkyriefb.c -- frame buffer device for the PowerMac 'valkyrie' display * - * Created 8 August 1998 by + * Created 8 August 1998 by * Martin Costabel and Kevin Schoedel * * Vmode-switching changes and vmode 15/17 modifications created 29 August @@ -77,13 +77,13 @@ struct fb_info_valkyrie { struct fb_par_valkyrie par; struct cmap_regs __iomem *cmap_regs; unsigned long cmap_regs_phys; - + struct valkyrie_regs __iomem *valkyrie_regs; unsigned long valkyrie_regs_phys; - + __u8 __iomem *frame_buffer; unsigned long frame_buffer_phys; - + int sense; unsigned long total_vram; @@ -244,7 +244,7 @@ static inline int valkyrie_vram_reqd(int video_mode, int color_mode) { int pitch; struct valkyrie_regvals *init = valkyrie_reg_init[video_mode-1]; - + if ((pitch = init->pitch[color_mode]) == 0) pitch = 2 * init->pitch[0]; return init->vres * pitch; @@ -467,7 +467,7 @@ static int valkyrie_var_to_par(struct fb_var_screeninfo *var, printk(KERN_ERR "valkyriefb: vmode %d not valid.\n", vmode); return -EINVAL; } - + if (cmode != CMODE_8 && cmode != CMODE_16) { printk(KERN_ERR "valkyriefb: cmode %d not valid.\n", cmode); return -EINVAL; @@ -516,7 +516,7 @@ static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valk fix->ywrapstep = 0; fix->ypanstep = 0; fix->xpanstep = 0; - + } /* Fix must already be inited above */ From patchwork Mon Mar 6 16:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660146 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E27E3C74A5B for ; Mon, 6 Mar 2023 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbjCFQCU (ORCPT ); Mon, 6 Mar 2023 11:02:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjCFQBH (ORCPT ); Mon, 6 Mar 2023 11:01:07 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2C0E33463; Mon, 6 Mar 2023 08:01:00 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 66A7B1FEFF; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCuFu5SU57CJHGfgdFQfRit83nbssA/Udz2hcttdwvo=; b=W1nzjeHYtW6hzk14lqyszCbBcEyq+8sp1neVZkcFBMWzDWHpoD8hvd9fJ3XnrradACZnRR V76iuXULIzy+1BbZuk5joOrpdRBBC4XeTuNp/6Oli/pO5cyLRKWRInJPHx7z8l5wz2cdNC BHDp6sWJypFqjb5/34UCDmkWLRk1b/I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCuFu5SU57CJHGfgdFQfRit83nbssA/Udz2hcttdwvo=; b=P1f84vfZfPvK+9BrjhaXylpZL4FXUF/HeEJ+a5miwhRpk/t6QiJVhJ316MSaNST23ETt/X OFH2X0fV9excSxDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0A93113A6A; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CDilATsOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:59 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 90/99] fbdev/valkyriefb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:07 +0100 Message-Id: <20230306160016.4459-91-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/valkyriefb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c index b166b7cfe0e5..a787b0142d00 100644 --- a/drivers/video/fbdev/valkyriefb.c +++ b/drivers/video/fbdev/valkyriefb.c @@ -39,6 +39,7 @@ * more details. */ +#include #include #include #include @@ -90,7 +91,7 @@ struct fb_info_valkyrie { u32 pseudo_palette[16]; }; -static int valkyriefb_setup(char*); +static int valkyriefb_setup(const char *options); static int valkyriefb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); @@ -545,14 +546,14 @@ static int __init valkyrie_init_info(struct fb_info *info, /* * Parse user specified options (`video=valkyriefb:') */ -static int __init valkyriefb_setup(char *options) +static int __init valkyriefb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "vmode:", 6)) { int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX) @@ -571,6 +572,9 @@ static int __init valkyriefb_setup(char *options) } } } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 16:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 475A7C7618A for ; Mon, 6 Mar 2023 16:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjCFQCV (ORCPT ); Mon, 6 Mar 2023 11:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231519AbjCFQBI (ORCPT ); Mon, 6 Mar 2023 11:01:08 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6716B360B9; Mon, 6 Mar 2023 08:01:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C0FC61FF02; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q00Utiwa/F841Bfuw5zq1QJNoc8fZ3VllqOH/C02QCE=; b=2YyHro04N0b6hHpoFP2VQC2IKhOpPCA1BPziXoC8McHbOvN7SlzhzzcOmFrBQ/kuMBc6/M v1MGvf6vmWPMlCx2NfyBp/wOLsQcY8OBo1YEvYItF7ChD6r1wAXIh6TkZWKdBInE9vha+B V/jdd2v6HfQsHjY0nc9fVZYomGui0+A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q00Utiwa/F841Bfuw5zq1QJNoc8fZ3VllqOH/C02QCE=; b=rJ3Km2Gruxrmh0L4o3E6JxO9pq9pA1bXR3yUWfn53OmQ45VXvbngIFjQYfNujwP4uQIhdT OKZJtBSdJKn6/KBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 68E7E13513; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cNKzGDsOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:59 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 91/99] fbdev/vermilion: Remove unused option string Date: Mon, 6 Mar 2023 17:00:08 +0100 Message-Id: <20230306160016.4459-92-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The option string is unused. Remove the variable. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vermilion/vermilion.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c index 0374ee6b6d03..bea318504475 100644 --- a/drivers/video/fbdev/vermilion/vermilion.c +++ b/drivers/video/fbdev/vermilion/vermilion.c @@ -1056,16 +1056,11 @@ static void __exit vmlfb_cleanup(void) static int __init vmlfb_init(void) { - -#ifndef MODULE - char *option = NULL; -#endif - if (fb_modesetting_disabled("vmlfb")) return -ENODEV; #ifndef MODULE - if (fb_get_options(MODULE_NAME, &option)) + if (fb_get_options(MODULE_NAME, NULL)) return -ENODEV; #endif From patchwork Mon Mar 6 16:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 100C2C76188 for ; Mon, 6 Mar 2023 16:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230478AbjCFQCW (ORCPT ); Mon, 6 Mar 2023 11:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbjCFQBI (ORCPT ); Mon, 6 Mar 2023 11:01:08 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D2D3645B; Mon, 6 Mar 2023 08:01:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 303DA1FEF0; Mon, 6 Mar 2023 16:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dONd6f2HgnZB2y++YdhIG1SYI1ymM+yxwiajgTlzEkA=; b=WFHDKQyhwL+2euaP6YonRjhjvt+FCdLlPmnJTmspLca2E5fjTy7i1HEaB7Rh/ECcoJL/Xn P8VM3lCEjSXW+PL6Ix43BmAtiQx0vLCnSj62DHsyEOSmWYts+3pKQg/sBKaTsdKLoHrWA6 6u5coGZIbNKXB8cetIf35K6ubW9w+bA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dONd6f2HgnZB2y++YdhIG1SYI1ymM+yxwiajgTlzEkA=; b=b6f38i2LHYIoNOB6S8lYYbfGHHtVdSSlSWqn159gGK0kCo86FioTrNkfEnU1b80kfhfsv0 qs6hh9K+ME2PFwDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C5E2913A6A; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cHBjLzsOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:59 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 92/99] fbdev/vesafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:09 +0100 Message-Id: <20230306160016.4459-93-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vesafb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c index 3f8bdfcf51f0..0310a3db2b10 100644 --- a/drivers/video/fbdev/vesafb.c +++ b/drivers/video/fbdev/vesafb.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -209,16 +210,14 @@ static struct fb_ops vesafb_ops = { .fb_imageblit = cfb_imageblit, }; -static int vesafb_setup(char *options) +static int vesafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (! strcmp(this_opt, "inverse")) inverse=1; else if (! strcmp(this_opt, "redraw")) @@ -240,6 +239,9 @@ static int vesafb_setup(char *options) else if (! strncmp(this_opt, "vremap:", 7)) vram_remap = simple_strtoul(this_opt+7, NULL, 0); } + + option_iter_release(&iter); + return 0; } From patchwork Mon Mar 6 16:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B98EC76186 for ; Mon, 6 Mar 2023 16:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbjCFQCW (ORCPT ); Mon, 6 Mar 2023 11:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbjCFQBJ (ORCPT ); Mon, 6 Mar 2023 11:01:09 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D28D36696; Mon, 6 Mar 2023 08:01:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8DF771FF07; Mon, 6 Mar 2023 16:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MXGv0fdp1SeaTBkcusJuAlPjwuf6QThoq9N0qSVQosw=; b=xEBvVtc7IHAwtr8aMdThOyNogMbo2jDUcd40NuQu+ZPz+tWqoZ3ZgZIb28m0Vth5qLdT1O TdfRrjPUmkmyFds2fInAA4eFuEns6jW/mtJ+uu3xLJkNAoPapFXbrluzXcaSVdl/qIEZDK Uky6A4KqcMOhZUQV4qDzWlWPWouO9PM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MXGv0fdp1SeaTBkcusJuAlPjwuf6QThoq9N0qSVQosw=; b=N+XPBP7uH1ru2SSAXWo9HC/OdhcR8kP2omP1FXPZhhMsytvzeSYbJ6G0WttlIcnv7XJbHk HdhebkDvmKr83gAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 330F013513; Mon, 6 Mar 2023 16:01:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YFeSCzwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:00 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 93/99] fbdev/vfb: Remove trailing whitespaces Date: Mon, 6 Mar 2023 17:00:10 +0100 Message-Id: <20230306160016.4459-94-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vfb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index 95d3c59867d0..680c88267ef4 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -110,7 +110,7 @@ static u_long get_line_length(int xres_virtual, int bpp) * First part, xxxfb_check_var, must not write anything * to hardware, it should only verify and adjust var. * This means it doesn't alter par but it does use hardware - * data from it to check this var. + * data from it to check this var. */ static int vfb_check_var(struct fb_var_screeninfo *var, @@ -168,7 +168,7 @@ static int vfb_check_var(struct fb_var_screeninfo *var, /* * Now that we checked it we alter var. The reason being is that the video - * mode passed in might not work but slight changes to it might make it + * mode passed in might not work but slight changes to it might make it * work. This way we let the user know what is acceptable. */ switch (var->bits_per_pixel) { @@ -234,8 +234,8 @@ static int vfb_check_var(struct fb_var_screeninfo *var, } /* This routine actually sets the video mode. It's in here where we - * the hardware state info->par and fix which can be affected by the - * change in par. For this driver it doesn't do much. + * the hardware state info->par and fix which can be affected by the + * change in par. For this driver it doesn't do much. */ static int vfb_set_par(struct fb_info *info) { @@ -378,7 +378,7 @@ static int vfb_pan_display(struct fb_var_screeninfo *var, } /* - * Most drivers don't need their own mmap function + * Most drivers don't need their own mmap function */ static int vfb_mmap(struct fb_info *info, From patchwork Mon Mar 6 16:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C28EFC6FD1B for ; Mon, 6 Mar 2023 16:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjCFQCY (ORCPT ); Mon, 6 Mar 2023 11:02:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbjCFQBK (ORCPT ); Mon, 6 Mar 2023 11:01:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F7722FCEF; Mon, 6 Mar 2023 08:01:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EAD252245C; Mon, 6 Mar 2023 16:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ycoi4td43MhalPP9ez+KkigUFBrWFEhU6qfgrbIMAG0=; b=mTVFrA71Y/lKqIayleCJsy7TiNv3hllchoXLngFUEk8al+vQdE7pKPjgELc5k7neotZaiR DEHJ4F5nXnql0FFRwGz6s2FtzOrb78g3feEGDhaY/vHxE6HZ9rgj6zFdemib0AvFWGebBM DSG79E0tIJ9OL14LtyE/18jRZIrCn+M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ycoi4td43MhalPP9ez+KkigUFBrWFEhU6qfgrbIMAG0=; b=WqtHLrbbrM54fNxv9XHbii5NOEwV8YHpN5nWAUxfOXnJ95zppxmIVqShefTwT2NxRXy0UF tIkszX43AseTZ6CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9067D13A6A; Mon, 6 Mar 2023 16:01:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OPpkIjwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:00 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 94/99] fbdev/vfb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 17:00:11 +0100 Message-Id: <20230306160016.4459-95-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vfb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index 680c88267ef4..15a6a0896ab5 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -412,8 +412,17 @@ static int __init vfb_setup(char *options) /* Test disable for backwards compatibility */ if (!strcmp(this_opt, "disable")) vfb_enable = 0; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "vfb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "vfb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 1; } From patchwork Mon Mar 6 16:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99809C7618B for ; Mon, 6 Mar 2023 16:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjCFQCX (ORCPT ); Mon, 6 Mar 2023 11:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231529AbjCFQBJ (ORCPT ); Mon, 6 Mar 2023 11:01:09 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2D922FCF8; Mon, 6 Mar 2023 08:01:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5B49A22460; Mon, 6 Mar 2023 16:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118461; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yHX8se/a6g2QABvUAuzQQZnhm45LSCTjkT4aQxcZgwg=; b=IO1wQ7s6J51f7IGHE42mtkVSBcrzo6+KDsNJYhUTEDsyqxrZEPNsl1OP+jCGGj3EzzLUc3 XyZR1rytImeAn4HIA6EfC9OINCWP9QPc6im9N8cCCm5J+jKeUaudbAy6dytj0iJpF/O6h6 J4xTsMUmBJpZCWu2hkOE+CTLQlQrasM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118461; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yHX8se/a6g2QABvUAuzQQZnhm45LSCTjkT4aQxcZgwg=; b=jRT7I0wvGwJFHKoOvaHLkubbf/RB6iKsyZiAqxFyXlE35ZE2Q3265uqsjCZrEKXO9uvqzg yjBObXwHcb/0KEDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EF81513513; Mon, 6 Mar 2023 16:01:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uDFuOTwOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:00 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 95/99] fbdev/vfb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:12 +0100 Message-Id: <20230306160016.4459-96-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vfb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index 15a6a0896ab5..ef22a6815e70 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -10,6 +10,7 @@ * more details. */ +#include #include #include #include @@ -392,9 +393,10 @@ static int vfb_mmap(struct fb_info *info, * The virtual framebuffer driver is only enabled if explicitly * requested by passing 'video=vfb:' (or any actual options). */ -static int __init vfb_setup(char *options) +static int __init vfb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; vfb_enable = 0; @@ -403,12 +405,9 @@ static int __init vfb_setup(char *options) vfb_enable = 1; - if (!*options) - return 1; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { /* Test disable for backwards compatibility */ if (!strcmp(this_opt, "disable")) vfb_enable = 0; @@ -424,6 +423,9 @@ static int __init vfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 1; } #endif /* MODULE */ From patchwork Mon Mar 6 16:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05ABAC76196 for ; Mon, 6 Mar 2023 16:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229988AbjCFQCZ (ORCPT ); Mon, 6 Mar 2023 11:02:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231534AbjCFQBK (ORCPT ); Mon, 6 Mar 2023 11:01:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A8FD32E58; Mon, 6 Mar 2023 08:01:03 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BB3BB22461; Mon, 6 Mar 2023 16:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118461; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hBXQKYm2hwrIwZ4Y9UCOS67Q8TAQ+vGWXSDQRXHtNhc=; b=lJKTCD/WkcNYmZcY9jTjFh4dh4nexnA6fZYSMd2FXhI8VEExrA31xcfu6sLhx0cbPbO5XC MT2x6Ay7AdH6Ig3Ok40g6nyOSzSVBBJm4A7DuIagaOeDwdnorjnsPWwfR/hXEyMkOHZCjD JKsjU5HN9urjGFivrJOIsujXg4OllaE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118461; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hBXQKYm2hwrIwZ4Y9UCOS67Q8TAQ+vGWXSDQRXHtNhc=; b=FWT2P+1YsMeg6ZH2ng/TlropyQSDKfG/VjgGc9g6/aefVAQF04kUk3tGoX2oF0tj0gwxPr w+4J3U1BCwIwfmCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5EC2813A6A; Mon, 6 Mar 2023 16:01:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IMI5Fj0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:01 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 96/99] fbdev/viafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:13 +0100 Message-Id: <20230306160016.4459-97-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/via/viafbdev.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c index 2d67c92c5774..4f39319e21f8 100644 --- a/drivers/video/fbdev/via/viafbdev.c +++ b/drivers/video/fbdev/via/viafbdev.c @@ -5,6 +5,7 @@ */ +#include #include #include #include @@ -1922,21 +1923,18 @@ void via_fb_pci_remove(struct pci_dev *pdev) #ifndef MODULE static int __init viafb_setup(void) { - char *this_opt; char *options; + struct option_iter iter; + const char *this_opt; DEBUG_MSG(KERN_INFO "viafb_setup!\n"); if (fb_get_options("viafb", &options)) return -ENODEV; - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "viafb_mode1=", 12)) { viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL); if (!viafb_mode1) @@ -2009,6 +2007,9 @@ static int __init viafb_setup(void) return -ENOMEM; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Mon Mar 6 16:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6EEFC761AF for ; Mon, 6 Mar 2023 16:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230097AbjCFQC0 (ORCPT ); Mon, 6 Mar 2023 11:02:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbjCFQBK (ORCPT ); Mon, 6 Mar 2023 11:01:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 926702E0D3; Mon, 6 Mar 2023 08:01:03 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3427B2245B; Mon, 6 Mar 2023 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118462; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9jPw1gekX+dS3alKpIhYWuod0yFkaKVmgthd+u+9Q3I=; b=BZCIBnjT4VG2watd8QiYGZnfT3gnTX0oWbbZ/wo0QDvu1fLYkpFx8+kzl197N8PW9XiMgK dK8wIAlA4l5TYEOwT3EpDASIhkF5Ain2/FyssDJ9BvNyQDHPqWHxxabnciQI9Fc0rDeOnm HRLN5ZIRHvdY51yTQDrtWsM6emHsZAI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118462; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9jPw1gekX+dS3alKpIhYWuod0yFkaKVmgthd+u+9Q3I=; b=Xj87SiI0F2lYajydSZ9VDJqbuHcFCbMfqbg59Q1PzPiAgepDEYeJTtbYJQUfEIF9IdLmBR wyl+8GbplWzpOLDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BF9B813513; Mon, 6 Mar 2023 16:01:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2EfpLT0OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:01 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 97/99] fbdev/vt8623fb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 17:00:14 +0100 Message-Id: <20230306160016.4459-98-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vt8623fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 034333ee6e45..cbdca42d1708 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -929,8 +929,17 @@ static int __init vt8623fb_init(void) if (fb_get_options("vt8623fb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + if (option && *option) { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", option); + if (WARN(ret < 0, "vt8623fb: ignoring invalid option, ret=%d\n", ret)) + break; + if (WARN(ret >= sizeof(mode_option_buf), "vt8623fb: option too long\n")) + break; + mode_option = mode_option_buf; + } #endif pr_debug("vt8623fb: initializing\n"); From patchwork Mon Mar 6 16:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 659515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE2FDC761A6 for ; Mon, 6 Mar 2023 16:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbjCFQC0 (ORCPT ); Mon, 6 Mar 2023 11:02:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbjCFQBL (ORCPT ); Mon, 6 Mar 2023 11:01:11 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E14242410D; Mon, 6 Mar 2023 08:01:03 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8513B22464; Mon, 6 Mar 2023 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118462; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9yTAZ+fWm46H8QqfoRrnwlZTk5mIqjHDcgi+SJhTWtw=; b=Br3YluVLuR6Ry7K8JR11i7Y6BwJ19Dy/SS6WvZZAGFao7VqxeQstljX9BKQYatqUH2U3rH axSSd2rIfWBlmyfaMa12nNRbc/B5dJqqSdy25DF0nC1nEAOXc9jMTwPnxZ1BSMYnR/T49x CPQiy+jEp9/hwLaVA9unYphnWPW5HHk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118462; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9yTAZ+fWm46H8QqfoRrnwlZTk5mIqjHDcgi+SJhTWtw=; b=MLgmOCvBzQ+4wPhXhi5GV8EsH1wxUxxiGUfGTH6NUSq1yo7nucXwNLckj5yvLlXfHg6gu2 1YwmvZcohBoEQVCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2C7AE13A6A; Mon, 6 Mar 2023 16:01:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uHMGCj4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:02 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 98/99] staging/sm750fb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:15 +0100 Message-Id: <20230306160016.4459-99-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/staging/sm750fb/sm750.c | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index effc7fcc3703..2eb223f0631e 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include @@ -867,9 +868,10 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) } /* chip specific g_option configuration routine */ -static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) +static void sm750fb_setup(struct sm750_dev *sm750_dev, const char *src) { - char *opt; + struct option_iter iter; + const char *opt; int swap; swap = 0; @@ -889,9 +891,12 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) goto NO_PARAM; } - while ((opt = strsep(&src, ":")) != NULL && *opt != 0) { + dev_info(&sm750_dev->pdev->dev, "src=%s\n", src); + + option_iter_init(&iter, src); + + while (option_iter_next(&iter, opt)) { dev_info(&sm750_dev->pdev->dev, "opt=%s\n", opt); - dev_info(&sm750_dev->pdev->dev, "src=%s\n", src); if (!strncmp(opt, "swap", strlen("swap"))) { swap = 1; @@ -924,6 +929,8 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) } } + option_iter_release(&iter); + NO_PARAM: if (sm750_dev->revid != SM750LE_REVISION_ID) { if (sm750_dev->fb_count > 1) { @@ -1096,10 +1103,12 @@ static void lynxfb_pci_remove(struct pci_dev *pdev) kfree(g_settings); } -static int __init lynxfb_setup(char *options) +static int __init lynxfb_setup(const char *options) { + struct option_iter iter; + const char *opt; int len; - char *opt, *tmp; + char *tmp; if (!options || !*options) { pr_warn("no options.\n"); @@ -1112,19 +1121,11 @@ static int __init lynxfb_setup(char *options) g_settings = kzalloc(len, GFP_KERNEL); if (!g_settings) return -ENOMEM; - tmp = g_settings; - /* - * Notes: - * char * strsep(char **s,const char * ct); - * @s: the string to be searched - * @ct :the characters to search for - * - * strsep() updates @options to pointer after the first found token - * it also returns the pointer ahead the token. - */ - while ((opt = strsep(&options, ":")) != NULL) { + option_iter_init(&iter, options); + + while (option_iter_next(&iter, opt)) { /* options that mean for any lynx chips are configured here */ if (!strncmp(opt, "noaccel", strlen("noaccel"))) { g_noaccel = 1; @@ -1133,15 +1134,15 @@ static int __init lynxfb_setup(char *options) } else if (!strncmp(opt, "dual", strlen("dual"))) { g_dualview = 1; } else { + if (tmp != g_settings) + *tmp++ = ':'; // add separator strcat(tmp, opt); tmp += strlen(opt); - if (options) - *tmp++ = ':'; - else - *tmp++ = 0; } } + option_iter_release(&iter); + /* misc g_settings are transport to chip specific routines */ pr_info("parameter left for chip specific analysis:%s\n", g_settings); return 0; From patchwork Mon Mar 6 16:00:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 660144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F6FBC77B60 for ; Mon, 6 Mar 2023 16:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbjCFQC2 (ORCPT ); Mon, 6 Mar 2023 11:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231472AbjCFQBg (ORCPT ); Mon, 6 Mar 2023 11:01:36 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4409A30B34; Mon, 6 Mar 2023 08:01:04 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F3FE01FF16; Mon, 6 Mar 2023 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118463; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXai0tXnhsrWHlNkhv/7Ht5WujOnGX+SqDiXb2FAn/g=; b=oqzz+Zx4USaXLXCHHTejLyrlL6HmGFK4Sm8oby6z3kHEMNHVdXaSV1kOtvzXSbDmzIAKy1 T9R0F0u+zFeO+grBSvPEp2RNVvwPOmfP8o7p5WZQDHXcaneZyzH/8XB4rEQ8mxrJDHTiWV xC5QJGVHovj4oX1eP4DAP0KQT5A6918= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118463; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXai0tXnhsrWHlNkhv/7Ht5WujOnGX+SqDiXb2FAn/g=; b=wu4mwcx+Ec2lfTeN+k0515s86k79yTS93XEJ4AX+k9kb1KwmhYscJNdqfHX7d3gBTAU1bj tfph8stTq8raF3Bg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8C11813513; Mon, 6 Mar 2023 16:01:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2L1NIT4OBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:01:02 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 99/99] fbdev: Constify option strings Date: Mon, 6 Mar 2023 17:00:16 +0100 Message-Id: <20230306160016.4459-100-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Return the option string as const char* from fb_get_options() to enforce fbdev's ownership of the memory region. Also avoids memory allocation within fb_get_options(). Callers that have to modify the option string must create their own copy. As most drivers use struct option_iter, this already happens transparently in many cases. Adapt all callers of fb_get_options(). Signed-off-by: Thomas Zimmermann --- drivers/staging/sm750fb/sm750.c | 2 +- drivers/video/fbdev/acornfb.c | 2 +- drivers/video/fbdev/amifb.c | 2 +- drivers/video/fbdev/arkfb.c | 2 +- drivers/video/fbdev/atafb.c | 2 +- drivers/video/fbdev/aty/aty128fb.c | 2 +- drivers/video/fbdev/aty/atyfb_base.c | 2 +- drivers/video/fbdev/aty/radeon_base.c | 2 +- drivers/video/fbdev/au1100fb.c | 2 +- drivers/video/fbdev/au1200fb.c | 2 +- drivers/video/fbdev/cirrusfb.c | 2 +- drivers/video/fbdev/controlfb.c | 2 +- drivers/video/fbdev/core/fb_cmdline.c | 13 +++---------- drivers/video/fbdev/core/modedb.c | 8 ++------ drivers/video/fbdev/cyber2000fb.c | 2 +- drivers/video/fbdev/efifb.c | 2 +- drivers/video/fbdev/ep93xx-fb.c | 2 +- drivers/video/fbdev/fm2fb.c | 2 +- drivers/video/fbdev/fsl-diu-fb.c | 2 +- drivers/video/fbdev/gbefb.c | 2 +- drivers/video/fbdev/geode/gx1fb_core.c | 2 +- drivers/video/fbdev/geode/gxfb_core.c | 2 +- drivers/video/fbdev/geode/lxfb_core.c | 2 +- drivers/video/fbdev/grvga.c | 3 ++- drivers/video/fbdev/gxt4500.c | 2 +- drivers/video/fbdev/hyperv_fb.c | 2 +- drivers/video/fbdev/i740fb.c | 2 +- drivers/video/fbdev/i810/i810_main.c | 2 +- drivers/video/fbdev/imsttfb.c | 2 +- drivers/video/fbdev/imxfb.c | 2 +- drivers/video/fbdev/intelfb/intelfbdrv.c | 2 +- drivers/video/fbdev/kyro/fbdev.c | 2 +- drivers/video/fbdev/macfb.c | 2 +- drivers/video/fbdev/matrox/matroxfb_base.c | 2 +- drivers/video/fbdev/mx3fb.c | 2 +- drivers/video/fbdev/neofb.c | 2 +- drivers/video/fbdev/nvidia/nvidia.c | 2 +- drivers/video/fbdev/ocfb.c | 2 +- drivers/video/fbdev/omap/omapfb_main.c | 2 +- drivers/video/fbdev/platinumfb.c | 2 +- drivers/video/fbdev/pm2fb.c | 2 +- drivers/video/fbdev/pm3fb.c | 2 +- drivers/video/fbdev/ps3fb.c | 2 +- drivers/video/fbdev/pvr2fb.c | 2 +- drivers/video/fbdev/pxafb.c | 2 +- drivers/video/fbdev/riva/fbdev.c | 2 +- drivers/video/fbdev/s3fb.c | 2 +- drivers/video/fbdev/savage/savagefb_driver.c | 2 +- drivers/video/fbdev/sis/sis_main.c | 2 +- drivers/video/fbdev/skeletonfb.c | 2 +- drivers/video/fbdev/sm712fb.c | 2 +- drivers/video/fbdev/sstfb.c | 2 +- drivers/video/fbdev/stifb.c | 2 +- drivers/video/fbdev/tdfxfb.c | 2 +- drivers/video/fbdev/tgafb.c | 2 +- drivers/video/fbdev/tridentfb.c | 2 +- drivers/video/fbdev/uvesafb.c | 2 +- drivers/video/fbdev/valkyriefb.c | 2 +- drivers/video/fbdev/vesafb.c | 2 +- drivers/video/fbdev/vfb.c | 2 +- drivers/video/fbdev/via/viafbdev.c | 2 +- drivers/video/fbdev/vt8623fb.c | 3 +-- include/linux/fb.h | 2 +- 63 files changed, 67 insertions(+), 78 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 2eb223f0631e..fe5c18e00ac8 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -1167,7 +1167,7 @@ static struct pci_driver lynxfb_driver = { static int __init lynxfb_init(void) { - char *option; + const char *option; if (fb_modesetting_disabled("sm750fb")) return -ENODEV; diff --git a/drivers/video/fbdev/acornfb.c b/drivers/video/fbdev/acornfb.c index 1d6dec45615c..be4aafb23a5c 100644 --- a/drivers/video/fbdev/acornfb.c +++ b/drivers/video/fbdev/acornfb.c @@ -926,7 +926,7 @@ static int acornfb_probe(struct platform_device *dev) unsigned long size; u_int h_sync, v_sync; int rc, i; - char *option = NULL; + const char *option = NULL; if (fb_get_options("acornfb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index b968cf2c5f06..ef8518fd4fdc 100644 --- a/drivers/video/fbdev/amifb.c +++ b/drivers/video/fbdev/amifb.c @@ -3546,7 +3546,7 @@ static int __init amifb_probe(struct platform_device *pdev) u_int defmode; #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("amifb", &option)) { amifb_video_off(); diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c index f83fcdaec7a0..5c39b872e52d 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -1186,7 +1186,7 @@ static int __init arkfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("arkfb")) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index 82d5567f2ffb..a77794ad18a7 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -2999,7 +2999,7 @@ static int __init atafb_probe(struct platform_device *pdev) int pad, detected_mode, error; unsigned int defmode = 0; unsigned long mem_req; - char *option = NULL; + const char *option = NULL; if (fb_get_options("atafb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index 4a200eabe80b..40b42dcd00bb 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -2514,7 +2514,7 @@ static int __maybe_unused aty128_pci_resume(struct device *dev) static int aty128fb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("aty128fb")) diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c index 1920ee5c9a2a..fe3742cf4eb8 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c @@ -3970,7 +3970,7 @@ static int __init atyfb_init(void) { int err1 = 1, err2 = 1; #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("atyfb")) diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 185cd98ad59d..1d19a4b664ab 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -2616,7 +2616,7 @@ static int __init radeonfb_setup (const char *options) static int __init radeonfb_init (void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("radeonfb")) diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c index 17dae92ac53f..6976b201a3aa 100644 --- a/drivers/video/fbdev/au1100fb.c +++ b/drivers/video/fbdev/au1100fb.c @@ -366,7 +366,7 @@ static const struct fb_ops au1100fb_ops = static int au1100fb_setup(struct au1100fb_device *fbdev) { - char *options; + const char *options; struct option_iter iter; const char *this_opt; int num_panels = ARRAY_SIZE(known_lcd_panels); diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c index 31a3f6afd8aa..c39bf715abad 100644 --- a/drivers/video/fbdev/au1200fb.c +++ b/drivers/video/fbdev/au1200fb.c @@ -1578,7 +1578,7 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev) static int au1200fb_setup(struct au1200fb_platdata *pd) { - char *options = NULL; + const char *options = NULL; struct option_iter iter; const char *this_opt; char *endptr; diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index c6882bff3862..28526af217c2 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -2369,7 +2369,7 @@ static int __init cirrusfb_init(void) int error = 0; #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("cirrusfb")) diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c index 3633e874ab2e..dc1d1c7ebeee 100644 --- a/drivers/video/fbdev/controlfb.c +++ b/drivers/video/fbdev/controlfb.c @@ -1004,7 +1004,7 @@ static int __init control_of_init(struct device_node *dp) static int __init control_init(void) { struct device_node *dp; - char *option = NULL; + const char *option = NULL; int ret = -ENXIO; if (fb_get_options("controlfb", &option)) diff --git a/drivers/video/fbdev/core/fb_cmdline.c b/drivers/video/fbdev/core/fb_cmdline.c index 4d1634c492ec..67f9df7096f1 100644 --- a/drivers/video/fbdev/core/fb_cmdline.c +++ b/drivers/video/fbdev/core/fb_cmdline.c @@ -28,12 +28,9 @@ * (video=:) * @option: the option will be stored here * - * The caller owns the string returned in @option and is - * responsible for releasing the memory. - * * NOTE: Needed to maintain backwards compatibility */ -int fb_get_options(const char *name, char **option) +int fb_get_options(const char *name, const char **option) { const char *options = NULL; bool is_of = false; @@ -49,12 +46,8 @@ int fb_get_options(const char *name, char **option) enabled = false; } - if (option) { - if (options) - *option = kstrdup(options, GFP_KERNEL); - else - *option = NULL; - } + if (option) + *option = options; return enabled ? 0 : 1; // 0 on success, 1 otherwise } diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c index 23cf8eba785d..5ff5a56925cc 100644 --- a/drivers/video/fbdev/core/modedb.c +++ b/drivers/video/fbdev/core/modedb.c @@ -620,7 +620,6 @@ int fb_find_mode(struct fb_var_screeninfo *var, const struct fb_videomode *default_mode, unsigned int default_bpp) { - char *mode_option_buf = NULL; int i; /* Set up defaults */ @@ -636,10 +635,8 @@ int fb_find_mode(struct fb_var_screeninfo *var, default_bpp = 8; /* Did the user specify a video mode? */ - if (!mode_option) { - fb_get_options(NULL, &mode_option_buf); - mode_option = mode_option_buf; - } + if (!mode_option) + fb_get_options(NULL, &mode_option); if (mode_option) { const char *name = mode_option; unsigned int namelen = strlen(name); @@ -718,7 +715,6 @@ int fb_find_mode(struct fb_var_screeninfo *var, res_specified = 1; } done: - kfree(mode_option_buf); if (cvt) { struct fb_videomode cvt_mode; int ret; diff --git a/drivers/video/fbdev/cyber2000fb.c b/drivers/video/fbdev/cyber2000fb.c index 939dde664b53..4c147d1500bc 100644 --- a/drivers/video/fbdev/cyber2000fb.c +++ b/drivers/video/fbdev/cyber2000fb.c @@ -1877,7 +1877,7 @@ static int __init cyber2000fb_init(void) int ret = -1, err; #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("CyberPro")) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 1ae7574aaa82..669b259b78ab 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -366,7 +366,7 @@ static int efifb_probe(struct platform_device *dev) unsigned int size_vmode; unsigned int size_remap; unsigned int size_total; - char *option = NULL; + const char *option = NULL; efi_memory_desc_t md; if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled) diff --git a/drivers/video/fbdev/ep93xx-fb.c b/drivers/video/fbdev/ep93xx-fb.c index 305f1587bd89..33a9aa2ecc3b 100644 --- a/drivers/video/fbdev/ep93xx-fb.c +++ b/drivers/video/fbdev/ep93xx-fb.c @@ -464,7 +464,7 @@ static int ep93xxfb_probe(struct platform_device *pdev) struct fb_info *info; struct ep93xx_fbi *fbi; struct resource *res; - char *video_mode; + const char *video_mode; int err; if (!mach_info) diff --git a/drivers/video/fbdev/fm2fb.c b/drivers/video/fbdev/fm2fb.c index 4f17bc8e6c1d..a466e8ddfe8a 100644 --- a/drivers/video/fbdev/fm2fb.c +++ b/drivers/video/fbdev/fm2fb.c @@ -315,7 +315,7 @@ static int __init fm2fb_setup(const char *options) static int __init fm2fb_init(void) { - char *option = NULL; + const char *option = NULL; if (fb_get_options("fm2fb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index c97a9c04e8e8..8341332b52a8 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -1908,7 +1908,7 @@ static int __init fsl_diu_init(void) #endif int ret; #ifndef MODULE - char *option; + const char *option; /* * For kernel boot options (in 'video=xxxfb:' format) diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 36651bb6006d..d7fd55405169 100644 --- a/drivers/video/fbdev/gbefb.c +++ b/drivers/video/fbdev/gbefb.c @@ -1125,7 +1125,7 @@ static int gbefb_probe(struct platform_device *p_dev) struct fb_info *info; struct gbefb_par *par; #ifndef MODULE - char *options = NULL; + const char *options = NULL; #endif info = framebuffer_alloc(sizeof(struct gbefb_par), &p_dev->dev); diff --git a/drivers/video/fbdev/geode/gx1fb_core.c b/drivers/video/fbdev/geode/gx1fb_core.c index dd1dc7ee7f83..174c0dd8f389 100644 --- a/drivers/video/fbdev/geode/gx1fb_core.c +++ b/drivers/video/fbdev/geode/gx1fb_core.c @@ -445,7 +445,7 @@ static struct pci_driver gx1fb_driver = { static int __init gx1fb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("gx1fb")) diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c index f5e88e92ba16..3d70e13e1f7a 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -517,7 +517,7 @@ static int __init gxfb_setup(const char *options) static int __init gxfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("gxfb")) diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c index d687054cdb09..2d529ad6a391 100644 --- a/drivers/video/fbdev/geode/lxfb_core.c +++ b/drivers/video/fbdev/geode/lxfb_core.c @@ -653,7 +653,7 @@ static int __init lxfb_setup(const char *options) static int __init lxfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("lxfb")) diff --git a/drivers/video/fbdev/grvga.c b/drivers/video/fbdev/grvga.c index f803dc37c891..727a8f793877 100644 --- a/drivers/video/fbdev/grvga.c +++ b/drivers/video/fbdev/grvga.c @@ -334,7 +334,8 @@ static int grvga_probe(struct platform_device *dev) unsigned long physical_start = 0; unsigned long grvga_mem_size = 0; struct grvga_par *par = NULL; - char *options = NULL, *mode_opt = NULL; + const char *options = NULL; + const *mode_opt = NULL; struct option_iter iter; const char *this_opt; diff --git a/drivers/video/fbdev/gxt4500.c b/drivers/video/fbdev/gxt4500.c index 61bc714693f5..d9c0aea36719 100644 --- a/drivers/video/fbdev/gxt4500.c +++ b/drivers/video/fbdev/gxt4500.c @@ -780,7 +780,7 @@ static struct pci_driver gxt4500_driver = { static int gxt4500_init(void) { #ifndef MODULE - char *options; + const char *options; #endif if (fb_modesetting_disabled("gxt4500")) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index edb0555239c6..c7956626eed0 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -903,7 +903,7 @@ static const struct fb_ops hvfb_ops = { static void hvfb_get_option(struct fb_info *info) { struct hvfb_par *par = info->par; - char *options = NULL; + const char *options = NULL; char *optbuf, *opt, *p; uint x = 0, y = 0; diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index cf45d6280f38..89455ce69c41 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -1294,7 +1294,7 @@ static int __init i740fb_setup(const char *options) static int __init i740fb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("i740fb")) diff --git a/drivers/video/fbdev/i810/i810_main.c b/drivers/video/fbdev/i810/i810_main.c index 3e624522fe7a..77d784261c6a 100644 --- a/drivers/video/fbdev/i810/i810_main.c +++ b/drivers/video/fbdev/i810/i810_main.c @@ -2155,7 +2155,7 @@ static void i810fb_remove_pci(struct pci_dev *dev) #ifndef MODULE static int i810fb_init(void) { - char *option = NULL; + const char *option = NULL; if (fb_modesetting_disabled("i810fb")) return -ENODEV; diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index fc046886599c..3edb7b752553 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1620,7 +1620,7 @@ imsttfb_setup(const char *options) static int __init imsttfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("imsttfb")) diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index 950df484e5be..b62767553b29 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -846,7 +846,7 @@ static struct lcd_ops imxfb_lcd_ops = { static int imxfb_setup(void) { - char *options = NULL; + const char *options = NULL; struct option_iter iter; const char *opt; diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 2d4e03b9e7fd..bff36914b62f 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -390,7 +390,7 @@ static int __init intelfb_setup(const char *options) static int __init intelfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif DBG_MSG("intelfb_init\n"); diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index c2c6e1bba3a0..eb15b26bdffc 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -797,7 +797,7 @@ static void kyrofb_remove(struct pci_dev *pdev) static int __init kyrofb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("kyrofb")) diff --git a/drivers/video/fbdev/macfb.c b/drivers/video/fbdev/macfb.c index a72edb98b170..c05e790f223b 100644 --- a/drivers/video/fbdev/macfb.c +++ b/drivers/video/fbdev/macfb.c @@ -541,7 +541,7 @@ static int __init macfb_init(void) { int video_cmap_len, video_is_nubus = 0; struct nubus_rsrc *ndev = NULL; - char *option = NULL; + const char *option = NULL; int err; if (fb_get_options("macfb", &option)) diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c index f690ee0c9b1f..20d42ddc021f 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.c +++ b/drivers/video/fbdev/matrox/matroxfb_base.c @@ -2475,7 +2475,7 @@ static int __initdata initialized = 0; static int __init matroxfb_init(void) { - char *option = NULL; + const char *option = NULL; int err = 0; DBG(__func__) diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c index cb9f5ac69e79..9c561b3bb508 100644 --- a/drivers/video/fbdev/mx3fb.c +++ b/drivers/video/fbdev/mx3fb.c @@ -1654,7 +1654,7 @@ static struct platform_driver mx3fb_driver = { static int __init mx3fb_setup(void) { #ifndef MODULE - char *options = NULL; + const char *options = NULL; struct option_iter iter; const char *opt; diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index e9b132d660ab..55b47961c03e 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -2218,7 +2218,7 @@ static int __init neofb_setup(const char *options) static int __init neofb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("neofb")) diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index 58b1b13f09dd..9986e9f61458 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -1537,7 +1537,7 @@ static struct pci_driver nvidiafb_driver = { static int nvidiafb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("nvidiafb")) diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c index 546230483f53..26222e0c46ca 100644 --- a/drivers/video/fbdev/ocfb.c +++ b/drivers/video/fbdev/ocfb.c @@ -417,7 +417,7 @@ static struct platform_driver ocfb_driver = { static int __init ocfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("ocfb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c index 464a667708db..b490fe342200 100644 --- a/drivers/video/fbdev/omap/omapfb_main.c +++ b/drivers/video/fbdev/omap/omapfb_main.c @@ -1905,7 +1905,7 @@ static int __init omapfb_setup(const char *options) static int __init omapfb_init(void) { #ifndef MODULE - char *option; + const char *option; if (fb_get_options("omapfb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c index 71d5b7c169e7..5840c6e385a5 100644 --- a/drivers/video/fbdev/platinumfb.c +++ b/drivers/video/fbdev/platinumfb.c @@ -683,7 +683,7 @@ static struct platform_driver platinum_driver = static int __init platinumfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("platinumfb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c index a6a793efb0fe..8e9b9c7b4787 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -1814,7 +1814,7 @@ static int __init pm2fb_setup(const char *options) static int __init pm2fb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("pm2fb")) diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c index 4eec0ad1e984..598200143a0d 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -1550,7 +1550,7 @@ static int __init pm3fb_init(void) * For kernel boot options (in 'video=pm3fb:' format) */ #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("pm3fb")) diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c index d7c287089c64..2b54460c5bfe 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -1256,7 +1256,7 @@ static struct ps3_system_bus_driver ps3fb_driver = { static int __init ps3fb_setup(void) { - char *options; + const char *options; struct option_iter iter; const char *this_opt; diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index 9255b3506b81..7a62e5048703 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -1090,7 +1090,7 @@ static int __init pvr2fb_init(void) int i, ret = -ENODEV; #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("pvr2fb")) diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c index 1937a58e47a1..b856e268f3b2 100644 --- a/drivers/video/fbdev/pxafb.c +++ b/drivers/video/fbdev/pxafb.c @@ -2040,7 +2040,7 @@ static char g_options[256] = ""; #ifndef MODULE static int __init pxafb_setup_options(void) { - char *options = NULL; + const char *options = NULL; if (fb_get_options("pxafb", &options)) return -ENODEV; diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index d95319bb93cc..0cbff9c43ca4 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -2172,7 +2172,7 @@ static struct pci_driver rivafb_driver = { static int rivafb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("rivafb")) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index f3bd7b1c2c9a..7745801b4ff4 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1566,7 +1566,7 @@ static int __init s3fb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("s3fb")) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 94026848d67d..e08ae210ad5c 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -2564,7 +2564,7 @@ static int __init savagefb_setup(const char *options) static int __init savagefb_init(void) { - char *option; + const char *option; DBG("savagefb_init"); diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c index 7e6e2251e62f..3ab07e6795cf 100644 --- a/drivers/video/fbdev/sis/sis_main.c +++ b/drivers/video/fbdev/sis/sis_main.c @@ -6587,7 +6587,7 @@ static struct pci_driver sisfb_driver = { static int __init sisfb_init(void) { #ifndef MODULE - char *options = NULL; + const char *options = NULL; #endif if (fb_modesetting_disabled("sisfb")) diff --git a/drivers/video/fbdev/skeletonfb.c b/drivers/video/fbdev/skeletonfb.c index 1e876ad2a261..0d24620836bf 100644 --- a/drivers/video/fbdev/skeletonfb.c +++ b/drivers/video/fbdev/skeletonfb.c @@ -899,7 +899,7 @@ static int __init xxxfb_init(void) * For kernel boot options (in 'video=xxxfb:' format) */ #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("xxxfb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index b0f3898125f4..19ebbf2b019d 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1754,7 +1754,7 @@ static struct pci_driver smtcfb_driver = { static int __init sm712fb_init(void) { - char *option = NULL; + const char *option = NULL; if (fb_modesetting_disabled("sm712fb")) return -ENODEV; diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c index 6c3769062d50..d20dbd881133 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -1512,7 +1512,7 @@ static struct pci_driver sstfb_driver = { static int sstfb_init(void) { - char *option = NULL; + const char *option = NULL; if (fb_modesetting_disabled("sstfb")) return -ENODEV; diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c index 304ce8fcb9f8..c1f28bb046d3 100644 --- a/drivers/video/fbdev/stifb.c +++ b/drivers/video/fbdev/stifb.c @@ -1401,7 +1401,7 @@ static int __init stifb_init(void) int i; #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("stifb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index 54b19ce40bff..96f8a511a24f 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -1640,7 +1640,7 @@ static void tdfxfb_remove(struct pci_dev *pdev) static int __init tdfxfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("tdfxfb")) diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c index 704909edf89d..cf7e08c1523e 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -1605,7 +1605,7 @@ static int tgafb_init(void) { int status; #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("tgafb")) diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c index 0b8d4bc514e2..07ac9232a6ae 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -1823,7 +1823,7 @@ static int __init tridentfb_setup(const char *options) static int __init tridentfb_init(void) { #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("tridentfb")) diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c index aada6a44380c..a9ac1f111f37 100644 --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c @@ -1891,7 +1891,7 @@ static int uvesafb_init(void) int err; #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("uvesafb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c index a787b0142d00..8756f0690b09 100644 --- a/drivers/video/fbdev/valkyriefb.c +++ b/drivers/video/fbdev/valkyriefb.c @@ -304,7 +304,7 @@ static int __init valkyriefb_init(void) struct fb_info_valkyrie *p; unsigned long frame_buffer_phys, cmap_regs_phys; int err; - char *option = NULL; + const char *option = NULL; if (fb_get_options("valkyriefb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c index 0310a3db2b10..6bba8759b9c4 100644 --- a/drivers/video/fbdev/vesafb.c +++ b/drivers/video/fbdev/vesafb.c @@ -253,7 +253,7 @@ static int vesafb_probe(struct platform_device *dev) unsigned int size_vmode; unsigned int size_remap; unsigned int size_total; - char *option = NULL; + const char *option = NULL; /* ignore error return of fb_get_options */ fb_get_options("vesafb", &option); diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index ef22a6815e70..ddab307c4073 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -518,7 +518,7 @@ static int __init vfb_init(void) int ret = 0; #ifndef MODULE - char *option = NULL; + const char *option = NULL; if (fb_get_options("vfb", &option)) return -ENODEV; diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c index 4f39319e21f8..3704dbfa21df 100644 --- a/drivers/video/fbdev/via/viafbdev.c +++ b/drivers/video/fbdev/via/viafbdev.c @@ -1923,7 +1923,7 @@ void via_fb_pci_remove(struct pci_dev *pdev) #ifndef MODULE static int __init viafb_setup(void) { - char *options; + const char *options; struct option_iter iter; const char *this_opt; diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index cbdca42d1708..b68dc71e9791 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -917,9 +917,8 @@ static void __exit vt8623fb_cleanup(void) static int __init vt8623fb_init(void) { - #ifndef MODULE - char *option = NULL; + const char *option = NULL; #endif if (fb_modesetting_disabled("vt8623fb")) diff --git a/include/linux/fb.h b/include/linux/fb.h index d96529caa35e..0bebdd03f287 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -601,7 +601,7 @@ extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u3 extern void fb_set_suspend(struct fb_info *info, int state); extern int fb_get_color_depth(struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix); -extern int fb_get_options(const char *name, char **option); +extern int fb_get_options(const char *name, const char **option); extern int fb_new_modelist(struct fb_info *info); extern bool fb_center_logo;