From: Hsin-Te Yuan <yuanhsinte@chromium.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Hsin-Te Yuan <yuanhsinte@chromium.org>
Subject: [PATCH] thermal: sysfs: Return ENODATA instead of EAGAIN for reads
Date: Wed, 09 Apr 2025 09:13:11 +0000 [thread overview]
Message-ID: <20250409-temp-v1-1-9a391d8c60fd@chromium.org> (raw)
When userspace nonblocking reads temperature via sysfs, EAGAIN error
returned by thermal driver will confuse user from the usual meaning of
EAGAIN, the read would block. Change to throw ENODATA instead of EAGAIN
to userspace. Also, ENODATA more accurately reflects that data is not
currently available.
Signed-off-by: Hsin-Te Yuan <yuanhsinte@chromium.org>
---
drivers/thermal/thermal_sysfs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 24b9055a0b6c515b865e0d7e2db1d0de176ff767..3d1713e053dfb867933d95131f1f2491d2ecd07e 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -40,8 +40,11 @@ temp_show(struct device *dev, struct device_attribute *attr, char *buf)
ret = thermal_zone_get_temp(tz, &temperature);
- if (ret)
+ if (ret) {
+ if (ret == -EAGAIN)
+ return -ENODATA;
return ret;
+ }
return sprintf(buf, "%d\n", temperature);
}
---
base-commit: a24588245776dafc227243a01bfbeb8a59bafba9
change-id: 20250409-temp-6ebd13ad0dbd
Best regards,
--
Hsin-Te Yuan <yuanhsinte@chromium.org>
next reply other threads:[~2025-04-09 9:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 9:13 Hsin-Te Yuan [this message]
2025-04-09 17:31 ` [PATCH] thermal: sysfs: Return ENODATA instead of EAGAIN for reads Rafael J. Wysocki
2025-04-10 9:58 ` Hsin-Te Yuan
2025-04-10 10:09 ` Rafael J. Wysocki
2025-04-10 11:04 ` Hsin-Te Yuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250409-temp-v1-1-9a391d8c60fd@chromium.org \
--to=yuanhsinte@chromium.org \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).