Skip to content

Commit b52718d

Browse files
ziyao233gregkh
authored andcommitted
platform/x86: panasonic-laptop: Return errno correctly in show callback
[ Upstream commit 5c7bebc ] 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: 468f96b ("platform/x86: panasonic-laptop: Add support for battery charging threshold (eco mode)") Fixes: d5a81d8 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 73521f1 commit b52718d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/platform/x86/panasonic-laptop.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ static ssize_t eco_mode_show(struct device *dev, struct device_attribute *attr,
614614
result = 1;
615615
break;
616616
default:
617-
result = -EIO;
618-
break;
617+
return -EIO;
619618
}
620619
return sysfs_emit(buf, "%u\n", result);
621620
}
@@ -761,7 +760,12 @@ static ssize_t current_brightness_store(struct device *dev, struct device_attrib
761760
static ssize_t cdpower_show(struct device *dev, struct device_attribute *attr,
762761
char *buf)
763762
{
764-
return sysfs_emit(buf, "%d\n", get_optd_power_state());
763+
int state = get_optd_power_state();
764+
765+
if (state < 0)
766+
return state;
767+
768+
return sysfs_emit(buf, "%d\n", state);
765769
}
766770

767771
static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)