From patchwork Mon Mar 6 16:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 64899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1935050wrd; Mon, 6 Mar 2023 08:23:29 -0800 (PST) X-Google-Smtp-Source: AK7set/f1G5U4WHw5ImGYVE6ASb+ReABRNPszI4HUXipRV9PAEGLwjmIKDJFcy0n0hSJRVEuc/QE X-Received: by 2002:a05:6a20:918a:b0:be:ea27:3c16 with SMTP id v10-20020a056a20918a00b000beea273c16mr9783571pzd.35.1678119809038; Mon, 06 Mar 2023 08:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678119809; cv=none; d=google.com; s=arc-20160816; b=Bh6cplJUAy0G7EnEXv1V3KjXb3NTgWdNn4RRqLmd7r7N5jX2d3MGMT6x/DqnOKcDv5 CCSOu7JiLaxmcaSQRi8x/be6MwThvYS1RyhPzq1Slfd7tik5LqeUN9re4FlptAUP+LjE +K0yCwo9MWlJ9YTAhTAFv3RGiFd3hHUppI6Cbn13CPpsDo/bY9LzcssNUOulcR/EgMNK Wq1GZqMOoGJKvhCeuxjDcxI+YRSTduYk5wR1kuj4d6qOMGa3kLVp4Sk8naRrkAOxt9Bu bKJCFKnog9nstiAyJSM6tma7uHcOpzLbDG3Am3lRaUsyjs0UcbMw2ZmVm1s32+D/Wo7U QJww== 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=QCuFu5SU57CJHGfgdFQfRit83nbssA/Udz2hcttdwvo=; b=xOerXlEPve/TQMEfQfCLL7sAFPhOkLMpHGwiToJpllG7IUgykjXimV4MF2huId7Oec zbvvzaPCTf+9TKKE9mzXTr60vhsQgXx65XR3p1WFLYR6pLfx4hisIootDwL0WFM6Wq8i vWFJ5/oqL6HF9/4wr+ciPyCGqeqW3jeU3bf6HUsQHzzssgzv07GMNJt4w9mFZTQZ/iZ9 UZR3Fia4LeGbMsq8jJoIYuWjRqgNtc4kTtJ1afFSXJ+jt43aojSWFYtvL/2SdL8YvJVo ngKDiQbClSWhx1TaPGW8ZKxruSrX2OJabYcjNcZXyTcsVwJGucvfPOrponqg0uplCSKv b2pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W1nzjeHY; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=P1f84vfZ; 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 5-20020a630705000000b004a4eae7c943si9389755pgh.535.2023.03.06.08.23.17; Mon, 06 Mar 2023 08:23:29 -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=W1nzjeHY; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=P1f84vfZ; 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 S231579AbjCFQG2 (ORCPT + 99 others); Mon, 6 Mar 2023 11:06:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjCFQBH (ORCPT ); Mon, 6 Mar 2023 11:01:07 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2C0E33463; Mon, 6 Mar 2023 08:01:00 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 66A7B1FEFF; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCuFu5SU57CJHGfgdFQfRit83nbssA/Udz2hcttdwvo=; b=W1nzjeHYtW6hzk14lqyszCbBcEyq+8sp1neVZkcFBMWzDWHpoD8hvd9fJ3XnrradACZnRR V76iuXULIzy+1BbZuk5joOrpdRBBC4XeTuNp/6Oli/pO5cyLRKWRInJPHx7z8l5wz2cdNC BHDp6sWJypFqjb5/34UCDmkWLRk1b/I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QCuFu5SU57CJHGfgdFQfRit83nbssA/Udz2hcttdwvo=; b=P1f84vfZfPvK+9BrjhaXylpZL4FXUF/HeEJ+a5miwhRpk/t6QiJVhJ316MSaNST23ETt/X OFH2X0fV9excSxDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0A93113A6A; Mon, 6 Mar 2023 16:00:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CDilATsOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:59 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 90/99] fbdev/valkyriefb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 17:00:07 +0100 Message-Id: <20230306160016.4459-91-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 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?1759636156484928194?= X-GMAIL-MSGID: =?utf-8?q?1759636156484928194?= Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/valkyriefb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c index b166b7cfe0e5..a787b0142d00 100644 --- a/drivers/video/fbdev/valkyriefb.c +++ b/drivers/video/fbdev/valkyriefb.c @@ -39,6 +39,7 @@ * more details. */ +#include #include #include #include @@ -90,7 +91,7 @@ struct fb_info_valkyrie { u32 pseudo_palette[16]; }; -static int valkyriefb_setup(char*); +static int valkyriefb_setup(const char *options); static int valkyriefb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); @@ -545,14 +546,14 @@ static int __init valkyrie_init_info(struct fb_info *info, /* * Parse user specified options (`video=valkyriefb:') */ -static int __init valkyriefb_setup(char *options) +static int __init valkyriefb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { if (!strncmp(this_opt, "vmode:", 6)) { int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX) @@ -571,6 +572,9 @@ static int __init valkyriefb_setup(char *options) } } } + + option_iter_release(&iter); + return 0; }