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: 66946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp372552wrd; Thu, 9 Mar 2023 08:05:06 -0800 (PST) X-Google-Smtp-Source: AK7set/a/M7r353WUvOUINA+4RsVjXTR5JzksRX7+9s9sWj/kBv3EZN6twUWV+I8dLeoAxCzC0/R X-Received: by 2002:a17:90a:498b:b0:236:84a:8d9d with SMTP id d11-20020a17090a498b00b00236084a8d9dmr23202166pjh.39.1678377906439; Thu, 09 Mar 2023 08:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678377906; cv=none; d=google.com; s=arc-20160816; b=KnnY4f32x/4K9jfs9TQ5s3fuAmoD/zrpxF/JJgre6RZDvjW6plgMid1vtlznZmts+H WIs5Yv5na4Rq32bDarbkOw6nBSk3G1Jrkt9J4xKaSgTdTdcplk6uiT7wJezZk3sqV/8Q bLSB7lSYNf+GPTtjm+OBIP15gN3Oj4G8/YmsYgOI/8Kr/ze0N+PzTwnNSSt59WTr+MZS 7Ryvef1wdczQ0IwMSh27jcbH8yRNTX1lLk18Q9bSUb7bTrIGbhddliOHtWT3NafWByuw Fi71QdpW87J7hySVc87L8QHaPSLIOi2sjoPND13DsVIDABlYw0iBPbRBoNxF8IMJRft2 FG8g== 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=armA2RVjP0J+ugM2i/E2t8spkqjiPSbrGaAq9XUWPvU=; b=SS9BCS1ERPav/HDOSUdUlXXIBU4XLk4KVvIpW3+AdlWRdumneN6qTGvEKB4InyHeJ7 yrR+KtP6T8XTQZvknvZ02P5VWyL344lJhnkSk2W5Gg8MUcDkbzuVFoZanXEmjn8mgmo8 Tve01jcXyH6BiCnsGVhqynIZ8PJDvu4jvjWlRCBfcl73in0LF3micIHMY5HCxPGpyLpK Yk60dFhxgY5KfF5HfNRXDh6yiCwITIXE7BTLPG9QGDHcQ38uPyGmPnISIv30X6Gnv1gA RDABE8s8g581Tj/LHNAjLFHV5Tpg9wVsZ5zJoTtZiMWYVtNwYBl3mdrzKFywXKFbdypV GCRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="ryF/T115"; 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 o88-20020a17090a0a6100b00230a3b016fesi156402pjo.66.2023.03.09.08.04.52; Thu, 09 Mar 2023 08:05:06 -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="ryF/T115"; 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 S232048AbjCIQEN (ORCPT + 99 others); Thu, 9 Mar 2023 11:04:13 -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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759906791435803847?= X-GMAIL-MSGID: =?utf-8?q?1759906791435803847?= 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 */