Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp233384imm; Mon, 21 May 2018 05:19:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQcTcV0eR/Qe1haWCsUGn+EbTsQqadYPJROY+AhI12GVgvoFZf2P+g9YtsqK/q5YSVnF/H X-Received: by 2002:a17:902:6e4:: with SMTP id 91-v6mr20146011plh.63.1526905144461; Mon, 21 May 2018 05:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526905144; cv=none; d=google.com; s=arc-20160816; b=CmBa4sDdCNeQhKBkUAV/SdDiaxmVRG8fkQSEDRRjXrLdUG0wGDJyCveKOFjCEIq9mr 228YzvapTCxcE0s+zEN3kE2cWjQMsXLpDPT9OuDvjhgj+6fzNVe71VLz4jS2ms6ftEnL VXW2jv+aTLiL9s4iRTTFhevpk7/DmNNuiQqVUyhYlpK9qeeE2hEoCjofFktPACdmjYEj HQsGXzoMae2m1VcopDoCX3iWwfiOqBLB3igUt/nSF3Fs4YwyRKWRXQHnro6EffxndIdy iEm2I72rgP2txiMY/XTdvNN9Bj38m/13Q+b4fKubUtORTJzJZjrm4NLnaJBiVsAKPm1K k9IQ== 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=iRx9jKcrOS3rhHhwPPE7Q1woBVe/s2L9ohvWBe7jJLs=; b=TTgr9V2wk8fSFQ5M2oJkOha6Y/ndUTl+hCQWiYZzPGVrUfRVVgLekwOUfYN7sAn5Hx DFKKYyRFFHjIqEumPx1YSJWr12v10yeJwE+/PT5+xRyuZ/Gz4uUf1jXEKlKoRE5W9LB1 rLZKjPXWQeaccMZdPMDbWjCqiXGtEXsBFrcAojrYU6K9CYE2xP8iFgA9xexmvDvDXEBX p4h6WkT9Eg1ptWM0LG85UGL7v0ZNEtkEFzgCCUvrv+rrYr1aduOw0sDQYll+DapMnuVJ GHW8McYi1Z6aCR9AJDEQ1EkvlYbzn3LM5JwCut1Z9tHlvHUceQknWLc8kLkowKCFlNEJ bFNA== 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 e26-v6si13684749pfn.244.2018.05.21.05.18.49; Mon, 21 May 2018 05:19:04 -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 S1751152AbeEUMQk (ORCPT + 99 others); Mon, 21 May 2018 08:16:40 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:38662 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752781AbeEUMJC (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 2369ED33BB2EC; 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 , , "Felipe Balbi" , Greg Kroah-Hartman Subject: [PATCH 01/33] usb: phy: use match_string() helper Date: Mon, 21 May 2018 19:57:38 +0800 Message-ID: <1526903890-35761-2-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: linux-usb@vger.kernel.org Cc: Felipe Balbi Cc: Greg Kroah-Hartman Signed-off-by: Yisheng Xie --- drivers/usb/phy/of.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c index 1ab134f..5777c9f 100644 --- a/drivers/usb/phy/of.c +++ b/drivers/usb/phy/of.c @@ -28,16 +28,14 @@ enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) { const char *phy_type; - int err, i; + int ret; - err = of_property_read_string(np, "phy_type", &phy_type); - if (err < 0) + ret = of_property_read_string(np, "phy_type", &phy_type); + if (ret < 0) return USBPHY_INTERFACE_MODE_UNKNOWN; - for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++) - if (!strcmp(phy_type, usbphy_modes[i])) - return i; + ret = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type); - return USBPHY_INTERFACE_MODE_UNKNOWN; + return (ret < 0) ? USBPHY_INTERFACE_MODE_UNKNOWN : ret; } EXPORT_SYMBOL_GPL(of_usb_get_phy_mode); -- 1.7.12.4