Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp230729imm; Mon, 21 May 2018 05:16:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpfl68/7Jm08VAsBZMLKswBSN4ZXUAYz8bTbllIfXwbBhkTH7FTQ+IFOVJmuEUXQYtgdZQu X-Received: by 2002:a62:5c06:: with SMTP id q6-v6mr19904649pfb.118.1526904982755; Mon, 21 May 2018 05:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904982; cv=none; d=google.com; s=arc-20160816; b=SHPrJ++CraU4JDD74bXL13bUPph01lqhFnpnRud84WhDndtNjNuh/oO7ylo6T+c/uG 9gsJ3xmqBOZjCdcB7alF+dgNKN9DSkwdqOovFFEqK+mjdM/cZmZ7hMcXnRgi/v8uyj5c yycM91RV8+IwkeLKQq1M2maxUZ0O6qkfMnR7GFnPqPnAP8XMnrmj+7UnYPC1sQUeR112 REeESWStcBU6rjH8BPWTuzB8BvtIzXlHyL+bJN3uG2u1TSdkvclQxAC8pCH3i5fmXFZ+ Q0nA9PBSE5FBnelP3P1gqs9FdT5hdDLv81IMcoLpzK3ygvXvsl0FU3A5w13kuHmaaPjl 1HSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=lPiKA01VktlBEGMszqC2wkUReQqrxVoD+eKxlykD0yQ=; b=BM9WhTLTJbLWy0mMlc0a7yTpD0o8HO2TtnPcBAS+Lg7QOoBe3hvo9FHNGoTbdGBnTU SZWZWVxw6G+EPK6QA2iLcEfqsTAIzN2I7kVCzewTRcXm41wmf2smzx/XHsAqyHeA4IMM 2hHYZ/GO78AWQjnkS3FhHEIWYWYkic1v20UzwF9PFch8cP7pv3GGA+9VUj85fYIvnAQo LiqLcnLyqO8nO4j6CjFliIizVRVvicLXEzO/y3Mxuai274paQ6VhnVpBImMW5BmyKuMn R1uumc5vqZX8AX+v1AX3nEj8MZIe76mkljKOxY/eR9GnffL4048bfQBoqT+ov69Weskx UEqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11-v6si15128767plo.41.2018.05.21.05.16.07; Mon, 21 May 2018 05:16:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752918AbeEUMJN (ORCPT + 99 others); Mon, 21 May 2018 08:09:13 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:38622 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751730AbeEUMJA (ORCPT ); Mon, 21 May 2018 08:09:00 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DE7C7FAB82E2D; Mon, 21 May 2018 20:08:55 +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:49 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Linus Walleij , Subject: [PATCH 04/33] gpiolib-of: use match_string() helper Date: Mon, 21 May 2018 19:57:41 +0800 Message-ID: <1526903890-35761-5-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 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Cc: Linus Walleij Cc: linux-gpio@vger.kernel.org Signed-off-by: Yisheng Xie --- drivers/gpio/gpiolib-of.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 586d151..9cbc898 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -202,7 +202,6 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char * }; struct device_node *np = dev->of_node; struct gpio_desc *desc; - int i; if (!IS_ENABLED(CONFIG_REGULATOR)) return ERR_PTR(-ENOENT); @@ -210,11 +209,7 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char * if (!con_id) return ERR_PTR(-ENOENT); - for (i = 0; i < ARRAY_SIZE(whitelist); i++) - if (!strcmp(con_id, whitelist[i])) - break; - - if (i == ARRAY_SIZE(whitelist)) + if (match_string(whitelist, ARRAY_SIZE(whitelist), con_id) < 0) return ERR_PTR(-ENOENT); desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags); -- 1.7.12.4