Skip to content

Commit 82e55e1

Browse files
ziyao233mehmetb0
authored andcommitted
platform/x86: panasonic-laptop: Return errno correctly in show callback
BugLink: https://bugs.launchpad.net/bugs/2095283 [ 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> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
1 parent 77adb92 commit 82e55e1

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
@@ -602,8 +602,7 @@ static ssize_t eco_mode_show(struct device *dev, struct device_attribute *attr,
602602
result = 1;
603603
break;
604604
default:
605-
result = -EIO;
606-
break;
605+
return -EIO;
607606
}
608607
return sysfs_emit(buf, "%u\n", result);
609608
}
@@ -749,7 +748,12 @@ static ssize_t current_brightness_store(struct device *dev, struct device_attrib
749748
static ssize_t cdpower_show(struct device *dev, struct device_attribute *attr,
750749
char *buf)
751750
{
752-
return sysfs_emit(buf, "%d\n", get_optd_power_state());
751+
int state = get_optd_power_state();
752+
753+
if (state < 0)
754+
return state;
755+
756+
return sysfs_emit(buf, "%d\n", state);
753757
}
754758

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

0 commit comments

Comments
 (0)