From patchwork Thu Mar 9 16:00: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: 661276 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 DAC2CC74A5B for ; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231410AbjCIQCL (ORCPT ); Thu, 9 Mar 2023 11:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbjCIQCJ (ORCPT ); Thu, 9 Mar 2023 11:02:09 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F74F3670; Thu, 9 Mar 2023 08:02:06 -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 D326022145; Thu, 9 Mar 2023 16:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377724; 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=6AMUD/BAuZ3/uSqv29KEQ12Je2fDNnYZyOW1M3To6s0=; b=wE4xX58Z5CXD6dYAmm+iqWbzxjWJCqFuU7QfOJOmNubsbrDL/cQUo8fGtlMA9m0EFllqW9 RGWOzzg2z10IEWTGY6jZF/pbhMwrUoHOqR5hCFymDREy52NrO2UqHbvribIJHMBtNBMBCf ldGf/ZbQxyoA94ysms+Xp1mbdn6rH9k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377724; 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=6AMUD/BAuZ3/uSqv29KEQ12Je2fDNnYZyOW1M3To6s0=; b=HsNK6R2jZqi6S+bROf5OqWJTras+HUKrV8PkphRR4gTwFJOizG4IjDvCSgEfwgTX9Hz6N8 bmbOsYrlDrsXNFAQ== 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 7111513A73; Thu, 9 Mar 2023 16:02:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OF3DGvwCCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:04 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 001/101] lib: Add option iterator Date: Thu, 9 Mar 2023 17:00:21 +0100 Message-Id: <20230309160201.5163-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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. v2: * improve documentation (Randy) * implement option_iter_next() as function * allow modification of the returned options Signed-off-by: Thomas Zimmermann --- Documentation/core-api/kernel-api.rst | 9 +++ include/linux/cmdline.h | 36 +++++++++ lib/Makefile | 2 +- lib/cmdline_iter.c | 109 ++++++++++++++++++++++++++ 4 files changed, 155 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..e9e0eb68e176 --- /dev/null +++ b/include/linux/cmdline.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef LINUX_CMDLINE_H +#define LINUX_CMDLINE_H + +#include + +/** + * 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); +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. + * + * Return: + * True to continue the loop, or false if no further option has been found. + */ +static inline bool option_iter_next(struct option_iter *iter, char **opt) +{ + return ((*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..3e53aa8d8a3d --- /dev/null +++ b/lib/cmdline_iter.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include + +/** + * DOC: overview + * + * A kernel parameter's option string can contain multiple comma-separated + * options. Struct &option_iter and its helpers parse the string and return + * the individual substrings. + * + * After obtaining the string from the kernel, initialize an instance of the + * option iterator and loop over its content as show below. + * + * .. code-block:: c + * + * const char *options = ...; // kernel-provided option string + * + * struct option_iter iter; + * 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 functions option_iter_init() and option_iter_release() enclose + * all code that uses struct &option_iter. The call to option_iter_init() + * initializes the iterator instance from the option string and sets it + * up to return the first contained substring. The iterator owns a copy + * of the option string, which is later freed by option_iter_release(). + * The state of an instance of struct &option_iter is undefined after the + * release function has returned. + * + * The loop walks over the individual options while option_iter_next() + * succeeds. In this case, the second argument returns a pointer to the + * contained substring. If the option string contains an empty option + * (i.e., two commas next to each other), option_iter_next() skips the + * empty option automatically. + * + * The parsing process does not modify the original option string that + * was used to initialize the iterator. The memory returned by + * option_iter_next() is owned by the iterator instance. Callers are + * allowed to modify its content but may not free it. References to the + * returned string become stale after option_iter_release() has returned. + */ + +/** + * 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 + * + * Return: + * The current option string, or NULL if there are no more options. + */ +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 Thu Mar 9 16:00: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: 661277 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 87750C6FD19 for ; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbjCIQCL (ORCPT ); Thu, 9 Mar 2023 11:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjCIQCI (ORCPT ); Thu, 9 Mar 2023 11:02:08 -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 E074EF5AA4; Thu, 9 Mar 2023 08:02:06 -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 46A7722146; Thu, 9 Mar 2023 16:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377725; 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=wUHZNCYoMsbJ3mTnwSWHOyd/Q7JcnrlOz3m8Af3LxaC8cQ+FHtBO4/CE+bLsegTKX9IWGT HqIEV7AuFFOrTdmersz2nNxeKzzas1FD4DEB1mIODP/wwOn7dUBFSajp2/DgiH4lt9JhVM l60Rbw8VYe9gEG9Vjln9r3rbtyVEY+k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377725; 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=z2KN9D1vGDa+RWJlNGjXhDJrWkdw1OShlOpg8FPT5T7j2jQE3UFelAaNCvkplEQykIfSTM aUpGgoQb4AyS2MCw== 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 D8DD013A79; Thu, 9 Mar 2023 16:02:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WOP0M/wCCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:04 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 002/101] fbdev/68328fb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:00:22 +0100 Message-Id: <20230309160201.5163-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:00: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: 662262 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 A2A6AC64EC4 for ; Thu, 9 Mar 2023 16:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230398AbjCIQCJ (ORCPT ); Thu, 9 Mar 2023 11:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbjCIQCI (ORCPT ); Thu, 9 Mar 2023 11:02:08 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45CCAF5AAA; Thu, 9 Mar 2023 08:02:07 -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 BA93B22142; Thu, 9 Mar 2023 16:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377725; 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=w2M1ASgu0lZrCMsHXHgnXvxWhi2LBlHQCDDLgWuIP0gFC5e6mu5hzpWJzazJOov2ElhEYC ulE40vpfEzs48sPfMh/R3esYMAiK47tSrCWDWDWSKGYbPSZ6QJZd1C4ZdtffnJKduHIGVx Q1EPOozEEYnFkboac+0B+vVedCm/SYY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377725; 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=IilZvr3APCBNyl1rJ4raIBeZJOQqVsdBC5cVa5NCgCiQiHv0KknIZilA6kKT3GZJkSEnLU FrMnow3H6WtNcrCA== 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 4A6A11391B; Thu, 9 Mar 2023 16:02:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eDdJEf0CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:05 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 003/101] fbdev/68328fb: Remove unused option string Date: Thu, 9 Mar 2023 17:00:23 +0100 Message-Id: <20230309160201.5163-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:00: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: 662261 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 A9D39C74A4B for ; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbjCIQCK (ORCPT ); Thu, 9 Mar 2023 11:02:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjCIQCI (ORCPT ); Thu, 9 Mar 2023 11:02:08 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694E3F5AAE; Thu, 9 Mar 2023 08:02:07 -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 240EC20178; Thu, 9 Mar 2023 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377726; 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=pTHEcIUkdO4RI5ksVY5B1WkUN4P012LmRqtrO58/N4kKDBnDCWa9oM29LMeCFurbgFl4Zf ZlNri4lJcHlRlaHn+bEVUmULumv/9LTsYKpXmhimbXL20VD1q7fM0mzTLivplERk0xqEN8 KcGf6hg5/SpVqncFC1gMCU3l42OU3G8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377726; 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=RTDEI9dmQRgy9k6aJ3HYKRujJ9aekExTA8pjDDMIHuVtJB+zt+BAbb4SJfWoDA0dJYAsAr QmBe2pzjY8kcHQAw== 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 B733F13A73; Thu, 9 Mar 2023 16:02:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SCy/K/0CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:05 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 004/101] fbdev/acornfb: Only init fb_info once Date: Thu, 9 Mar 2023 17:00:24 +0100 Message-Id: <20230309160201.5163-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:00: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: 661273 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 1C13FC74A4B for ; Thu, 9 Mar 2023 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231658AbjCIQCp (ORCPT ); Thu, 9 Mar 2023 11:02:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbjCIQCJ (ORCPT ); Thu, 9 Mar 2023 11:02: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 6C7A7F4002; Thu, 9 Mar 2023 08:02:08 -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 8D9EA20179; Thu, 9 Mar 2023 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377726; 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=MA6x97k7aP7QRzZKpKQzdIkdDwykRU28DukMccXbTyw=; b=vSx80YLIE+D2jM1cCMS/+8ygwlbFykEO6KrFcXuVzkXiu9kUO1tow2qtWn2dmIzpDg0NDM CcvgasHR9tf3WVBK4Lt/u0HkOq94BksvpDB3daCbqRM7oyGSigF0h6YYnjPgQ/DLPhU/I4 i32iGBhQaHOmk6+9264asGqdRM4P4b8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377726; 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=MA6x97k7aP7QRzZKpKQzdIkdDwykRU28DukMccXbTyw=; b=kWwyOmkQAc3/zuQ9YjPsTcffs0NoczG7MRwySa+PIUHqhwUS6t8NyTcYprHLCuKXHkEikw f8er8WNqYjf6asAA== 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 29EFF1391B; Thu, 9 Mar 2023 16:02:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OD80Cf4CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:06 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 005/101] fbdev/acornfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:25 +0100 Message-Id: <20230309160201.5163-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/acornfb.c b/drivers/video/fbdev/acornfb.c index 8642136a6bdc..3fed89e03554 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; + struct option_iter iter; 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 Thu Mar 9 16:00: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: 662259 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 EB828C742A7 for ; Thu, 9 Mar 2023 16:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbjCIQCn (ORCPT ); Thu, 9 Mar 2023 11:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjCIQCJ (ORCPT ); Thu, 9 Mar 2023 11:02:09 -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 6CBCCF6C4F; Thu, 9 Mar 2023 08:02:08 -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 EEFA822147; Thu, 9 Mar 2023 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377726; 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=lqqiwJisVH/SAzHfF2Z9EuhM1jnh+DNN6yoV0M1wteU=; b=xiFACuqremRu3gpC320ePcV8wZYe25+7E1u76jHQkErsmQu7yJlFnJNQGW5UYBZ9SQv5ot bOJU2ibthwLG/3GRKurnyiM+5pGzEzNNXleZRAo7u2koBtXCfSlz5rL7e9u2+FabOmsT/d A7lNPBm0yB0uEA2jxRkC1VxLlHOPhz4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377726; 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=lqqiwJisVH/SAzHfF2Z9EuhM1jnh+DNN6yoV0M1wteU=; b=c+5tBBtUF7Pe6+RmCA6axMVd3JFqEAs3odqujArmd2jPBkWAbsfx7CWjteAitmvohzjvmY RhvH9JTrpfkHYdBw== 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 92BC013A73; Thu, 9 Mar 2023 16:02:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CEgAI/4CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:06 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 006/101] fbdev/amifb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:26 +0100 Message-Id: <20230309160201.5163-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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/amifb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index d88265dbebf4..9517aa5bd2c0 100644 --- a/drivers/video/fbdev/amifb.c +++ b/drivers/video/fbdev/amifb.c @@ -2345,7 +2345,7 @@ static void __init amifb_setup_mcap(char *spec) amifb_vfmax = vmax; } -static int __init amifb_setup(char *options) +static int __init amifb_setup(char *options, struct platform_device *pdev) { char *this_opt; @@ -2363,8 +2363,10 @@ 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 { + // ignore errors + mode_option = devm_kstrdup(&pdev->dev, this_opt, GFP_KERNEL); + } } if (min_fstrt < 48) @@ -3542,7 +3544,7 @@ static int __init amifb_probe(struct platform_device *pdev) amifb_video_off(); return -ENODEV; } - amifb_setup(option); + amifb_setup(option, pdev); #endif custom.dmacon = DMAF_ALL | DMAF_MASTER; From patchwork Thu Mar 9 16:00: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: 661275 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 3BE1AC64EC4 for ; Thu, 9 Mar 2023 16:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231761AbjCIQCl (ORCPT ); Thu, 9 Mar 2023 11:02:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjCIQCJ (ORCPT ); Thu, 9 Mar 2023 11:02: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 DC32AF6C5E; Thu, 9 Mar 2023 08:02:08 -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 5CC402017A; Thu, 9 Mar 2023 16:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377727; 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=fAKwWillpJMLRw6wMQPDlzuh9+KWUcuRQNAZe1IaSrQ=; b=RSlu/cjSsyBJb0MNuFlWjDGlixOEHTWKfPF4CA+Rq/LSjRBhQiMJVX6fcb/RDWUtkmGaJN WxBFUszBc4pRI2i7IhFqOz7kntSHcGEOqd8h7jajUJqkFhvJfHTAbVYvHPu+OszvS03e1r uATh4kb07ZzFr8ryJzEhzb7B4hhjHxg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377727; 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=fAKwWillpJMLRw6wMQPDlzuh9+KWUcuRQNAZe1IaSrQ=; b=AMAKtOMDSze1CiWVcaaE9i5u9eSGfP91ts9jiKv2c+WvFiqtTHhXEtSSpMJBfV7138SSHC sERhL8+1fIr3VdDw== 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 F35161391B; Thu, 9 Mar 2023 16:02:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gBB2Ov4CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:06 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 007/101] fbdev/amifb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:27 +0100 Message-Id: <20230309160201.5163-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index 9517aa5bd2c0..a09edc576437 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, struct platform_device *pdev) +static int __init amifb_setup(const char *options, struct platform_device *pdev) { + struct option_iter iter; 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")) @@ -2369,6 +2368,8 @@ static int __init amifb_setup(char *options, struct platform_device *pdev) } } + option_iter_release(&iter); + if (min_fstrt < 48) min_fstrt = 48; From patchwork Thu Mar 9 16:00: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: 662257 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 5D057C74A5B for ; Thu, 9 Mar 2023 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbjCIQC5 (ORCPT ); Thu, 9 Mar 2023 11:02:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231224AbjCIQCK (ORCPT ); Thu, 9 Mar 2023 11:02:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC633F4B43; Thu, 9 Mar 2023 08:02:09 -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 BFF1922148; Thu, 9 Mar 2023 16:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377727; 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=+o0nKnK7DSPy1Ib3Bv1R1mVbwQPH782fXsSg9TrWayg=; b=ds9BVXOXcsc0L1GpIOU5m5mEsLa2GZFmgjUEVW1kVdMlOc11Zz4N8EAov+7woqI7LF5+3C sq74CAdP0eh2oIhJBY/S+ftDm3zDFektGWxf5t6SBO+dvPbVX0pDSj82wnHpRt0M224YBN kJ9+VNHyI5Ewx5Dbkx2LfsAw983rHjA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377727; 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=+o0nKnK7DSPy1Ib3Bv1R1mVbwQPH782fXsSg9TrWayg=; b=cAXmDe1ZXcW9Oq/X5vQNlcBGtv2ULwaGXsQK4pBNgTlpeAJLp/70WKkMESVoPnTLdPQZtx sQ55D/b67gXXUwDQ== 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 611E013A73; Thu, 9 Mar 2023 16:02:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UGDFFv8CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:07 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 008/101] fbdev/arkfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:28 +0100 Message-Id: <20230309160201.5163-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/arkfb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c index 60a96fdb5dd8..98c710cadaab 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -97,6 +97,7 @@ static const struct svga_timing_regs ark_timing_regs = { /* Module parameters */ +static char *mode_option_buf; static char *mode_option = "640x480-8@60"; MODULE_AUTHOR("(c) 2007 Ondrej Zajicek "); @@ -1178,6 +1179,7 @@ static void __exit arkfb_cleanup(void) { pr_debug("arkfb: cleaning up\n"); pci_unregister_driver(&arkfb_pci_driver); + kfree(mode_option_buf); } /* Driver Initialisation */ @@ -1196,8 +1198,10 @@ static int __init arkfb_init(void) if (fb_get_options("arkfb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + if (option && *option) { + mode_option_buf = kstrdup(option, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } #endif pr_debug("arkfb: initializing\n"); From patchwork Thu Mar 9 16:00: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: 662258 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 919A2C7618A for ; Thu, 9 Mar 2023 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231778AbjCIQC4 (ORCPT ); Thu, 9 Mar 2023 11:02:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231269AbjCIQCK (ORCPT ); Thu, 9 Mar 2023 11:02:10 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D76F3670; Thu, 9 Mar 2023 08:02:09 -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 3403B2017B; Thu, 9 Mar 2023 16:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377728; 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=AJxf0lFvTB2HQ0JfmzXfmeLR3kXSn2VgL48irVHdc4o=; b=OfP4AUqE1G6wqcMwo+biFpyvRku0GsvDk2KcxTo82UkvW0KlMksgCFcaLvI42vcmAgHWvD T7c84ECqUxcqCDCJ9yfERGuWnFJ0FYvaN5wnBKkgUwu7wsWjBK5BwfSh7FoQj/bqIRFiAM fgmUGc47BupFlUJzKL+488arK+q9DK8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377728; 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=AJxf0lFvTB2HQ0JfmzXfmeLR3kXSn2VgL48irVHdc4o=; b=mooOxt9sv6gR3aoiuNS1J+h19T0EnHD1fByofsVZVu2Mq32B6Lujc/C6Li+smhWDqdvS1Q G3R5S4Th8NrjBkDA== 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 C47D51391B; Thu, 9 Mar 2023 16:02:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kIcEL/8CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:07 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 009/101] fbdev/atafb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:29 +0100 Message-Id: <20230309160201.5163-10-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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/atafb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index 2bc4089865e6..f0cc7c992c88 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -2934,7 +2934,7 @@ static void __init atafb_setup_user(char *spec) } } -static int __init atafb_setup(char *options) +static int __init atafb_setup(char *options, struct platform_device *pdev) { char *this_opt; int temp; @@ -2946,8 +2946,9 @@ static int __init atafb_setup(char *options) if (!*this_opt) continue; if ((temp = get_video_mode(this_opt))) { + // ignore errors + mode_option = devm_kstrdup(&pdev->dev, this_opt, GFP_KERNEL); default_par = temp; - mode_option = this_opt; } else if (!strcmp(this_opt, "inverse")) fb_invert_cmaps(); else if (!strncmp(this_opt, "hwscroll_", 9)) { @@ -2992,7 +2993,7 @@ static int __init atafb_probe(struct platform_device *pdev) if (fb_get_options("atafb", &option)) return -ENODEV; - atafb_setup(option); + atafb_setup(option, pdev); dev_dbg(&pdev->dev, "%s: start\n", __func__); do { From patchwork Thu Mar 9 16:00: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: 661274 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 385FFC76186 for ; Thu, 9 Mar 2023 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231774AbjCIQCz (ORCPT ); Thu, 9 Mar 2023 11:02:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231350AbjCIQCL (ORCPT ); Thu, 9 Mar 2023 11:02:11 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFFDBF4B7A; Thu, 9 Mar 2023 08:02:09 -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 9D3A322149; Thu, 9 Mar 2023 16:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377728; 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=qPLL2nIMXVIbOX360ZiaSKuPOUXR3YFNZkhMEK9hl5o=; b=trE7up6tmAL8SM9RbL+ai1E5Cq3JpkvyWTc+J3fidroMRDQ4e2RJKpFjXU01wCryg/ONIP 0L+NcJvqQG5Hn1WbN5zu84UJjaBmnQQkCs05aIy/CNGn7O+atljpOQJwrVG6VHd95Ymumq ZoUwZGockmE47KlNWpBdmfnQGfvVJ94= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377728; 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=qPLL2nIMXVIbOX360ZiaSKuPOUXR3YFNZkhMEK9hl5o=; b=61DoR8i/KKWWcskabhK7cyMJ3KnsxiG6NbRhVV4D1pVyBP0r2ztvDjpLiMqUP5fBBZc5J/ qpDb4TCqn25oLIDg== 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 391291391B; Thu, 9 Mar 2023 16:02:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mB4KDQADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:08 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 010/101] fbdev/atafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:30 +0100 Message-Id: <20230309160201.5163-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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. v2: * add missing call to option_iter_init() Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/atafb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index f0cc7c992c88..6e625ac020b5 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,15 @@ static void __init atafb_setup_user(char *spec) } } -static int __init atafb_setup(char *options, struct platform_device *pdev) +static int __init atafb_setup(const char *options, struct platform_device *pdev) { + struct option_iter iter; char *this_opt; int temp; - 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 ((temp = get_video_mode(this_opt))) { // ignore errors mode_option = devm_kstrdup(&pdev->dev, this_opt, GFP_KERNEL); @@ -2981,6 +2980,9 @@ static int __init atafb_setup(char *options, struct platform_device *pdev) else if (!strncmp(this_opt, "R", 1)) atafb_setup_user(this_opt + 1); } + + option_iter_release(&iter); + return 0; } From patchwork Thu Mar 9 16:00: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: 662255 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 A3008C6FD19 for ; Thu, 9 Mar 2023 16:03:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231785AbjCIQDA (ORCPT ); Thu, 9 Mar 2023 11:03:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbjCIQCL (ORCPT ); Thu, 9 Mar 2023 11:02:11 -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 7B99FF7ECC; Thu, 9 Mar 2023 08:02:10 -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 0F0662017C; Thu, 9 Mar 2023 16:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377729; 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=ym5HuZho+njp3rS/G6tDZ4qDsVBX7VtriAnydblKDT0=; b=vf4a2GRs3xu4nDAXLU3y7QYwgfM4JjVf7Pi0P34wctrW7I/0ISZotE4hqOazqxK8OOSKKa GPGQOMfoMDk3jLHzl4ft5p/GoDD7xhUX7yxzUQfyQHDeBcMXbZmhPJZ5iYm7Y5H0ub34ir FSOL0DYmJPxbsN+u7df3vD3kmLswLmQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377729; 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=ym5HuZho+njp3rS/G6tDZ4qDsVBX7VtriAnydblKDT0=; b=R1sHxZf+v8isa6e5JoALDT9zwUOlMSuZCg9Iuc5fbLpMMJcoKCnxwZrNtJMB9Ri99eLxLA dvX1y91zRr0zv8BA== 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 A374A13A73; Thu, 9 Mar 2023 16:02:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eO36JgADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:08 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 011/101] fbdev/aty: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:31 +0100 Message-Id: <20230309160201.5163-12-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the drivers do not own the option string or its substrings and hence duplicate the option string for the video mode. Allocate the copy's memory with kstrdup() and free it in each module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/aty/aty128fb.c | 8 +++++++- drivers/video/fbdev/aty/atyfb_base.c | 9 +++++++-- drivers/video/fbdev/aty/radeon_base.c | 9 +++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index 36a9ac05a340..0e725a6eb40b 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -383,6 +383,7 @@ static const struct fb_fix_screeninfo aty128fb_fix = { .accel = FB_ACCEL_ATI_RAGE128, }; +static char *mode_option_buf; static char *mode_option = NULL; #ifdef CONFIG_PPC_PMAC @@ -1723,7 +1724,11 @@ static int aty128fb_setup(char *options) continue; } #endif /* CONFIG_PPC_PMAC */ - mode_option = this_opt; + { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -2518,6 +2523,7 @@ static int aty128fb_init(void) static void __exit aty128fb_exit(void) { pci_unregister_driver(&aty128fb_driver); + kfree(mode_option_buf); } module_init(aty128fb_init); diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c index b02e4e645035..d83b3dae795b 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c @@ -326,6 +326,7 @@ static int pll; static int mclk; static int xclk; static int comp_sync = -1; +static char *mode_buf; static char *mode; static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT); @@ -3896,8 +3897,11 @@ static int __init atyfb_setup(char *options) } } #endif - else - mode = this_opt; + else { + kfree(mode_buf); + mode_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode = mode_buf; + } } return 0; } @@ -3995,6 +3999,7 @@ static void __exit atyfb_exit(void) #ifdef CONFIG_PCI pci_unregister_driver(&atyfb_driver); #endif + kfree(mode_buf); } module_init(atyfb_init); diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 657064227de8..dc2657ae96f2 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -257,6 +257,7 @@ static reg_val common_regs[] = { * globals */ +static char *mode_option_buf; static char *mode_option; static char *monitor_layout; static bool noaccel = 0; @@ -2596,8 +2597,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -2624,6 +2628,7 @@ static int __init radeonfb_init (void) static void __exit radeonfb_exit (void) { pci_unregister_driver (&radeonfb_driver); + kfree(mode_option_buf); } module_init(radeonfb_init); From patchwork Thu Mar 9 16:00: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: 661272 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 C0DCCC7618B for ; Thu, 9 Mar 2023 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbjCIQDD (ORCPT ); Thu, 9 Mar 2023 11:03:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbjCIQCM (ORCPT ); Thu, 9 Mar 2023 11:02:12 -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 08299F7ED7; Thu, 9 Mar 2023 08:02:10 -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 73A842017D; Thu, 9 Mar 2023 16:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377729; 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=+FUi3cC4ZbNfnVzDlRVuUkJNsL1SkMquCeIFMmvAC8o=; b=IUPQEEYnXT7GyVhVVIVQfYM1bet8PDGuc1h2UDerjes0SxQAn2C/FlvGez6Ic/PqalEUDD 49x+fRHdnUJGSmwspY4kgfcCJcXJGr0qXuD+yvcfq5r4Co+jFz7McSNgO83mkT2+QqbQco clCYFpog5JZXedsiH8jEaZ+BSeBABa8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377729; 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=+FUi3cC4ZbNfnVzDlRVuUkJNsL1SkMquCeIFMmvAC8o=; b=04hFjl3HX3Hs4/ETS8p0/KG+5HcDpCm4C1v6z24G2Oa2NO/APnZuQK90gwFrwfZ40Y+tDF /0HyodwPVhZ2lgDg== 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 13C0C1391B; Thu, 9 Mar 2023 16:02:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MJniAwEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:09 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 012/101] fbdev/aty: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:32 +0100 Message-Id: <20230309160201.5163-13-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 12 ++++++++---- drivers/video/fbdev/aty/atyfb_base.c | 12 ++++++++---- drivers/video/fbdev/aty/radeon_base.c | 15 ++++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index 0e725a6eb40b..ee2be122de2d 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -48,6 +48,7 @@ #include +#include #include #include #include @@ -1674,14 +1675,14 @@ static int aty128fb_sync(struct fb_info *info) } #ifndef MODULE -static int aty128fb_setup(char *options) +static int aty128fb_setup(const char *options) { + struct option_iter iter; 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; @@ -1730,6 +1731,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 d83b3dae795b..f4b22d2f0d3d 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 @@ -3832,14 +3833,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) { + struct option_iter iter; 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)) { @@ -3903,6 +3904,9 @@ static int __init atyfb_setup(char *options) mode = mode_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 dc2657ae96f2..975323e82f52 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 @@ -2562,17 +2563,14 @@ static struct pci_driver radeonfb_driver = { }; #ifndef MODULE -static int __init radeonfb_setup (char *options) +static int __init radeonfb_setup (const char *options) { + struct option_iter iter; 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)) { @@ -2603,6 +2601,9 @@ static int __init radeonfb_setup (char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Thu Mar 9 16:00: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: 661271 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 25C79C76195 for ; Thu, 9 Mar 2023 16:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbjCIQDE (ORCPT ); Thu, 9 Mar 2023 11:03:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbjCIQCM (ORCPT ); Thu, 9 Mar 2023 11:02:12 -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 2E6DBF4B43; Thu, 9 Mar 2023 08:02:11 -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 D9A1522140; Thu, 9 Mar 2023 16:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377729; 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=BakC+qpuW38aK0OvnJ1f/WEGdxh5L35SOezAYZ73eHU=; b=XFi7a4C45OfxOHx5jgZ+i0LKNg8gAwwfcG3ShZqKuRXRvUkqWivkW2ccfIGNTCXLYSoE4j qNBQORlM3eqc2qAnUBVeuPmN1TspI/Kgo2IxshP2Nx3bHhJKiDOlw7/c2LJZWBB4tXC/xB Ent68vf/FIDuj+AYJPa+IIcpSxHB0bM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377729; 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=BakC+qpuW38aK0OvnJ1f/WEGdxh5L35SOezAYZ73eHU=; b=Ef6P6ITBLVfSGVJO3NvkatljcdmXt75pT+KY1K9qlZnnXcUypKQX1VufQCoBjDUfpvNt9r pQ9vkEojb+plrEAA== 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 7840613A73; Thu, 9 Mar 2023 16:02:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oNJwHAEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:09 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 013/101] fbdev/au1100fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:33 +0100 Message-Id: <20230309160201.5163-14-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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..0c063c8e6312 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; + 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 Thu Mar 9 16:00: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: 661270 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 7B366C7619A for ; Thu, 9 Mar 2023 16:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbjCIQDG (ORCPT ); Thu, 9 Mar 2023 11:03:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231499AbjCIQCM (ORCPT ); Thu, 9 Mar 2023 11:02:12 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AFDF4B7A; Thu, 9 Mar 2023 08:02:11 -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 5144920180; Thu, 9 Mar 2023 16:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377730; 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=Xqb9CgIoQGPm/XxyMitPmhdSDaGH79IsOOqR6TG8g1I=; b=CeFZiktdszGYTi/TFyAP/ldlwhwuYupWUIF8tFKc6aafQMfvB68x2fKK6RCTZ2dKq0yJFe PKiygqiGal7n0KWo4eMoRqzqq8uDvuKdTrrsqodbae/SHTXusnmBmasNUmYf5B9gRr/hCa +l7440uanYzdUVQVbOhZzu5inLDIDqo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377730; 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=Xqb9CgIoQGPm/XxyMitPmhdSDaGH79IsOOqR6TG8g1I=; b=2ZDnOM33w7luTv8IUcn8JfTZUfCM8NDRECPE/CedbN1GUmMeWxZ515kMbjBj1afytoFiPy SarN+ubFAu54ViDw== 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 DCA331391B; Thu, 9 Mar 2023 16:02:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aDToNAEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:09 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 014/101] fbdev/au1200fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:34 +0100 Message-Id: <20230309160201.5163-15-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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..43b6a9dfeec4 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; + 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 Thu Mar 9 16:00: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: 662256 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 42EFBC7618E for ; Thu, 9 Mar 2023 16:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231797AbjCIQDF (ORCPT ); Thu, 9 Mar 2023 11:03:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjCIQCM (ORCPT ); Thu, 9 Mar 2023 11:02:12 -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 1EC5CF7EC6; Thu, 9 Mar 2023 08:02:12 -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 B6D902017E; Thu, 9 Mar 2023 16:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377730; 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=dDLfWugx/oPOz6pILs/JXlPMBz5A3FDUfG3kXQPg+jE=; b=10+7N1KxIlvvKdllrJbUahxa/LQ75ZbLFlZVVLr7VD9pJtlR073sO6rv7I/YqFMa6lB4Ok bIAY8IaxEgsaExB8N45YhTJ4oZLhdYKhrO80gW9ugwYYCXgn3bXNcVeV8bFwCvmZRQqLMS WNWxVj7CVPsE3vjYH7XZ6eW5xex3mD4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377730; 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=dDLfWugx/oPOz6pILs/JXlPMBz5A3FDUfG3kXQPg+jE=; b=ffHZR+Za2tyTYGAnEwADCX6f12QPIzo3WuhS/V+mV+h1tYUfmHyGDHFJ7YVHeQxV8FWUIt gJ/d4jgTaNNdRMDg== 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 552E913A73; Thu, 9 Mar 2023 16:02:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SITtEwIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:10 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 015/101] fbdev/cirrusfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:35 +0100 Message-Id: <20230309160201.5163-16-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/cirrusfb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index ba45e2147c52..85b9442031b3 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -367,6 +367,7 @@ struct cirrusfb_info { }; static bool noaccel; +static char *mode_option_buf; static char *mode_option = "640x480@60"; /****************************************************************************/ @@ -2336,10 +2337,13 @@ 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 { + if (!strncmp(this_opt, "mode:", 5)) + this_opt += 5; + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -2387,6 +2391,7 @@ static void __exit cirrusfb_exit(void) #ifdef CONFIG_ZORRO zorro_unregister_driver(&cirrusfb_zorro_driver); #endif + kfree(mode_option_buf); } module_init(cirrusfb_init); From patchwork Thu Mar 9 16:00: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: 661269 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 2163BC742A7 for ; Thu, 9 Mar 2023 16:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231816AbjCIQDJ (ORCPT ); Thu, 9 Mar 2023 11:03:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbjCIQCP (ORCPT ); Thu, 9 Mar 2023 11:02:15 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78606F7EC9; Thu, 9 Mar 2023 08:02:12 -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 2D88920181; Thu, 9 Mar 2023 16:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377731; 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=SJYqvik/3Pi6dI1miyqZ08ohqvv4ZrpaT119P+hD1IU=; b=gZYHkAGGCBpzucB+9DfvAz7g3V1UNyAxmXrngjZEG0L4g1gfYV7XA3QOJH5mbsOnKadlra GJUqh69NK1elgbJH/i1IBM9KQ90ZG0lYk79d5Lp0bYcoUd++JSItVK/TukQSdzNtI6t3c3 ILe/E6xdn7X/FHegdfzPAc4Jy2dxrDU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377731; 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=SJYqvik/3Pi6dI1miyqZ08ohqvv4ZrpaT119P+hD1IU=; b=ZQ/k/eGGYhinigMgOYX4ZC7cDP3vEqf1mMU5WFIp+4HmVyn5ftu8J6Yw/+ordqALw4zoJa Jr1gXN4EPyi4MQBA== 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 BA9591391B; Thu, 9 Mar 2023 16:02:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UCGKLAIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:10 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 016/101] fbdev/cirrusfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:36 +0100 Message-Id: <20230309160201.5163-17-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index 85b9442031b3..a5e99a8feadd 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -35,6 +35,7 @@ */ #include +#include #include #include #include @@ -2324,17 +2325,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) { + struct option_iter iter; 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 { @@ -2345,6 +2343,9 @@ static int __init cirrusfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:00: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: 662254 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 60667C76196 for ; Thu, 9 Mar 2023 16:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbjCIQDJ (ORCPT ); Thu, 9 Mar 2023 11:03:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjCIQCS (ORCPT ); Thu, 9 Mar 2023 11:02:18 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0A0F7EE0; Thu, 9 Mar 2023 08:02:12 -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 8710522144; Thu, 9 Mar 2023 16:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377731; 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=j1bUaZro/GNGy+fk2Wz8LtwD3PwaoT3szr70HO9xRwywQmSvVc5n74ILV3zN+NPNlwkmfe niX/uSfACrRB2qjWrXSwhOh9PVFHWH1dwikt7bE4OJVnVIA5tGkgb0a2lZNDc0zOtqvI4i oIB6e6N/tEU1P6HHDnjfls8k6AW0qFQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377731; 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=O9zGDvNLBJIyGgz1z92xgWyFir304ZwIsysIm0XE7/mCdh754FeZI3iNEFYas34k3i/1km l9KMuOW3SqzIEJCw== 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 26E6A13A73; Thu, 9 Mar 2023 16:02:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qP+GCAMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:11 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 017/101] fbdev/controlfb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:00:37 +0100 Message-Id: <20230309160201.5163-18-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:00: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: 662253 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 06961C74A5B for ; Thu, 9 Mar 2023 16:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231824AbjCIQDR (ORCPT ); Thu, 9 Mar 2023 11:03:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbjCIQCS (ORCPT ); Thu, 9 Mar 2023 11:02:18 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BBD7F6C7A; Thu, 9 Mar 2023 08:02:13 -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 EC80A2214B; Thu, 9 Mar 2023 16:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377731; 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=yiri3tc/a1MXdsd+j79tZAwP26XU744YZButEfhgQbE=; b=070go3KipUxMIObSkyt1ar879i99/CaFVQa+B8/HlgVXaI5PIj5+RV5jgjrZfjZRDwt+Je ZOMRUVB0EvGdDZpRLn9DV0BNp4+e71kmvf7kV8QglGKDREyZ7UfD2dYh4jEuvUI1uI3syu 54KWh7ePUe630ooMf+Q2v4GlzhzNhn0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377731; 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=yiri3tc/a1MXdsd+j79tZAwP26XU744YZButEfhgQbE=; b=bmV9xsaxTmBlD4rVnIpNT+ss9CvC4ALPa0sCOYGgaIMlK7ZMQkkgWY/vrMx+aAFqnVNsxX hbjPh4XgwBi2uODw== 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 8CEA11391B; Thu, 9 Mar 2023 16:02:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iC2DIQMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:11 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 018/101] fbdev/controlfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:38 +0100 Message-Id: <20230309160201.5163-19-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c index 82eeb139c4eb..65e2f9949420 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) { + struct option_iter iter; 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 Thu Mar 9 16:00: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: 662252 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 C04D7C74A44 for ; Thu, 9 Mar 2023 16:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbjCIQDM (ORCPT ); Thu, 9 Mar 2023 11:03:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbjCIQCT (ORCPT ); Thu, 9 Mar 2023 11:02:19 -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 A51DEF7EE7; Thu, 9 Mar 2023 08:02:13 -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 5D44820182; Thu, 9 Mar 2023 16:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377732; 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=armA2RVjP0J+ugM2i/E2t8spkqjiPSbrGaAq9XUWPvU=; b=ryF/T115JDXa1uFGASX6UK1HG1fza/6drBaEOmioYeQn9KKVXgpgSpyGoYaSBhZhssTrOf qApRUfvU4k2yqTbanYsL1ubQB0oDFNXJ9xKE7XzsoJOG00V0mpKgdnTuBBNLqMiFkyRqPm BjubRDhc4vkZNe9Ywe3VlPdGe56eHJI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377732; 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=armA2RVjP0J+ugM2i/E2t8spkqjiPSbrGaAq9XUWPvU=; b=dC+nM6CuGsA4PcOJxaE5DvmTCXOaMIl3hitx8lFT7ahO/oCmUYIOAXnuQTAbNVo0ItX05y 0j3G/lB5NsWFD+CA== 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 F262E13A73; Thu, 9 Mar 2023 16:02:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CKAOOgMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:11 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 019/101] fbdev/cyber2000fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:39 +0100 Message-Id: <20230309160201.5163-20-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/cyber2000fb.c b/drivers/video/fbdev/cyber2000fb.c index 38c0a6866d76..f21d11a73455 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) { + struct option_iter iter; 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 Thu Mar 9 16:00: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: 661267 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 D785EC76195 for ; Thu, 9 Mar 2023 16:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231883AbjCIQDV (ORCPT ); Thu, 9 Mar 2023 11:03:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjCIQCT (ORCPT ); Thu, 9 Mar 2023 11:02:19 -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 225F0F7EDF; Thu, 9 Mar 2023 08:02:14 -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 C8DAA20183; Thu, 9 Mar 2023 16:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377732; 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=PVdpUcThieHjdBQBTJhLTZp8YL7s1ZuPBMFCE/O3DfA=; b=16Hw9Sfr6Z2pS0gL7MptHMWvTf11QUZOFD9jaXUqUcma/ijNYD6dWj95PKRUBgzn+4ROgT hv9vWl5weWTtTeR651/eU2I3Sh1mFmRJ9tBjByxuuJiPAliq0ThR5nlMC2LeKxSTFTtEeu z5iP0+h5DxNe+WXAyg3dQL1TgYHvL9g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377732; 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=PVdpUcThieHjdBQBTJhLTZp8YL7s1ZuPBMFCE/O3DfA=; b=nlEd+LNVfDtgynpThxA8Ms6+nW6bkD4nYQo3XkK+bvgmVFMlPUzEig0NE/Q7QYPW1HY8Jf 3tVPZCAUwX8XNxAw== 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 62EFF1391B; Thu, 9 Mar 2023 16:02:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aAomFwQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:12 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 020/101] fbdev/efifb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:40 +0100 Message-Id: <20230309160201.5163-21-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 42 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index a5779fb453a2..be77a76f7d1d 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) { + struct option_iter iter; 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; - } + 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 Thu Mar 9 16:00: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: 662250 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 9CDC9C61DA4 for ; Thu, 9 Mar 2023 16:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbjCIQDW (ORCPT ); Thu, 9 Mar 2023 11:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231572AbjCIQCT (ORCPT ); Thu, 9 Mar 2023 11:02:19 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7804DF7EE8; Thu, 9 Mar 2023 08:02:14 -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 3814E2214D; Thu, 9 Mar 2023 16:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377733; 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=Np3KLwLTug/nY/Fdd85EALZxqT4po64Lr1C8Ggq6sKU=; b=qvbadaxKvp1noT6DoGvm+AwRmeC6+21r6LfXUfUDvwRu0mb/OxVeBXKEHcGHW6A+uaJ2NC XN586IeAxIbL/ffgerbQqAb//Ho1djkmuB1acbrdxBkaHCS5tQf4pSp6jRYEK8Xb5vc0E/ 9G3CLxpHuKhTO+u6SrCLAL4eniXryLE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377733; 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=Np3KLwLTug/nY/Fdd85EALZxqT4po64Lr1C8Ggq6sKU=; b=pjO7IvuP4Vs4aCtukvv53fpiuI2YNdDpNI5GArfbsx4voonpeNabkDl9wD8yP7pW1as614 gC5DNeizEYxJZfAg== 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 CC5FA13A73; Thu, 9 Mar 2023 16:02:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YJv2MAQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:12 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 021/101] fbdev/fm2fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:41 +0100 Message-Id: <20230309160201.5163-22-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/fm2fb.c b/drivers/video/fbdev/fm2fb.c index 942e382cf1cf..a787884a6a7f 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) { + struct option_iter iter; 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 Thu Mar 9 16:00: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: 661264 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 74EC3C7618A for ; Thu, 9 Mar 2023 16:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231876AbjCIQDU (ORCPT ); Thu, 9 Mar 2023 11:03:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbjCIQCT (ORCPT ); Thu, 9 Mar 2023 11:02:19 -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 EAEAEF7ECA; Thu, 9 Mar 2023 08:02:14 -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 A35C620184; Thu, 9 Mar 2023 16:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377733; 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=EaSo/FjIqDYQ8wz/hJX7q8fOkI//7V7PpDYHGeI1dog=; b=Zl37TQUBIFv35lY19n3nS3tLa2FFsxJiXyKu0ntn9OitQvN9qV64et55L5ncF8OcVjf1WG +XhohQK5UXH052azkgnzyxd2nz1Qkd2OpTkdSpPgCbdwQm66W2+1CxhiLiFNZG+6j0kYbB FCaopvk9eAADime7c/aNy05Dz1WxNs8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377733; 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=EaSo/FjIqDYQ8wz/hJX7q8fOkI//7V7PpDYHGeI1dog=; b=5Z9bcjxfst7+0FQNfLF+GH7Fj0qv2kRw4n2NnnA6eoV1qR3tPb9t9COkW0Qxg//N/8Sp1y VxZyjZLTaEHrOGCw== 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 3D4AF1391B; Thu, 9 Mar 2023 16:02:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sJ7uDQUDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:13 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 022/101] fbdev/fsl-diu-fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:42 +0100 Message-Id: <20230309160201.5163-23-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert, Timur) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/fsl-diu-fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index e332017c6af6..033bbf0c40b7 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -307,6 +307,7 @@ static struct fb_videomode fsl_diu_mode_db[] = { }, }; +static char *fb_mode_buf; static char *fb_mode; static unsigned long default_bpp = 32; static enum fsl_diu_monitor_port monitor_port; @@ -1858,8 +1859,11 @@ 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 { + kfree(fb_mode_buf); + fb_mode_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + fb_mode = fb_mode_buf; + } } return 0; @@ -1978,6 +1982,7 @@ static void __exit fsl_diu_exit(void) #if defined(CONFIG_NOT_COHERENT_CACHE) vfree(coherence_data); #endif + kfree(fb_mode_buf); } module_init(fsl_diu_init); From patchwork Thu Mar 9 16:00: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: 662251 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 4CA71C7618B for ; Thu, 9 Mar 2023 16:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbjCIQDT (ORCPT ); Thu, 9 Mar 2023 11:03:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231583AbjCIQCT (ORCPT ); Thu, 9 Mar 2023 11:02:19 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58CFBF7EEB; Thu, 9 Mar 2023 08:02:15 -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 130A922146; Thu, 9 Mar 2023 16:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377734; 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=ThHqTav4uwh2rVs7lCpTQaurYmXorgnHNJfG5xnTYZU=; b=JI/MM8UOj3mttyyvNxQT55J/DxrPlDbv/0caRtrtlq8Jc0peUKF8xVYKT2FaC1z4WrWpnU vOiGRr6uyQzJmVzrMBXtTq1loGz9P5ib1QR66nxFPW5EPvfOU2RpqzEqvPKP+o0FTO+M5T nQM5DVwKaki7iMgitGDhenysoa2oZrw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377734; 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=ThHqTav4uwh2rVs7lCpTQaurYmXorgnHNJfG5xnTYZU=; b=v4AQH/idjIDBITGE+v54gw4Arl0gq7SNLszKCyHqthcol/GcusstzRAfHdaE7J9qA+5p1k XL5jStaexJg5AqDQ== 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 A799D13A73; Thu, 9 Mar 2023 16:02:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YAPyJwUDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:13 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 023/101] fbdev/fsl-diu-fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:43 +0100 Message-Id: <20230309160201.5163-24-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index 033bbf0c40b7..78996995568c 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 @@ -1843,17 +1844,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) { + struct option_iter iter; 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)) { @@ -1866,6 +1865,8 @@ static int __init fsl_diu_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:00: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: 661268 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 B5E33C7618E for ; Thu, 9 Mar 2023 16:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231745AbjCIQDT (ORCPT ); Thu, 9 Mar 2023 11:03:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231205AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -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 E629EF7EF5; Thu, 9 Mar 2023 08:02:15 -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 789972214C; Thu, 9 Mar 2023 16:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377734; 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=5JMjEoQogcrjmsqu51HKwpFrv2iLEJJ/Oo/4GHoGRws=; b=sNBIHSrLX9UvltrCxEcNhqallLDoo+9VXOnZec4nZMBSLwzlfl2c3nz7lONy+VXn9VMXMI U5e+3ktrbB6Qlbel+eXxH3jkO2I8TQXYdu6X0LIBqQAUtQDpKCW9vookqY/06OI9mC3aCl eS1ru2OwhdknbFgbq2x1o/haR1PVf1I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377734; 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=5JMjEoQogcrjmsqu51HKwpFrv2iLEJJ/Oo/4GHoGRws=; b=4P9Op4fI40mAiOVLUlkOpvDux7d9MlcMnN8FO/CPJMtW+wvKHIVh+dcEAPZ04A3kieV2XL vdrX+cBk3qouBODQ== 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 188A21391B; Thu, 9 Mar 2023 16:02:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cCEKBQYDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:14 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 024/101] fbdev/gbefb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:44 +0100 Message-Id: <20230309160201.5163-25-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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..6afccd4ef0a8 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); // ignore errors + } } 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 Thu Mar 9 16:00: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: 661266 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 37759C76186 for ; Thu, 9 Mar 2023 16:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231839AbjCIQDS (ORCPT ); Thu, 9 Mar 2023 11:03:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62BFDF7EF8; Thu, 9 Mar 2023 08:02:16 -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 DF52F20185; Thu, 9 Mar 2023 16:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377734; 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=TLAbF/IxrYzQxfqgNl+fEpo2kh27uLHCXxP09jiRWPw=; b=kj2x0IHOwQcNEXkOXVMEVAYq0EewgaGYxEERzn/eUbv3dzSYiIwsdTCp8d3VJPgZrl7NNB Qw/yTygda3ZtiOgJ+5cD/md3t5yrORSJ2RH03DZaphZ9rWEPO2Tyff73AvkubvHTUITkC1 TVfM6Kf1/lomVGt9sGU8Q/UCRmzXfUk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377734; 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=TLAbF/IxrYzQxfqgNl+fEpo2kh27uLHCXxP09jiRWPw=; b=e2yv93PwS/2CiePmwpZz9ZSeF+8FyK/MqZwOhx/1thcc4CLcKfEXMIIF7PZqCAAHSRtMqB H6wSXe69c+C35SBQ== 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 7E2CF1391B; Thu, 9 Mar 2023 16:02:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8GzaHQYDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:14 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 025/101] fbdev/gbefb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:45 +0100 Message-Id: <20230309160201.5163-26-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 6afccd4ef0a8..d20ef48263f3 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) { + struct option_iter iter; 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); // ignore errors } } + + option_iter_release(&iter); + return 0; } From patchwork Thu Mar 9 16:00: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: 661265 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 B5554C761AF for ; Thu, 9 Mar 2023 16:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbjCIQDX (ORCPT ); Thu, 9 Mar 2023 11:03:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -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 A89ABF63A3; Thu, 9 Mar 2023 08:02:16 -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 51F312214E; Thu, 9 Mar 2023 16:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377735; 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=beRjODUzm3MKJbdpk2tBhf5WWDQY92luTF+R5dqwPjA=; b=pUwW8HBJkF2ocJX9qli2ulpDhWr2ssZMvfQASEOr7bslcgCqmt5rDyF3SwAaxwQXObPchh VZHCfyivOK0DJPNrnkgiUuDJawuRJQurJ35rCJoCq3jVMvDTI7vFpFgdqmlM3qrhdbETtv 7tsuJiCJyOOcsegB/oLGrVZpGyEIB7g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377735; 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=beRjODUzm3MKJbdpk2tBhf5WWDQY92luTF+R5dqwPjA=; b=A2hAg8tHxO+4wrA5qr2HRyoVQc3FWQZz70HH0NzdlGLnr94vmvgD36NUurqW0Nxg/G6x6S BjZBRq81pUDC6zAQ== 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 E5A901391B; Thu, 9 Mar 2023 16:02:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qNQFNwYDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:14 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 026/101] fbdev/geode: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:46 +0100 Message-Id: <20230309160201.5163-27-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the drivers do not own the option string or its substrings and hence duplicate the option string for the video mode. Allocate the copy's memory with kstrdup() and free it in each module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/geode/gxfb_core.c | 6 +++++- drivers/video/fbdev/geode/lxfb_core.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c index 8e05e76de075..491de0ac5876 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -33,6 +33,7 @@ #include "gxfb.h" +static char *mode_option_buf; static char *mode_option; static int vram; static int vt_switch; @@ -500,7 +501,9 @@ static int __init gxfb_setup(char *options) if (!*opt) continue; - mode_option = opt; + kfree(mode_option_buf); + mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } return 0; @@ -528,6 +531,7 @@ static int __init gxfb_init(void) static void __exit gxfb_cleanup(void) { pci_unregister_driver(&gxfb_driver); + kfree(mode_option_buf); } module_init(gxfb_init); diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c index 8130e9eee2b4..6863ee858d8d 100644 --- a/drivers/video/fbdev/geode/lxfb_core.c +++ b/drivers/video/fbdev/geode/lxfb_core.c @@ -24,6 +24,7 @@ #include "lxfb.h" +static char *mode_option_buf; static char *mode_option; static int noclear, nopanel, nocrt; static int vram; @@ -635,8 +636,11 @@ static int __init lxfb_setup(char *options) nopanel = 1; else if (!strcmp(opt, "nocrt")) nocrt = 1; - else - mode_option = opt; + else { + kfree(mode_option_buf); + mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; @@ -663,6 +667,7 @@ static int __init lxfb_init(void) static void __exit lxfb_cleanup(void) { pci_unregister_driver(&lxfb_driver); + kfree(mode_option_buf); } module_init(lxfb_init); From patchwork Thu Mar 9 16:00: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: 662249 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 E0106C761A6 for ; Thu, 9 Mar 2023 16:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbjCIQDZ (ORCPT ); Thu, 9 Mar 2023 11:03:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18893F7EFC; Thu, 9 Mar 2023 08:02:17 -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 B7B0D2214F; Thu, 9 Mar 2023 16:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377735; 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=+LCPnE0PvSg4ksW4Mbo0BTVzmnwiVhW4dlBlf8qPj4I=; b=PqRrBXh01Cg3q8TTHIOI/uhfGA5xwgkQR0vRfXOCnUpdoMS6hfu04lU+LExJu06pbfdsTy YudHFIQEjsnmgVR2fSH1C+yP65HXPMmndxOYNtsXNs1jQtbjAx804V5aGF5uXTbZXEqe4r rq4pQthY6+rcQObIDye+/gPOJ6ZPAyc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377735; 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=+LCPnE0PvSg4ksW4Mbo0BTVzmnwiVhW4dlBlf8qPj4I=; b=c6PsjnI3bYIAosToN9XB+TlFNL/q0KEHpA2Rio+iVK9q7QwDZ2+u2l4sN91dqweSe0BQar G9cTAZuEUnp+6EDg== 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 55C4313A73; Thu, 9 Mar 2023 16:02:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +Nf9EwcDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:15 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 027/101] fbdev/geode: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:47 +0100 Message-Id: <20230309160201.5163-28-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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. v2: * add missing call to option_iter_release() Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/geode/gx1fb_core.c | 14 +++++++------- drivers/video/fbdev/geode/gxfb_core.c | 15 +++++++-------- drivers/video/fbdev/geode/lxfb_core.c | 14 +++++++------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/video/fbdev/geode/gx1fb_core.c b/drivers/video/fbdev/geode/gx1fb_core.c index 9c942001ac10..6f1e9aadc192 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) { + struct option_iter iter; 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 491de0ac5876..aede22566775 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 @@ -489,23 +490,21 @@ 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; 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)) { kfree(mode_option_buf); mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors 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 6863ee858d8d..855dc96b5669 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 @@ -619,17 +620,14 @@ static struct pci_driver lxfb_driver = { }; #ifndef MODULE -static int __init lxfb_setup(char *options) +static int __init lxfb_setup(const char *options) { + struct option_iter iter; 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")) @@ -643,6 +641,8 @@ static int __init lxfb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:00: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: 661262 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 36306C77B6C for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231429AbjCIQD3 (ORCPT ); Thu, 9 Mar 2023 11:03:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB759F7EFE; Thu, 9 Mar 2023 08:02:17 -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 2A09820186; Thu, 9 Mar 2023 16:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377736; 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=79twlirOUmPL24Yx299EScp7mDUr++Nf+Ag16S4Xxjs=; b=J8/6/7EEKDakmOzjuqFZ+wJphKc8bmbN8uy81393+ZynnFwzLZQD1dOhcO2PNr4o877mX1 Ia2b9IHWAPHVVmBtaNcZQFHNcEY2T3j13kyfRIrVYsD4ldyscl1OxHI8F6KJ+gdXWhghZP m9AIHZYMmWqx/hOTBqmxPRh+JA92IfA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377736; 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=79twlirOUmPL24Yx299EScp7mDUr++Nf+Ag16S4Xxjs=; b=ysXUn8HbMlNrgNIfgiTqsz4EOHt+nWtL9fHeP6kDN6Cff9+KI5dfv41EtZS0h0lwn/TTgq sbxm4h5lYYBZDXCA== 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 BBDC91391B; Thu, 9 Mar 2023 16:02:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EAnxLAcDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:15 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 028/101] fbdev/grvga: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:48 +0100 Message-Id: <20230309160201.5163-29-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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/grvga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/grvga.c b/drivers/video/fbdev/grvga.c index 24818b276241..28c2e0e0763a 100644 --- a/drivers/video/fbdev/grvga.c +++ b/drivers/video/fbdev/grvga.c @@ -370,7 +370,7 @@ static int grvga_probe(struct platform_device *dev) else if (!strncmp(this_opt, "size", 4)) grvga_mem_size = simple_strtoul(this_opt + 5, NULL, 0); else - mode_opt = this_opt; + mode_opt = devm_kstrdup(&dev->dev, opt, GFP_KERNEL); // ignore errors } par = info->par; From patchwork Thu Mar 9 16:00: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: 662248 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 0593FC77B60 for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbjCIQDc (ORCPT ); Thu, 9 Mar 2023 11:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -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 DEABCF8A48; Thu, 9 Mar 2023 08:02:17 -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 91F6020187; Thu, 9 Mar 2023 16:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377736; 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=+Fvb4dPXHzZD/13C8edGQz9gQl5cXDYn4iOfZr+To1w=; b=pm629shnQGKiBBzrb5+svkmSoJF+pNnls41PQ/vMQxKfkhV3DvoddGC87F2oTKavt6j+zN 8cuw0qj8h167xmuDD1saIJ4SB+ScJxIpnBuFm+DdsWeh/UgpJ6Dlv6fg8kVtxNG4iEFTFv bncU6vSQJft37xWHdbIUKU9ZZIiqmTA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377736; 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=+Fvb4dPXHzZD/13C8edGQz9gQl5cXDYn4iOfZr+To1w=; b=9LVYwwmbreLK0qJ6oYY8OIE07dDgcNSwoV8BwX3bZbTbHofzMoswL4EnI2dsAQwqNFx6lH vAYXKckuD1SFU8Ag== 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 2E8B013A73; Thu, 9 Mar 2023 16:02:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gL9qCggDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:16 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 029/101] fbdev/grvga: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:49 +0100 Message-Id: <20230309160201.5163-30-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 28c2e0e0763a..742331d0f08b 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; + 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; } @@ -373,6 +374,8 @@ static int grvga_probe(struct platform_device *dev) mode_opt = devm_kstrdup(&dev->dev, opt, GFP_KERNEL); // ignore errors } + option_iter_release(&iter); + par = info->par; info->fbops = &grvga_ops; info->fix = grvga_fix; From patchwork Thu Mar 9 16:00: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: 661263 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 562E1C77B6D for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbjCIQDd (ORCPT ); Thu, 9 Mar 2023 11:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E73F7ED7; Thu, 9 Mar 2023 08:02:18 -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 0690B22151; Thu, 9 Mar 2023 16:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377737; 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=mOJRS9DbzwjJAtDnq9gbzKlqhGtP/9e84GLDpJD2PAc=; b=dmbO1My0VEsrfehWJQphCmuDLEDRyugyo2oCtg6Om48efhz6TaciAkI2te+daozi6/4UYp ZqydCAlg2Xw2FPV+Mh+jldMrnbz2UouxENxa3ayhkFCdCNbQQEZRf2xJ9dhb8ABiKo8UCY aIRnsnaoVBxc8eKmKA2b1T7owKmKftc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377737; 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=mOJRS9DbzwjJAtDnq9gbzKlqhGtP/9e84GLDpJD2PAc=; b=v8Ul8UMoXoBnv7XJVeXlR9wlvfT/Lkfi/hSq34WjrzCIHulVpmtEHu3YOZljjamfIjzFhg 9EipOjM8Ib+//bDA== 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 973811391B; Thu, 9 Mar 2023 16:02:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WMTxIwgDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:16 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 030/101] fbdev/gxt4500: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:50 +0100 Message-Id: <20230309160201.5163-31-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/gxt4500.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/gxt4500.c b/drivers/video/fbdev/gxt4500.c index 5f42d3d9d6ce..65cb44c281c1 100644 --- a/drivers/video/fbdev/gxt4500.c +++ b/drivers/video/fbdev/gxt4500.c @@ -158,6 +158,7 @@ struct gxt4500_par { }; /* mode requested by user */ +static char *mode_option_buf; static char *mode_option; /* default mode: 1280x1024 @ 60 Hz, 8 bpp */ @@ -779,12 +780,21 @@ 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; + + if (options && *options) { + mode_option_buf = kstrdup(options, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } #endif return pci_register_driver(&gxt4500_driver); @@ -794,6 +804,7 @@ module_init(gxt4500_init); static void __exit gxt4500_exit(void) { pci_unregister_driver(&gxt4500_driver); + kfree(mode_option_buf); } module_exit(gxt4500_exit); From patchwork Thu Mar 9 16:00: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: 662246 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 B6F3DC77B70 for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231958AbjCIQDf (ORCPT ); Thu, 9 Mar 2023 11:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbjCIQCU (ORCPT ); Thu, 9 Mar 2023 11:02:20 -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 BBCD1F3670; Thu, 9 Mar 2023 08:02:18 -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 6ED1722152; Thu, 9 Mar 2023 16:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377737; 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=jBhUeHAiZtHj5w0OHCClBUsdhGNNr/Mpx36csnTC1VjalZbz/ujMyeQStVoWpcvitGc1p8 ywHU2HzIR2NcHa+P60b2S71DlryhFt0IrY0GderO0YUjbAICm9w593P5E6EVkzdZbWQjmf 4tNJ0CXzhbEQ5idJV7fZ1Dd0FltqjCo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377737; 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=5lKnZxp2h7vlv0rHhmQcFlwWIUCOfpYmAYE3sc99d60+piWXHA9tnj6cR2/qUVaj1MeK/G UTteoFXco8iT5BDA== 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 0C16213A73; Thu, 9 Mar 2023 16:02:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QBn1AQkDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:17 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 031/101] fbdev/hyperv_fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:51 +0100 Message-Id: <20230309160201.5163-32-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Reviewed-by: Michael Kelley --- 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 Thu Mar 9 16:00: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: 661260 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 3B81AC77B73 for ; Thu, 9 Mar 2023 16:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbjCIQDl (ORCPT ); Thu, 9 Mar 2023 11:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjCIQCV (ORCPT ); Thu, 9 Mar 2023 11:02:21 -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 31BBAF4B7A; Thu, 9 Mar 2023 08:02:19 -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 D0CB020179; Thu, 9 Mar 2023 16:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377737; 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=c/RxdU96+Et0kzCkk2iYUxqvPXUD67Kvpv1fXm/8kdc=; b=mfnholkjsMEQvpK82mVARspwIIfUUYeOFssQ09i02V6sLrf/qO41Jfj6e585c7gBPyoull dhQBuCYg7Hb2mbaazaJ8z0cuyXmEoIlVTRMNSgs27zJ72mDU7bdVMzxPEXgkI6jIPEhbhD squjRb32eWRLLEM1w29gCulbq+jbMsA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377737; 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=c/RxdU96+Et0kzCkk2iYUxqvPXUD67Kvpv1fXm/8kdc=; b=Puy71ZT0dgYe9nmL3wzhzAklO8doO12DACnGbhg9wZXEfQQpN4ejuRSV1kY5sakar8RV81 W5sYnqsQz0BSykBw== 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 72EE11391B; Thu, 9 Mar 2023 16:02:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IJgiGwkDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:17 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 032/101] fbdev/i740fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:52 +0100 Message-Id: <20230309160201.5163-33-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/i740fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index 3860b137b86a..61c022b8d5de 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -31,6 +31,7 @@ #include "i740_reg.h" +static char *mode_option_buf; static char *mode_option; static int mtrr = 1; @@ -1273,8 +1274,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; @@ -1302,6 +1306,7 @@ static int __init i740fb_init(void) static void __exit i740fb_exit(void) { pci_unregister_driver(&i740fb_driver); + kfree(mode_option_buf); } module_init(i740fb_init); From patchwork Thu Mar 9 16:00: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: 662247 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 6DD93C742A7 for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbjCIQDd (ORCPT ); Thu, 9 Mar 2023 11:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbjCIQCV (ORCPT ); Thu, 9 Mar 2023 11:02:21 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A89EDF7EC0; Thu, 9 Mar 2023 08:02:19 -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 3EB1920188; Thu, 9 Mar 2023 16:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377738; 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=3kZX8EmQe3IAEU0LH1oxMIvRcDm5wiAbtU7Jk+5Zv3U=; b=gti5ZhgRVsHxsNxkdlXALqaCbMRiaTHS0TRUzri2radJZ/SfVaDFK9XPwpb6WPPcKfE5EZ BvlFkTZR4WYS+PmVybjuBzDW42WBqTaac51zYkwJr11j/dCqGKwxecOw29eukQcpmif3Vq WqWbQKKszxYt7KRCLZC9BTEhr0wSlms= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377738; 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=3kZX8EmQe3IAEU0LH1oxMIvRcDm5wiAbtU7Jk+5Zv3U=; b=InBj3RHeVLA4P9g9rV4Lf4l+c5fbol1a3uFH8jZRP49oUktbeaTjpaK3cWysqd9Y7XAKll MptlT9eKu/3m6yCw== 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 D551B13A73; Thu, 9 Mar 2023 16:02:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OJkjMwkDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:17 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 033/101] fbdev/i740fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:53 +0100 Message-Id: <20230309160201.5163-34-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index 61c022b8d5de..6da2f3b7846d 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -1262,17 +1263,15 @@ static struct pci_driver i740fb_driver = { }; #ifndef MODULE -static int __init i740fb_setup(char *options) +static int __init i740fb_setup(const char *options) { + struct option_iter iter; 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 { kfree(mode_option_buf); @@ -1281,6 +1280,8 @@ static int __init i740fb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:00: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: 661261 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 224B8C77B71 for ; Thu, 9 Mar 2023 16:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231969AbjCIQDk (ORCPT ); Thu, 9 Mar 2023 11:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbjCIQCV (ORCPT ); Thu, 9 Mar 2023 11:02:21 -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 E61E7F7EC5; Thu, 9 Mar 2023 08:02:19 -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 9F04B22153; Thu, 9 Mar 2023 16:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377738; 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=nwl3kz4xEfi+kFr4X5T9B5f4fwGq1KRCd8RDOfDQzo0=; b=gOeZatVxgGe+cpIIeFougES1zofL+NlEHV/eOudyX3AW6ZYPG8X334bEP/YXuHXsqb6LAX 84ExTInSVUfqUbBpwCTAOAELJAgmwBzE/+RU/Xf4XZG82gNj5MsGLvcXsBXxaSLP1dklFU BUZzpsH8kYRJKTson7H+Z0BzMYF9ZBE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377738; 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=nwl3kz4xEfi+kFr4X5T9B5f4fwGq1KRCd8RDOfDQzo0=; b=T9b4Udg7bSqvRnNiAbt/Q1dQX9lDrOCkFSkTATVk9OJnn9HjeajpneLD/8CgcDJ2w6nZ/Z lJMIzTMBeewWAABA== 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 434ED1391B; Thu, 9 Mar 2023 16:02:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kPWIDwoDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:18 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 034/101] fbdev/i810: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:54 +0100 Message-Id: <20230309160201.5163-35-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/i810/i810_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/i810/i810_main.c b/drivers/video/fbdev/i810/i810_main.c index 85abb65f07d7..3b2648a2de29 100644 --- a/drivers/video/fbdev/i810/i810_main.c +++ b/drivers/video/fbdev/i810/i810_main.c @@ -134,6 +134,7 @@ static struct pci_driver i810fb_driver = { .resume = i810fb_resume, }; +static char *mode_option_buf; static char *mode_option = NULL; static int vram = 4; static int bpp = 8; @@ -2002,8 +2003,11 @@ static int i810fb_setup(char *options) dcolor = true; else if (!strncmp(this_opt, "ddc3", 4)) ddc3 = true; - else - mode_option = this_opt; + else { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -2224,6 +2228,7 @@ MODULE_LICENSE("GPL"); static void __exit i810fb_exit(void) { pci_unregister_driver(&i810fb_driver); + kfree(mode_option_buf); } module_exit(i810fb_exit); From patchwork Thu Mar 9 16:00: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: 662244 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 E436CC77B72 for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbjCIQDi (ORCPT ); Thu, 9 Mar 2023 11:03:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbjCIQCV (ORCPT ); Thu, 9 Mar 2023 11:02:21 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5535DF7EC6; Thu, 9 Mar 2023 08:02:20 -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 0BF2820178; Thu, 9 Mar 2023 16:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377739; 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=5/1yjZdCEsHswl6kWyLnnij2E1O9wtb/V5OB2pojQL4=; b=X/pcj17sHz1d67F+ltpqRe9XbF/MOV+VikOqacWgq7S/uIsyrDSMgC5pSdenr1E32vQPU9 TiuyHK9MJnyZsuf80hLyb2o51qN2Y9mG4/Jxb5DsGCWNG5U5+4/VuG5rkSYqkOldjlh6c4 pHZD+V7VQeIOlKQpGw2GOB7jLmeBfvg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377739; 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=5/1yjZdCEsHswl6kWyLnnij2E1O9wtb/V5OB2pojQL4=; b=KRRPqvM9ciI6IaH9/wmLdsbsmrBPUIoG3R5Z7hxF71yTTrJwx0W174eDvVKjVsMlL41H9W NMlDg6cRC1cqHPAg== 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 A48701391B; Thu, 9 Mar 2023 16:02:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UEARJwoDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:18 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 035/101] fbdev/i810: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:55 +0100 Message-Id: <20230309160201.5163-36-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 3b2648a2de29..952d1a69dfb9 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 @@ -1959,14 +1960,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; + 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)) @@ -2009,6 +2011,9 @@ static int i810fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:00: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: 661259 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 CAE05C77B6F for ; Thu, 9 Mar 2023 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231364AbjCIQDg (ORCPT ); Thu, 9 Mar 2023 11:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbjCIQCV (ORCPT ); Thu, 9 Mar 2023 11:02:21 -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 BA8B8F4002; Thu, 9 Mar 2023 08:02:20 -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 6E17722154; Thu, 9 Mar 2023 16:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377739; 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=AL2Wq5/miOGD6TwZBTlJlNXJ3vVAo4s/zJwjQWmdvKM=; b=On41eD//q+Cf4q8tc82zPn6aQu87CEx5+0wW6oNOs4HOjNtYjvy116UWmzG6xJiYg3YKQ/ SCLSG7Qv8AyjVwZZM5YHLQx5s7KvJ+4DhHUxe0RIxDmZwYoomR3z714q/dcDIZoF5IN10R /6fSPNoI0zVUtxZSJZw0QdN7c6TQ9Kw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377739; 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=AL2Wq5/miOGD6TwZBTlJlNXJ3vVAo4s/zJwjQWmdvKM=; b=usZ/URghjqA2NS/XJEW99fqSmd7LRgtp/k2eMSWn60TBvu/R3JRY6dhcw0jan9lmhTizwO l/DJ6ZOoDT2xryDg== 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 1160113A73; Thu, 9 Mar 2023 16:02:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MHZWAwsDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:19 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 036/101] fbdev/imsttfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:56 +0100 Message-Id: <20230309160201.5163-37-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index bea45647184e..1e2b45faa26b 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) { + struct option_iter iter; 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 Thu Mar 9 16:00: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: 662245 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 58596C77B74 for ; Thu, 9 Mar 2023 16:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231982AbjCIQDm (ORCPT ); Thu, 9 Mar 2023 11:03:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbjCIQCW (ORCPT ); Thu, 9 Mar 2023 11:02:22 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA9CF6C7A; Thu, 9 Mar 2023 08:02:21 -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 D30E422145; Thu, 9 Mar 2023 16:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377739; 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=TSIv++fYLAZmyWwx814uxi5mIIjCM/vEYMYPw331r64=; b=MmLKPkY1yv1R9ubNRxdVcxU5Z69SKIvXV0NQZSNRQqAstGoY6/oDxM0GIqwDDjc7BxI6ir AEOOJcHXlnT1NEFEsJmWsFsX7nmmKZbCqWwUW0CrOw7ZjT/15R652gWnofCiGVYGc+6zX5 4zaYLbj5G8+s1rx/8TMvo3t6WUnBqK4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377739; 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=TSIv++fYLAZmyWwx814uxi5mIIjCM/vEYMYPw331r64=; b=ebrXzHEfrnbTluV/lK74Ja0CsRQJZhCCwrtNtuQS8EMGjLOcEwBBX4Ye0CAUXKS9hTTwSJ o4sktccX0nM33nDA== 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 721351391B; Thu, 9 Mar 2023 16:02:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wHvWGgsDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:19 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 037/101] fbdev/intelfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:57 +0100 Message-Id: <20230309160201.5163-38-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/intelfb/intelfbdrv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 0a9e5067b201..8368c3601cdb 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -238,6 +238,7 @@ static bool probeonly = 0; static bool idonly = 0; static int bailearly = 0; static int voffset = 48; +static char *mode_buf; static char *mode = NULL; module_param(accel, bool, S_IRUGO); @@ -365,8 +366,11 @@ 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 { + kfree(mode_buf); + mode_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode = mode_buf; + } } return 0; @@ -405,6 +409,7 @@ static void __exit intelfb_exit(void) { DBG_MSG("intelfb_exit\n"); pci_unregister_driver(&intelfb_driver); + kfree(mode_buf); } module_init(intelfb_init); From patchwork Thu Mar 9 16:00: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: 661257 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 945FDC74A4B for ; Thu, 9 Mar 2023 16:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231350AbjCIQDq (ORCPT ); Thu, 9 Mar 2023 11:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231638AbjCIQCW (ORCPT ); Thu, 9 Mar 2023 11:02:22 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC09DF7EC9; Thu, 9 Mar 2023 08:02:21 -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 41F5722156; Thu, 9 Mar 2023 16:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377740; 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=UUhTX6veO6KsY0Dpn+In+/O3oAyGJ8vyl1FETD8qkzA=; b=idWhZvv1OFds5xjRkPCJSk7FUrp/5Q+5yONgyOkRk74bgyQR6l2Hu1Ldh9Czwafi2kvpb6 JDE3IVHFJZrlPfSrHcLWwMYl8CDKEspqus0mb+eN629cWYmF0Zk+nIGUN/tliQTK7hS+di ivOD/T7z7BxIyuDXhRtIuPEYTj0nTmg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377740; 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=UUhTX6veO6KsY0Dpn+In+/O3oAyGJ8vyl1FETD8qkzA=; b=VW4393UvuEQyXD1vy0JgI3/62OjzOgpoo3xaehvYjXVrFZMzeUR8iwtJTX7uevpydCf5bf +ZIXjKbN08MUscCA== 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 D7A931391B; Thu, 9 Mar 2023 16:02:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qITRMwsDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:19 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 038/101] fbdev/intelfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:00:58 +0100 Message-Id: <20230309160201.5163-39-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 8368c3601cdb..43d677897392 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -108,6 +108,7 @@ */ #include +#include #include #include #include @@ -324,8 +325,9 @@ 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) { + struct option_iter iter; char *this_opt; DBG_MSG("intelfb_setup\n"); @@ -349,9 +351,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)) @@ -373,6 +375,8 @@ static int __init intelfb_setup(char *options) } } + option_iter_release(&iter); + return 0; } From patchwork Thu Mar 9 16:00: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: 662243 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 79437C74A44 for ; Thu, 9 Mar 2023 16:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231993AbjCIQDo (ORCPT ); Thu, 9 Mar 2023 11:03:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbjCIQCX (ORCPT ); Thu, 9 Mar 2023 11:02:23 -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 F1F49F7ECC; Thu, 9 Mar 2023 08:02:21 -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 A14712017B; Thu, 9 Mar 2023 16:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377740; 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=MrW7pYFX5R5J7fTSEP6NHJNhtqFQ7aaj+PBS3SvPTGg=; b=KMyi1ArSofl/bsuzaDcxSPA6St3dbkNeQtu4GG/uXz+mB3OSzgwPJRG/SVapYXPcoZudSI F7o/npDk+E29i4ursyWn9ajqDmAW8KzUMZ5sl21zEJ+MJfjD2rNMX/sDmkl4m8npxWvwT+ 86BW9xhw7Q2fbROUtPyJ1oSOxlM9pec= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377740; 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=MrW7pYFX5R5J7fTSEP6NHJNhtqFQ7aaj+PBS3SvPTGg=; b=lf0QPjtylGKlpjax3PSZ8yyUW9A+oDhATNg9XPu1acJ5HWImpCm+MTnRl0ICzIJB+Uv0s8 PgCWdEKJOhB0P4CA== 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 4509513A73; Thu, 9 Mar 2023 16:02:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iCHxDwwDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:20 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 039/101] fbdev/imxfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:59 +0100 Message-Id: <20230309160201.5163-40-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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/imxfb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index 51fde1b2a793..aad7d447385c 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -843,7 +843,7 @@ static struct lcd_ops imxfb_lcd_ops = { .set_power = imxfb_lcd_set_power, }; -static int imxfb_setup(void) +static int imxfb_setup(struct platform_device *pdev) { char *opt, *options = NULL; @@ -856,8 +856,8 @@ static int imxfb_setup(void) while ((opt = strsep(&options, ",")) != NULL) { if (!*opt) continue; - else - fb_mode = opt; + + fb_mode = devm_kstrdup(&pdev->dev, opt, GFP_KERNEL); // ignore errors } return 0; @@ -877,7 +877,7 @@ static int imxfb_probe(struct platform_device *pdev) dev_info(&pdev->dev, "i.MX Framebuffer driver\n"); - ret = imxfb_setup(); + ret = imxfb_setup(pdev); if (ret < 0) return ret; From patchwork Thu Mar 9 16:01: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: 662239 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 AB20FC76188 for ; Thu, 9 Mar 2023 16:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbjCIQDx (ORCPT ); Thu, 9 Mar 2023 11:03:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbjCIQCX (ORCPT ); Thu, 9 Mar 2023 11:02:23 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD83F4B43; Thu, 9 Mar 2023 08:02:22 -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 0E85422144; Thu, 9 Mar 2023 16:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377741; 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=c7fzbHMZo/4t6EopunsYCvjOPtf7sTkieu2cfrSqxh4=; b=AcjpdxWm5zvGSYbFoeuEUnP4boRb5za5KSjPBQem5PqUCIGbTC1YQyR0bzLfnSXfEcfp9S vWozmmoOveM6DUzJIicy12AOaBWeCqhkuylaJ1kIHgqynt7NsGG5AeIERZ5raI1UEhL72P wPGK+lXTR1+AXZKJkrDaAmewHFLLSfQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377741; 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=c7fzbHMZo/4t6EopunsYCvjOPtf7sTkieu2cfrSqxh4=; b=zXFSwT+RVObgE93n73DBA0+4VkgBUJV055XbmNaTwRb7OgJFPKZRLUApY764qMPHJl8HXL cL0gZLXVd47G5BAQ== 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 A79A01391B; Thu, 9 Mar 2023 16:02:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AJoaKAwDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:20 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 040/101] fbdev/imxfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:00 +0100 Message-Id: <20230309160201.5163-41-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 aad7d447385c..d4e347aca0b0 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,21 @@ static struct lcd_ops imxfb_lcd_ops = { static int imxfb_setup(struct platform_device *pdev) { - char *opt, *options = NULL; + char *options = NULL; + struct option_iter iter; + char *opt; if (fb_get_options("imxfb", &options)) return -ENODEV; - if (!options || !*options) - return 0; - - while ((opt = strsep(&options, ",")) != NULL) { - if (!*opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, &opt)) { fb_mode = devm_kstrdup(&pdev->dev, opt, GFP_KERNEL); // ignore errors } + option_iter_release(&iter); + return 0; } From patchwork Thu Mar 9 16:01: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: 661258 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 F31CCC74A5B for ; Thu, 9 Mar 2023 16:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231548AbjCIQDs (ORCPT ); Thu, 9 Mar 2023 11:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbjCIQCX (ORCPT ); Thu, 9 Mar 2023 11:02:23 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C90D2F786F; Thu, 9 Mar 2023 08:02:22 -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 6E20322155; Thu, 9 Mar 2023 16:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377741; 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=i5PgfaO6hx580hMewU4zouv2NIVdCtMZiQTH6Xeh3Y0=; b=OxplyLZ8PZLhwMHdW9CSfy3+3/6UPfg4V0ga+qxHNiA+/tEAib/yIpRxC9NncZ3bI9EHok 3KkgvPls3saHo/wvZrG1YKCkendDAjEIlUBmN9gdGVqjsb5vAyxBtN/LpOwja2NkboYzbh 7na0S+K24HgdL1DpMBNn8MhFdGrMxJc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377741; 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=i5PgfaO6hx580hMewU4zouv2NIVdCtMZiQTH6Xeh3Y0=; b=4s08p0a2T6+MyG/KDAuw9YiK+s+lyGGLLBa9SNu/Ciee0vTt9foheCqlwknCIBVOBnvYem 1V1zhtFa9nZfoFAg== 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 1262D13A73; Thu, 9 Mar 2023 16:02:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qIInAw0DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:21 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 041/101] fbdev/kyrofb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:01 +0100 Message-Id: <20230309160201.5163-42-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/kyro/fbdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index 0596573ef140..97f4d8995e36 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -79,6 +79,7 @@ typedef struct { /* global graphics card info structure (one per card) */ static device_info_t deviceInfo; +static char *mode_option_buf; static char *mode_option = NULL; static int nopan = 0; static int nowrap = 1; @@ -579,7 +580,9 @@ static int __init kyrofb_setup(char *options) } else if (strcmp(this_opt, "nomtrr") == 0) { nomtrr = 1; } else { - mode_option = this_opt; + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } } @@ -805,6 +808,7 @@ static int __init kyrofb_init(void) static void __exit kyrofb_exit(void) { pci_unregister_driver(&kyrofb_pci_driver); + kfree(mode_option_buf); } module_init(kyrofb_init); From patchwork Thu Mar 9 16:01: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: 662240 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 80254C7618B for ; Thu, 9 Mar 2023 16:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbjCIQDv (ORCPT ); Thu, 9 Mar 2023 11:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231653AbjCIQCY (ORCPT ); Thu, 9 Mar 2023 11:02:24 -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 412E4F63A3; Thu, 9 Mar 2023 08:02:23 -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 D28C622148; Thu, 9 Mar 2023 16:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377741; 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=f7/w5Q61x+4mYCVkBoPT/boR5xsta3AhSkrJ0HBOQOk=; b=ZYzcqN+DteNaiTPy/Sd2Ez4lpvoB7nNdQHMa+VGZ2FIVbrvaAjz+8bK0VBpxp1Fc4AoEfh 8r5Lv13OagNfktx+oqDsn1M/KGGADarW8SQ6X5FKxsyx4Uf1pxhQTZoSeUCVe6e8KFNvpt oIhaTNuz18xbohURjmj9/rFkLgv7XFM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377741; 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=f7/w5Q61x+4mYCVkBoPT/boR5xsta3AhSkrJ0HBOQOk=; b=p8/kuaWc4uPtZEFrF6v3k+t808YmOdHgDk0LOkZOfMkdh/dSY3Q9KtWH+/MPYQBA4LPR9b yFN9UU+P+NF6KNDA== 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 71CED1391B; Thu, 9 Mar 2023 16:02:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YPDaGg0DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:21 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 042/101] fbdev/kyrofb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:02 +0100 Message-Id: <20230309160201.5163-43-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index 97f4d8995e36..ccfec4e55ecf 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -563,16 +564,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) { + struct option_iter iter; 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) { @@ -586,6 +585,8 @@ static int __init kyrofb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:01: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: 662242 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 66317C7618A for ; Thu, 9 Mar 2023 16:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231707AbjCIQDt (ORCPT ); Thu, 9 Mar 2023 11:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbjCIQCY (ORCPT ); Thu, 9 Mar 2023 11:02:24 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3AC1F7EDF; Thu, 9 Mar 2023 08:02:23 -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 3EDDB2214D; Thu, 9 Mar 2023 16:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377742; 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=1GOpxKfrjjGckfdWBckK8lTMMWjUiFaD2WxMxiMLn7VPCW+agT5PZwDUfFtXgQUXgYP8qR 39pNiP/D9YTBFcwtQsh/i8ws+abIYU5huxxDLLtqovGZFa5bhLdVgKks57abtUZdbPsC8u oeRrrPseEbzJaCXGsr7VBwTtSMxWmXc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377742; 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=9xjIyggr5kkLYDs+dyPnBfcVfnq0cuhQlKupTXSl2bzzfa99inGZUg3TUx4BhAPXNIVmzz LOlvRmwdNDI6/mAw== 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 D704713A73; Thu, 9 Mar 2023 16:02:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SFucMw0DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:21 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 043/101] fbdev/macfb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:01:03 +0100 Message-Id: <20230309160201.5163-44-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 662233 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 D17A0C64EC4 for ; Thu, 9 Mar 2023 16:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbjCIQEH (ORCPT ); Thu, 9 Mar 2023 11:04:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbjCIQC0 (ORCPT ); Thu, 9 Mar 2023 11:02:26 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34844F7ED7; Thu, 9 Mar 2023 08:02:24 -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 9829222157; Thu, 9 Mar 2023 16:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377742; 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=CsLXoWVq0oVkycpG6cywKJmSZDW0W9mttSoEkq92BAA=; b=VqJgOkH85wpepK8t/nG/myX7s+/stYVpojzuzc5YsN7/c9HgpiuimUpvtwIT3AQAlPPzZ7 nuRStiAxj+utM8o4scM/oviLSkAtx388ZVR8Afhfye44Va1CDjEgmM7rfQ/tYqMTfyASkw wMmop9TyGQPU+5i6VN8U4m61I0PRGqM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377742; 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=CsLXoWVq0oVkycpG6cywKJmSZDW0W9mttSoEkq92BAA=; b=a1ZNaaHEc5m7bOfGZxxqdIVgcWq6fcePeDHAj20hxoGD/xUVmPHGR1CnHGuDIaHlmw0GuN ldwEx6ZXTyIBMfDQ== 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 431511391B; Thu, 9 Mar 2023 16:02:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CAFvDw4DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:22 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 044/101] fbdev/macfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:04 +0100 Message-Id: <20230309160201.5163-45-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/macfb.c b/drivers/video/fbdev/macfb.c index 44ff860a3f37..c7e17a14daf1 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) { + struct option_iter iter; 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 Thu Mar 9 16:01: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: 662241 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 E23C0C61DA4 for ; Thu, 9 Mar 2023 16:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbjCIQDr (ORCPT ); Thu, 9 Mar 2023 11:03:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231659AbjCIQCZ (ORCPT ); Thu, 9 Mar 2023 11:02:25 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41AA3F7EE2; Thu, 9 Mar 2023 08:02:24 -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 F3CC920189; Thu, 9 Mar 2023 16:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377743; 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=L8sTlmFAIEYjGf/xMWjBdmdvaz1qIS9TL0x1Z8/8ESg=; b=Jx/cdr4saXpUkoi5xNEm0dH6/pc+Nm9w1N47Q9Y3wj24Jvq3WZreC8KxOjqGHI5eFbAdj8 4Wa0rwhaMD5EK2UBDyUdldSUPkMMqs0rjJPd0LLIjS3VrMtXKeaTeejRZly8Ky7/biDATh KWLiIirbeCcla0AwDz5x7Xknw1Mqi2I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377743; 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=L8sTlmFAIEYjGf/xMWjBdmdvaz1qIS9TL0x1Z8/8ESg=; b=E1tv0ydMgl1akO+Ymzgw1Y15ff7EzGNdKqau/hDrgJ6hrLZi/oqdhH/safjC1XW0/PdrPC cjAGhE2wOkqzL1Dw== 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 9BDD013A73; Thu, 9 Mar 2023 16:02:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AF42JQ4DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:22 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 045/101] fbdev/matroxfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:05 +0100 Message-Id: <20230309160201.5163-46-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c index a043a737ea9f..4c2086136e9b 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) { +static int __init matroxfb_setup(const char *options) +{ + struct option_iter iter; char *this_opt; - DBG(__func__) - - 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)) { 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 Thu Mar 9 16:01: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: 661254 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 E09E3C6FD19 for ; Thu, 9 Mar 2023 16:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231995AbjCIQDz (ORCPT ); Thu, 9 Mar 2023 11:03:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231660AbjCIQCZ (ORCPT ); Thu, 9 Mar 2023 11:02:25 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB5B2F7EE7; Thu, 9 Mar 2023 08:02:24 -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 5754A22158; Thu, 9 Mar 2023 16:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377743; 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=ai+UeCW+AhsoKfqWG5QFx6U/VSD9FuiIhsYKiqWB00A=; b=nxteKXOcJTnmZ+AfjBKZCbhwRbte4JILVsUC4GnBe5KlaPlLHXmTuGtVu+ViN+ECW+44P/ Ly+dus4n/DRJHs2ySjeVVOF6Tzz5e/rNNJvysuW1h7tYti59rXT29y7lqTHHM/3enOOUIW a7CI5LbqIYbCVSYm1UGD3ocJMpq/un8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377743; 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=ai+UeCW+AhsoKfqWG5QFx6U/VSD9FuiIhsYKiqWB00A=; b=qCR2hPQslBhn94hWgs9F4HlXq7ylQCuN35HGlZHqBA5tV8/mpI6q/xgjZg6Utr/YKiGfc/ /zofyFiq7pUsA0Dw== 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 03F3C1391B; Thu, 9 Mar 2023 16:02:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CKobAA8DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:23 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 046/101] fbdev/mx3fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:06 +0100 Message-Id: <20230309160201.5163-47-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/mx3fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c index 76771e126d0a..e33ad125318f 100644 --- a/drivers/video/fbdev/mx3fb.c +++ b/drivers/video/fbdev/mx3fb.c @@ -332,6 +332,7 @@ static void mx3fb_exit_backlight(struct mx3fb_data *fbd) static void mx3fb_dma_done(void *); /* Used fb-mode and bpp. Can be set on kernel command line, therefore file-static. */ +static const char *fb_mode_buf; static const char *fb_mode; static unsigned long default_bpp = 16; @@ -1666,8 +1667,11 @@ 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 { + kfree(fb_mode_buf); + fb_mode_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + fb_mode = fb_mode_buf; + } } #endif @@ -1688,6 +1692,7 @@ static int __init mx3fb_init(void) static void __exit mx3fb_exit(void) { platform_driver_unregister(&mx3fb_driver); + kfree(fb_mode_buf); } module_init(mx3fb_init); From patchwork Thu Mar 9 16:01: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: 661256 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 93BA1C7618D for ; Thu, 9 Mar 2023 16:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231835AbjCIQDy (ORCPT ); Thu, 9 Mar 2023 11:03:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbjCIQC0 (ORCPT ); Thu, 9 Mar 2023 11:02:26 -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 576F4F7EEF; Thu, 9 Mar 2023 08:02:25 -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 B475222159; Thu, 9 Mar 2023 16:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377743; 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=A4w8kD6lS+dFzIR63p5dUUwf4D44kkwhnZ/hkW7PWvQ=; b=iDXxHErhFvLptDDcHlghTmcBvSp1EOtHjXWV9z7c4sMdO0MmTcmFUZba4t8Tgko6jidwvf 7izSf1/V7pekx7B33M3cKNXsdppS5eHTOtSB4LGfgDAlC9AX6713Pv7Ulilr/lwLYry5Cq tppXhFt4Jdw44vRZnVJ2W2Nn0TvWcoc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377743; 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=A4w8kD6lS+dFzIR63p5dUUwf4D44kkwhnZ/hkW7PWvQ=; b=x0I9OXLcL+NnyqJYs6yQHXgnjh0C8YZXabB8ASmWG/y2Fyeu7R+tvqHtbYVpxQWyZaBOwF Zx/7CPvfEv66pBBA== 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 5C3BA13A73; Thu, 9 Mar 2023 16:02:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GB6gFQ8DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:23 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 047/101] fbdev/mx3fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:07 +0100 Message-Id: <20230309160201.5163-48-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 e33ad125318f..ca58afe366b4 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 @@ -1654,17 +1655,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; + 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 { @@ -1673,6 +1673,8 @@ static int __init mx3fb_setup(void) fb_mode = fb_mode_buf; } } + + option_iter_release(&iter); #endif return 0; From patchwork Thu Mar 9 16:01: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: 662236 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 E4534C77B6C for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232016AbjCIQEE (ORCPT ); Thu, 9 Mar 2023 11:04:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbjCIQC1 (ORCPT ); Thu, 9 Mar 2023 11:02:27 -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 F0533F7EF5; Thu, 9 Mar 2023 08:02:25 -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 25DDE2214C; Thu, 9 Mar 2023 16:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377744; 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=oiht1Q677qYpu9/3uJW+gjpB4dNDmWpMrYhgfn9g2bY=; b=DxMk3p9pHKgXUCXSS9Kql+DZLobewJ5VeFW2S3TV7oTkGJbY95wtdOCPVMj7KBU8TDSSn0 jj913Ar5Psna5Ck6IhBstQTcKktCdX0kTxmq6ssOSjp0sE+kln31aSLeafAQHhlJy7IASM oOqfk0BYxACG9UVMKmcJElhzndt2XEM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377744; 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=oiht1Q677qYpu9/3uJW+gjpB4dNDmWpMrYhgfn9g2bY=; b=4BMvzee+Y7GQI119psWkGbS3oWLO9HQ6S8ktySDte0nmC3x32D4oZtQHAaJB00NzzF6pDi EZG1tCBuTByvxaCg== 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 B82951391B; Thu, 9 Mar 2023 16:02:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uJIaLA8DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:23 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 048/101] fbdev/neofb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:08 +0100 Message-Id: <20230309160201.5163-49-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/neofb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 39d8cdef5c97..98edb6822832 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -83,6 +83,7 @@ static bool external; static bool libretto; static bool nostretch; static bool nopciburst; +static char *mode_option_buf; static char *mode_option = NULL; #ifdef MODULE @@ -2198,8 +2199,11 @@ static int __init neofb_setup(char *options) nopciburst = 1; else if (!strncmp(this_opt, "libretto", 8)) libretto = 1; - else - mode_option = this_opt; + else { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -2228,6 +2232,7 @@ module_init(neofb_init); static void __exit neofb_exit(void) { pci_unregister_driver(&neofb_driver); + kfree(mode_option_buf); } module_exit(neofb_exit); From patchwork Thu Mar 9 16:01: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: 662235 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 CAC04C77B62 for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbjCIQEC (ORCPT ); Thu, 9 Mar 2023 11:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbjCIQC0 (ORCPT ); Thu, 9 Mar 2023 11:02:26 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04A1F7EF4; Thu, 9 Mar 2023 08:02:25 -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 8B8212018B; Thu, 9 Mar 2023 16:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377744; 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=cQ2DtNxZR8mSDNCzRs15eZzz4O2bOn4Fr0rdTgKspbY=; b=MDEOKQAFmFxywtO/cuCUTf6WSof184UY1L/JcPHoY6AnQHaz4P04j+qt0+1FMKfypbhVUY DqjeMhDAnO0Q/XivvkvT4C0VJq6tRQ2N0oz3OfYgcmnG2a8ugFT5RU4JHx25BM32JCYJqg 0Z3X8WjLBUb5FBjko5pFSH2sRxm4OmY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377744; 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=cQ2DtNxZR8mSDNCzRs15eZzz4O2bOn4Fr0rdTgKspbY=; b=R7EttlbkGLw1fZ3h390/UUsW76PaNqYjD6OOyF8T+gRSAP0BCIOVrQUoyvwJXiycn/jrzx HyE7bEZVnmLFJQDQ== 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 271B113A73; Thu, 9 Mar 2023 16:02:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UFWJCBADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:24 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 049/101] fbdev/neofb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:09 +0100 Message-Id: <20230309160201.5163-50-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 98edb6822832..01ed78d987b1 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -55,6 +55,7 @@ */ #include +#include #include #include #include @@ -2176,19 +2177,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) { + struct option_iter iter; 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)) @@ -2205,6 +2203,9 @@ static int __init neofb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Thu Mar 9 16:01: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: 661251 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 42962C77B6D for ; Thu, 9 Mar 2023 16:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232020AbjCIQEG (ORCPT ); Thu, 9 Mar 2023 11:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231672AbjCIQC1 (ORCPT ); Thu, 9 Mar 2023 11:02:27 -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 7EC6DF7EE0; Thu, 9 Mar 2023 08:02: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 EAF752215C; Thu, 9 Mar 2023 16:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377744; 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=AEmjb0U5MuWqCkAOg6DDslP0tiDJ52eRVcjJgkB7ll8=; b=JMxEG6FCTf6enGWwT1TPrS4+ts8GsZgGOwWGh3JfpppPZ80S9Fgn2+LA7srFwU2uDJhyl4 dMRgs6qUYLCMg1NwjmfVCNpm6dQi/pAMPk/8TAz8m8H0i+Np3Yj1eLXt/nx+jyZvoPFTfm MxlO4bIxQXfd3eWsvyp/9a8Lfbw9B84= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377744; 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=AEmjb0U5MuWqCkAOg6DDslP0tiDJ52eRVcjJgkB7ll8=; b=2upOe/xQ6PSzZfw4H5ESkUIDirwNOxL9JcIZRVLqsPWEO2dzYBBo0U8F7h7EySBb1iLg+4 Gu3a2LXpv0460BDg== 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 8FA691391B; Thu, 9 Mar 2023 16:02:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +Mo9IhADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:24 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 050/101] fbdev/nvidiafb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:10 +0100 Message-Id: <20230309160201.5163-51-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/nvidia/nvidia.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index e60a276b4855..8ad4bcff84df 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -77,6 +77,7 @@ static int reverse_i2c; static bool nomtrr = false; static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT); +static char *mode_option_buf; static char *mode_option = NULL; static struct fb_fix_screeninfo nvidiafb_fix = { @@ -1498,8 +1499,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } NVTRACE_LEAVE(); return 0; @@ -1542,6 +1546,7 @@ module_init(nvidiafb_init); static void __exit nvidiafb_exit(void) { pci_unregister_driver(&nvidiafb_driver); + kfree(mode_option_buf); } module_exit(nvidiafb_exit); From patchwork Thu Mar 9 16:01: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: 662237 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 759BFC761A6 for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232004AbjCIQD7 (ORCPT ); Thu, 9 Mar 2023 11:03:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231675AbjCIQC1 (ORCPT ); Thu, 9 Mar 2023 11:02:27 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADB3FF3670; Thu, 9 Mar 2023 08:02: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-out2.suse.de (Postfix) with ESMTPS id 5C1EC2018C; Thu, 9 Mar 2023 16:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377745; 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=ivKIUtt4Tv/ceojYymrkPyms/2b1cDfnVVV/f9m3J8k=; b=mL4MJv0b9/9cWbQh2Huq3UG4Eo8alb8Jxflikg/rrO/UqgSji9yPWjJySPlJFuLdfDcCBe TwSj/ZUNlkCxNtQg1hM8tUeuQKwjENbt7ZYYPi5B/ArbYchVv/YcwJd9f591P7oX3ou1w4 Z/IERGkenK/o/YjIIS/fN+Y153in8f8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377745; 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=ivKIUtt4Tv/ceojYymrkPyms/2b1cDfnVVV/f9m3J8k=; b=FBGV+v9pvuBtm0W5ZqsIb7iUwxFCOIG14ZQyJaHqa0MgrEIKaTZ/CGyqNpwvX8nM/GomTx s8dAJpiRsreFunBg== 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 F12661391B; Thu, 9 Mar 2023 16:02:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AETmORADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:24 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 051/101] fbdev/nvidiafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:11 +0100 Message-Id: <20230309160201.5163-52-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index 8ad4bcff84df..d779163f919a 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -1459,17 +1460,18 @@ static void nvidiafb_remove(struct pci_dev *pd) * ------------------------------------------------------------------------- */ #ifndef MODULE -static int nvidiafb_setup(char *options) +static int nvidiafb_setup(const char *options) { + struct option_iter iter; 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)) @@ -1505,6 +1507,9 @@ static int nvidiafb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + NVTRACE_LEAVE(); return 0; } From patchwork Thu Mar 9 16:01: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: 661247 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 A1939C77B6F for ; Thu, 9 Mar 2023 16:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbjCIQEO (ORCPT ); Thu, 9 Mar 2023 11:04:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231676AbjCIQC1 (ORCPT ); Thu, 9 Mar 2023 11:02:27 -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 0BD51F7EE1; Thu, 9 Mar 2023 08:02: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 B800E2017D; Thu, 9 Mar 2023 16:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377745; 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=IF7qw7uSWJcZb5FaybgvSCxkEvHFzuPQ1jc0G69w/cE=; b=vyel0prki1EuPSH1Aur9iWt58AApZgQdYoDnK+7lawNbPMnd6gizRh8aAQuZvVUPzjLW3x ar480W7CDYfdPZEHdE3I3MLa+i+M5zNvsRc93qYFTzbFgGUvyIl83m85AozAgmg54qT2R8 BQJWohSIRBusBBa0bGa3OYq3Zr59okE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377745; 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=IF7qw7uSWJcZb5FaybgvSCxkEvHFzuPQ1jc0G69w/cE=; b=tFG2udPAxdaB+v6HFkVOi+IphiHjOGhCN5vhAn3XQAS3fmG/ZAJKRZwyNVtjr2Ck3t1SdK bxtgTyssrE6x3lBA== 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 601C113A73; Thu, 9 Mar 2023 16:02:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kFeiFhEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:25 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 052/101] fbdev/ocfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:12 +0100 Message-Id: <20230309160201.5163-53-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ocfb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c index da7e1457e58f..9786c3641448 100644 --- a/drivers/video/fbdev/ocfb.c +++ b/drivers/video/fbdev/ocfb.c @@ -47,6 +47,7 @@ #define OCFB_NAME "OC VGA/LCD" +static char *mode_option_buf; static char *mode_option; static const struct fb_videomode default_mode = { @@ -77,7 +78,10 @@ static int __init ocfb_setup(char *options) while ((curr_opt = strsep(&options, ",")) != NULL) { if (!*curr_opt) continue; - mode_option = curr_opt; + + kfree(mode_option_buf); + mode_option_buf = kstrdup(curr_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } return 0; @@ -420,6 +424,7 @@ static int __init ocfb_init(void) static void __exit ocfb_exit(void) { platform_driver_unregister(&ocfb_driver); + kfree(mode_option_buf); } module_init(ocfb_init); From patchwork Thu Mar 9 16:01: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: 661246 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 9CFBFC74A4B for ; Thu, 9 Mar 2023 16:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbjCIQEP (ORCPT ); Thu, 9 Mar 2023 11:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbjCIQC2 (ORCPT ); Thu, 9 Mar 2023 11:02:28 -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 82377F7EEA; Thu, 9 Mar 2023 08:02: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 209942018A; Thu, 9 Mar 2023 16:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377746; 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=0qu+C7a1d7Q6FMdCh/jaUiqGd0/V74XGNJzxH1lrkhI=; b=I3LLaTHcoFcV15bZl8c57EAjhZqy+fwPXsIZ/Uc6at1tyf+QWfUvdEjQPUA2tISrUnUrFB LRlxxoHBUxgfijNG3Rb/178vAQgR7aNZk5DWUiHm6u5jXYGoetob27gG9cs+nnUfUfP7nW Lvjbwz11PXtm2qLQNLN6JEMGR0MZn1g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377746; 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=0qu+C7a1d7Q6FMdCh/jaUiqGd0/V74XGNJzxH1lrkhI=; b=oBd+AsXDparAk0XMGi3Y6EPLeIeP1ZOz2A+oRaJ1Z7LvPFow8UCpPjMLjnWzNN8yQydqSg v/BsrO+rKo4QnCDw== 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 BCA4C1391B; Thu, 9 Mar 2023 16:02:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0LEjLREDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:25 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 053/101] fbdev/ocfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:13 +0100 Message-Id: <20230309160201.5163-54-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c index 9786c3641448..fa15b932b323 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 @@ -68,22 +69,21 @@ struct ocfb_dev { }; #ifndef MODULE -static int __init ocfb_setup(char *options) +static int __init ocfb_setup(const char *options) { + struct option_iter iter; char *curr_opt; - if (!options || !*options) - return 0; - - while ((curr_opt = strsep(&options, ",")) != NULL) { - if (!*curr_opt) - continue; + option_iter_init(&iter, options); + while (option_iter_next(&iter, &curr_opt)) { kfree(mode_option_buf); mode_option_buf = kstrdup(curr_opt, GFP_KERNEL); // ignore errors mode_option = mode_option_buf; } + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:01: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: 662229 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 8D0E9C76186 for ; Thu, 9 Mar 2023 16:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232049AbjCIQEN (ORCPT ); Thu, 9 Mar 2023 11:04:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231683AbjCIQC2 (ORCPT ); Thu, 9 Mar 2023 11:02:28 -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 02E08F7EC0; Thu, 9 Mar 2023 08:02: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 7C59D2018D; Thu, 9 Mar 2023 16:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377746; 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=W/0ZjJnUahwB+uDTmK6gOidiMLdF9SLqHErBxx1LZFA=; b=sde/W8mkq20pfs9Lu23oerLWqFKCK7Ve6Z3emOo1rc8iQ5dtAT5rrBIuQ8EEsScc2Cq1tW etL7jJDPhJju0rI0zknbepYz4yQspUtRn6D6Sgwi+OkpxYOwpV0LPTipZND1bxrvgtK0// 3bblfF5ajVNFkOBL7h8EVvgbEXgD8Qo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377746; 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=W/0ZjJnUahwB+uDTmK6gOidiMLdF9SLqHErBxx1LZFA=; b=k75q3gjqGTjoy7fOj98md7bjeSqPMrPYUc0TVTkEo46OIhA4k8TsIhpdCt1MtBd7R9bguu vB4z8fBtKXQfkRAw== 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 25DD213A73; Thu, 9 Mar 2023 16:02:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cAtPCBIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:26 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 054/101] fbdev/omapfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:14 +0100 Message-Id: <20230309160201.5163-55-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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..db5256c71f5b 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; + 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 Thu Mar 9 16:01: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: 661252 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 B7710C77B60 for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbjCIQEB (ORCPT ); Thu, 9 Mar 2023 11:04:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbjCIQC3 (ORCPT ); Thu, 9 Mar 2023 11:02:29 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48DC4F7EEB; Thu, 9 Mar 2023 08:02: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 D57122018E; Thu, 9 Mar 2023 16:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377746; 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=DVKSKncJpzS1v2ei+mT1NVs9sZ9KzWGbHpOfs6YjLReK629huuuiPXaKzgjncXEJo6MBfl cSDFBRCsvbDdvjHE7bAc48tkcsbW29N8r3ecj/PniZhkM7ynug2mSqmxe7dNf1ba+CfQU6 ScvpfixiFisQD3PHBgc6zdXiCXoW3UA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377746; 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=46kl+HIqC9g5ujQujVCmmmYWHp/U6HJfMXpBKfI1LGWOMWuSgaeyvZRXYIIBaw9EHLWX+M CxCEV8zbYXkYcnDQ== 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 813ED1391B; Thu, 9 Mar 2023 16:02:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aJC2HhIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:26 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 055/101] fbdev/platinumfb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:01:15 +0100 Message-Id: <20230309160201.5163-56-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 661248 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 EC024C77B71 for ; Thu, 9 Mar 2023 16:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232036AbjCIQEJ (ORCPT ); Thu, 9 Mar 2023 11:04:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231686AbjCIQC3 (ORCPT ); Thu, 9 Mar 2023 11:02:29 -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 87025F7EF2; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id 40F8E2215B; Thu, 9 Mar 2023 16:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377747; 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=bdheHRRXPtj0yTkibiJ2+U48OpRbRtaMNPl40pFJdHw=; b=LULnSu1WQFER6Ed8rvQ/Bi2/QoM2WGNwzBn6+btAxjSyTr5mIX1CLupgOAqnSmumryoUQt DQHCzkpQeOS4KuagxjaEamyqM8ogLda290xtwFRWLR57fgZyFZVd+/a1PCGe8QRir5G9fF fkjBlfbUzHDYH25/6k2NSjGggWJHZiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377747; 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=bdheHRRXPtj0yTkibiJ2+U48OpRbRtaMNPl40pFJdHw=; b=CkX4Hr4vitl7H8PIT1SJljwAoToekrnCbjMBjIWNGLi/kNNo195pC0gFZ3gy2rI1X3hNKZ cI72xTaKNEsXbMCg== 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 DA49813A73; Thu, 9 Mar 2023 16:02:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OH11NBIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:26 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 056/101] fbdev/platinumfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:16 +0100 Message-Id: <20230309160201.5163-57-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c index c7172174c1b7..33bf75309815 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) { + struct option_iter iter; 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 Thu Mar 9 16:01: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: 661253 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 448AFC7619A for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232002AbjCIQD6 (ORCPT ); Thu, 9 Mar 2023 11:03:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbjCIQC3 (ORCPT ); Thu, 9 Mar 2023 11:02:29 -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 E944FF4B7A; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id A20712215D; Thu, 9 Mar 2023 16:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377747; 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=JrTWZ35A8KxaVoBf2I0MCmqaACOIQrBJsCXoiqqjOIA=; b=jS0ssRuCETelh7ixW7TzhRrWWiUInqyfgqWQeYCgO9RNtbERztNuozpHaAMoWgl8npDobz 5y5FeFw9/wSwZBbVV8ga82Whtu9q0orO7y60gRBTE9sm+paDV0gGPqtbWrY2kVMv6MelVo nXhYZ9q5UPoc5R3G9HKCVBIFofxskvU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377747; 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=JrTWZ35A8KxaVoBf2I0MCmqaACOIQrBJsCXoiqqjOIA=; b=2edF2x5brkFqa+DmyZWXVmjoNOy+6kv0RKfqRxrbUk+Za1jSvWMtiQ81zvUCgCGJhblwix XzdXKe0+xVf67bDg== 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 4386B1391B; Thu, 9 Mar 2023 16:02:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SIOdDxMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:27 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 057/101] fbdev/pm2fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:17 +0100 Message-Id: <20230309160201.5163-58-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pm2fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c index 47d212944f30..69a0b2216a86 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -64,6 +64,7 @@ * Driver data */ static int hwcursor = 1; +static char *mode_option_buf; static char *mode_option; /* @@ -1792,8 +1793,11 @@ static int __init pm2fb_setup(char *options) nomtrr = 1; else if (!strncmp(this_opt, "noaccel", 7)) noaccel = 1; - else - mode_option = this_opt; + else { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -1828,6 +1832,7 @@ module_init(pm2fb_init); static void __exit pm2fb_exit(void) { pci_unregister_driver(&pm2fb_driver); + kfree(mode_option_buf); } #endif From patchwork Thu Mar 9 16:01: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: 662238 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 1F02CC76196 for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbjCIQD5 (ORCPT ); Thu, 9 Mar 2023 11:03:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231697AbjCIQCa (ORCPT ); Thu, 9 Mar 2023 11:02:30 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A6EF4002; Thu, 9 Mar 2023 08:02: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 05FA02215E; Thu, 9 Mar 2023 16:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377748; 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=71NPoACrbZYXzx2EVEDFYpfxXoR5Lt0/br1gYRvJZ1s=; b=PDSYamFAvdpsNxkYPQ7q4E07996MFmALIasY9cH5+bB0WndN84+0CsLzZqlw5POoAZUNOT 4izLv7YUOTl4GTE9RjOz68tyNINfWJfBSm5mHn7xE+Q6DSCN8baSitNYtH/3IC/WsXstf1 iwISlhDWxLOg9hBAyWWE8NQ6gCYRjuU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377748; 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=71NPoACrbZYXzx2EVEDFYpfxXoR5Lt0/br1gYRvJZ1s=; b=0USMu/YO6c75D4K5oEn9YSfTlN+2GxrlMl5ooCR6NMrPf4lDq+s/Scxr+sdA+Mgj67VN4j ZSXGJvb0I/v23/Dw== 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 A266513A73; Thu, 9 Mar 2023 16:02:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mMbPJhMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:27 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 058/101] fbdev/pm2fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:18 +0100 Message-Id: <20230309160201.5163-59-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c index 69a0b2216a86..38c5c57ce2b0 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include @@ -1773,16 +1774,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) { + struct option_iter iter; 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")) @@ -1799,6 +1798,9 @@ static int __init pm2fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:01: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: 661250 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 7B1CDC77B70 for ; Thu, 9 Mar 2023 16:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232032AbjCIQEI (ORCPT ); Thu, 9 Mar 2023 11:04:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231702AbjCIQCa (ORCPT ); Thu, 9 Mar 2023 11:02:30 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3593F7EC5; Thu, 9 Mar 2023 08:02: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 628AD2215A; Thu, 9 Mar 2023 16:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377748; 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=U+Wv5+2Mg/OOpac2b+Kt6VAraiPSH3rcxItITwlujo0=; b=2MNMPBZYCIIHTJ2a9JkvDWsYV8evjucSV74au32ruPU/hzE/mOYrSxmf61i7KgGaAYkliZ DWu+fI20MDJORKJm3G1h6mvegZdTJ5/Fl91EZGDPqh1Goif9fF/ROHx893iPmOCjMZAniT IRpWPGDs9DVrRLU/zkJD4qSX+cGhguI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377748; 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=U+Wv5+2Mg/OOpac2b+Kt6VAraiPSH3rcxItITwlujo0=; b=IYkv7jGmizkWRSS1WbdG2KFhNI5g5MrC25KLR887jQRD8KgRS6cMUcN2U/skNhJzjD0g2k SMKmJL+ohR28VlCg== 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 09A8C1391B; Thu, 9 Mar 2023 16:02:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0CqGARQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:28 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 059/101] fbdev/pm3fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:19 +0100 Message-Id: <20230309160201.5163-60-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pm3fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c index b46a471df9ae..b6b378e7554d 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -54,6 +54,7 @@ * Driver data */ static int hwcursor = 1; +static char *mode_option_buf; static char *mode_option; static bool noaccel; static bool nomtrr; @@ -1526,8 +1527,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -1558,6 +1562,7 @@ static int __init pm3fb_init(void) static void __exit pm3fb_exit(void) { pci_unregister_driver(&pm3fb_driver); + kfree(mode_option_buf); } module_exit(pm3fb_exit); From patchwork Thu Mar 9 16:01: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: 661255 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 0688BC76195 for ; Thu, 9 Mar 2023 16:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231996AbjCIQD4 (ORCPT ); Thu, 9 Mar 2023 11:03:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjCIQCb (ORCPT ); Thu, 9 Mar 2023 11:02: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 10186F6C7A; Thu, 9 Mar 2023 08:02: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-out2.suse.de (Postfix) with ESMTPS id BCD8420187; Thu, 9 Mar 2023 16:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377748; 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=K8bkfkzbWNgSDb6UtVHWjSzMDHH7LhwKp4EFJ55njm8=; b=w4EIuTVBeN0feJKOOtNEj5vGW/wAZ+fU4ZpvjQMPvYoul6LP+doggvYb5Iie4fyBYmPZ1g uZk2b/+YBRkClHSL+nK1+PryPFUi8JIXCJ4r5xPKGMc2sKz4rxq5FbgqY4yoBpxyztfUvs toGZvC+a66chNsYFTtVL9ioCEtfuvnY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377748; 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=K8bkfkzbWNgSDb6UtVHWjSzMDHH7LhwKp4EFJ55njm8=; b=HwoRzadflSA9cICi6RZ2cgaMT22CIUrMkxkbxlmG4cqeCclu1b5QGcK585lZS0NI83UA3S gxUBdX8kUW0yYgBQ== 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 669C213A73; Thu, 9 Mar 2023 16:02:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2CA1GBQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:28 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 060/101] fbdev/pm3fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:20 +0100 Message-Id: <20230309160201.5163-61-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c index b6b378e7554d..c4d4f08b4114 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -1510,18 +1511,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) { + struct option_iter iter; 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); @@ -1533,6 +1532,9 @@ static int __init pm3fb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif /* MODULE */ From patchwork Thu Mar 9 16:01: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: 662231 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 B4F0AC61DA4 for ; Thu, 9 Mar 2023 16:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232062AbjCIQEP (ORCPT ); Thu, 9 Mar 2023 11:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231708AbjCIQCb (ORCPT ); Thu, 9 Mar 2023 11:02:31 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626B5F7EC6; Thu, 9 Mar 2023 08:02: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 2389322160; Thu, 9 Mar 2023 16:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377749; 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=0OUYBLEIZcEGaUUIng7YnnYmnpc0Gk2LmDknjSg1lT8=; b=HHyh9U+3DSvAJPIq2fS/7MfoeTzd9ObdeJFQMqxok1yiU1rJWTiLvkXevHpyQbRRwFO96x 0NkhHnyZ+E5GlKDN6rl9vjIMXHGaW6suVHsS2OlvEnSS+b9KEh40L1smvlgHvzhYSQ/yD1 aOebOveTWnG6osC9mFLo5t2nNZ0/GFA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377749; 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=0OUYBLEIZcEGaUUIng7YnnYmnpc0Gk2LmDknjSg1lT8=; b=R8KA2keggD95kmGethWRsJYpX9jmMj2Y1uKN3FdxDP9nIhNjdO2/O4nVZhvn1pRybcyAJj 3IHbjBH38DmiLYAA== 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 C14891391B; Thu, 9 Mar 2023 16:02:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6PhPLhQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:28 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 061/101] fbdev/ps3fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:21 +0100 Message-Id: <20230309160201.5163-62-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ps3fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c index 2fe08b67eda7..d67ef2701b18 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -260,6 +260,7 @@ static const struct fb_videomode ps3fb_modedb[] = { static int ps3fb_mode; module_param(ps3fb_mode, int, 0); +static char *mode_option_buf; static char *mode_option; static int ps3fb_cmp_mode(const struct fb_videomode *vmode, @@ -1276,8 +1277,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -1294,6 +1298,7 @@ static void __exit ps3fb_exit(void) { pr_debug(" -> %s:%d\n", __func__, __LINE__); ps3_system_bus_driver_unregister(&ps3fb_driver); + kfree(mode_option_buf); pr_debug(" <- %s:%d\n", __func__, __LINE__); } From patchwork Thu Mar 9 16:01: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: 661249 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 40313C742A7 for ; Thu, 9 Mar 2023 16:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232045AbjCIQEM (ORCPT ); Thu, 9 Mar 2023 11:04:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbjCIQCb (ORCPT ); Thu, 9 Mar 2023 11:02:31 -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 04E02F4B43; Thu, 9 Mar 2023 08:02: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 7D07122142; Thu, 9 Mar 2023 16:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377749; 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=uyi0fNSRbdaL+ECiynmB37t7h6m4wxRWWhsvx+mW63E=; b=rbkjCdES6w3axNa/kmEE3QcczxQ/m9Sedz13V8dhYK33E5RzIZhlqVlN0uosCDWlJ5hvDF 6/3L/Wwu4pAQgcj/1Hgm9T6oExh65xwUtR0B2lxFodk68ON8Enj0l+w9RbVjkQE1Aw7Sl2 UbJs/Jx4vMcxWD3gOo2gLpIA4KyQwkI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377749; 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=uyi0fNSRbdaL+ECiynmB37t7h6m4wxRWWhsvx+mW63E=; b=SuticJtoh7v0eDYCOnlvxfOZE6ACagzZS7r7ckcyaySDRQfszV8CkFcgLM4Cg3fwRdn8Da OpfHWsiSCgEUR6DA== 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 285CC1391B; Thu, 9 Mar 2023 16:02:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mPfpCBUDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:29 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 062/101] fbdev/ps3fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:22 +0100 Message-Id: <20230309160201.5163-63-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 d67ef2701b18..575b2911977a 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -17,6 +17,7 @@ * more details. */ +#include #include #include #include @@ -1257,6 +1258,8 @@ static struct ps3_system_bus_driver ps3fb_driver = { static int __init ps3fb_setup(void) { char *options; + struct option_iter iter; + char *this_opt; #ifdef MODULE return 0; @@ -1265,16 +1268,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 { @@ -1283,6 +1279,9 @@ static int __init ps3fb_setup(void) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } From patchwork Thu Mar 9 16:01: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: 661243 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 CFDA0C7618B for ; Thu, 9 Mar 2023 16:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbjCIQEV (ORCPT ); Thu, 9 Mar 2023 11:04:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjCIQCc (ORCPT ); Thu, 9 Mar 2023 11:02:32 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335B2F63A3; Thu, 9 Mar 2023 08:02: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 D940A2018F; Thu, 9 Mar 2023 16:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377749; 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=QjJ38kmNT4VpiL0XGaIUsP41fKqpOphAgyzqkf5KhKA=; b=JLe11LJEmiD4nLl8O7epakDml/E/WNFxS8XYIxOcUyoCg3JN580rEa+XFFqIuJ01mwt/pq jbY9KoIsTr78epKZ8bw0X6sdPaS16SEqEvp4pJ/00qWTCkD7INw9UYOQuzLeNO5g8zYHhG 4Qi/RVEwLUZBux2CjvrnfsbBZkhS+yA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377749; 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=QjJ38kmNT4VpiL0XGaIUsP41fKqpOphAgyzqkf5KhKA=; b=bz5poN1CD5ySwXlFVjpP3CyHkn8fTspT1RxOz5lCIW1I2NIbHe6SrgZ8As5oiHQSjSsubf MF73NTrD34lgu6Bw== 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 825E01391B; Thu, 9 Mar 2023 16:02:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sGn5HhUDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:29 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 063/101] fbdev/pvr2fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:23 +0100 Message-Id: <20230309160201.5163-64-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function, as well as the init function's error handling. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/pvr2fb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index 6888127a5eb8..f6be2649840d 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -225,6 +225,7 @@ static struct fb_videomode pvr2_modedb[] = { #define DEFMODE_VGA 2 static int defmode = DEFMODE_NTSC; +static char *mode_option_buf; static char *mode_option = NULL; static inline void pvr2fb_set_pal_type(unsigned int type) @@ -1049,7 +1050,9 @@ static int __init pvr2fb_setup(char *options) } else if (!strncmp(this_opt, "nowrap", 6)) { nowrap = 1; } else { - mode_option = this_opt; + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } } @@ -1094,8 +1097,11 @@ static int __init pvr2fb_init(void) #endif fb_info = framebuffer_alloc(sizeof(struct pvr2fb_par), NULL); - if (!fb_info) + if (!fb_info) { + kfree(mode_option_buf); + mode_option_buf = NULL; return -ENOMEM; + } currentpar = fb_info->par; @@ -1111,6 +1117,8 @@ static int __init pvr2fb_init(void) printk(KERN_ERR "pvr2fb: Failed init of %s device\n", pvr_board->name); framebuffer_release(fb_info); + kfree(mode_option_buf); + mode_option_buf = NULL; break; } } @@ -1135,6 +1143,7 @@ static void __exit pvr2fb_exit(void) unregister_framebuffer(fb_info); framebuffer_release(fb_info); + kfree(mode_option_buf); } module_init(pvr2fb_init); From patchwork Thu Mar 9 16:01: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: 662232 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 581C8C74A5B for ; Thu, 9 Mar 2023 16:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232042AbjCIQEL (ORCPT ); Thu, 9 Mar 2023 11:04:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbjCIQCc (ORCPT ); Thu, 9 Mar 2023 11:02:32 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD06FF5AAA; Thu, 9 Mar 2023 08:02: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 423EF20191; Thu, 9 Mar 2023 16:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377750; 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=wUduy0AuOjKoirEH3M4ZgQWRTKWt0MXYaCWhrGLsjaw=; b=tvjhW16Wva/AA4h26PDcnH3qVIk7m64jqixdJMYwVnvZhbr+HoV8r8MvvgoiLUD4ZU8jgO Hw6YKrCXDrrasvxTHac2Z7n6KCkmM5/wY5vzZlHBLORr/DqkeaadTp+8VGNfkxVbR4il59 YcmPUm5WT8xLjNrtVkDtT3VaBWTpMig= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377750; 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=wUduy0AuOjKoirEH3M4ZgQWRTKWt0MXYaCWhrGLsjaw=; b=L0zcwibam7U69C5b9SNulUE2ace4gMAgny98/CFfo6soy3LxgN2bPxaZT0dV5MXhTs718V BENdEmvFEJf6izDg== 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 DC3E313A73; Thu, 9 Mar 2023 16:02:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SKXdNBUDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:29 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 064/101] fbdev/pvr2fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:24 +0100 Message-Id: <20230309160201.5163-65-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 f6be2649840d..c332f2c38114 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -46,6 +46,7 @@ #undef DEBUG #include +#include #include #include #include @@ -1025,20 +1026,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; + 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)) { @@ -1056,6 +1055,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 Thu Mar 9 16:01: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: 662234 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 8605BC77B73 for ; Thu, 9 Mar 2023 16:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232040AbjCIQEK (ORCPT ); Thu, 9 Mar 2023 11:04:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231720AbjCIQCc (ORCPT ); Thu, 9 Mar 2023 11:02:32 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF96CF786F; Thu, 9 Mar 2023 08:02: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 9D54C20192; Thu, 9 Mar 2023 16:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377750; 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=i9kXMRzl84QLn/fJf6kdz3b+HhhBrJcv0BrlgL/PbEg=; b=lcW5jkLqcuR67+A4lDjPzUQmUXrC1v0MNNCKRJEl+PUF2DjZ1Z5p8aI59In8NRD2grpFi8 L3x+183urkgRk2mUMZ2d/Vofzua7YVUSrMEXHIVzMj1wN8mGAsbqxI4v+XDe2zjM2URfb9 e0zsFsbXMNLaAJJ9tkn/YHbBj961978= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377750; 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=i9kXMRzl84QLn/fJf6kdz3b+HhhBrJcv0BrlgL/PbEg=; b=3He5Ygju0enbSqJS3GobyTos5rFr008eOHgqKgbqqs3295oCQSSiLg15pj8L5QjzPxotmw AMejKys/mzYKzkAQ== 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 45B561391B; Thu, 9 Mar 2023 16:02:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QHc4EBYDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:30 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 065/101] fbdev/pxafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:25 +0100 Message-Id: <20230309160201.5163-66-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c index c46ed78298ae..d2db9c20d515 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) { + struct option_iter iter; 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 Thu Mar 9 16:01: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: 662227 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 94582C7618E for ; Thu, 9 Mar 2023 16:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjCIQEX (ORCPT ); Thu, 9 Mar 2023 11:04:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbjCIQCd (ORCPT ); Thu, 9 Mar 2023 11:02:33 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6369CF7ECC; Thu, 9 Mar 2023 08:02: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 0F68020193; Thu, 9 Mar 2023 16:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377751; 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=qhxzR92z1gnpV02wXcKkiw7ZsurBsIYnaSNVC8cfCP4=; b=uYsfoW4ECejLPwttGFBGUGD4gLEdEd80fTWe3UzEOX3btCFwFsTktATnfUBAiCquJWj+/G g4P50AJ7UpL1l371Y04zZ16W+uoetlO9JPUxY2hwW7zq6uZijLpU/PJsn2N7b8vFEDoxcw Y+v2J5rvfziaChputQXngTNqx7vsU/U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377751; 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=qhxzR92z1gnpV02wXcKkiw7ZsurBsIYnaSNVC8cfCP4=; b=/OwuWGoJQQin7zgG2uk571pfTIalbBa+hAtKlVQp3pCJudT+zkV8PPOp7e+5EPgkNv6juH 8pq28SOkm/ibFpAw== 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 9FF2213A73; Thu, 9 Mar 2023 16:02:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iL44JhYDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:30 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 066/101] fbdev/rivafb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:26 +0100 Message-Id: <20230309160201.5163-67-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/riva/fbdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index 41edc6e79460..8a7dc7452938 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -205,6 +205,7 @@ static bool noaccel = 0; static bool nomtrr = 0; static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT); +static char *mode_option_buf; static char *mode_option = NULL; static bool strictmode = 0; @@ -2132,8 +2133,11 @@ static int rivafb_setup(char *options) strictmode = 1; } else if (!strncmp(this_opt, "noaccel", 7)) { noaccel = 1; - } else - mode_option = this_opt; + } else { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } NVTRACE_LEAVE(); return 0; @@ -2178,6 +2182,7 @@ module_init(rivafb_init); static void __exit rivafb_exit(void) { pci_unregister_driver(&rivafb_driver); + kfree(mode_option_buf); } module_exit(rivafb_exit); From patchwork Thu Mar 9 16:01: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: 661244 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 9D34FC77B78 for ; Thu, 9 Mar 2023 16:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbjCIQEY (ORCPT ); Thu, 9 Mar 2023 11:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231728AbjCIQCd (ORCPT ); Thu, 9 Mar 2023 11:02:33 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED377F7ED7; Thu, 9 Mar 2023 08:02: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 69DA320190; Thu, 9 Mar 2023 16:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377751; 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=zBQBNruRFSNZlolPcBWrGJ3VsKzDOc5MQ8RhK9SMylU=; b=TGhSUeAz++JXt77WCiLYR+LnHm9NTwtouH57PfcrnypMafHbIMYvZ3j1t3pgOskxp8BZC4 GrDAqDsOARGADkhF9XQ7ByB8mFanj71S2MGXf32LTNjalW/QS/2DCK+FvDCST9oRi2UKEY hUhz0jrJznh+WJS2lVI5qa98IbI//kM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377751; 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=zBQBNruRFSNZlolPcBWrGJ3VsKzDOc5MQ8RhK9SMylU=; b=J9Rm0NBDh4ETa4lT0gih7jpI9Z4JH5I7yt4ZY1k5h8IQaaCdRuAqbDD1odTkr9TuW8me5n 0M8rrLC4hFVAL0CQ== 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 13DB31391B; Thu, 9 Mar 2023 16:02:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oN4EBBcDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:31 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 067/101] fbdev/rivafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:27 +0100 Message-Id: <20230309160201.5163-68-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index 8a7dc7452938..7f35edad249e 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -30,6 +30,7 @@ */ #include +#include #include #include #include @@ -2106,17 +2107,18 @@ static void rivafb_remove(struct pci_dev *pd) * ------------------------------------------------------------------------- */ #ifndef MODULE -static int rivafb_setup(char *options) +static int rivafb_setup(const char *options) { + struct option_iter iter; 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; @@ -2139,6 +2141,9 @@ static int rivafb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + NVTRACE_LEAVE(); return 0; } From patchwork Thu Mar 9 16:01: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: 662230 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 CD054C77B75 for ; Thu, 9 Mar 2023 16:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbjCIQER (ORCPT ); Thu, 9 Mar 2023 11:04:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbjCIQCe (ORCPT ); Thu, 9 Mar 2023 11:02:34 -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 77733F7EDF; Thu, 9 Mar 2023 08:02: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 C832E20194; Thu, 9 Mar 2023 16:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377751; 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=2NH6+VMOHM5Bo+HTdsXwHkuMcnMRmvfOynxZTybH+bo=; b=go1Eo7rsPRB5BTU6t1uZeaY1P9a+UShfP9tySZW6muM3zfoSxWuJ0JgsuNBQ23dT9Avu82 vMyTTtUhQoqe513nmX0H/WS6nKOdeXIx4OFmD+UGQZXCL1l+oY4OiLIrWOtouY02A85513 GEPk0Gg699Q4RykUQPURPtRxv2Nhs38= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377751; 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=2NH6+VMOHM5Bo+HTdsXwHkuMcnMRmvfOynxZTybH+bo=; b=E2S+X322wx/wHA2eX9UG4JiDR8pRg9/T2WXFXdRMBwmB1EvU4abjgoqd+RB6MO/AftXP+T XJzzO7fUrj/3LeCA== 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 6EE4A13A73; Thu, 9 Mar 2023 16:02:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iNk9GhcDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:31 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 068/101] fbdev/s3fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:28 +0100 Message-Id: <20230309160201.5163-69-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/s3fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 7d257489edcc..6bcedcde8aad 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -150,6 +150,7 @@ static const struct svga_timing_regs s3_timing_regs = { /* Module parameters */ +static char *mode_option_buf; static char *mode_option; static int mtrr = 1; static int fasttext = 1; @@ -1535,8 +1536,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; @@ -1549,6 +1553,7 @@ static void __exit s3fb_cleanup(void) { pr_debug("s3fb: cleaning up\n"); pci_unregister_driver(&s3fb_pci_driver); + kfree(mode_option_buf); } /* Driver Initialisation */ From patchwork Thu Mar 9 16:01: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: 661245 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 E99D2C7618D for ; Thu, 9 Mar 2023 16:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231191AbjCIQET (ORCPT ); Thu, 9 Mar 2023 11:04:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbjCIQCe (ORCPT ); Thu, 9 Mar 2023 11:02:34 -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 12072F7EE2; Thu, 9 Mar 2023 08:02: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 3049F20196; Thu, 9 Mar 2023 16:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377752; 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=C0mdrdYY6WhTpvHBsfeX6P5OoEx5EyTBYrjtJOl3HBs=; b=BkCig/A7RfJH2OsuwyUFdvUqV0LXetnqBM+gUG1ZY4qlCG0XCIWf/pA9pzTy5+6yhGL16O X7OT1Eqw/NXmFNkuYs0ILD3KUO++5/kR5Qi6qUAut0jxeJYothELdeIJS+HcvCN1Xh0NDj ht7LSpnNY4GFjSelHUuKwU9NxLwos8o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377752; 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=C0mdrdYY6WhTpvHBsfeX6P5OoEx5EyTBYrjtJOl3HBs=; b=eFqUwD3scQ6k2cl+QjN0flfozu+J92KahG9F15ISWAypw0XFoq2VISamfFI5ilBXhH1zdg LPk+/2l9iJ+YQgCg== 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 CD7451391B; Thu, 9 Mar 2023 16:02:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GPZRMRcDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:31 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 069/101] fbdev/s3fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:29 +0100 Message-Id: <20230309160201.5163-70-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 6bcedcde8aad..37f5ea25efd6 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -1521,18 +1522,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) { + struct option_iter iter; 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); @@ -1543,6 +1541,8 @@ static int __init s3fb_setup(char *options) } } + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:01: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: 662228 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 29920C76195 for ; Thu, 9 Mar 2023 16:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231866AbjCIQEZ (ORCPT ); Thu, 9 Mar 2023 11:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230288AbjCIQCe (ORCPT ); Thu, 9 Mar 2023 11:02:34 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D86C1F7EE0; Thu, 9 Mar 2023 08:02: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 931CF22161; Thu, 9 Mar 2023 16:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377752; 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=yPzn7zXM7yj42koki0aANjXUDhnwLRtgpbH+HR/F9bc=; b=hVbhDNWRVOwus2xxkHmc/4gF3MymqYwK8KfEjd7hiO/1foTLysxr6pY3x9QTB21pfXhCrZ rL79SiO9dVnHM1kCiAn7XxEcVb1yf4DBn6GHi77/m1k8mX/Gi77Ylfz5i6VIQCBQY00Pqb pSeFzeEkGp/5b11SM/UeJiRKLMJ9U5s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377752; 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=yPzn7zXM7yj42koki0aANjXUDhnwLRtgpbH+HR/F9bc=; b=lW6WAUz/SE0GTx65vIG2i/+fVrq2paAzGgiR4MR+B7LSQ8dSaU/fC3ywfoNIo0UDbYm1fX yvVg50kSj3KjGCCQ== 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 33C1213A73; Thu, 9 Mar 2023 16:02:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EH/TCxgDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:32 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 070/101] fbdev/savagefb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:30 +0100 Message-Id: <20230309160201.5163-71-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/savage/savagefb_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 4a27b68798bf..0ca5894114c9 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -65,6 +65,7 @@ /* --------------------------------------------------------------------- */ +static char *mode_option_buf; static char *mode_option = NULL; #ifdef MODULE @@ -2530,6 +2531,7 @@ static void __exit savage_done(void) { DBG("savage_done"); pci_unregister_driver(&savagefb_driver); + kfree(mode_option_buf); } @@ -2544,7 +2546,9 @@ static int __init savagefb_setup(char *options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { - mode_option = this_opt; + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } #endif /* !MODULE */ return 0; From patchwork Thu Mar 9 16:01: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: 662224 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 9AEEBC76188 for ; Thu, 9 Mar 2023 16:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbjCIQEe (ORCPT ); Thu, 9 Mar 2023 11:04:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbjCIQCf (ORCPT ); Thu, 9 Mar 2023 11:02:35 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C8CF3670; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id 02C5C22162; Thu, 9 Mar 2023 16:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377753; 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=LrR4dEV8fvot4krXRpemBNzsGqKxI9Iidiw4W2qbfcs=; b=ae6f8RbIy2Rv+yRmon5XxI4seRFmyMdyJOQsgGV+2HydP0zUWHk7HHsifkPYnKLIYZC9/0 Pyxr7sE69YfCOtNMuW3hi9Kxe8uBAQBHdNECFnYgbyAyaTHteLKJSALCLE/vVCHZC517Wj PdaCKJVkqobG0szMc/ZRUj2X4u7Abhg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377753; 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=LrR4dEV8fvot4krXRpemBNzsGqKxI9Iidiw4W2qbfcs=; b=QECZeFxqwtZvMCizXWX7OraDZ3sytS0NpgbSyW9YFP6OWcxicrmEQvBtHYvmh8ZO7P+JLl zZg/1Cbxo1k/GfDA== 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 985B61391B; Thu, 9 Mar 2023 16:02:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KIZQJBgDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:32 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 071/101] fbdev/savagefb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:31 +0100 Message-Id: <20230309160201.5163-72-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 0ca5894114c9..4650688fd23c 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 @@ -2537,19 +2538,22 @@ 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 + struct option_iter iter; 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)) { kfree(mode_option_buf); mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors mode_option = mode_option_buf; } + + option_iter_release(&iter); + #endif /* !MODULE */ return 0; } From patchwork Thu Mar 9 16:01: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: 661240 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 D2634C7618D for ; Thu, 9 Mar 2023 16:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232083AbjCIQEg (ORCPT ); Thu, 9 Mar 2023 11:04:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231736AbjCIQCg (ORCPT ); Thu, 9 Mar 2023 11:02:36 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B06F1F4002; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id 6DA9522163; Thu, 9 Mar 2023 16:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377753; 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=B6Nvx8dkSj/OuX3zLARuzm8vSuXgcocSuJ64uOslQxtq5UrlzuVeuxSn1ErjZi3/1k1HPx Hl2QEF0xiXJvD044nqLxt6sXP6l5YM4rCR07kznwZ2T91F55Sfz77toaePc2oEQ5yLb0i9 J7yB4F0craiC8zEvcQP4oJzcfH/Q06A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377753; 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=U6ZELyDp1F44OU7kM0Bc/rgo3cqI2drgIFZ4W2eywOt8CWDyHqIbljR/CH9s4oXdcfv6TA PpioaS121e3OYbAQ== 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 079B513A73; Thu, 9 Mar 2023 16:02:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gHXcABkDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:33 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 072/101] fbdev/sisfb: Constify mode string Date: Thu, 9 Mar 2023 17:01:32 +0100 Message-Id: <20230309160201.5163-73-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 662226 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 7D521C761A6 for ; Thu, 9 Mar 2023 16:04:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbjCIQE0 (ORCPT ); Thu, 9 Mar 2023 11:04:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231738AbjCIQCg (ORCPT ); Thu, 9 Mar 2023 11:02:36 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C92F4B7A; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id D464322164; Thu, 9 Mar 2023 16:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377753; 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=lTED/VgPHa5wOEvVPPDcN/pf/+4+mXP+rnXQB1MZTbI=; b=ivrPro47qs/FUUYxTMSy9TTlxQwM6PjsxdmAQuR0jJqj+3eYk028UGvVMQLgWojig86pkz hlbUUYnGoPW6gBkRX1sjK9RDucyT264XOyNIkimtM9dNACDlQ3r7bPO3DXLjTYk0C0Fj6c FWyfND0mMLxLoFmDILdS1kWOn5COid4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377753; 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=lTED/VgPHa5wOEvVPPDcN/pf/+4+mXP+rnXQB1MZTbI=; b=TD+0JkuVOLoSVfrQvFdVZML9zV5qJRYVYV+7HFuBB1aUuMxo/VMpgRTScyuMuCD4FNi+l2 aIwqV+1tCxUACrCQ== 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 728F61391B; Thu, 9 Mar 2023 16:02:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4G/lGhkDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:33 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 073/101] fbdev/sisfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:33 +0100 Message-Id: <20230309160201.5163-74-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c index c16493d3ac4f..9f63812a5f66 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) { + struct option_iter iter; 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 Thu Mar 9 16:01: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: 661242 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 48406C76196 for ; Thu, 9 Mar 2023 16:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231872AbjCIQEc (ORCPT ); Thu, 9 Mar 2023 11:04:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231739AbjCIQCg (ORCPT ); Thu, 9 Mar 2023 11:02:36 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83667F6C7A; Thu, 9 Mar 2023 08:02: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 44B6420179; Thu, 9 Mar 2023 16:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377754; 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=k8XeD13siGTPg6ur3jYfV0pIQmZ74GbDCRGpLHT3KYY=; b=usVstNaMvRiiNGybfSZtuWZwo3o9DGS90YmiNS0IerHlu++zx9+fuYsOeVk4z0EgLQTlP8 14EDFUpo8H9GZmISw0ir5bUUpescdqkii0CWQ9VMU9VZvUb4BxdVaAytuOV9oq0xdv0TOG uHSraghKEl2vhKBCAMaVsBA1wC6TXuA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377754; 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=k8XeD13siGTPg6ur3jYfV0pIQmZ74GbDCRGpLHT3KYY=; b=/A7j3hhwjwv8mVq2lH3pzqblM4RD5k5cYFw3kOjsSVifHYNdq7tqboxQQcrw+F+RpFjPDD OeM8vPaucJ9tCuBg== 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 D9D8613A73; Thu, 9 Mar 2023 16:02:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SMUxNBkDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:33 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 074/101] fbdev/skeletonfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:34 +0100 Message-Id: <20230309160201.5163-75-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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..ee6944d0ebc1 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; + char *this_opt; + + option_iter_init(&iter, options); + + while (option_iter_next(&iter, &this_opt)) { + } + + option_iter_release(&iter); } #endif /* MODULE */ From patchwork Thu Mar 9 16:01: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: 662225 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 D0130C61DA4 for ; Thu, 9 Mar 2023 16:04:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232081AbjCIQEe (ORCPT ); Thu, 9 Mar 2023 11:04:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjCIQCg (ORCPT ); Thu, 9 Mar 2023 11:02:36 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB30DF4B43; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id A52DF22166; Thu, 9 Mar 2023 16:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377754; 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=0gZ1Tmm3JEgeMqN/NPKY8oH5C/7S9gy9JQ3mKL7gtCM=; b=aClCiEjhtEvWWtKnoezDVvFJ/0p8+II1/ANYf4pu5EiDL7XF2rdltVl0y85P+Ha4Dn4ZNH zwMyiHi4MWV1eiin5k+j/f+5rLop399Dwzr+Ch3RBWzELK6MsXeMNTcWo3Tk5STdrD/tFI 04JdiAGAHPMFYJ40iwVJCCMsxvqG+Eg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377754; 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=0gZ1Tmm3JEgeMqN/NPKY8oH5C/7S9gy9JQ3mKL7gtCM=; b=u2IBZGAN1hguKZ934fTSEqBEE8/y5bWBVazblvDiXW5m5qNf9v2Uth46VrOGnZkWdgS5qR m/u8q/ceCBwgOIBQ== 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 496031391B; Thu, 9 Mar 2023 16:02:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OJ4JERoDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:34 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 075/101] fbdev/sm712fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:35 +0100 Message-Id: <20230309160201.5163-76-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sm712fb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index b528776c7612..a83f48fce5b1 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -831,6 +831,7 @@ static const struct modeinit vgamode[] = { static struct screen_info smtc_scr_info; +static char *mode_option_buf; static char *mode_option; /* process command line options, get vga parameter */ @@ -1761,8 +1762,12 @@ static int __init sm712fb_init(void) if (fb_get_options("sm712fb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + + if (option && *option) { + mode_option_buf = kstrdup(option, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } + sm7xx_vga_setup(mode_option); return pci_register_driver(&smtcfb_driver); @@ -1773,6 +1778,7 @@ module_init(sm712fb_init); static void __exit sm712fb_exit(void) { pci_unregister_driver(&smtcfb_driver); + kfree(mode_option_buf); } module_exit(sm712fb_exit); From patchwork Thu Mar 9 16:01: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: 661241 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 3053AC7618A for ; Thu, 9 Mar 2023 16:04:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231875AbjCIQEd (ORCPT ); Thu, 9 Mar 2023 11:04:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbjCIQCh (ORCPT ); Thu, 9 Mar 2023 11:02: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 5EFA4F5AAA; Thu, 9 Mar 2023 08:02: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 14ED120188; Thu, 9 Mar 2023 16:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377755; 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=JVZXeFOij00kRcHliLoRJrMyHyqeyRSXeS/4JiKw1+4=; b=oycjPTqX0Nu9kVuARt5SyGrF4xBlSmhXVQTpgeM0jHtxkgEDQ9Sycw+FpNBC1aJYAc3B4g nTHE/VRCf+2lto6LOSXg9ylMDlKD1kB9rbdqJ6DxrJIRxd8RpHVyOGwx4s0N+U6c5vB4zs Q6g4PygtLOu6Ra/I7MEJPj/GMaGHm8Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377755; 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=JVZXeFOij00kRcHliLoRJrMyHyqeyRSXeS/4JiKw1+4=; b=iU9zauDRacbuOoy7KnMjtREgfUQLKh4m4lqK+t7ilZ2003HWOx3Zq+waNLG5fWMeFCu9kZ 9EWupGJkvHEIsmAQ== 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 A9F6613A73; Thu, 9 Mar 2023 16:02:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cL2VKBoDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:34 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 076/101] fbdev/sstfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:36 +0100 Message-Id: <20230309160201.5163-77-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/sstfb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c index da296b2ab54a..f422b1882950 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -106,6 +106,7 @@ static bool slowpci; /* slow PCI settings */ */ #define DEFAULT_VIDEO_MODE "640x480@60" +static char *mode_option_buf; static char *mode_option = DEFAULT_VIDEO_MODE; enum { @@ -1301,8 +1302,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -1516,6 +1520,7 @@ static int sstfb_init(void) static void sstfb_exit(void) { pci_unregister_driver(&sstfb_driver); + kfree(mode_option_buf); } From patchwork Thu Mar 9 16:01: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: 661237 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 B2B67C742A7 for ; Thu, 9 Mar 2023 16:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbjCIQEn (ORCPT ); Thu, 9 Mar 2023 11:04:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbjCIQCh (ORCPT ); Thu, 9 Mar 2023 11:02:37 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDE4CF63A3; Thu, 9 Mar 2023 08:02: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 7CE4922165; Thu, 9 Mar 2023 16:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377755; 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=dGao4/+8v2Z8tcDrT7BpBJJdc9l6qPzCWFNHVL07Dog=; b=D48VvNxyqJC0+3C96A/gjn2QUSVi1/g6GhkIJcAn4n37t4cSXLG/Iui1Z0O2BIBcMKx1uy U2C1OzdbUo4rC+Z1apkhOzEFuzeD706Asp9LTwnYiIWjA+phTO7OweRyJMDlvIsFee8scQ 38FrRzcn3S51koKPqh1EMMjDmlGA/gw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377755; 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=dGao4/+8v2Z8tcDrT7BpBJJdc9l6qPzCWFNHVL07Dog=; b=KZkjQPv1Xu+J25KY5xlpJ830zCOjOREV3SPXtwhwc4i6xTueGcrfNcQe8DmtbcNH947aB2 fvHsjrXGWRD53XDQ== 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 193271391B; Thu, 9 Mar 2023 16:02:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8DolBRsDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:35 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 077/101] fbdev/sstfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:37 +0100 Message-Id: <20230309160201.5163-78-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c index f422b1882950..b509020fed74 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -81,6 +81,7 @@ */ #include +#include #include #include #include @@ -1274,16 +1275,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) { + struct option_iter iter; 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")) @@ -1308,6 +1307,9 @@ static int sstfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } From patchwork Thu Mar 9 16:01: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: 662221 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 4FAF8C61DA4 for ; Thu, 9 Mar 2023 16:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232102AbjCIQEo (ORCPT ); Thu, 9 Mar 2023 11:04:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231752AbjCIQCj (ORCPT ); Thu, 9 Mar 2023 11:02:39 -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 47F90F3670; Thu, 9 Mar 2023 08:02: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 F1DEF20195; Thu, 9 Mar 2023 16:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377756; 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=Ky3ShGlxEanIrfpn7zZQyNxaIPMbvxly5yS2adKSlQKys6YXV6fi1OBRbWewTttGHIaOSu s2xuyBmwUuvG75Ivhf31MVNx3P94Ct+9tWD0ucSZR4n+xnZCqst19etrlG8HT9Td+2vZMR u+ITSIGP0nBZcNcAUSjPw2TZR+TYOFE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377756; 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=GnPNBRHENkhw4eDratWcLnPSDFkFWcxIxpeIQ/nVDZLY/KrCK7gb+iaKLgb9LhV2LtTgLM hU1xvk4Jj0vyWxAA== 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 83FEC1391B; Thu, 9 Mar 2023 16:02:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GAFUHxsDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:35 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 078/101] fbdev/stifb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:01:38 +0100 Message-Id: <20230309160201.5163-79-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 661235 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 48BFBC742A7 for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232111AbjCIQEr (ORCPT ); Thu, 9 Mar 2023 11:04:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231747AbjCIQCi (ORCPT ); Thu, 9 Mar 2023 11:02: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 A94B7F7EC0; Thu, 9 Mar 2023 08:02: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 624F322167; Thu, 9 Mar 2023 16:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377756; 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=LTM3CGrNdrXHYDt3uvNdE9HVmQsT5bWUcDXgP42T3Vw=; b=aEwptXQdCCH+AJ6u2L2xYdN2fF80ZjhX3VqQxgndG0KrIdZF76bRLH07xcfggmBfj+K8HX R5CIgQ3pkLkK+HaCIm8UbgRwSKMQvdAWI0xxPC625t6nY2jjWXS4XGhxRRGL0uRIdIp9C/ uFOSm+SYL+Nunq6xFZ5mX35ulJ/XGrg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377756; 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=LTM3CGrNdrXHYDt3uvNdE9HVmQsT5bWUcDXgP42T3Vw=; b=K7r4EOgkK1n3HkqGvnXwPSIxWAcooJM04yuU58O/ZH8Qm8g6hw+VEogus+YPrAqkcW3tFO e6Yk9g42vXUNnQCA== 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 0131613A73; Thu, 9 Mar 2023 16:02:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OBb0OhsDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:35 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 079/101] fbdev/stifb: Constify option string Date: Thu, 9 Mar 2023 17:01:39 +0100 Message-Id: <20230309160201.5163-80-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Constify the internal 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. v2: * say 'stifb' and fix typos in commit message 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 Thu Mar 9 16:01: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: 662222 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 0F9D0C6FD19 for ; Thu, 9 Mar 2023 16:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbjCIQEl (ORCPT ); Thu, 9 Mar 2023 11:04:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231749AbjCIQCi (ORCPT ); Thu, 9 Mar 2023 11:02:38 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ADB7F7EC5; Thu, 9 Mar 2023 08:02: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 CD0EE20198; Thu, 9 Mar 2023 16:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377756; 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=IEKnK2TGMp6xvHidEfAOl+l/D8RLHbl+ZLabvMskLSc=; b=vi06xusirr6ldOsZy4e9GSl5XJsFNCPrbCstz+9i/fse4+a7GLHUhM4hAM8xv+uS9NES5C rqW1RIQOqpTv3wweoRWD9vm/shbKFmJBQaeReQmoQUYZOg5wlM9rR7tFyaXrxuusgiKdj1 YrdSYr/osBmi86JFP25HBEc8eOFz6ro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377756; 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=IEKnK2TGMp6xvHidEfAOl+l/D8RLHbl+ZLabvMskLSc=; b=hpbkYxQ3m6mi8JnxXTD/wpfQlIxx2YgBaNdi9aBPaHSAiuL8cUhb152l6R3Ro7ah9NAgAf yCtePBDsdp7cqODg== 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 65FC91391B; Thu, 9 Mar 2023 16:02:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6H4XGBwDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:36 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 080/101] fbdev/tdfxfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:40 +0100 Message-Id: <20230309160201.5163-81-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tdfxfb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index d17e5e1472aa..ccce6dac443d 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -150,6 +150,7 @@ MODULE_DEVICE_TABLE(pci, tdfxfb_id_table); static int nopan; static int nowrap = 1; /* not implemented (yet) */ static int hwcursor = 1; +static char *mode_option_buf; static char *mode_option; static bool nomtrr; @@ -1589,7 +1590,9 @@ static void __init tdfxfb_setup(char *options) } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; } else { - mode_option = this_opt; + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } } } @@ -1649,6 +1652,7 @@ static int __init tdfxfb_init(void) static void __exit tdfxfb_exit(void) { pci_unregister_driver(&tdfxfb_driver); + kfree(mode_option_buf); } MODULE_AUTHOR("Hannu Mallat "); From patchwork Thu Mar 9 16:01: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: 661239 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 2288AC64EC4 for ; Thu, 9 Mar 2023 16:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232086AbjCIQEh (ORCPT ); Thu, 9 Mar 2023 11:04:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbjCIQCj (ORCPT ); Thu, 9 Mar 2023 11:02:39 -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 8C519F4002; Thu, 9 Mar 2023 08:02: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 43F9220197; Thu, 9 Mar 2023 16:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377757; 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=A4ky75dPBFi9k/HE+Zb+n8M0fUvTx84PLGN/ySVqcxc=; b=NgeqLJjfybkxoTIRgBlxaLMWmKDaYSeF1X7pU8jY1vhCqU8zo9XQ/YcgZKJhBzV2mXyjoK g19QGerRWAYQJJuXVU+C54zaRVyNlbwEplU0wVZJBxbHOTcCDgAQSx0I76q5KeTSNZoCMu +2RIIrd2OqQsUu3Kvx/5pMqMwscMbbY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377757; 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=A4ky75dPBFi9k/HE+Zb+n8M0fUvTx84PLGN/ySVqcxc=; b=sr3Tx4KAiqIF5dx3JVMxYsGw/mXt/+tYG+I3WWJNkiTNG1iQpXWomOCVxzhIJMKZ4XuF7t MFg2XqJOObu/ZICA== 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 D122E13A73; Thu, 9 Mar 2023 16:02:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0F0TMhwDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:36 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 081/101] fbdev/tdfxfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:41 +0100 Message-Id: <20230309160201.5163-82-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index ccce6dac443d..1fdaf328f03e 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -65,6 +65,7 @@ */ #include +#include #include #include #include @@ -1571,16 +1572,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) { + struct option_iter iter; 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")) { @@ -1595,6 +1594,8 @@ static void __init tdfxfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); } #endif From patchwork Thu Mar 9 16:01: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: 661234 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 3788FC6FD19 for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbjCIQEp (ORCPT ); Thu, 9 Mar 2023 11:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231757AbjCIQCk (ORCPT ); Thu, 9 Mar 2023 11:02:40 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F23F4B43; Thu, 9 Mar 2023 08:02: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 AAE8520199; Thu, 9 Mar 2023 16:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377757; 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=aJn8o7oO7CwCuILwl2JzQiMbBkeRnmXaxFrDAwCxN8U=; b=fXbV1Qzw6LMJxHNXe60qu6ZDrqzwHGI1/kll5TDILVXN7pmt/2bhsJnP7xW6o/TFQHJDcs 59PNq2nicPe7LasGax9LCjMfVzz6tBIRJE3o5xYpVQ3NpfMwWKd0SGxdkXLNGKg6TmEOEA ny9MDx+0uJnh1GtOvY110idgnhIhDLY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377757; 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=aJn8o7oO7CwCuILwl2JzQiMbBkeRnmXaxFrDAwCxN8U=; b=/U0nSzLLSxyCFAM90iXf1RdWq2BiPXb9dOCzpVgYQagu40T1mHm444umGb2ChCsYIH+LW4 1Oc7pL9roq++vfBg== 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 48DA81391B; Thu, 9 Mar 2023 16:02:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2APSEB0DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:37 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 082/101] fbdev/tgafb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:42 +0100 Message-Id: <20230309160201.5163-83-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tgafb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c index 14d37c49633c..cf00b8a91bfb 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -59,6 +59,7 @@ static int tgafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info static int tgafb_register(struct device *dev); static void tgafb_unregister(struct device *dev); +static const char *mode_option_buf; static const char *mode_option; static const char *mode_option_pci = "640x480@60"; static const char *mode_option_tc = "1280x1024@72"; @@ -1568,6 +1569,7 @@ static void tgafb_exit(void) { tc_unregister_driver(&tgafb_tc_driver); pci_unregister_driver(&tgafb_pci_driver); + kfree(mode_option_buf); } #ifndef MODULE @@ -1579,9 +1581,11 @@ 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)) { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } else printk(KERN_ERR "tgafb: unknown parameter %s\n", this_opt); From patchwork Thu Mar 9 16:01: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: 662223 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 EBE0BC74A44 for ; Thu, 9 Mar 2023 16:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232090AbjCIQEi (ORCPT ); Thu, 9 Mar 2023 11:04:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbjCIQCk (ORCPT ); Thu, 9 Mar 2023 11:02:40 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A677F4B7A; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id 1943222168; Thu, 9 Mar 2023 16:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377758; 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=RWxZWY+4j2LC2Hx/5MOho9tKeaDUwd+4OyC3KjTGJWQ=; b=zd7cerjvtXSD5/ZFuxef9nGjxgvuTB582pMlonjx0j51ZWbIoghzyETfnBO1ogCSBHS+wF pm1m+RHKt5wLvznwnAxxdzXSslaqlGdNPM3JVLwcNZTk8QkCG+Twrifylhhs9YB9ESyzmb SnFqVtPrZfWNHQ4rLuWfMLE0Y/b6sag= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377758; 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=RWxZWY+4j2LC2Hx/5MOho9tKeaDUwd+4OyC3KjTGJWQ=; b=fqQaqd2BL8XzkymFmmW3qiWauivlafHo91dkqosAWz6s2bUBUVfZRkPtfULXf4jQdZUdCt px33SMNQ8sEdt7Cg== 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 AF17513A73; Thu, 9 Mar 2023 16:02:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OMTAKR0DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:37 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 083/101] fbdev/tgafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:43 +0100 Message-Id: <20230309160201.5163-84-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c index cf00b8a91bfb..0862d9a54aef 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -1573,25 +1574,24 @@ static void tgafb_exit(void) } #ifndef MODULE -static int tgafb_setup(char *arg) +static int tgafb_setup(const char *arg) { + struct option_iter iter; char *this_opt; - if (arg && *arg) { - while ((this_opt = strsep(&arg, ","))) { - if (!*this_opt) - continue; - if (!strncmp(this_opt, "mode:", 5)) { - kfree(mode_option_buf); - mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors - mode_option = mode_option_buf; - } else - printk(KERN_ERR - "tgafb: unknown parameter %s\n", - this_opt); - } + option_iter_init(&iter, arg); + + while (option_iter_next(&iter, &this_opt)) { + if (!strncmp(this_opt, "mode:", 5)) { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + 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 Thu Mar 9 16:01: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: 661238 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 456A5C74A5B for ; Thu, 9 Mar 2023 16:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjCIQEj (ORCPT ); Thu, 9 Mar 2023 11:04:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231759AbjCIQCk (ORCPT ); Thu, 9 Mar 2023 11:02:40 -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 BDA4AF5AAA; Thu, 9 Mar 2023 08:02: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-out1.suse.de (Postfix) with ESMTPS id 7991422169; Thu, 9 Mar 2023 16:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377758; 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=AV+21/bVPDGAbr8VTqIZjqTw5fFW2X2dMnMFickwpWVWfsJ9W8Czdelk58P8hclKTQVsfr nQtXNuzPZMcOVkff5HAhRAKW13TtjUx2gWAlEdFIJPNKlML5K3rUCf+JCm/WnntJNAnVsy tXGGZbT+tlwCGTUDcrs5rPfR9acPHnc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377758; 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=MyGRnIxwQ5h/MHRygWADLYZfzgeWe1uSumvb2FyfsdkD+JY8UL/Rx7c6nweT1Tq2/NcUh1 CqvYKFVmvLEjr9AA== 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 1E5CB1391B; Thu, 9 Mar 2023 16:02:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gJZ0Bh4DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:38 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 084/101] fbdev/tmiofb: Remove unused option string Date: Thu, 9 Mar 2023 17:01:44 +0100 Message-Id: <20230309160201.5163-85-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 662220 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 5F921C74A44 for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232132AbjCIQEu (ORCPT ); Thu, 9 Mar 2023 11:04:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjCIQCl (ORCPT ); Thu, 9 Mar 2023 11:02:41 -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 3252EF63A3; Thu, 9 Mar 2023 08:02: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 DAF912216A; Thu, 9 Mar 2023 16:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377758; 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=vc3MhzDf1ytnsAQte0if7o8oovAVmX2ICQWxWSrkdIk=; b=FiIMR8Ipp0/ClhsoBteb/TvJRP0rhUbP77FigucWxvGsSnBXDm5mji5cyXuX5Dgt1z54Aw CEsrVTLMb3ftymT/7LOvI29Y/RpcTSYV+SULwqpDyPf+IoE82APXQYFfh8i9g0KstECaVl OhkN5jXd7y617eM7cMxRmGHC6h+GUHE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377758; 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=vc3MhzDf1ytnsAQte0if7o8oovAVmX2ICQWxWSrkdIk=; b=DpafcnkE6VWfFGcvZg5uAQpABZ6r8j3l67ZybvrYWYYSn5NnlszCl9POswvSGQpfn/LcKM whxPMWE1BywtHAAQ== 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 7E75F13A73; Thu, 9 Mar 2023 16:02:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aBb6HR4DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:38 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 085/101] fbdev/tridentfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:45 +0100 Message-Id: <20230309160201.5163-86-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/tridentfb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c index 6099b9768ba1..dbde64aef91f 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -61,6 +61,7 @@ static struct fb_fix_screeninfo tridentfb_fix = { /* defaults which are normally overriden by user values */ /* video mode */ +static char *mode_option_buf; static char *mode_option; static int bpp = 8; @@ -1800,8 +1801,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 0; } @@ -1827,6 +1831,7 @@ static int __init tridentfb_init(void) static void __exit tridentfb_exit(void) { pci_unregister_driver(&tridentfb_pci_driver); + kfree(mode_option_buf); } module_init(tridentfb_init); From patchwork Thu Mar 9 16:01: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: 661236 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 70FB3C74A5B for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232122AbjCIQEr (ORCPT ); Thu, 9 Mar 2023 11:04:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbjCIQCl (ORCPT ); Thu, 9 Mar 2023 11:02:41 -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 9CBC8F7EC6; Thu, 9 Mar 2023 08:02: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 4A6372019A; Thu, 9 Mar 2023 16:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377759; 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=UMQfn/Di+mzhMXJ1P/cB4qgg1VwC7tNWXSpJys3dy58=; b=ShYOoj8DlMWCtme6AbxQraL7jF2sMiEHM2PbNQNfqipagCHaT/6O//yr2fBIWfJkILaCXQ RZvZCRtgvr86ZMingR4G6wx61PF2T6qP+f1BeQfa6mA2TJr1Q8rw+qqEOxZifOVgYGss9j gyughj5hbZ0Da81lMAOgOd9XpaAlXAM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377759; 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=UMQfn/Di+mzhMXJ1P/cB4qgg1VwC7tNWXSpJys3dy58=; b=B0IegUKamsGSkJf42+3JE62wFj3Mrhu+I4W5BmUkn9mill0DZQxCwn/Z41shnFe2FcPoie 3XAibMzs4bfJtPBA== 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 DE7801391B; Thu, 9 Mar 2023 16:02:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4IVpNR4DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:38 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 086/101] fbdev/tridentfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:46 +0100 Message-Id: <20230309160201.5163-87-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c index dbde64aef91f..3299806c0f58 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -1775,14 +1776,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) { + struct option_iter iter; 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, "noaccel", 7)) noaccel = 1; else if (!strncmp(opt, "fp", 2)) @@ -1807,6 +1808,9 @@ static int __init tridentfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 0; } #endif From patchwork Thu Mar 9 16:01: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: 662219 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 A4AE5C76188 for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbjCIQEu (ORCPT ); Thu, 9 Mar 2023 11:04:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjCIQCl (ORCPT ); Thu, 9 Mar 2023 11:02:41 -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 25685F7EEF; Thu, 9 Mar 2023 08:02: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 B1E1A2216B; Thu, 9 Mar 2023 16:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377759; 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=MbkEoqNuabDKTrYaFVmNx0VjwVOlQDJULtP3vwgd1E0=; b=Cn8uGqp5M5smyRMMNCsXWHxfc/s4Z5peRZTRDoPdA2g9IOYOgWr2rzh3xx+V4sdGFgxvdv 8yI6Zuhl8I6oaIKM4fKLNPc94cWJ7xQDOixwbE0TlrIk0VRuDROcy0xPywTsRaGcmshX9+ jk/i3u0/vsw2BUXA8EkQ3hGIdJRIWKg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377759; 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=MbkEoqNuabDKTrYaFVmNx0VjwVOlQDJULtP3vwgd1E0=; b=uRdHWmq96txYBHIvZDC762EjfU5koNZU/tZip6TPvrOcv/cYJbOwK+/p+a1gCcTNlvDQXG PBZUyIYWK8ZAhVBw== 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 4EADE13A73; Thu, 9 Mar 2023 16:02:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CJ1DEh8DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:39 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 087/101] fbdev/uvesafb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:47 +0100 Message-Id: <20230309160201.5163-88-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/uvesafb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c index f09f483c219b..ff8f511a00c2 100644 --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c @@ -56,6 +56,7 @@ static u16 maxclk; /* maximum pixel clock */ static u16 maxvf; /* maximum vertical frequency */ static u16 maxhf; /* maximum horizontal frequency */ static u16 vbemode; /* force use of a specific VBE mode */ +static char *mode_option_buf; static char *mode_option; static u8 dac_width = 6; @@ -1851,7 +1852,9 @@ 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; + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; } else { pr_warn("unrecognized option %s\n", this_opt); } @@ -1937,6 +1940,7 @@ static void uvesafb_exit(void) driver_remove_file(&uvesafb_driver.driver, &driver_attr_v86d); platform_device_unregister(uvesafb_device); platform_driver_unregister(&uvesafb_driver); + kfree(mode_option_buf); } module_exit(uvesafb_exit); From patchwork Thu Mar 9 16:01: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: 661233 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 C26ABC76186 for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232141AbjCIQEv (ORCPT ); Thu, 9 Mar 2023 11:04:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbjCIQCm (ORCPT ); Thu, 9 Mar 2023 11:02: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 6CBB2F7EF6; Thu, 9 Mar 2023 08:02: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 25E942216C; Thu, 9 Mar 2023 16:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377760; 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=/dsBu08X7CrCBT10ixXdDAS0haFqJIXlgAumcvDvbBg=; b=FsD5gBy583vIY7YvnpfIJKy9uwiqlhb9qvnQE8ps1jInPHVviMB8rEaW/PmYSER4KTOobP aibSid/g9QFS3VWXaHgS4wei5jKdcFmTTU/w3OEU0btlJw0MR36KBBr+/haDB9hbHMWGFn qzYafoVt13nFr3qXebOnSyeo1sv0PAg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377760; 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=/dsBu08X7CrCBT10ixXdDAS0haFqJIXlgAumcvDvbBg=; b=/nqtmYu+X988xVpabmzApU1pgK/FeOvOlSfibJW+gWR53wche8LJzbjSgv8TAYn9Giu0jW 90PQDH5uY+rtokDQ== 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 B5C201391B; Thu, 9 Mar 2023 16:02:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CIhsKx8DCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:39 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 088/101] fbdev/uvesafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:48 +0100 Message-Id: <20230309160201.5163-89-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c index ff8f511a00c2..13bd8503a06b 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 @@ -1809,16 +1810,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) { + struct option_iter iter; 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")) @@ -1860,6 +1859,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 Thu Mar 9 16:01: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: 662218 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 E290DC7618A for ; Thu, 9 Mar 2023 16:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjCIQEw (ORCPT ); Thu, 9 Mar 2023 11:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjCIQCm (ORCPT ); Thu, 9 Mar 2023 11:02:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1399F8A4A; Thu, 9 Mar 2023 08:02: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 8B85C2216E; Thu, 9 Mar 2023 16:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377760; 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=UWaK8P0g3sCaFuoHIcA5TkOeGtNYmQJWNp0DHIPKSgtkOZKtIoX7/FmyXPBJI7Xs/Wqg3o IPdwwn4Q2cQDI0SgGU9q+TrF/zPdPgWHMnI36GEQe3uKLmB/SzOUX4g5l+n9JaSVr32Dkc /6G74uWNoUdYxkGTIBzA/h/bZD96lR8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377760; 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=Qpcp50lVKeOW4dqdgpyQxI6xdJFmVLB+rsHPNDlQWX1Rt6AB4ARb87qoSFSYp3N0hMQLJ/ NB1qy2X2gHLovWAA== 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 2BBEA1391B; Thu, 9 Mar 2023 16:02:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EFG9CSADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:40 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 089/101] fbdev/valkyriefb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:01:49 +0100 Message-Id: <20230309160201.5163-90-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 662217 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 198F7C7618B for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232155AbjCIQEw (ORCPT ); Thu, 9 Mar 2023 11:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231402AbjCIQCo (ORCPT ); Thu, 9 Mar 2023 11:02: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 A913BF8A6A; Thu, 9 Mar 2023 08:02: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 00FC72216F; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377761; 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=Ahzg3qOQnqmKttHmLkku+DucBs/UrBngr7lLUmjxogk=; b=dsmfX3KGntHoLUbrAb5ZH4Y5RErDBIpwAd9ocfT3wu+mIu6MZKjjfRe8/1VtyntpFS0r3x Mg30vrvB/5N3vCIy5KfkrMS/3TA9fj7ISDo+mm47IwuFDor8aFMLZahcxdWhQqpijTqX1D ASmtqkIbvurk0UvylHMeUp9XTY1pSGQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377761; 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=Ahzg3qOQnqmKttHmLkku+DucBs/UrBngr7lLUmjxogk=; b=IKULeMJxZk8V041juSJKWX9+yvDz4Jltpvsy36rLCi+W8/Ps/PJD06/aKcM/yUeQoGjria gSXhUGqwNlmrCVCw== 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 926871391B; Thu, 9 Mar 2023 16:02:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eDLJIiADCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:40 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 090/101] fbdev/valkyriefb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:50 +0100 Message-Id: <20230309160201.5163-91-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c index b166b7cfe0e5..3c20f392370a 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) { + struct option_iter iter; 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 Thu Mar 9 16:01: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: 662213 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 AF4C1C761AF for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232178AbjCIQE7 (ORCPT ); Thu, 9 Mar 2023 11:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231529AbjCIQCo (ORCPT ); Thu, 9 Mar 2023 11:02: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 50BC7F7ED7; Thu, 9 Mar 2023 08:02: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 6BC6922170; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377761; 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=0P8Tgh1FoQAhGrSiCMIv50ZZoyI5J3PnrRMmYmdVLK2Aq5JGua3ZkSiBLMlhMqVQ+1GYyU QTXRyHEfrzzc7o9PZg3tJKC66D1cjWk/fzcRcudCTj1IFQbZ2y0100O0ipCGX8pcCpOIYZ /3l9s/RWTmfgrz3Q8Tu1urzKjhCEz60= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377761; 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=TB6WBT+lJi7vvrTaYSYiIbfmp1jlbBWpJme2pc8J3M+NesAZ0kjqd/m8JODdEtERVjV8tL F5fkTgZRBKYTBeAg== 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 0525013A73; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MAZRACEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:41 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 091/101] fbdev/vermilion: Remove unused option string Date: Thu, 9 Mar 2023 17:01:51 +0100 Message-Id: <20230309160201.5163-92-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 662216 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 73416C76195 for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbjCIQE6 (ORCPT ); Thu, 9 Mar 2023 11:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbjCIQCp (ORCPT ); Thu, 9 Mar 2023 11:02:45 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26D9F8A70; Thu, 9 Mar 2023 08:02: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 D381522171; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377761; 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=6WgjdpbBXxXsBLz/IEVgF5fpRgaJeZorG1YR+YEngSE=; b=081B+YgdqGdjrANr1SgbBsH3kOj3puNl3kjuTwrcxp2hAH+anEiJYpe7qicjtl3HnEyEWp KWIaYFbl1xCVjipCwYvq8G9XWWzjobnPydit04fo/tZL5AYFHV4qQnD6V835zTThXuP45x TgMzMMw1mJwPLc/CvqEOiVmPXBOE7AA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377761; 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=6WgjdpbBXxXsBLz/IEVgF5fpRgaJeZorG1YR+YEngSE=; b=6MNvP2gLdKTMeRozmrfx5c7pVwULUAclNq27A4YBqUN2kyjKkib9aUFGdWtL4Gg5yvudtz ffM/WXRMxfrqrYDA== 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 70DBC1391B; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4NGrGiEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:41 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 092/101] fbdev/vesafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:52 +0100 Message-Id: <20230309160201.5163-93-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c index 3f8bdfcf51f0..7299cebb6962 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) { + struct option_iter iter; 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 Thu Mar 9 16:01: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: 661231 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 84E9EC7619A for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbjCIQE5 (ORCPT ); Thu, 9 Mar 2023 11:04:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbjCIQCp (ORCPT ); Thu, 9 Mar 2023 11:02: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 929C4F7ECC; Thu, 9 Mar 2023 08:02: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-out2.suse.de (Postfix) with ESMTPS id 455E62018C; Thu, 9 Mar 2023 16:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377762; 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=xlWyJnkuPuu6nOB8pKnY9bz5FaQg8uW0CAoXIDVbCm50gKKdTuLAkyCkcKbRpxToQB3aqi RI9lqEYQL/+I64o8X1ylORGeeHr5g9TdA2f1adJxWqk45TwScSWXzW5gEzWUOQjTgrv151 0F28vVUlS+AvlasBkMdaU9c3lVIXwh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377762; 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=Ci2/DaCW1F0NCKh0fD5Ag8qRu4gP/nqNp4F3MwWn9e/odIUWFPgjeqJnKR34mM8noNmeoK ismdrOuqpsn3vEAQ== 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 D96391391B; Thu, 9 Mar 2023 16:02:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oFIfNCEDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:41 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 093/101] fbdev/vfb: Remove trailing whitespaces Date: Thu, 9 Mar 2023 17:01:53 +0100 Message-Id: <20230309160201.5163-94-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 Thu Mar 9 16:01: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: 661232 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 4768AC7618D for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232161AbjCIQE4 (ORCPT ); Thu, 9 Mar 2023 11:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjCIQCp (ORCPT ); Thu, 9 Mar 2023 11:02: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 0194DF4B7A; Thu, 9 Mar 2023 08:02: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 A5E3C2018E; Thu, 9 Mar 2023 16:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377762; 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=KeY2ExOwmSx8zLHCGIHXA1tubiVzXH1BzWog2OAH98g=; b=LZFm7R8Of8rUK0MPl8Rv51d9MNca4y4qBiUfwCYMAjb8Ez2GFtPGCqBZOI9FyEB1sWV60f 50vBojV0zeTvTjBJcFnwIW0RX2mB44FAJqfg4RWIWVz5sxsOaX+JZP6Wqy69YJasouluLv jPbSywMOwccCbHhprxaXHud+yKVuxlU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377762; 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=KeY2ExOwmSx8zLHCGIHXA1tubiVzXH1BzWog2OAH98g=; b=LwuaA/5VcZNBiLfHYsJBO6Ju3pNq48IVDuopszjyOASThdVEfJypODY6G6ri3qHb31UWkD yWwOSR1FhQJDVFDA== 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 495E013A73; Thu, 9 Mar 2023 16:02:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +AAeESIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:42 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 094/101] fbdev/vfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:54 +0100 Message-Id: <20230309160201.5163-95-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vfb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index 680c88267ef4..de27fe84d820 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -37,6 +37,7 @@ static u_long videomemorysize = VIDEOMEMSIZE; module_param(videomemorysize, ulong, 0); MODULE_PARM_DESC(videomemorysize, "RAM available to frame buffer (in bytes)"); +static char *mode_option_buf; static char *mode_option = NULL; module_param(mode_option, charp, 0); MODULE_PARM_DESC(mode_option, "Preferred video mode (e.g. 640x480-8@60)"); @@ -412,8 +413,11 @@ 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 { + kfree(mode_option_buf); + mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } } return 1; } @@ -543,6 +547,7 @@ static void __exit vfb_exit(void) { platform_device_unregister(vfb_device); platform_driver_unregister(&vfb_driver); + kfree(mode_option_buf); } module_exit(vfb_exit); From patchwork Thu Mar 9 16:01: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: 661229 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 D2C05C761A6 for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232184AbjCIQFA (ORCPT ); Thu, 9 Mar 2023 11:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjCIQCp (ORCPT ); Thu, 9 Mar 2023 11:02:45 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6249FF4002; Thu, 9 Mar 2023 08:02: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 155E02019B; Thu, 9 Mar 2023 16:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377763; 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=zGetZdXUeEv2x/Fcv995cdEBibV8mYINv0DLdPj96AI=; b=Fj94byZ460xsDFnplb2N0lh+i6F2zk4puOsHbXCPjyxeu9EIjRHqZ1KOqmkx+IX5aIzlFq fpNQ+Xg8w2QRQhw0EqbkCTtQk1MJNC9YXJU5EN2MQXrZkyrnAg94vRNtL/4GmsaIxp3G19 2/6C0BRhxN4zzzZCFcY4COzQ6qYikNg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377763; 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=zGetZdXUeEv2x/Fcv995cdEBibV8mYINv0DLdPj96AI=; b=WSDB0EaMEQ6OrPVnvB+sj+PxPuuOIVv3m+vlhqu+M3atDbMsIKvCtMHCCdSee0SPLuAGHh EwdIAt+s6WVpWqBg== 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 A9C1D1391B; Thu, 9 Mar 2023 16:02:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gMGGKCIDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:42 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 095/101] fbdev/vfb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:55 +0100 Message-Id: <20230309160201.5163-96-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index de27fe84d820..7694e5026155 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -10,6 +10,7 @@ * more details. */ +#include #include #include #include @@ -393,8 +394,9 @@ 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) { + struct option_iter iter; char *this_opt; vfb_enable = 0; @@ -404,12 +406,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; @@ -419,6 +418,9 @@ static int __init vfb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + return 1; } #endif /* MODULE */ From patchwork Thu Mar 9 16:01: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: 661230 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 EBF65C77B61 for ; Thu, 9 Mar 2023 16:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232197AbjCIQFB (ORCPT ); Thu, 9 Mar 2023 11:05:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231765AbjCIQCp (ORCPT ); Thu, 9 Mar 2023 11:02:45 -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 D72B4F7EE2; Thu, 9 Mar 2023 08:02: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 7CB1622158; Thu, 9 Mar 2023 16:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377763; 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=jWp/QupJ7lE9lZrkHkA8/CsL9Gj47AgqbuLGp0xrG1c=; b=XRSsNo3dtACqfxy0a48JxdH15rwMVIHpG1l3WXc2kEYIigrEdk28EP+Nn76+l4FNgLwVHz zr4pBxNmpg8zZTyVJdW3FoVYQg+Aihdd4UMunIwiMopFYYjQbpYBaNXdIYjZlzuQqsWjGn 6MRaiG04ik99uB6GQUFFFBsVk2U+7aQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377763; 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=jWp/QupJ7lE9lZrkHkA8/CsL9Gj47AgqbuLGp0xrG1c=; b=1VLdQckklPlS8Lm6AMQ7rfktOYxy4ECYo2JAc26tLf8sFvOswz6SWNJ+7EI3SRphcrBRsc 5Felkaa2IufKu6Dw== 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 1B7D01391B; Thu, 9 Mar 2023 16:02:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KKKyBSMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:43 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 096/101] fbdev/viafb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:01:56 +0100 Message-Id: <20230309160201.5163-97-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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..749aee9f6c56 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; + 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 Thu Mar 9 16:01: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: 662212 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 09481C77B60 for ; Thu, 9 Mar 2023 16:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232211AbjCIQFD (ORCPT ); Thu, 9 Mar 2023 11:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231769AbjCIQCq (ORCPT ); Thu, 9 Mar 2023 11:02:46 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37888F7EC9; Thu, 9 Mar 2023 08:02: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-out2.suse.de (Postfix) with ESMTPS id E51032019C; Thu, 9 Mar 2023 16:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377763; 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=Ewk1zW+eJTNjlZhtMIf7xoC1lhKXLT0JOMFhSzbnk2I=; b=W8t0NpW6nUBoUC6nOtj8OYG4dlb2Wir2e0S7qsu1tGBDg1OVfUMaZC9SfNnFPv83dlgal5 ATx9fPTNlMgxGGrnOxh+/3azWFejpIvlXRgDbHbDThikNI1gTLmbrcm7LNNu67rjERZrL1 mFqMzEQ7gpFZBZ8yZQupXA1CVuXDZHI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377763; 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=Ewk1zW+eJTNjlZhtMIf7xoC1lhKXLT0JOMFhSzbnk2I=; b=nmkM7AlEnDqTw3Pxe33LJ0VWVSWtjwybLvxhhm0zRm+ZLzRBaNwjKqWdKjJyqPghMVb4IO C/JmGbL+n0AJKrCA== 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 80F5813A73; Thu, 9 Mar 2023 16:02:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6NCMHiMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:43 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 097/101] fbdev/vt8623fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:57 +0100 Message-Id: <20230309160201.5163-98-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 kstrdup() and free it in the module's exit function. Done in preparation of constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/vt8623fb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 034333ee6e45..321b1813cf3c 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -95,6 +95,7 @@ static const struct svga_timing_regs vt8623_timing_regs = { /* Module parameters */ +static char *mode_option_buf; static char *mode_option = "640x480-8@60"; static int mtrr = 1; @@ -911,6 +912,7 @@ static void __exit vt8623fb_cleanup(void) { pr_debug("vt8623fb: cleaning up\n"); pci_unregister_driver(&vt8623fb_pci_driver); + kfree(mode_option_buf); } /* Driver Initialisation */ @@ -929,8 +931,10 @@ static int __init vt8623fb_init(void) if (fb_get_options("vt8623fb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + if (option && *option) { + mode_option_buf = kstrdup(option, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } #endif pr_debug("vt8623fb: initializing\n"); From patchwork Thu Mar 9 16:01: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: 662215 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 21920C77B6C for ; Thu, 9 Mar 2023 16:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232217AbjCIQFE (ORCPT ); Thu, 9 Mar 2023 11:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjCIQDE (ORCPT ); Thu, 9 Mar 2023 11:03:04 -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 AE631F8F0B; Thu, 9 Mar 2023 08:02: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-out2.suse.de (Postfix) with ESMTPS id 577792019D; Thu, 9 Mar 2023 16:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377764; 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=qhLabhC1FIHHBl6vHn75Sdi6c+0lehlO1hOW2wnnzIk=; b=nLLiHnJyAkWEMzDS6gjlT7FAdHKqeDNCtYCIowjWNGDofjK1AIIxp8zGGtJcR/KkquSxDT PVrA32O9RAps2X653Z/8p6kX3gRKcE67DEmuX4qka13Y+AmhcKSVcHi/p1ACdn2OXJN8x/ DTPilzT4nPENL7eMgxCCo7c4CL9/Pj0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377764; 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=qhLabhC1FIHHBl6vHn75Sdi6c+0lehlO1hOW2wnnzIk=; b=KoO3w/NPCYL06ZUt0wLOVphV7yy1GS9O2qp8D5I5nJAWbw9LROqi6LRRuxmQXywwjAWvyJ xXny5w07zN9e80Bw== 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 EA5F81391B; Thu, 9 Mar 2023 16:02:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4M1LOCMDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:43 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 098/101] staging/sm750fb: Release g_settings in module-exit function Date: Thu, 9 Mar 2023 17:01:58 +0100 Message-Id: <20230309160201.5163-99-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Free g_settings in module-exit function for symmetry with its allocation in module-init function. Fixes a possible undefined dereference of the pointer. The string g_settings is initialized ifrom within the module-init function lynxfb_init() and used from within the PCI probe function. It is later freed in the PCI device's remove function. Probing another PCI device afterwards accesses g_settings in an undefined state. Fix this by freeing g_settings in lynxfb_exit(). Also streamline the code that creates g_settings in the first place. Signed-off-by: Thomas Zimmermann --- drivers/staging/sm750fb/sm750.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index effc7fcc3703..fa8ae20bb688 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -1093,13 +1093,12 @@ static void lynxfb_pci_remove(struct pci_dev *pdev) iounmap(sm750_dev->pvReg); iounmap(sm750_dev->pvMem); - kfree(g_settings); } static int __init lynxfb_setup(char *options) { - int len; - char *opt, *tmp; + size_t len; + char *opt, *outbuf; if (!options || !*options) { pr_warn("no options.\n"); @@ -1109,11 +1108,10 @@ static int __init lynxfb_setup(char *options) pr_info("options:%s\n", options); len = strlen(options) + 1; - g_settings = kzalloc(len, GFP_KERNEL); - if (!g_settings) + outbuf = kzalloc(len, GFP_KERNEL); + if (!outbuf) return -ENOMEM; - - tmp = g_settings; + g_settings = outbuf; /* * Notes: @@ -1133,12 +1131,11 @@ static int __init lynxfb_setup(char *options) } else if (!strncmp(opt, "dual", strlen("dual"))) { g_dualview = 1; } else { - strcat(tmp, opt); - tmp += strlen(opt); - if (options) - *tmp++ = ':'; - else - *tmp++ = 0; + if (outbuf != g_settings) + *outbuf++ = ':'; // add separator + len = strlen(opt); + memcpy(outbuf, opt, len); + outbuf += len; } } @@ -1186,6 +1183,7 @@ module_init(lynxfb_init); static void __exit lynxfb_exit(void) { pci_unregister_driver(&lynxfb_driver); + kfree(g_settings); } module_exit(lynxfb_exit); From patchwork Thu Mar 9 16:01: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: 662214 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 324C1C77B62 for ; Thu, 9 Mar 2023 16:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjCIQFE (ORCPT ); Thu, 9 Mar 2023 11:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231825AbjCIQDR (ORCPT ); Thu, 9 Mar 2023 11:03:17 -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 20889F8F12; Thu, 9 Mar 2023 08:02: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 BD68421CCF; Thu, 9 Mar 2023 16:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377764; 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=g10CyGX8LN7jmhoB07O8PTYOwqUFbPdF+9x3En0LlPQ=; b=qVY89Ub6EbFQOTKqDemyKSPew7jktkhiNjNPqV6mSd1tpTxpCzi6NY/O2SVA2FQQ1jjcem BjcyTzaawenSa7gVGO8Uh//B/B5zelqoylpQSZfwWTUGlgzYmtB9kp9HEfBcBTe2WtNEXv 0DKXom4/6+gpTGMkZMuDwcOBugxSWvs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377764; 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=g10CyGX8LN7jmhoB07O8PTYOwqUFbPdF+9x3En0LlPQ=; b=cLgZD6S21fT2maB/cW7YcTSSRfcn0OAQtMslOudmC3yWf0xgrJaMhlEI4LRnMeFFSe5Kai q391y6SEol87MVBA== 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 5B64B13A73; Thu, 9 Mar 2023 16:02:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UKdXFSQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:44 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 099/101] staging/sm750fb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:01:59 +0100 Message-Id: <20230309160201.5163-100-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 stringis for the video mode. Allocate each copy's memory with kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/staging/sm750fb/sm750.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index fa8ae20bb688..f0dbf7535ca8 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -911,11 +911,11 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) g_hwcursor = 0; } else { if (!g_fbmode[0]) { - g_fbmode[0] = opt; + g_fbmode[0] = kstrdup(opt, GFP_KERNEL); // ignore errors dev_info(&sm750_dev->pdev->dev, "find fbmode0 : %s\n", g_fbmode[0]); } else if (!g_fbmode[1]) { - g_fbmode[1] = opt; + g_fbmode[1] = kstrdup(opt, GFP_KERNEL); // ignore errors dev_info(&sm750_dev->pdev->dev, "find fbmode1 : %s\n", g_fbmode[1]); } else { @@ -1182,7 +1182,14 @@ module_init(lynxfb_init); static void __exit lynxfb_exit(void) { + size_t i = ARRAY_SIZE(g_fbmode); + pci_unregister_driver(&lynxfb_driver); + + while (i) { + --i; + kfree(g_fbmode[i]); + } kfree(g_settings); } module_exit(lynxfb_exit); From patchwork Thu Mar 9 16:02: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: 661228 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 D061FC77B6D for ; Thu, 9 Mar 2023 16:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232235AbjCIQFG (ORCPT ); Thu, 9 Mar 2023 11:05:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbjCIQDR (ORCPT ); Thu, 9 Mar 2023 11:03:17 -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 BA282F7EDF; Thu, 9 Mar 2023 08:02: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 3014E21CF8; Thu, 9 Mar 2023 16:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377765; 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=ALsO4IX+lXOr2/9jJ7xM7oWEJtpk0lY0JvNUM21acD0=; b=ibeXiYlRwFX3kYpd0p9A7lMTdVMC9Fwe5CosSJaVaakK7R2YBZ3fXTlozkbl/UiL5jTS8y xXFPFpQgBHAUE6pmwaV+xKG4iGnskk7Y/bPBzSTtL3W77qowzQ6ugXnIq17I+ZiAI5CtbK U2JPW0KhaLVuLn52/QgPlViOuwijmU4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377765; 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=ALsO4IX+lXOr2/9jJ7xM7oWEJtpk0lY0JvNUM21acD0=; b=LWt569FfZOyzTosHPQg/ga7WhTjnw20OX+GhU9e53/rp4wj+b9RmbVDPnRjtEZlMaiCGP9 F9Wa7b7tLTzP6RAg== 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 C26901391B; Thu, 9 Mar 2023 16:02:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EDJ2LiQDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:44 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 100/101] staging/sm750fb: Parse option string with struct option_iter Date: Thu, 9 Mar 2023 17:02:00 +0100 Message-Id: <20230309160201.5163-101-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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. v2: * move string handling into separate patches Signed-off-by: Thomas Zimmermann --- drivers/staging/sm750fb/sm750.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index f0dbf7535ca8..0e3712fcf0e0 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,8 +868,9 @@ 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) { + struct option_iter iter; char *opt; int swap; @@ -889,7 +891,9 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) goto NO_PARAM; } - while ((opt = strsep(&src, ":")) != NULL && *opt != 0) { + 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); @@ -924,6 +928,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) { @@ -1095,9 +1101,10 @@ static void lynxfb_pci_remove(struct pci_dev *pdev) iounmap(sm750_dev->pvMem); } -static int __init lynxfb_setup(char *options) +static int __init lynxfb_setup(const char *options) { size_t len; + struct option_iter iter; char *opt, *outbuf; if (!options || !*options) { @@ -1113,16 +1120,9 @@ static int __init lynxfb_setup(char *options) return -ENOMEM; g_settings = outbuf; - /* - * 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; @@ -1139,6 +1139,8 @@ static int __init lynxfb_setup(char *options) } } + 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 Thu Mar 9 16:02: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: 661227 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 B26D1C61DA4 for ; Thu, 9 Mar 2023 16:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232244AbjCIQFH (ORCPT ); Thu, 9 Mar 2023 11:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbjCIQDT (ORCPT ); Thu, 9 Mar 2023 11:03:19 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3B7AF8F16; Thu, 9 Mar 2023 08:02: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 AC3A72017C; Thu, 9 Mar 2023 16:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377765; 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=x6nOdyACdlp2+E7E8cMNwfz97h9DQ5BqN65CR4y0Dbo=; b=lQYJVy+mhC2ctbwQXeLl/39u2oV6GDl6doXRuE0K58xJgh4yJ8lYSd9Fvn0QdZaGXrgXhb BT9Q58D34KuI6piQCudvOYdu1LuRS53gBS+EAVNGc/IBIJ9UZUB63HXpeu3O/1ZVwnjawG JPrhXzKgUUApgMeEFSU7z+VMOgZ9c6g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377765; 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=x6nOdyACdlp2+E7E8cMNwfz97h9DQ5BqN65CR4y0Dbo=; b=Yo+F/nO3imM1VV8MOoD01kgpwd/AbpFgU6nrXqnWSDfc/cqr4DLUa8KuX01aJNtCmImYKi CGircmhCF23YFvDw== 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 39BD41391B; Thu, 9 Mar 2023 16:02:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SA/sDCUDCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:45 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 101/101] fbdev: Constify option strings Date: Thu, 9 Mar 2023 17:02:01 +0100 Message-Id: <20230309160201.5163-102-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-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 0e3712fcf0e0..3d7cde9add4e 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -1165,7 +1165,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 3fed89e03554..27e6796b27b6 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 a09edc576437..f0ed718a4f3c 100644 --- a/drivers/video/fbdev/amifb.c +++ b/drivers/video/fbdev/amifb.c @@ -3539,7 +3539,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 98c710cadaab..7e9f5b37fd50 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -1188,7 +1188,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 6e625ac020b5..2ede6ce0ec0e 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -2991,7 +2991,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 ee2be122de2d..e7e1c7c0da92 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -2509,7 +2509,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 f4b22d2f0d3d..73a54738f58c 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c @@ -3965,7 +3965,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 975323e82f52..a44f9c423703 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -2611,7 +2611,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 0c063c8e6312..4034aeb37d45 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; 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 43b6a9dfeec4..9e84a1095d2f 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; char *this_opt; char *endptr; diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index a5e99a8feadd..dc900f2fcd01 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -2363,7 +2363,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 65e2f9949420..a02a5ea99a7a 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 f21d11a73455..c6a46e870e98 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 be77a76f7d1d..1fc1dee75552 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 a787884a6a7f..79607301e176 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 78996995568c..c0c13135a6e1 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -1903,7 +1903,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 d20ef48263f3..a5e480964fa4 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 6f1e9aadc192..c51e69b98ba8 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 aede22566775..6a1391f88599 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -512,7 +512,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 855dc96b5669..2496bf85b6f3 100644 --- a/drivers/video/fbdev/geode/lxfb_core.c +++ b/drivers/video/fbdev/geode/lxfb_core.c @@ -650,7 +650,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 742331d0f08b..e39997a36ccc 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; char *this_opt; diff --git a/drivers/video/fbdev/gxt4500.c b/drivers/video/fbdev/gxt4500.c index 65cb44c281c1..21c0fbddcbdb 100644 --- a/drivers/video/fbdev/gxt4500.c +++ b/drivers/video/fbdev/gxt4500.c @@ -781,7 +781,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 6da2f3b7846d..2c852f3ce450 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -1289,7 +1289,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 952d1a69dfb9..428bd5b53e98 100644 --- a/drivers/video/fbdev/i810/i810_main.c +++ b/drivers/video/fbdev/i810/i810_main.c @@ -2150,7 +2150,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 1e2b45faa26b..98a9a5891822 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 d4e347aca0b0..ca67b32a29dd 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(struct platform_device *pdev) { - char *options = NULL; + const char *options = NULL; struct option_iter iter; char *opt; diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index 43d677897392..664a8625e25c 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -385,7 +385,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 ccfec4e55ecf..903f0ac03bca 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -792,7 +792,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 c7e17a14daf1..dbddf9e83b2f 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 4c2086136e9b..c1d1076bc172 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 ca58afe366b4..04818f352eea 100644 --- a/drivers/video/fbdev/mx3fb.c +++ b/drivers/video/fbdev/mx3fb.c @@ -1655,7 +1655,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; char *opt; diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 01ed78d987b1..21e8a72cda90 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -2213,7 +2213,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 d779163f919a..bd649539181f 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -1532,7 +1532,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 fa15b932b323..07b7d5e61895 100644 --- a/drivers/video/fbdev/ocfb.c +++ b/drivers/video/fbdev/ocfb.c @@ -412,7 +412,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 db5256c71f5b..8715eaf8ddf6 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 33bf75309815..ab75df9d0bb6 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 38c5c57ce2b0..d87ceaaf529d 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -1809,7 +1809,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 c4d4f08b4114..500a8c1130c6 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -1545,7 +1545,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 575b2911977a..62236bbb02b5 100644 --- a/drivers/video/fbdev/ps3fb.c +++ b/drivers/video/fbdev/ps3fb.c @@ -1257,7 +1257,7 @@ static struct ps3_system_bus_driver ps3fb_driver = { static int __init ps3fb_setup(void) { - char *options; + const char *options; struct option_iter iter; char *this_opt; diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index c332f2c38114..acc81fb11da1 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c @@ -1085,7 +1085,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 d2db9c20d515..0699710b0beb 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 7f35edad249e..934c6e30109b 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -2167,7 +2167,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 37f5ea25efd6..824325eb9fbe 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1562,7 +1562,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 4650688fd23c..a6e573b2d996 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -2560,7 +2560,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 9f63812a5f66..d8109dd20bc6 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 ee6944d0ebc1..f6efad18e4d7 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 a83f48fce5b1..c6232bc688ea 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1755,7 +1755,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 b509020fed74..7a0a612a7658 100644 --- a/drivers/video/fbdev/sstfb.c +++ b/drivers/video/fbdev/sstfb.c @@ -1507,7 +1507,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 1fdaf328f03e..3158644454d7 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -1635,7 +1635,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 0862d9a54aef..ad88fc0cd01e 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -1600,7 +1600,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 3299806c0f58..2a70b48e6d15 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -1818,7 +1818,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 13bd8503a06b..98e074d3e61b 100644 --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c @@ -1886,7 +1886,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 3c20f392370a..daf218632d53 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 7299cebb6962..5d909d88a251 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 7694e5026155..b68c0dd747cf 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -513,7 +513,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 749aee9f6c56..40a4739ff060 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; char *this_opt; diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 321b1813cf3c..9bd908dace15 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -919,9 +919,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;