mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
platform/x86: panasonic-laptop: Return errno correctly in show callback
When an error occurs in sysfs show callback, we should return the errno directly instead of formatting it as the result, which produces meaningless output and doesn't inform the userspace of the error. Fixes:468f96bfa3
("platform/x86: panasonic-laptop: Add support for battery charging threshold (eco mode)") Fixes:d5a81d8e86
("platform/x86: panasonic-laptop: Add support for optical driver power in Y and W series") Signed-off-by: Yao Zi <ziyao@disroot.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20241118064637.61832-3-ziyao@disroot.org Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
6674c5a0ee
commit
5c7bebc1a3
@ -614,8 +614,7 @@ static ssize_t eco_mode_show(struct device *dev, struct device_attribute *attr,
|
||||
result = 1;
|
||||
break;
|
||||
default:
|
||||
result = -EIO;
|
||||
break;
|
||||
return -EIO;
|
||||
}
|
||||
return sysfs_emit(buf, "%u\n", result);
|
||||
}
|
||||
@ -761,7 +760,12 @@ static ssize_t current_brightness_store(struct device *dev, struct device_attrib
|
||||
static ssize_t cdpower_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return sysfs_emit(buf, "%d\n", get_optd_power_state());
|
||||
int state = get_optd_power_state();
|
||||
|
||||
if (state < 0)
|
||||
return state;
|
||||
|
||||
return sysfs_emit(buf, "%d\n", state);
|
||||
}
|
||||
|
||||
static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,
|
||||
|
Loading…
Reference in New Issue
Block a user