diff options
author | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2023-08-09 16:14:41 +0300 |
---|---|---|
committer | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2023-08-11 14:58:06 +0300 |
commit | 39df52ddd932244f2cc08ce520ad064b7dc8c278 (patch) | |
tree | c7960726e1c1c7bb289a0e705e82e7833f9109b2 /drivers/gpio/gpio-sim.c | |
parent | 87d0688483f56c748b37a5298bdc382df5cf8f74 (diff) | |
download | linux-39df52ddd932244f2cc08ce520ad064b7dc8c278.tar.xz |
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: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/gpio/gpio-sim.c')
-rw-r--r-- | drivers/gpio/gpio-sim.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index cfbdade841e8..1a3729eb44eb 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -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; |