]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
iio: core: Use __sysfs_match_string() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 9 Jun 2017 12:08:16 +0000 (15:08 +0300)
committerJonathan Cameron <jic23@kernel.org>
Sun, 11 Jun 2017 14:07:34 +0000 (15:07 +0100)
Use __sysfs_match_string() helper instead of open coded variant.

Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-core.c

index 4a1de59d153aacedcd7e5519ebc241fe02c643f3..15c86a8cd704dfc2490928dfb6bb21fcb6656f9e 100644 (file)
@@ -478,21 +478,16 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
        size_t len)
 {
        const struct iio_enum *e = (const struct iio_enum *)priv;
-       unsigned int i;
        int ret;
 
        if (!e->set)
                return -EINVAL;
 
-       for (i = 0; i < e->num_items; i++) {
-               if (sysfs_streq(buf, e->items[i]))
-                       break;
-       }
-
-       if (i == e->num_items)
-               return -EINVAL;
+       ret = __sysfs_match_string(e->items, e->num_items, buf);
+       if (ret < 0)
+               return ret;
 
-       ret = e->set(indio_dev, chan, i);
+       ret = e->set(indio_dev, chan, ret);
        return ret ? ret : len;
 }
 EXPORT_SYMBOL_GPL(iio_enum_write);