Message ID | 1526903890-35761-2-git-send-email-xieyisheng1@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote: > match_string() returns the index of an array for a matching string, > which can be used intead of open coded variant. > - int err, i; > + int ret; int err; would still work.
On Tue, May 22, 2018 at 01:20:01AM +0300, Andy Shevchenko wrote: > On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote: > > match_string() returns the index of an array for a matching string, > > which can be used intead of open coded variant. > > > - int err, i; > > + int ret; > > int err; > > would still work. And it reduces churn. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi, On 2018/5/22 18:02, Greg Kroah-Hartman wrote: > On Tue, May 22, 2018 at 01:20:01AM +0300, Andy Shevchenko wrote: >> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote: >>> match_string() returns the index of an array for a matching string, >>> which can be used intead of open coded variant. >> >>> - int err, i; >>> + int ret; >> >> int err; >> >> would still work. > > And it reduces churn. I will keep it as err in next version. Thanks Yisheng > > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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);
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 <balbi@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com> --- drivers/usb/phy/of.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)