Skip to content

Commit 17f76be

Browse files
committed
thermal: core: Pass trip descriptors to trip bind/unbind functions
The code is somewhat cleaner if struct thermal_trip_desc pointers are passed to thermal_bind_cdev_to_trip(), thermal_unbind_cdev_from_trip(), and print_bind_err_msg() instead of struct thermal_trip pointers, so modify it accordingly. 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 0dc2356 commit 17f76be

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

drivers/thermal/thermal_core.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,9 @@ struct thermal_zone_device *thermal_zone_get_by_id(int id)
759759
/**
760760
* thermal_bind_cdev_to_trip - bind a cooling device to a thermal zone
761761
* @tz: pointer to struct thermal_zone_device
762-
* @trip: trip point the cooling devices is associated with in this zone.
762+
* @td: descriptor of the trip point to bind @cdev to
763763
* @cdev: pointer to struct thermal_cooling_device
764-
* @cool_spec: cooling specification for @trip and @cdev
764+
* @cool_spec: cooling specification for the trip point and @cdev
765765
*
766766
* This interface function bind a thermal cooling device to the certain trip
767767
* point of a thermal zone device.
@@ -770,11 +770,10 @@ struct thermal_zone_device *thermal_zone_get_by_id(int id)
770770
* Return: 0 on success, the proper error value otherwise.
771771
*/
772772
static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
773-
struct thermal_trip *trip,
773+
struct thermal_trip_desc *td,
774774
struct thermal_cooling_device *cdev,
775775
struct cooling_spec *cool_spec)
776776
{
777-
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
778777
struct thermal_instance *dev, *instance;
779778
bool upper_no_limit;
780779
int result;
@@ -798,7 +797,7 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
798797
return -ENOMEM;
799798

800799
dev->cdev = cdev;
801-
dev->trip = trip;
800+
dev->trip = &td->trip;
802801
dev->upper = cool_spec->upper;
803802
dev->upper_no_limit = upper_no_limit;
804803
dev->lower = cool_spec->lower;
@@ -869,18 +868,17 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
869868
/**
870869
* thermal_unbind_cdev_from_trip - unbind a cooling device from a thermal zone.
871870
* @tz: pointer to a struct thermal_zone_device.
872-
* @trip: trip point the cooling devices is associated with in this zone.
871+
* @td: descriptor of the trip point to unbind @cdev from
873872
* @cdev: pointer to a struct thermal_cooling_device.
874873
*
875874
* This interface function unbind a thermal cooling device from the certain
876875
* trip point of a thermal zone device.
877876
* This function is usually called in the thermal zone device .unbind callback.
878877
*/
879878
static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
880-
struct thermal_trip *trip,
879+
struct thermal_trip_desc *td,
881880
struct thermal_cooling_device *cdev)
882881
{
883-
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
884882
struct thermal_instance *pos, *next;
885883

886884
mutex_lock(&cdev->lock);
@@ -932,11 +930,11 @@ static struct class *thermal_class;
932930

933931
static inline
934932
void print_bind_err_msg(struct thermal_zone_device *tz,
935-
const struct thermal_trip *trip,
933+
const struct thermal_trip_desc *td,
936934
struct thermal_cooling_device *cdev, int ret)
937935
{
938936
dev_err(&tz->device, "binding cdev %s to trip %d failed: %d\n",
939-
cdev->type, thermal_zone_trip_id(tz, trip), ret);
937+
cdev->type, thermal_zone_trip_id(tz, &td->trip), ret);
940938
}
941939

942940
static bool __thermal_zone_cdev_bind(struct thermal_zone_device *tz,
@@ -949,20 +947,19 @@ static bool __thermal_zone_cdev_bind(struct thermal_zone_device *tz,
949947
return false;
950948

951949
for_each_trip_desc(tz, td) {
952-
struct thermal_trip *trip = &td->trip;
953950
struct cooling_spec c = {
954951
.upper = THERMAL_NO_LIMIT,
955952
.lower = THERMAL_NO_LIMIT,
956953
.weight = THERMAL_WEIGHT_DEFAULT
957954
};
958955
int ret;
959956

960-
if (!tz->ops.should_bind(tz, trip, cdev, &c))
957+
if (!tz->ops.should_bind(tz, &td->trip, cdev, &c))
961958
continue;
962959

963-
ret = thermal_bind_cdev_to_trip(tz, trip, cdev, &c);
960+
ret = thermal_bind_cdev_to_trip(tz, td, cdev, &c);
964961
if (ret) {
965-
print_bind_err_msg(tz, trip, cdev, ret);
962+
print_bind_err_msg(tz, td, cdev, ret);
966963
continue;
967964
}
968965

@@ -1281,7 +1278,7 @@ static void __thermal_zone_cdev_unbind(struct thermal_zone_device *tz,
12811278
struct thermal_trip_desc *td;
12821279

12831280
for_each_trip_desc(tz, td)
1284-
thermal_unbind_cdev_from_trip(tz, &td->trip, cdev);
1281+
thermal_unbind_cdev_from_trip(tz, td, cdev);
12851282
}
12861283

12871284
static void thermal_zone_cdev_unbind(struct thermal_zone_device *tz,

0 commit comments

Comments
 (0)