Message ID | 20230306160016.4459-11-tzimmermann@suse.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1922524wrd; Mon, 6 Mar 2023 08:03:15 -0800 (PST) X-Google-Smtp-Source: AK7set9S73FXUWmIt8BxSmnJYvtBfU3amQCN466EbN31yNFjaLUgatMkUX0YvjsTlbKoVclWG95T X-Received: by 2002:aa7:9496:0:b0:5a8:ae97:2273 with SMTP id z22-20020aa79496000000b005a8ae972273mr9911235pfk.25.1678118595434; Mon, 06 Mar 2023 08:03:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678118595; cv=none; d=google.com; s=arc-20160816; b=mzQn2/wHc6YhWITqabiCYfi7z27yT27IaawMT11oLSyKI4wl3oBvJjVLeKIPDJ3GWB 8CGVFQVRPQmjuhwKklITZraLV+J23s2eMNPcd6/R5dbDfiLQL+rR66WXzRpoZ7DFTKmL FC49KskMuoSd4+nGVAw/mnkH8hltRRLCa+v+ejcHtOde/OA3J5W8dZZyOK0+Mq12ogQh XR0r8tU4NUMTJbZTq4077N9T5YN4O9kZAo8eu+fjzNuAX2CjJz4V3hupxDESwmyiXOs+ vzO2YQcN2aI6lFBsdAVV9cRBrrOqPTYFTuaWLL032clodQFGtaLQyNIsdHVzxZQID0Fv Wf5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=vW0Ol4SV/VF9Oy6zvE1dkGppBSF1ye6q+ZpyZhscWGg=; b=DWk/qBuX0V13cOHCDNs52e55wIbCpaFPaEa5UJi45N2/m4eJ7dgqWYrHHbEgKFZ7rj Al5sIkBILJ4W61Xdn336tzwj8N5E740AjTA6Pe5+s97Rg3FD1ZJR7OFmMi7j59sPpg3b QpP9VJMz2zOOImYo1DClxGFTI6U3JD8yxUJUZK3ZFBK06XBQP+GkXuixjIwRrkBfFlWq Oy+7zKB0pDpVkqNrRUjGZuFvRmKODCRXE1gu5BmGJbBDMb0UeI2y1/8SxFL8F/qPTyKD 1A49rxmdkOSVaMr1MiP/jQT6pLk+Fs3akmXPYbytqNIeYrcunDgRTL9bcYEbnENscXx8 R09w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=s2t6HZxN; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u69-20020a638548000000b00478368ceee9si9767949pgd.235.2023.03.06.08.02.58; Mon, 06 Mar 2023 08:03:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=s2t6HZxN; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbjCFQA7 (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 11:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjCFQAb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 11:00:31 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECE12E0D3; Mon, 6 Mar 2023 08:00:29 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2149C22384; Mon, 6 Mar 2023 16:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vW0Ol4SV/VF9Oy6zvE1dkGppBSF1ye6q+ZpyZhscWGg=; b=s2t6HZxNp2vyhC92hpPPuy5KnMNHVjZUkvHxsdoE9ro2sw1Jt+S4kGZPAZDGYA2+P8ZG/3 We+YjqMKQydkpiwakk7or+c9HgB6BfqI3jiAGBh7DXSL0/apIIw1mN/0YUQaRqnPg0y7Mb yQrB5SUrakfUCCHEZCDLufdlaD2eKYE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vW0Ol4SV/VF9Oy6zvE1dkGppBSF1ye6q+ZpyZhscWGg=; b=IJz+A+PqwW/VxnAl/Xw9sr3jtwXAyRnqxXipfpVfJp1kPa3tUf0/XrKlu3ZctUZe0jOvfH YpWKCZ6hV7jeO0BA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BC84613A6A; Mon, 6 Mar 2023 16:00:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iAsXLRsOBmQ/PwAAMHmgww (envelope-from <tzimmermann@suse.de>); Mon, 06 Mar 2023 16:00:27 +0000 From: Thomas Zimmermann <tzimmermann@suse.de> To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann <tzimmermann@suse.de> Subject: [PATCH 10/99] fbdev/atafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:58:47 +0100 Message-Id: <20230306160016.4459-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759634884296249103?= X-GMAIL-MSGID: =?utf-8?q?1759634884296249103?= |
Series |
fbdev: Fix memory leak in option parsing
|
|
Commit Message
Thomas Zimmermann
March 6, 2023, 3:58 p.m. UTC
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 <tzimmermann@suse.de>
---
drivers/video/fbdev/atafb.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
Comments
Hi Thomas, I love your patch! Perhaps something to improve: [auto build test WARNING on drm-misc/drm-misc-next] [also build test WARNING on staging/staging-testing staging/staging-next staging/staging-linus linus/master v6.3-rc1 next-20230306] [cannot apply to deller-parisc/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230306160016.4459-11-tzimmermann%40suse.de patch subject: [PATCH 10/99] fbdev/atafb: Parse option string with struct option_iter config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230307/202303070232.fCaufe3z-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/c5b52a9aafa2bf0107e27c7c2aa66bee9a449521 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524 git checkout c5b52a9aafa2bf0107e27c7c2aa66bee9a449521 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/video/fbdev/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202303070232.fCaufe3z-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/video/fbdev/atafb.c: In function 'ext_setcolreg': drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not used [-Wunused-but-set-variable] 2187 | unsigned char tmp = INB(0x3da); \ | ^~~ drivers/video/fbdev/atafb.c:2210:17: note: in expansion of macro 'DACDelay' 2210 | DACDelay; | ^~~~~~~~ drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not used [-Wunused-but-set-variable] 2187 | unsigned char tmp = INB(0x3da); \ | ^~~ drivers/video/fbdev/atafb.c:2212:17: note: in expansion of macro 'DACDelay' 2212 | DACDelay; | ^~~~~~~~ drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not used [-Wunused-but-set-variable] 2187 | unsigned char tmp = INB(0x3da); \ | ^~~ drivers/video/fbdev/atafb.c:2214:17: note: in expansion of macro 'DACDelay' 2214 | DACDelay; | ^~~~~~~~ drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not used [-Wunused-but-set-variable] 2187 | unsigned char tmp = INB(0x3da); \ | ^~~ drivers/video/fbdev/atafb.c:2216:17: note: in expansion of macro 'DACDelay' 2216 | DACDelay; | ^~~~~~~~ drivers/video/fbdev/atafb.c: In function 'atafb_copyarea': drivers/video/fbdev/atafb.c:2464:13: warning: variable 'rev_copy' set but not used [-Wunused-but-set-variable] 2464 | int rev_copy = 0; | ^~~~~~~~ drivers/video/fbdev/atafb.c: In function 'atafb_setup': >> drivers/video/fbdev/atafb.c:2948:44: warning: passing argument 1 of 'get_video_mode' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 2948 | if ((temp = get_video_mode(this_opt))) { | ^~~~~~~~ drivers/video/fbdev/atafb.c:529:33: note: expected 'char *' but argument is of type 'const char *' 529 | static int get_video_mode(char *vname) | ~~~~~~^~~~~ >> drivers/video/fbdev/atafb.c:2973:50: warning: passing argument 1 of 'atafb_setup_ext' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 2973 | atafb_setup_ext(this_opt + 9); | ~~~~~~~~~^~~ drivers/video/fbdev/atafb.c:2720:42: note: expected 'char *' but argument is of type 'const char *' 2720 | static void __init atafb_setup_ext(char *spec) | ~~~~~~^~~~ >> drivers/video/fbdev/atafb.c:2976:50: warning: passing argument 1 of 'atafb_setup_int' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 2976 | atafb_setup_int(this_opt + 9); | ~~~~~~~~~^~~ drivers/video/fbdev/atafb.c:2837:42: note: expected 'char *' but argument is of type 'const char *' 2837 | static void __init atafb_setup_int(char *spec) | ~~~~~~^~~~ >> drivers/video/fbdev/atafb.c:2984:51: warning: passing argument 1 of 'atafb_setup_mcap' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 2984 | atafb_setup_mcap(this_opt + 11); | ~~~~~~~~~^~~~ drivers/video/fbdev/atafb.c:2873:43: note: expected 'char *' but argument is of type 'const char *' 2873 | static void __init atafb_setup_mcap(char *spec) | ~~~~~~^~~~ >> drivers/video/fbdev/atafb.c:2989:51: warning: passing argument 1 of 'atafb_setup_user' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 2989 | atafb_setup_user(this_opt + 1); | ~~~~~~~~~^~~ drivers/video/fbdev/atafb.c:2910:43: note: expected 'char *' but argument is of type 'const char *' 2910 | static void __init atafb_setup_user(char *spec) | ~~~~~~^~~~ vim +2948 drivers/video/fbdev/atafb.c ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2836 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 @2837 static void __init atafb_setup_int(char *spec) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2838 { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2839 /* Format to config extended internal video hardware like OverScan: a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2840 * "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2841 * Explanation: a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2842 * <xres>: x-resolution a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2843 * <yres>: y-resolution a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2844 * The following are only needed if you have an overscan which a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2845 * needs a black border: a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2846 * <xres_max>: max. length of a line in pixels your OverScan hardware would allow a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2847 * <yres_max>: max. number of lines your OverScan hardware would allow a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2848 * <offset>: Offset from physical beginning to visible beginning a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2849 * of screen in bytes ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2850 */ ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2851 int xres; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2852 char *p; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2853 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2854 if (!(p = strsep(&spec, ";")) || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2855 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2856 xres = simple_strtoul(p, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2857 if (!(p = strsep(&spec, ";")) || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2858 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2859 sttt_xres = xres; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2860 tt_yres = st_yres = simple_strtoul(p, NULL, 10); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2861 if ((p = strsep(&spec, ";")) && *p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2862 sttt_xres_virtual = simple_strtoul(p, NULL, 10); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2863 if ((p = strsep(&spec, ";")) && *p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2864 sttt_yres_virtual = simple_strtoul(p, NULL, 0); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2865 if ((p = strsep(&spec, ";")) && *p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2866 ovsc_offset = simple_strtoul(p, NULL, 0); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2867 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2868 if (ovsc_offset || (sttt_yres_virtual != st_yres)) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2869 use_hwscroll = 0; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2870 } ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2871 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2872 #ifdef ATAFB_FALCON ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2873 static void __init atafb_setup_mcap(char *spec) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2874 { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2875 char *p; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2876 int vmin, vmax, hmin, hmax; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2877 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2878 /* Format for monitor capabilities is: <Vmin>;<Vmax>;<Hmin>;<Hmax> ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2879 * <V*> vertical freq. in Hz ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2880 * <H*> horizontal freq. in kHz ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2881 */ ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2882 if (!(p = strsep(&spec, ";")) || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2883 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2884 vmin = simple_strtoul(p, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2885 if (vmin <= 0) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2886 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2887 if (!(p = strsep(&spec, ";")) || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2888 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2889 vmax = simple_strtoul(p, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2890 if (vmax <= 0 || vmax <= vmin) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2891 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2892 if (!(p = strsep(&spec, ";")) || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2893 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2894 hmin = 1000 * simple_strtoul(p, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2895 if (hmin <= 0) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2896 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2897 if (!(p = strsep(&spec, "")) || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2898 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2899 hmax = 1000 * simple_strtoul(p, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2900 if (hmax <= 0 || hmax <= hmin) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2901 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2902 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2903 fb_info.monspecs.vfmin = vmin; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2904 fb_info.monspecs.vfmax = vmax; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2905 fb_info.monspecs.hfmin = hmin; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2906 fb_info.monspecs.hfmax = hmax; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2907 } ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2908 #endif /* ATAFB_FALCON */ ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2909 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2910 static void __init atafb_setup_user(char *spec) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2911 { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2912 /* Format of user defined video mode is: <xres>;<yres>;<depth> ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2913 */ ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2914 char *p; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2915 int xres, yres, depth, temp; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2916 a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2917 p = strsep(&spec, ";"); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2918 if (!p || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2919 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2920 xres = simple_strtoul(p, NULL, 10); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2921 p = strsep(&spec, ";"); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2922 if (!p || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2923 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2924 yres = simple_strtoul(p, NULL, 10); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2925 p = strsep(&spec, ""); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2926 if (!p || !*p) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2927 return; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2928 depth = simple_strtoul(p, NULL, 10); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2929 temp = get_video_mode("user0"); a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2930 if (temp) { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2931 default_par = temp; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2932 atafb_predefined[default_par - 1].xres = xres; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2933 atafb_predefined[default_par - 1].yres = yres; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2934 atafb_predefined[default_par - 1].bits_per_pixel = depth; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2935 } ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2936 } ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2937 c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2938 static int __init atafb_setup(const char *options) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2939 { c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2940 struct option_iter iter; c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2941 const char *this_opt; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2942 int temp; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2943 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2944 if (!options || !*options) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2945 return 0; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2946 c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2947 while (option_iter_next(&iter, this_opt)) { a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 @2948 if ((temp = get_video_mode(this_opt))) { 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2949 static char mode_option_buf[256]; 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2950 int ret; 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2951 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2952 ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2953 if (WARN(ret < 0, "atafb: ignoring invalid option, ret=%d\n", ret)) 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2954 continue; 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2955 if (WARN(ret >= sizeof(mode_option_buf), "atafb: option too long\n")) 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2956 continue; 1d84bc16e985b8 drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2957 mode_option = mode_option_buf; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2958 default_par = temp; a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2959 } else if (!strcmp(this_opt, "inverse")) c7ef5e285c842b drivers/video/fbdev/atafb.c Geert Uytterhoeven 2022-07-11 2960 fb_invert_cmaps(); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2961 else if (!strncmp(this_opt, "hwscroll_", 9)) { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2962 hwscroll = simple_strtoul(this_opt + 9, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2963 if (hwscroll < 0) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2964 hwscroll = 0; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2965 if (hwscroll > 200) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2966 hwscroll = 200; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2967 } ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2968 #ifdef ATAFB_EXT ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2969 else if (!strcmp(this_opt, "mv300")) { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2970 external_bitspercol = 8; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2971 external_card_type = IS_MV300; a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2972 } else if (!strncmp(this_opt, "external:", 9)) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 @2973 atafb_setup_ext(this_opt + 9); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2974 #endif ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2975 else if (!strncmp(this_opt, "internal:", 9)) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 @2976 atafb_setup_int(this_opt + 9); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2977 #ifdef ATAFB_FALCON ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2978 else if (!strncmp(this_opt, "eclock:", 7)) { ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2979 fext.f = simple_strtoul(this_opt + 7, NULL, 10); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2980 /* external pixelclock in kHz --> ps */ ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2981 fext.t = 1000000000 / fext.f; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2982 fext.f *= 1000; a100501212f2e2 drivers/video/atafb.c Michael Schmitz 2007-05-01 2983 } else if (!strncmp(this_opt, "monitorcap:", 11)) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 @2984 atafb_setup_mcap(this_opt + 11); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2985 #endif ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2986 else if (!strcmp(this_opt, "keep")) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2987 DontCalcRes = 1; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2988 else if (!strncmp(this_opt, "R", 1)) ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 @2989 atafb_setup_user(this_opt + 1); ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2990 } c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2991 c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2992 option_iter_release(&iter); c5b52a9aafa2bf drivers/video/fbdev/atafb.c Thomas Zimmermann 2023-03-06 2993 ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2994 return 0; ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2995 } ^1da177e4c3f41 drivers/video/atafb.c Linus Torvalds 2005-04-16 2996
diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index 331e72096ebb..82d5567f2ffb 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -47,6 +47,7 @@ #define ATAFB_EXT #define ATAFB_FALCON +#include <linux/cmdline.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> @@ -2934,17 +2935,16 @@ static void __init atafb_setup_user(char *spec) } } -static int __init atafb_setup(char *options) +static int __init atafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; int temp; if (!options || !*options) return 0; - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; + while (option_iter_next(&iter, this_opt)) { if ((temp = get_video_mode(this_opt))) { static char mode_option_buf[256]; int ret; @@ -2988,6 +2988,9 @@ static int __init atafb_setup(char *options) else if (!strncmp(this_opt, "R", 1)) atafb_setup_user(this_opt + 1); } + + option_iter_release(&iter); + return 0; }