From patchwork Mon May 21 11:57:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yisheng X-Patchwork-Id: 10415053 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 D05946032C for ; Mon, 21 May 2018 12:16:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C139E28861 for ; Mon, 21 May 2018 12:16:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B61BD28866; Mon, 21 May 2018 12:16:50 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38DF828861 for ; Mon, 21 May 2018 12:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752586AbeEUMQi (ORCPT ); Mon, 21 May 2018 08:16:38 -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 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);