Skip to content

Commit 4ab4b3b

Browse files
committed
ACPI: thermal: Eliminate code duplication from acpi_thermal_notify()
Move the acpi_bus_generate_netlink_event() invocation into acpi_thermal_trips_update() which allows the code duplication in acpi_thermal_notify() to be cleaned up, but for this purpose the event value needs to be passed to acpi_thermal_trips_update() and from there to acpi_thermal_adjust_thermal_zone() which has to determine the flag value for __acpi_thermal_trips_update() by itself. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 2a74c4a commit 4ab4b3b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/acpi/thermal.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,10 @@ static void acpi_thermal_adjust_thermal_zone(struct thermal_zone_device *thermal
419419
unsigned long data)
420420
{
421421
struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
422+
int flag = data == ACPI_THERMAL_NOTIFY_THRESHOLDS ?
423+
ACPI_TRIPS_THRESHOLDS : ACPI_TRIPS_DEVICES;
422424

423-
__acpi_thermal_trips_update(tz, data);
425+
__acpi_thermal_trips_update(tz, flag);
424426

425427
for_each_thermal_trip(tz->thermal_zone, acpi_thermal_adjust_trip, tz);
426428
}
@@ -431,8 +433,10 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz)
431433
queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
432434
}
433435

434-
static void acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
436+
static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event)
435437
{
438+
struct acpi_device *adev = tz->device;
439+
436440
/*
437441
* Use thermal_zone_device_exec() to carry out the trip points
438442
* update, so as to protect thermal_get_trend() from getting stale
@@ -441,8 +445,10 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
441445
* results.
442446
*/
443447
thermal_zone_device_exec(tz->thermal_zone,
444-
acpi_thermal_adjust_thermal_zone, flag);
448+
acpi_thermal_adjust_thermal_zone, event);
445449
acpi_queue_thermal_check(tz);
450+
acpi_bus_generate_netlink_event(adev->pnp.device_class,
451+
dev_name(&adev->dev), event, 0);
446452
}
447453

448454
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
@@ -801,14 +807,8 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
801807
acpi_queue_thermal_check(tz);
802808
break;
803809
case ACPI_THERMAL_NOTIFY_THRESHOLDS:
804-
acpi_thermal_trips_update(tz, ACPI_TRIPS_THRESHOLDS);
805-
acpi_bus_generate_netlink_event(device->pnp.device_class,
806-
dev_name(&device->dev), event, 0);
807-
break;
808810
case ACPI_THERMAL_NOTIFY_DEVICES:
809-
acpi_thermal_trips_update(tz, ACPI_TRIPS_DEVICES);
810-
acpi_bus_generate_netlink_event(device->pnp.device_class,
811-
dev_name(&device->dev), event, 0);
811+
acpi_thermal_trips_update(tz, event);
812812
break;
813813
default:
814814
acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",

0 commit comments

Comments
 (0)