Commit 39df52dd authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

gpio: sim: use sysfs_streq() and avoid an strdup()

When comparing strings passed to us from configfs, we can pass the page
argument directly to sysfs_streq() and avoid manual string trimming.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 87d06884
......@@ -1272,7 +1272,6 @@ gpio_sim_hog_config_direction_store(struct config_item *item,
{
struct gpio_sim_hog *hog = to_gpio_sim_hog(item);
struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog);
char *trimmed;
int dir;
mutex_lock(&dev->lock);
......@@ -1282,23 +1281,15 @@ gpio_sim_hog_config_direction_store(struct config_item *item,
return -EBUSY;
}
trimmed = gpio_sim_strdup_trimmed(page, count);
if (!trimmed) {
mutex_unlock(&dev->lock);
return -ENOMEM;
}
if (strcmp(trimmed, "input") == 0)
if (sysfs_streq(page, "input"))
dir = GPIOD_IN;
else if (strcmp(trimmed, "output-high") == 0)
else if (sysfs_streq(page, "output-high"))
dir = GPIOD_OUT_HIGH;
else if (strcmp(trimmed, "output-low") == 0)
else if (sysfs_streq(page, "output-low"))
dir = GPIOD_OUT_LOW;
else
dir = -EINVAL;
kfree(trimmed);
if (dir < 0) {
mutex_unlock(&dev->lock);
return dir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment