From 975eddaac53e9d03ba58a198dfb2e8331c6b68cc Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 25 Dec 2024 15:51:03 +0800 Subject: [PATCH] Thermal/procfs: Do not print invalid target cooling state directly Diff - z:cpu-thermal t:48 t:1 h:16 l:0 c:fan0 s:0|4294967295 + z:cpu-thermal t:48 t:1 h:16 l:0 c:fan0 s:0|(invalid) The invalid value 4294967295(THERMAL_NO_TARGET, defined as UINT_MAX(0xffffffff)) may bother users. Signed-off-by: wangjianyu3 --- drivers/thermal/thermal_procfs.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_procfs.c b/drivers/thermal/thermal_procfs.c index 849547af32f..ff5f03f5e36 100644 --- a/drivers/thermal/thermal_procfs.c +++ b/drivers/thermal/thermal_procfs.c @@ -146,15 +146,26 @@ static ssize_t thermal_procfs_read(FAR struct file *filep, { ins->cdev->ops->get_state(ins->cdev, ¤t); procfs_sprintf(buffer, buflen, &offset, - "z:%s t:%d t:%d h:%u l:%u c:%s s:%u|%u\n", + "z:%s t:%d t:%d h:%u l:%u c:%s ", ins->zdev->name, ins->zdev->temperature, ins->trip, ins->upper, ins->lower, - ins->cdev->name, - current, - ins->target); + ins->cdev->name); + + if (ins->target == THERMAL_NO_TARGET) + { + procfs_sprintf(buffer, buflen, &offset, "s:%u|%s", + current, "(invalid)"); + } + else + { + procfs_sprintf(buffer, buflen, &offset, "s:%u|%u", + current, ins->target); + } + + procfs_sprintf(buffer, buflen, &offset, "\n"); } if (offset < 0)