From patchwork Mon May 21 11:57:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yisheng X-Patchwork-Id: 10415063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 093486032C for ; Mon, 21 May 2018 12:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECEF328867 for ; Mon, 21 May 2018 12:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E187F28869; Mon, 21 May 2018 12:20:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E0C928867 for ; Mon, 21 May 2018 12:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LBm6EglM4RIKn6RkjRHf6g6DvHer4uvWcWuGlc8F+Gw=; b=K932js+Q7ryWMf jOc+h5kdHAc+5PWpEY6BZw/tld9MFtz04FG8RSwGTrBbr19ftOdOAGGhhCh+oymgox3gl6Ob+R1wE AJ6m5o1mU0aNUe3bKI/2FchTilbcNBOWLJyG81rl1mjgRQ1NnsT+Upe6dKlD3dNQghFk4bGhksc9v 4tSRNe6IriSQclHnCZ3LLNDq2YJFgbdu4EHB48M2R1NT7EcwKDmaYyXbhEVpcEgLxduNLTamb/scH 96awsaHt02cLT8g7sbJNq58nhZBEMJZXFj6mwldlsHS+S4bDx+dBKSAsCMBtG8ovdEkDApf8K8o84 WzR/3aIpMyQUGR0eZxEg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKjo2-0006Lq-CK; Mon, 21 May 2018 12:20:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKjo0-0004pr-Vc for linux-arm-kernel@bombadil.infradead.org; Mon, 21 May 2018 12:20:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ctbcz5ZInlTFVmNfnxG58NNz8BmGabR/wvnmsupOrwA=; b=nze4oCuLqVQQxDavLsZDbYqmZ 04D5KGMGeWINzqdPq8ustLZiWzOHumj9Sr33JZQQOMXaBxKBLxKEodXd216Uo2/YvL+n22Vm0L2hm RG4IhSBSI8d5VmP+PeCCbm7nIYaEaOIq+Zg2kgqu9oDlQaYaGwerTnuTYvc1zbLVOoNKCKbJZ4rrS rJsx27AEd5Th/rvDHmWxfCJPohc/Rs2yyLBBRL/JfJnQjnEdqtXSp8pQcUNeUwJy1mlUVXjdacWhj mnv+QgfeAX3APCuzwW/l0ACUzVvJlDq1WvvncUcSZq6RFG5BRZFe2qqlUaVMafTGOINKC45GBKAXL xDoO3lMCw==; Received: from [45.249.212.35] (helo=huawei.com) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKjd1-00047D-29 for linux-arm-kernel@lists.infradead.org; Mon, 21 May 2018 12:09:30 +0000 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 52A7D2BFC0D78; Mon, 21 May 2018 20:09:01 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 20:08:56 +0800 From: Yisheng Xie To: Subject: [PATCH 17/33] pinctrl: armada-37xx: use match_string() helper Date: Mon, 21 May 2018 19:57:54 +0800 Message-ID: <1526903890-35761-18-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180521_130928_209826_F9DD608F X-CRM114-Status: GOOD ( 11.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yisheng Xie , Andrew Lunn , Jason Cooper , Gregory Clement , linux-gpio@vger.kernel.org, Linus Walleij , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Sebastian Hesselbarth Cc: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Cc: linux-gpio@vger.kernel.org Signed-off-by: Yisheng Xie --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 5b63248..e338327 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -214,18 +214,6 @@ static inline void armada_37xx_update_reg(unsigned int *reg, } } -static int armada_37xx_get_func_reg(struct armada_37xx_pin_group *grp, - const char *func) -{ - int f; - - for (f = 0; (f < NB_FUNCS) && grp->funcs[f]; f++) - if (!strcmp(grp->funcs[f], func)) - return f; - - return -ENOTSUPP; -} - static struct armada_37xx_pin_group *armada_37xx_find_next_grp_by_pin( struct armada_37xx_pinctrl *info, int pin, int *grp) { @@ -344,10 +332,10 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev, dev_dbg(info->dev, "enable function %s group %s\n", name, grp->name); - func = armada_37xx_get_func_reg(grp, name); + func = match_string(grp->funcs, NB_FUNCS, name); if (func < 0) - return func; + return -ENOTSUPP; val = grp->val[func];