From patchwork Mon Mar 6 15:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 64877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1933603wrd; Mon, 6 Mar 2023 08:21:03 -0800 (PST) X-Google-Smtp-Source: AK7set/OThx/EXV2Is9EWt1YKuCPm1v4fTZjq+UMHWhJQHm9hzWa3G60tG9XWft/255Vy2HP3T7M X-Received: by 2002:a17:90b:4a83:b0:234:a9df:db96 with SMTP id lp3-20020a17090b4a8300b00234a9dfdb96mr12254834pjb.33.1678119663519; Mon, 06 Mar 2023 08:21:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678119663; cv=none; d=google.com; s=arc-20160816; b=dr8zLTL36dETGzxSYC89js9epwhqguLXPFmTwsMpK/jqkoeb+9+GdlsPs32LkyhEPR XaT0kjfQSvcTENsYheWLh01hGWmv/OeUS7qjfQruZEQkvXDgzzlhRWBwVdHnSoydchl0 GIKvUmf1GINsEG0Nd5ZzfwQHT4HIZft2R+mLqC1NvZw15AJdLnvlRMKLKgiPyLaiaHeZ K41KA2IUmEqIU4pUmS4uVL7h1ZPcAiSvpmaHt0ejB60wNLBoCMPj8aiWohn5PvYT/Jq0 1NHjj/0e3g80B8g6EcigpD48whAiaJbXX3dpM7DmZijp9f4EKv3b/8OYsDo707twxRjz 3SCQ== 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=0DwH9PbkOKEqD3wmCjB0TQMZNUTuSApTKev00H3660E=; b=lw1hlp/DUAuYH71LOUUOwatUCCBw545jRV2qnJoL5wfNhxJgGL6ta6BMZOZb5TJOEr mWpUq+lnli/DfuZI+YbjJk2pdq2RVadQVoMmgUDuWjVhAMKjKhegtAWsfJHAZP4V6E3P QrfHHjXFzylLsOhBNCJcyf4UX4f/hppYpz9mldG7wRaz9MBk+GVf4nwPeoZJbqAW/TZ1 U1IuOvgWFOiDQpgL9BTAyfbq8oS66GjFay3EUq43w2SXMghdzEywFMSONsv0OGoUOBgm TRfH3s5mrkISn5Dtp+Mqcf1Czc+DCaK45v7Bk6vj2maO4rDKLKAwkP/F6txk0NKT/8yZ Nlfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Lk+8+JhT; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Sd8cn0Wt; 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 nn16-20020a17090b38d000b0023720e7e54dsi14035502pjb.49.2023.03.06.08.20.50; Mon, 06 Mar 2023 08:21:03 -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=Lk+8+JhT; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Sd8cn0Wt; 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 S231812AbjCFQFI (ORCPT + 99 others); Mon, 6 Mar 2023 11:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbjCFQA5 (ORCPT ); Mon, 6 Mar 2023 11:00:57 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E976B2ED7E; Mon, 6 Mar 2023 08:00:52 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 98CCE2242A; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0DwH9PbkOKEqD3wmCjB0TQMZNUTuSApTKev00H3660E=; b=Lk+8+JhT/+B3f0AwSzmLvFmEfURRKyVzWUrzHFGKzJ+mhJ98TLoYKnbcsJFoQp5T1KByW+ N47ktubG4HpzVPVQlOKinz0XONa5lwU3J3I7+rZKdK2y3PeTfS6UKzYuCfUywj/uJlh3fi W0Y+RRvd7RnHuwWrANQ1KFIaAn0NiLk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0DwH9PbkOKEqD3wmCjB0TQMZNUTuSApTKev00H3660E=; b=Sd8cn0Wty4HjwI7jXy8sDdskYz0sboQCIYBR22NrZ+XNj8yXkNNQOUqcan8o6sLDrqABUp 17idD2saMikjCrBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3E30D13513; Mon, 6 Mar 2023 16:00:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qB1eDjMOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:51 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 71/99] fbdev/savagefb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:48 +0100 Message-Id: <20230306160016.4459-72-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 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?1759636004389708412?= X-GMAIL-MSGID: =?utf-8?q?1759636004389708412?= Use struct option_iter to walk over the individual options in the driver's option string. Replaces the hand-written strsep() loop with a clean interface. The helpers for struct option_iter handle empty option strings and empty options transparently. The struct's _init and _release functions duplicate and release the option string's memory buffer as needed. Done in preparation of constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/savage/savagefb_driver.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 19fffe0b6cdd..94026848d67d 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -42,6 +42,7 @@ */ #include +#include #include #include #include @@ -2535,15 +2536,15 @@ static void __exit savage_done(void) /* ************************* init in-kernel code ************************** */ -static int __init savagefb_setup(char *options) +static int __init savagefb_setup(const char *options) { #ifndef MODULE - char *this_opt; + struct option_iter iter; + const char *this_opt; - if (!options || !*options) - return 0; + option_iter_init(&iter, options); - while ((this_opt = strsep(&options, ",")) != NULL) { + while (option_iter_next(&iter, this_opt)) { static char mode_option_buf[256]; int ret; @@ -2554,6 +2555,9 @@ static int __init savagefb_setup(char *options) continue; mode_option = mode_option_buf; } + + option_iter_release(&iter); + #endif /* !MODULE */ return 0; }