Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp495224imm; Thu, 31 May 2018 04:28:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLOgc6rtMo45ZpOst/RBUt0LhGVIkMJ5LnXa6AAaLdLXNwIk9dBTWpr4LTsK6avHV38ePuG X-Received: by 2002:a63:7208:: with SMTP id n8-v6mr5177985pgc.420.1527766109135; Thu, 31 May 2018 04:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527766109; cv=none; d=google.com; s=arc-20160816; b=zDr0lVEiOdqWHyFlMXZQ2Wy340tK9LprEAQ7BTOlHqX8JyrdNYFTi/CYm1cBUzGlmA 5XlFMmbMHqjwiMe+hxgY2Nmq2MKa04/3vqi8K8PswqGC8XUCkmd0/rX+MkaLPC1DYAtR Sz0FVuQetSn9IfPzCyX3wEcLdZiQs0eD289YdH61fpXtoWFn4PmpLDHJ1+g1fFtSHa0B IwN4/bweJ4Bh7BZZJxnFUQPBg1qaoXQwRabDACpOwVUuRKbSxmGoBqcHEEPcPQZyepgU b8wD2oFoW1NkgilrZNSwUz8yGZjx95zdqDrwgeHNcLGFtueYN/6zd5Qn7IXgYxbe+x+Y 7XSA== 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=0rC7fpl/jHUJMt8+hYefmcSblMg7MKVJwxd2NWXFEp8=; b=EM/+MB37kd10ZJSO8avrWhEwO27WxoVw3Ngps0koTCtN81lqMvT2HaY++cjxkIqVbl ylgRomrNUs/A8qnJf7R5Vqamghy5XOXxNkuDMyh8xbVkdzTLNVDlj/cQ5GjhhN4GctUs FJVgtTFg7iLwjjakep31syWBk4GcOwlgHgFaP8upwKv9uLqhWeuFZ0J8glbP/vaIfNrX jVR3G0wBSjWA29cQj1er11G7hsGDXLAgiDOEOomTmiCge3aFTCOaaJHFcAjtJbygt9Y4 5dCGrjDWulObRL5M4EO3flW8ty7rF/FuRd9FU2rTVg8Aqx5+QUNSPTEG3co97Eww97bM BiSw== 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 e9-v6si28899424pgr.477.2018.05.31.04.28.15; Thu, 31 May 2018 04:28:29 -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 S1755038AbeEaL1I (ORCPT + 99 others); Thu, 31 May 2018 07:27:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8224 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754634AbeEaLWk (ORCPT ); Thu, 31 May 2018 07:22:40 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id F0C63D486D83E; Thu, 31 May 2018 19:22:24 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 19:22:17 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Tony Lindgren" , Lee Jones , Subject: [PATCH v2 02/21] mfd: omap-usb-host: use match_string() helper Date: Thu, 31 May 2018 19:11:07 +0800 Message-ID: <1527765086-19873-3-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-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 instead of open coded variant. Acked-by: Tony Lindgren Reviewed-by: Andy Shevchenko Cc: Tony Lindgren Cc: Lee Jones Cc: linux-omap@vger.kernel.org Signed-off-by: Yisheng Xie --- v2: - add Acked-by and Reviewed-by tag. 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