Skip to content

Commit c597b4e

Browse files
committed
thermal: core: Introduce thermal_cdev_update_nocheck()
Three thermal governors call __thermal_cdev_update() under the cdev lock without doing any checks, so in order to reduce the related code duplication, introduce a new helper function called thermal_cdev_update_nocheck() for them and make them use it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Lukasz Luba <[email protected]>
1 parent c690dce commit c597b4e

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

drivers/thermal/gov_bang_bang.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ static void bang_bang_set_instance_target(struct thermal_instance *instance,
3030

3131
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
3232

33-
mutex_lock(&instance->cdev->lock);
34-
__thermal_cdev_update(instance->cdev);
35-
mutex_unlock(&instance->cdev->lock);
33+
thermal_cdev_update_nocheck(instance->cdev);
3634
}
3735

3836
/**

drivers/thermal/gov_fair_share.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ static void fair_share_throttle(struct thermal_zone_device *tz,
8989
}
9090
instance->target = div_u64(dividend, divisor);
9191

92-
mutex_lock(&cdev->lock);
93-
__thermal_cdev_update(cdev);
94-
mutex_unlock(&cdev->lock);
92+
thermal_cdev_update_nocheck(cdev);
9593
}
9694
}
9795

drivers/thermal/gov_power_allocator.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,8 @@ power_actor_set_power(struct thermal_cooling_device *cdev,
322322
return ret;
323323

324324
instance->target = clamp_val(state, instance->lower, instance->upper);
325-
mutex_lock(&cdev->lock);
326-
__thermal_cdev_update(cdev);
327-
mutex_unlock(&cdev->lock);
325+
326+
thermal_cdev_update_nocheck(cdev);
328327

329328
return 0;
330329
}

drivers/thermal/thermal_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
215215
}
216216

217217
void thermal_cdev_update(struct thermal_cooling_device *);
218+
void thermal_cdev_update_nocheck(struct thermal_cooling_device *cdev);
218219
void __thermal_cdev_update(struct thermal_cooling_device *cdev);
219220

220221
int get_tz_trend(struct thermal_zone_device *tz, const struct thermal_trip *trip);

drivers/thermal/thermal_helpers.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
205205
mutex_unlock(&cdev->lock);
206206
}
207207

208+
/**
209+
* thermal_cdev_update_nocheck() - Unconditionally update cooling device state
210+
* @cdev: Target cooling device.
211+
*/
212+
void thermal_cdev_update_nocheck(struct thermal_cooling_device *cdev)
213+
{
214+
mutex_lock(&cdev->lock);
215+
216+
__thermal_cdev_update(cdev);
217+
218+
mutex_unlock(&cdev->lock);
219+
}
220+
208221
/**
209222
* thermal_zone_get_slope - return the slope attribute of the thermal zone
210223
* @tz: thermal zone device with the slope attribute

0 commit comments

Comments
 (0)