Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp820687imm; Thu, 31 May 2018 09:57:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGl+eTxtpTpMV8JGUctsbUFiZnPs6GAhCjWOeeH22M8RT6mA5ef0F2n3m4mMwjepYwgBUy X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr7875269pld.118.1527785851964; Thu, 31 May 2018 09:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527785851; cv=none; d=google.com; s=arc-20160816; b=sdh0U6Q5KNZMpRDfX8hPF6FYvLgkuFk1POI/kBfcef41oDzQ+pOctfUI5vmfz0ktIk ye8WvNmHkwuQpfzuRdixUQ6hGZ4XZvoBva6ncEc/KS9JqjVxuuxJvH5+blbzDXFqobiP H2lMZQ6aAEeyYSlxYhA0rFVi3VRsuOHRpIkyANj7fF2u2gyEVLOTXmgYhFZ6T85B+dKp /J2449PTkD/iONfwaLRM8dN4X073j5YSDIxEFrqnNv6x4Fh7m3QeNFtASHqh159i6s5W Hm1V+OVUdRV2mdM5iPsLetvK+HDWuYNNRYrpdWiq+XlZQmxoi5jD7qDPZ/HwkUbzBLyl 3FRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=1nX/bA7ITZ4wuOqYRLEvGCsfNbhFHmvNEWI0s7FhH/A=; b=vHD8a36QP2+FgD9G7E7cjdFV8qvBmPWYFf8hxD1oOTL1H2ZgTuTCU6lj87ECjxSU3A 13yo9v7QUhV4YQCoo++eVUIqUX4cXtcf6nWRJAVhskmZ6O6/UpYJw8tf4W6ZOjtTUdAh HHClScpYa+Mf7f+KzFF+S+pcfJqr9RQktkDc0oLpzCUQwBkyhlH8BqELKCzc31WxK3Cx fOAXUKPH56JpkECwd9deaT4OVxQr1WNJJZdHfp86CtNQdhUYP6yNhMfL+ZBq4RRLq2IH AG9TE9TvS8S+Y7XbPGLpzrdzKQxICj6F6Fp1Z2DSmGpJtYy8P8EpeARrrhjo9nEgb6uY Bjfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=If6xuule; 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 h12-v6si15691109plk.535.2018.05.31.09.57.17; Thu, 31 May 2018 09:57:31 -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; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=If6xuule; 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 S1755846AbeEaQzR (ORCPT + 99 others); Thu, 31 May 2018 12:55:17 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42653 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755829AbeEaQzN (ORCPT ); Thu, 31 May 2018 12:55:13 -0400 Received: by mail-lf0-f68.google.com with SMTP id v135-v6so10752631lfa.9 for ; Thu, 31 May 2018 09:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1nX/bA7ITZ4wuOqYRLEvGCsfNbhFHmvNEWI0s7FhH/A=; b=If6xuuleOEidln/ckCBKybei63fekgi76ZQ4PVcpy7PC52LiU0Dko1oL+PUj0Ct3Ad z5zcbQMg0tHMe/P9wtE7UStLOPXdqFndU2hUiRwZcKFq7DcjRjceJNNHj6yAhLd76FHN F3NHCOu+mU9jLaOxBmDr3/3QjRHpflqdCIykPOMrjEWrBkOWAJWt8AwRLlXURLh3Np1A R4OWKCcjjCxDWog4FFPnnSWIwfsO4nsOGWA3lVpf2IXMfryMLuEIabXNaU0i9PnyHIkS X+xUJCDCYVbyV141jnTAHvey3zooxnLDi1R3SwHk6eiDWo3XJHKqciklbJzeIjDjKIJy QvBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=1nX/bA7ITZ4wuOqYRLEvGCsfNbhFHmvNEWI0s7FhH/A=; b=fqbbgg1rcGvelTxh68AGqpAGdvrmWNJaex++wIc5Ug5FYzOzBA02Lbu1o7qBorqjlo m9pv981KS8yUfnmLyyW7l3Iwy4C5bY++fiD+n/Qc6e0T2dRgbMbklivFRjImGlv+iuZH vc3qu06J4gJBQfRYKumUkAHtnp6B9kqCikn2wbu8gRoatOC0Xi67dsTnvGlBPyNBWWw9 o+0P8/ZQLX06aCvx7iiI9wSggNUZ9iD//+6LerNsJdr697/1gO9T6t/dJsTZTwULD9Oc M4vg4+jWSnp1CC1l80ZdBGSw9PwkAEYCK9kEtjjaQhxVvlOMWGKlCPxVE5opDCs5x0jq bM/Q== X-Gm-Message-State: ALKqPwdmGbgPJ8WaUhrKGJqxfRJqQ2i1JO942gNE9xrMlQRZpCSFGojj EmoNie92PeJtZGa03ExatgnoMw== X-Received: by 2002:a19:380a:: with SMTP id f10-v6mr4906519lfa.47.1527785712484; Thu, 31 May 2018 09:55:12 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.82.221]) by smtp.gmail.com with ESMTPSA id h6-v6sm1007735ljg.16.2018.05.31.09.55.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 09:55:11 -0700 (PDT) Subject: Re: [PATCH v2 01/21] usb: phy: use match_string() helper To: Yisheng Xie , linux-kernel@vger.kernel.org Cc: andy.shevchenko@gmail.com, linux-usb@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-2-git-send-email-xieyisheng1@huawei.com> From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: Date: Thu, 31 May 2018 19:55:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1527765086-19873-2-git-send-email-xieyisheng1@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-MW Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 05/31/2018 02:11 PM, Yisheng Xie wrote: > 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 Hm... > > 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) This is one of the few cases when 'err' is not the best name for such a variable. I'd prefer to see something like 'match' or even 'rc' or 'ret'... :-) > + return USBPHY_INTERFACE_MODE_UNKNOWN; > > - return USBPHY_INTERFACE_MODE_UNKNOWN; > + return err; > } > EXPORT_SYMBOL_GPL(of_usb_get_phy_mode); > MBR, Sergei