From patchwork Thu May 3 17:26:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10378781 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 E473460159 for ; Thu, 3 May 2018 17:27:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6EE8291FC for ; Thu, 3 May 2018 17:27:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB319291FF; Thu, 3 May 2018 17:27:12 +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 6F706291FD for ; Thu, 3 May 2018 17:27:12 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=tEfLMOnlFQwpQ3BqAwVYij/1AGq1wh3s3Cju1t9nsso=; b=kqQ tmn35n6zX3GIq9Ew7Yt/L68DoHPFwfAAw/XWEyDlrGU1QfGh/UnejEGcsbDfWaW3BKO0DNoFKlzsA 3UJa8JXF16BX2ELuTRN7yMPTE5WgKAxqhnyrZZRWJLk8FJloz9vfuBfUDA/jTv569SFRc12qHCiQo 4b3Qq5enNcCuB5cq8ztUUQlamESZCx/w9Ptrfhge6TVySO3SE1RdJIHxgLGo6pgbvdpTMjwDStzn9 80VALoHOTFYWypeb+VN79XmKcSq0eEc+cq7kVI0Y5PwwbBs999O2yif9uunL29hVfNuMnFqRqk0RD I7p8+VLhCHRlpx5FlYbQgOcP6vbxyyA==; 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 1fEI0V-00066F-Bh; Thu, 03 May 2018 17:27:03 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEI0R-00065M-Fd for linux-arm-kernel@lists.infradead.org; Thu, 03 May 2018 17:27:00 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 10:26:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,359,1520924400"; d="scan'208";a="225574012" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 03 May 2018 10:26:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 22B88CE; Thu, 3 May 2018 20:26:42 +0300 (EEST) From: Andy Shevchenko To: Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , linux-arm-kernel@lists.infradead.org, Linus Walleij , linux-gpio@vger.kernel.org Subject: [PATCH v1] pinctrl: armada-37xx: Convert to use match_string() helper Date: Thu, 3 May 2018 20:26:42 +0300 Message-Id: <20180503172642.21031-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.17.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180503_102659_547395_224DC6ED X-CRM114-Status: GOOD ( 14.26 ) 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: Andy Shevchenko MIME-Version: 1.0 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 The new helper returns index of the matching string in an array. We are going to use it here. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 29 ++++++--------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 5b63248c8209..0f1eafba0ded 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,9 @@ 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]; @@ -932,12 +919,12 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) struct armada_37xx_pin_group *gp = &info->groups[g]; int f; - for (f = 0; (f < NB_FUNCS) && gp->funcs[f]; f++) { - if (strcmp(gp->funcs[f], name) == 0) { - *groups = gp->name; - groups++; - } - } + f = match_string(gp->funcs, NB_FUNCS, name); + if (f < 0) + continue; + + *groups = gp->name; + groups++; } } return 0;