aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYisheng Xie <xieyisheng1@huawei.com>2018-05-21 07:57:39 -0400
committerLee Jones <lee.jones@linaro.org>2018-06-04 03:44:17 -0400
commit4c74a1fc948b32df9c5a61eb2203d1e4d977a489 (patch)
tree144a16d1bb248075269352779da3af067d5e8597
parentd95c9760d9c8e046b09b54a3bb6dd0c9aa7a0eff (diff)
mfd: omap-usb-host: Use match_string() helper
match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com> Acked-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/omap-usb-host.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 7aab376ecb84..e11ab12fbdf2 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -153,27 +153,6 @@ static const char * const port_modes[] = {
153 [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM] = "ohci-tll-2pin-dpdm", 153 [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM] = "ohci-tll-2pin-dpdm",
154}; 154};
155 155
156/**
157 * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode'
158 * from the port mode string.
159 * @mode: The port mode string, usually obtained from device tree.
160 *
161 * The function returns the 'enum usbhs_omap_port_mode' that matches the
162 * provided port mode string as per the port_modes table.
163 * If no match is found it returns -ENODEV
164 */
165static int omap_usbhs_get_dt_port_mode(const char *mode)
166{
167 int i;
168
169 for (i = 0; i < ARRAY_SIZE(port_modes); i++) {
170 if (!strcmp(mode, port_modes[i]))
171 return i;
172 }
173
174 return -ENODEV;
175}
176
177static struct platform_device *omap_usbhs_alloc_child(const char *name, 156static struct platform_device *omap_usbhs_alloc_child(const char *name,
178 struct resource *res, int num_resources, void *pdata, 157 struct resource *res, int num_resources, void *pdata,
179 size_t pdata_size, struct device *dev) 158 size_t pdata_size, struct device *dev)
@@ -529,7 +508,8 @@ static int usbhs_omap_get_dt_pdata(struct device *dev,
529 if (ret < 0) 508 if (ret < 0)
530 continue; 509 continue;
531 510
532 ret = omap_usbhs_get_dt_port_mode(mode); 511 /* get 'enum usbhs_omap_port_mode' from port mode string */
512 ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode);
533 if (ret < 0) { 513 if (ret < 0) {
534 dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n", 514 dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n",
535 i, mode); 515 i, mode);