提交 9295c012 编写于 作者: C Christophe Leroy 提交者: Linus Walleij

gpio: sysfs: correct error handling on 'value' attribute read.

'value' attribute is supposed to only return 0 or 1 according to
the documentation.
With today's implementation, if gpiod_get_value_cansleep() fails
the printed 'value' is a negative value.

This patch ensures that an error is returned on read instead.
Signed-off-by: NChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 7fda9100
......@@ -106,8 +106,12 @@ static ssize_t value_show(struct device *dev,
mutex_lock(&data->mutex);
status = sprintf(buf, "%d\n", gpiod_get_value_cansleep(desc));
status = gpiod_get_value_cansleep(desc);
if (status < 0)
goto err;
status = sprintf(buf, "%d\n", status);
err:
mutex_unlock(&data->mutex);
return status;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册