]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
thermal: sysfs: Return ENODATA instead of EAGAIN for reads
authorHsin-Te Yuan <yuanhsinte@chromium.org>
Fri, 20 Jun 2025 10:41:43 +0000 (10:41 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:28:17 +0000 (16:28 +0200)
commit753cd9f3d3968ac06875b200acc84c4a86c18a49
tree5ab7dd53cee7816e667d1c9e9955c6084bbf0da2
parent64d78290599abc92f624008369b00b80c8e7ec57
thermal: sysfs: Return ENODATA instead of EAGAIN for reads

[ Upstream commit 1a4aabc27e95674837f2e25f4ef340c0469e6203 ]

According to POSIX spec, EAGAIN returned by read with O_NONBLOCK set
means the read would block. Hence, the common implementation in
nonblocking model will poll the file when the nonblocking read returns
EAGAIN. However, when the target file is thermal zone, this mechanism
will totally malfunction because thermal zone doesn't implement sysfs
notification and thus the poll will never return.

For example, the read in Golang implemnts such method and sometimes
hangs at reading some thermal zones via sysfs.

Change to return -ENODATA instead of -EAGAIN to userspace.

Signed-off-by: Hsin-Te Yuan <yuanhsinte@chromium.org>
Link: https://patch.msgid.link/20250620-temp-v3-1-6becc6aeb66c@chromium.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/thermal_sysfs.c