Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp492080imm; Thu, 31 May 2018 04:24:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJTkvwAowIdbYcbdQcheefZgknwdgML0l0BBZcCvuZR9ioSLoiAvDFmyO3XXIS3AbiYbR6d X-Received: by 2002:a63:4004:: with SMTP id n4-v6mr5297996pga.248.1527765876994; Thu, 31 May 2018 04:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527765876; cv=none; d=google.com; s=arc-20160816; b=wpIWPfRtcTpnCUjAaEYdhz2J4i/W/io06H+wBilS04PHrCjwrKOKjt/pEEjS2pW1YT dX1L8i5TZpBAtE+rUfKTdyOlSJafjGteOydlqli7K5layS/zUGKBiISO8bn/AJ436Cry gxRM13dbYfAnbOGmhxox8/2Q1cAbWnY98ysotvv1d9qbQSCIMK3qn4ssRIq/pjiVsrf4 3hesTO027ywNVwigrn8lxcKQdFpg1iI2M0iNjboRIP85D0DT9vZqRXCAkp1gzJeui4Eu cciFrlHPMfglevvj9cmg/og0RtTidbDC84EnpZi8RaIseyfnCZMHffCxT4CrYft1iY5r 3n4g== 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=kilJ2Sb3lO2z27K40ndg19nvPdLpccelwo4lzbTuj6E=; b=Xb0xocMz99my7g8Sq73Oj2wbmxNZYIrptTlX1Ty0Fu6A9Zoowunsv+QphKAMwCRD3y yZ0Yoy66LmOwx8gvTifFYSA6A5hSRI/k0yOx0uaG7ZnWgYVMNPCMh389gOj9pQTbLpbV AofTGMg9SqHE8czZ0BuhWSbe/pBicZ1fKkW2HKuVX2E0G2cRti8Fjv9toKx9FJ3nDnrj McfNqzNG5WXjBf0lKxFBKYFDKaQnR4ff1IvUYviEd4dBzE2tY1vv/NpVNOqY94li50gl nRcO5RIGwR9rmblde5t8PrfE8kXB5csOQHt0J1irt+qS/dOuM+Fumg3AYo01xS5JbEZ3 S+hg== 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 x20-v6si36413673pln.235.2018.05.31.04.24.23; Thu, 31 May 2018 04:24:36 -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 S1754846AbeEaLWu (ORCPT + 99 others); Thu, 31 May 2018 07:22:50 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8221 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754593AbeEaLWi (ORCPT ); Thu, 31 May 2018 07:22:38 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C796DF680467B; 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:16 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , , Felipe Balbi , "Greg Kroah-Hartman" Subject: [PATCH v2 01/21] usb: phy: use match_string() helper Date: Thu, 31 May 2018 19:11:06 +0800 Message-ID: <1527765086-19873-2-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. Cc: linux-usb@vger.kernel.org Cc: Felipe Balbi Cc: Greg Kroah-Hartman Signed-off-by: Yisheng Xie --- v2: - donot rename err to ret - per Andy drivers/usb/phy/of.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c index 1ab134f..9d74081 100644 --- a/drivers/usb/phy/of.c +++ b/drivers/usb/phy/of.c @@ -28,16 +28,16 @@ enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) { const char *phy_type; - int err, i; + int err; err = of_property_read_string(np, "phy_type", &phy_type); if (err < 0) return USBPHY_INTERFACE_MODE_UNKNOWN; - for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++) - if (!strcmp(phy_type, usbphy_modes[i])) - return i; + err = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type); + if (err < 0) + return USBPHY_INTERFACE_MODE_UNKNOWN; - return USBPHY_INTERFACE_MODE_UNKNOWN; + return err; } EXPORT_SYMBOL_GPL(of_usb_get_phy_mode); -- 1.7.12.4