diff options
author | Bartosz Golaszewski | 2023-08-12 20:57:48 +0200 |
---|---|---|
committer | Bartosz Golaszewski | 2023-08-15 20:47:30 +0200 |
commit | ba0294df2dbdc006ffbf037da28bba64e9f6d709 (patch) | |
tree | f68db0d1d9b0b479b92e6b734eb5f1b04f0d9689 /drivers/gpio | |
parent | a40fe1ffb69b709835a0623959f95d6c81ff38c1 (diff) |
gpio: sim: replace memmove() + strstrip() with skip_spaces() + strim()
Turns out we can avoid the memmove() by using skip_spaces() and strim().
We did that in gpio-consumer, let's do it in gpio-sim.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-sim.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index 1fbbb49985f6..b7161c83c104 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -642,16 +642,13 @@ static bool gpio_sim_device_is_live_unlocked(struct gpio_sim_device *dev) static char *gpio_sim_strdup_trimmed(const char *str, size_t count) { - char *dup, *trimmed; + char *trimmed; - dup = kstrndup(str, count, GFP_KERNEL); - if (!dup) + trimmed = kstrndup(skip_spaces(str), count, GFP_KERNEL); + if (!trimmed) return NULL; - trimmed = strstrip(dup); - memmove(dup, trimmed, strlen(trimmed) + 1); - - return dup; + return strim(trimmed); } static ssize_t gpio_sim_device_config_dev_name_show(struct config_item *item, |