]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mfd: omap-usb-host: Use match_string() helper
authorYisheng Xie <xieyisheng1@huawei.com>
Mon, 21 May 2018 11:57:39 +0000 (19:57 +0800)
committerLee Jones <lee.jones@linaro.org>
Mon, 4 Jun 2018 07:44:17 +0000 (08:44 +0100)
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>
drivers/mfd/omap-usb-host.c

index 7aab376ecb848e1d4a95ed2e76d9782c7c60693a..e11ab12fbdf27228f7d003a542a61321ba3ca30b 100644 (file)
@@ -153,27 +153,6 @@ static const char * const port_modes[] = {
        [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM]     = "ohci-tll-2pin-dpdm",
 };
 
-/**
- * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode'
- * from the port mode string.
- * @mode: The port mode string, usually obtained from device tree.
- *
- * The function returns the 'enum usbhs_omap_port_mode' that matches the
- * provided port mode string as per the port_modes table.
- * If no match is found it returns -ENODEV
- */
-static int omap_usbhs_get_dt_port_mode(const char *mode)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(port_modes); i++) {
-               if (!strcmp(mode, port_modes[i]))
-                       return i;
-       }
-
-       return -ENODEV;
-}
-
 static struct platform_device *omap_usbhs_alloc_child(const char *name,
                        struct resource *res, int num_resources, void *pdata,
                        size_t pdata_size, struct device *dev)
@@ -529,7 +508,8 @@ static int usbhs_omap_get_dt_pdata(struct device *dev,
                if (ret < 0)
                        continue;
 
-               ret = omap_usbhs_get_dt_port_mode(mode);
+               /* get 'enum usbhs_omap_port_mode' from port mode string */
+               ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode);
                if (ret < 0) {
                        dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n",
                                        i, mode);