Skip to content

Commit 0fa1bf3

Browse files
committed
ACPI: thermal: Add device list to struct acpi_thermal_trip
The device lists present in struct acpi_thermal_passive and struct acpi_thermal_active can be located in struct acpi_thermal_trip which then will allow the same code to be used for handling both the passive and active trip points, so make that change. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Daniel Lezcano <[email protected]>
1 parent 0d9741a commit 0fa1bf3

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

drivers/acpi/thermal.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,18 @@ static struct workqueue_struct *acpi_thermal_pm_queue;
8181

8282
struct acpi_thermal_trip {
8383
unsigned long temperature;
84+
struct acpi_handle_list devices;
8485
};
8586

8687
struct acpi_thermal_passive {
8788
struct acpi_thermal_trip trip;
88-
struct acpi_handle_list devices;
8989
unsigned long tc1;
9090
unsigned long tc2;
9191
unsigned long tsp;
9292
};
9393

9494
struct acpi_thermal_active {
9595
struct acpi_thermal_trip trip;
96-
struct acpi_handle_list devices;
9796
};
9897

9998
struct acpi_thermal_trips {
@@ -205,6 +204,7 @@ static void acpi_thermal_update_passive_trip(struct acpi_thermal *tz)
205204

206205
static bool update_passive_devices(struct acpi_thermal *tz, bool compare)
207206
{
207+
struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip;
208208
struct acpi_handle_list devices;
209209
acpi_status status;
210210

@@ -217,10 +217,10 @@ static bool update_passive_devices(struct acpi_thermal *tz, bool compare)
217217
return false;
218218
}
219219

220-
if (compare && memcmp(&tz->trips.passive.devices, &devices, sizeof(devices)))
220+
if (compare && memcmp(&acpi_trip->devices, &devices, sizeof(devices)))
221221
ACPI_THERMAL_TRIPS_EXCEPTION(tz, "device");
222222

223-
memcpy(&tz->trips.passive.devices, &devices, sizeof(devices));
223+
memcpy(&acpi_trip->devices, &devices, sizeof(devices));
224224
return true;
225225
}
226226

@@ -276,6 +276,7 @@ static void acpi_thermal_update_active_trip(struct acpi_thermal *tz, int index)
276276
static bool update_active_devices(struct acpi_thermal *tz, int index, bool compare)
277277
{
278278
char method[] = { '_', 'A', 'L', '0' + index, '\0' };
279+
struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip;
279280
struct acpi_handle_list devices;
280281
acpi_status status;
281282

@@ -289,10 +290,10 @@ static bool update_active_devices(struct acpi_thermal *tz, int index, bool compa
289290
return false;
290291
}
291292

292-
if (compare && memcmp(&tz->trips.active[index].devices, &devices, sizeof(devices)))
293+
if (compare && memcmp(&acpi_trip->devices, &devices, sizeof(devices)))
293294
ACPI_THERMAL_TRIPS_EXCEPTION(tz, "device");
294295

295-
memcpy(&tz->trips.active[index].devices, &devices, sizeof(devices));
296+
memcpy(&acpi_trip->devices, &devices, sizeof(devices));
296297
return true;
297298
}
298299

@@ -602,6 +603,7 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
602603
{
603604
struct acpi_device *device = cdev->devdata;
604605
struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
606+
struct acpi_thermal_trip *acpi_trip;
605607
struct acpi_device *dev;
606608
acpi_handle handle;
607609
int i;
@@ -615,10 +617,11 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
615617
if (tz->trips.hot_valid)
616618
trip++;
617619

618-
if (acpi_thermal_trip_valid(&tz->trips.passive.trip)) {
620+
acpi_trip = &tz->trips.passive.trip;
621+
if (acpi_thermal_trip_valid(acpi_trip)) {
619622
trip++;
620-
for (i = 0; i < tz->trips.passive.devices.count; i++) {
621-
handle = tz->trips.passive.devices.handles[i];
623+
for (i = 0; i < acpi_trip->devices.count; i++) {
624+
handle = acpi_trip->devices.handles[i];
622625
dev = acpi_fetch_acpi_dev(handle);
623626
if (dev != device)
624627
continue;
@@ -640,12 +643,13 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
640643
}
641644

642645
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
643-
if (!acpi_thermal_trip_valid(&tz->trips.active[i].trip))
646+
acpi_trip = &tz->trips.active[i].trip;
647+
if (!acpi_thermal_trip_valid(acpi_trip))
644648
break;
645649

646650
trip++;
647-
for (j = 0; j < tz->trips.active[i].devices.count; j++) {
648-
handle = tz->trips.active[i].devices.handles[j];
651+
for (j = 0; j < acpi_trip->devices.count; j++) {
652+
handle = acpi_trip->devices.handles[j];
649653
dev = acpi_fetch_acpi_dev(handle);
650654
if (dev != device)
651655
continue;
@@ -1037,11 +1041,13 @@ static int acpi_thermal_resume(struct device *dev)
10371041
return -EINVAL;
10381042

10391043
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
1040-
if (!acpi_thermal_trip_valid(&tz->trips.active[i].trip))
1044+
struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip;
1045+
1046+
if (!acpi_thermal_trip_valid(acpi_trip))
10411047
break;
10421048

1043-
for (j = 0; j < tz->trips.active[i].devices.count; j++) {
1044-
acpi_bus_update_power(tz->trips.active[i].devices.handles[j],
1049+
for (j = 0; j < acpi_trip->devices.count; j++) {
1050+
acpi_bus_update_power(acpi_trip->devices.handles[j],
10451051
&power_state);
10461052
}
10471053
}

0 commit comments

Comments
 (0)