From patchwork Fri Dec 4 17:03:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francis Laniel X-Patchwork-Id: 338205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B019C4361A for ; Fri, 4 Dec 2020 17:06:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4E2422B3B for ; Fri, 4 Dec 2020 17:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388529AbgLDRGI (ORCPT ); Fri, 4 Dec 2020 12:06:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbgLDRGI (ORCPT ); Fri, 4 Dec 2020 12:06:08 -0500 Received: from latitanza.investici.org (latitanza.investici.org [IPv6:2001:888:2000:56::19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D077AC061A4F for ; Fri, 4 Dec 2020 09:05:27 -0800 (PST) Received: from mx3.investici.org (unknown [127.0.0.1]) by latitanza.investici.org (Postfix) with ESMTP id 4CnfFl70CTz8sj5; Fri, 4 Dec 2020 17:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=privacyrequired.com; s=stigmate; t=1607101483; bh=3TDaxIk3qaz2HcMErSZKF6ZFVsiVELk5Alr3JxrBrw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C04cefqXlKXobHFRfE8VmBbY+UyYIv881PE7UmyrCMfLJ7vMWyEsYeba75zKznWzJ GzwRX5nXxd1A++oVQMxoakccosirYT3cv5AVEqlbf706Rq9yfYo8PfXCrFLBsAwkRf ZgbVFEBRRwObAtqUZLZ1rhR03BJ3tmD+k4N8NggQ= Received: from [82.94.249.234] (mx3.investici.org [82.94.249.234]) (Authenticated sender: laniel_francis@privacyrequired.com) by localhost (Postfix) with ESMTPSA id 4CnfFl2NvVz8sj2; Fri, 4 Dec 2020 17:04:43 +0000 (UTC) From: laniel_francis@privacyrequired.com To: Bin Liu , Greg Kroah-Hartman Cc: Francis Laniel , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 11/12] musb: Replace strstarts() by str_has_prefix(). Date: Fri, 4 Dec 2020 18:03:17 +0100 Message-Id: <20201204170319.20383-12-laniel_francis@privacyrequired.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204170319.20383-1-laniel_francis@privacyrequired.com> References: <20201204170319.20383-1-laniel_francis@privacyrequired.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/usb/musb/musb_cppi41.c | 4 ++-- drivers/usb/musb/musb_debugfs.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 7fbb8a307145..a6d22c0957c5 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -686,9 +686,9 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) ret = of_property_read_string_index(np, "dma-names", i, &str); if (ret) goto err; - if (strstarts(str, "tx")) + if (str_has_prefix(str, "tx")) is_tx = 1; - else if (strstarts(str, "rx")) + else if (str_has_prefix(str, "rx")) is_tx = 0; else { dev_err(dev, "Wrong dmatype %s\n", str); diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 30a89aa8a3e7..47fc32bc6507 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c @@ -181,36 +181,36 @@ static ssize_t musb_test_mode_write(struct file *file, goto ret; } - if (strstarts(buf, "force host full-speed")) + if (str_has_prefix(buf, "force host full-speed")) test = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_FS; - else if (strstarts(buf, "force host high-speed")) + else if (str_has_prefix(buf, "force host high-speed")) test = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_HS; - else if (strstarts(buf, "force host")) + else if (str_has_prefix(buf, "force host")) test = MUSB_TEST_FORCE_HOST; - else if (strstarts(buf, "fifo access")) + else if (str_has_prefix(buf, "fifo access")) test = MUSB_TEST_FIFO_ACCESS; - else if (strstarts(buf, "force full-speed")) + else if (str_has_prefix(buf, "force full-speed")) test = MUSB_TEST_FORCE_FS; - else if (strstarts(buf, "force high-speed")) + else if (str_has_prefix(buf, "force high-speed")) test = MUSB_TEST_FORCE_HS; - else if (strstarts(buf, "test packet")) { + else if (str_has_prefix(buf, "test packet")) { test = MUSB_TEST_PACKET; musb_load_testpacket(musb); } - else if (strstarts(buf, "test K")) + else if (str_has_prefix(buf, "test K")) test = MUSB_TEST_K; - else if (strstarts(buf, "test J")) + else if (str_has_prefix(buf, "test J")) test = MUSB_TEST_J; - else if (strstarts(buf, "test SE0 NAK")) + else if (str_has_prefix(buf, "test SE0 NAK")) test = MUSB_TEST_SE0_NAK; musb_writeb(musb->mregs, MUSB_TESTMODE, test);