Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp227339imm; Mon, 21 May 2018 05:12:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6qQUrZHCn/wWkZBo4wrRC/TMixXbKF2rFpuzqbxeSpiEuibkwdExN5Y4bavY/0tS6llEc X-Received: by 2002:a63:730c:: with SMTP id o12-v6mr15484133pgc.1.1526904773936; Mon, 21 May 2018 05:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904773; cv=none; d=google.com; s=arc-20160816; b=wV8RUzna8ZL9WyZDdryeG06XZ2lEWbQ8fYFt03ztMqNQEtNUASim00i9nFlUrtMarG HjTCntu3rbMU7OwTXaLEbJovneLLsS5U/dQenSqNj0sRddiAzw5Nmd1b9vxB9ZDTVyNF p2m+jiuUnFtDM7vPCKwjZgxIPrJMO0sl434JcaWcuwbU/XcFFNStGX5cDWiwJBaz4Jsp bDZi5HbmRUM8YS0QRDS4bPYFN+W1It8ZOpIr6tnvvQV5OVvtuEX8Uw5Cdci6qGTNxL/g H3W4Zh6ns25quh+CQjEX1cqc5TUErGI7Do4vW61RxtQ8iEbzCMgvYd8xj5l1V8WaJwhv sgjA== 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=u1+Rzu/N4AuzKCa34niQ0m+FfAzp8lGwszm7Op2/1i0=; b=hXpHRFeNhAbok9LzxSAmz5AlrrwzwYx8hK3zo4d3na9yuexUZ7taalhLY/JKK2EgAw 4YxMckmewe2Dnjm+/n7LIDe8ZC2wUMydUq5qyMR3RRoxlk038cVs21sAuQfESbEDcNs3 sTsscEX1AoJgrUIUiSfqCU0EB1YXbJUchwV6XFHSGADSjd4DQMHKGTB441OkasJj+5Wy gARy2VXCQ3n9VXLm0+w2L+TIBPF2oNFCAD6mGYlN3nDUrko9ikWxsmA3CYucmI9GKhyn 7fuDaVDbyyK/T5jHlbD7M8BM36y5O6M+i53En1lPwtXTdCK+vm0wSuDMEe3vu2nRAHPS zBew== 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 v129-v6si11072816pgb.179.2018.05.21.05.12.38; Mon, 21 May 2018 05:12:53 -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 S1753013AbeEUMJY (ORCPT + 99 others); Mon, 21 May 2018 08:09:24 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:38663 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752814AbeEUMJC (ORCPT ); Mon, 21 May 2018 08:09:02 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3F589109B41D6; Mon, 21 May 2018 20:08:56 +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:48 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Tony Lindgren , Lee Jones , Subject: [PATCH 02/33] mfd: omap-usb-host: use match_string() helper Date: Mon, 21 May 2018 19:57:39 +0800 Message-ID: <1526903890-35761-3-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: Tony Lindgren Cc: Lee Jones Cc: linux-omap@vger.kernel.org Signed-off-by: Yisheng Xie --- drivers/mfd/omap-usb-host.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 7aab376..e11ab12 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -153,27 +153,6 @@ static inline u32 usbhs_read(void __iomem *base, u32 reg) [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM] = "ohci-tll-2pin-dpdm", }; -/** - * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode' - * from the port mode string. - * @mode: The port mode string, usually obtained from device tree. - * - * The function returns the 'enum usbhs_omap_port_mode' that matches the - * provided port mode string as per the port_modes table. - * If no match is found it returns -ENODEV - */ -static int omap_usbhs_get_dt_port_mode(const char *mode) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(port_modes); i++) { - if (!strcmp(mode, port_modes[i])) - return i; - } - - return -ENODEV; -} - static struct platform_device *omap_usbhs_alloc_child(const char *name, struct resource *res, int num_resources, void *pdata, size_t pdata_size, struct device *dev) @@ -529,7 +508,8 @@ static int usbhs_omap_get_dt_pdata(struct device *dev, if (ret < 0) continue; - ret = omap_usbhs_get_dt_port_mode(mode); + /* get 'enum usbhs_omap_port_mode' from port mode string */ + ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode); if (ret < 0) { dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n", i, mode); -- 1.7.12.4