Re: [PATCH] staging: greybus: audio: expect 0 from kstrtoint(), not 1
From: Greg Kroah-Hartman
Date: Thu May 21 2026 - 05:03:49 EST
On Wed, May 20, 2026 at 08:03:59PM +0200, Alexander A. Klimov wrote:
> kstrtoint() returns "0 on success, -ERANGE on overflow
> and -EINVAL on parsing error". In contrast,
> manager_sysfs_remove_store() and manager_sysfs_dump_store()
> checked for 1 which always failed the operation. I fixed this.
>
> Fixes: f9a21a3f4919 ("staging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable conversion.")
> Signed-off-by: Alexander A. Klimov <grandmaster@xxxxxxxxxxxx>
> ---
> drivers/staging/greybus/audio_manager_sysfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_manager_sysfs.c b/drivers/staging/greybus/audio_manager_sysfs.c
> index fcd518f9540c..581791d566e3 100644
> --- a/drivers/staging/greybus/audio_manager_sysfs.c
> +++ b/drivers/staging/greybus/audio_manager_sysfs.c
> @@ -44,7 +44,7 @@ static ssize_t manager_sysfs_remove_store(struct kobject *kobj,
>
> int num = kstrtoint(buf, 10, &id);
>
> - if (num != 1)
> + if (num != 0)
Doesn't checkpatch now complain about this?
> return -EINVAL;
>
> num = gb_audio_manager_remove(id);
> @@ -65,7 +65,7 @@ static ssize_t manager_sysfs_dump_store(struct kobject *kobj,
>
> int num = kstrtoint(buf, 10, &id);
>
> - if (num == 1) {
> + if (num == 0) {
Same here.
thanks,
greg k-h