Re: [PATCH v2 09/11] thermal: core: Add and use cooling device guard

From: Lukasz Luba
Date: Tue Oct 22 2024 - 18:24:25 EST




On 10/14/24 13:26, Rafael J. Wysocki wrote:
On Fri, Oct 11, 2024 at 12:22 AM Rafael J. Wysocki <rjw@xxxxxxxxxxxxx> wrote:

From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>

Add and use a special guard for cooling devices.

This allows quite a few error code paths to be simplified among
other things and brings in code size reduction for a good measure.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---

This is a new iteration of

https://lore.kernel.org/linux-pm/1890654.atdPhlSkOF@xxxxxxxxxxxxx/

v1 -> v2: Rearrange cur_state_store()

---
drivers/thermal/gov_power_allocator.c | 21 +++++++--------
drivers/thermal/gov_step_wise.c | 6 ++--
drivers/thermal/thermal_core.c | 17 +++---------
drivers/thermal/thermal_debugfs.c | 25 +++++++++++-------
drivers/thermal/thermal_helpers.c | 19 +++-----------
drivers/thermal/thermal_sysfs.c | 45 ++++++++++++----------------------
include/linux/thermal.h | 3 ++
7 files changed, 57 insertions(+), 79 deletions(-)


[snip]


stats = cdev->stats;
- if (!stats) {
- len = -ENODATA;
- goto unlock;
- }
+ if (!stats)
+ return -ENODATA;

len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n");
len += snprintf(buf + len, PAGE_SIZE - len, " : ");

There is one more "goto unlock" statement in this function that needs
to be replaced with "return".

I'll send an update of it shortly.


OK, I will review that when it's ready.