From patchwork Mon Mar 6 15:59: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: 64871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1930459wrd; Mon, 6 Mar 2023 08:15:28 -0800 (PST) X-Google-Smtp-Source: AK7set8BDKUEq7Oz1REZqlKbPk37oPdC7C1mWcnAo9jpIWJCa83Wx3owXkeDMLTeRkGWqQjxyZUN X-Received: by 2002:a17:90b:4b11:b0:237:9ce1:12aa with SMTP id lx17-20020a17090b4b1100b002379ce112aamr11555088pjb.35.1678119327791; Mon, 06 Mar 2023 08:15:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678119327; cv=none; d=google.com; s=arc-20160816; b=NWN7xuHjPhBL6gxBX0lGm/64J38q3rEQ6/b5RpYu2EAsa5Tl0YUGvjeYurOPRoaKIn 3z4uJnb237hisXOmpQbavgzU60eMDYuqYptRBsicOFrhA4HGBSkNHhWhqOuybigdtqWU foeDgzz95PMphtCFBIdJBFmwZc8KFETu7vlcAqri91/Qp7No3gYhLKK6fhbBGAbgN57C 54pmHCKExC6T1vtO2qrGr7G2Aw024CLv6QNrNe1ivICMHOBeBZNDUyISFieseEAlQIZH Js1rbdKjigUB9w2hPe4dLNqQyDW+Xp3fUafsvMFshqOd1iXXmCIldFPmamx1K1eGg1Ix sKwQ== 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=WSh0HckrJ14YnHwX8ou8Ih8C9aC0FM64D7FA3t8uE60=; b=0mmGWlLeRUugiaLC0lOx5qw6/rx8WWYKS2ggPmQ0MaA9wUH2M6XKmZCwSwPZQKAF35 tIZ6JBpaz0Xu5VuOZhBUS6oimOz5dhnGl9VDwg+zOdQJ6Fk0BCyquKlASBJ6AMaf6SXd vJIOBGATj4/MMSMpXaep/nSFo9VOeLQhOK7BlvTjrS9hVPfWezn/lnLDSMtgKoPBBux5 Dx269CnIkckuYeEUWyaCHBqdn8Tc4GrKUmkxZbIyIMovn3FyvfS9DRs93hB+8kM1oQdM /AK+FPz2+jmiEjsQDPY98Wb9xHTCIMtrNT24J+lHe1rstXWe1UXFdplzikLRa0RXtJYR agNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QneuH2XZ; 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 m19-20020a63f613000000b00502f457059dsi9905743pgh.330.2023.03.06.08.15.00; Mon, 06 Mar 2023 08:15:27 -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=QneuH2XZ; 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 S231658AbjCFQEu (ORCPT + 99 others); Mon, 6 Mar 2023 11:04:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjCFQA4 (ORCPT ); Mon, 6 Mar 2023 11:00:56 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8096D2E807; Mon, 6 Mar 2023 08:00:51 -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 2C50C22420; Mon, 6 Mar 2023 16:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118450; 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=WSh0HckrJ14YnHwX8ou8Ih8C9aC0FM64D7FA3t8uE60=; b=QneuH2XZ6Xs+drSTkA4ph3R2sAoTuAW3CggI3eegmR3uKEN2BcOB9D2md7FPav27gZsC4i N2dtuydW9qAIwtaK31qTu4b3ppxUXkKao9UsWKfQNBQr4LmjyoVgvoYeCbdyq+hhGCeXK3 MK2I2COBaOpjZNJGsrevr3MrsEOeUoE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118450; 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=WSh0HckrJ14YnHwX8ou8Ih8C9aC0FM64D7FA3t8uE60=; b=bp7IKviDrEyrrsnS0ceS6wdtj23PO79q69MreIKf7f5OkJkEJEbrbJ/lgUMhywPF7jBIkF wMEzF2Z7xEC/zkAg== 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 C10F813513; Mon, 6 Mar 2023 16:00:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uMnwLTEOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:49 +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 67/99] fbdev/rivafb: Parse option string with struct option_iter Date: Mon, 6 Mar 2023 16:59:44 +0100 Message-Id: <20230306160016.4459-68-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?1759635652282355583?= X-GMAIL-MSGID: =?utf-8?q?1759635652282355583?= 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 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index affb7c5ef69c..d95319bb93cc 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -30,6 +30,7 @@ */ #include +#include #include #include #include @@ -2105,17 +2106,18 @@ static void rivafb_remove(struct pci_dev *pd) * ------------------------------------------------------------------------- */ #ifndef MODULE -static int rivafb_setup(char *options) +static int rivafb_setup(const char *options) { - char *this_opt; + struct option_iter iter; + const 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; @@ -2144,6 +2146,9 @@ static int rivafb_setup(char *options) mode_option = mode_option_buf; } } + + option_iter_release(&iter); + NVTRACE_LEAVE(); return 0; }