Commit 4ab4b3b1 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 2a74c4ac
...@@ -419,8 +419,10 @@ static void acpi_thermal_adjust_thermal_zone(struct thermal_zone_device *thermal ...@@ -419,8 +419,10 @@ static void acpi_thermal_adjust_thermal_zone(struct thermal_zone_device *thermal
unsigned long data) unsigned long data)
{ {
struct acpi_thermal *tz = thermal_zone_device_priv(thermal); struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
int flag = data == ACPI_THERMAL_NOTIFY_THRESHOLDS ?
ACPI_TRIPS_THRESHOLDS : ACPI_TRIPS_DEVICES;
__acpi_thermal_trips_update(tz, data); __acpi_thermal_trips_update(tz, flag);
for_each_thermal_trip(tz->thermal_zone, acpi_thermal_adjust_trip, tz); for_each_thermal_trip(tz->thermal_zone, acpi_thermal_adjust_trip, tz);
} }
...@@ -431,8 +433,10 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz) ...@@ -431,8 +433,10 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz)
queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
} }
static void acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event)
{ {
struct acpi_device *adev = tz->device;
/* /*
* Use thermal_zone_device_exec() to carry out the trip points * Use thermal_zone_device_exec() to carry out the trip points
* update, so as to protect thermal_get_trend() from getting stale * 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) ...@@ -441,8 +445,10 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
* results. * results.
*/ */
thermal_zone_device_exec(tz->thermal_zone, thermal_zone_device_exec(tz->thermal_zone,
acpi_thermal_adjust_thermal_zone, flag); acpi_thermal_adjust_thermal_zone, event);
acpi_queue_thermal_check(tz); acpi_queue_thermal_check(tz);
acpi_bus_generate_netlink_event(adev->pnp.device_class,
dev_name(&adev->dev), event, 0);
} }
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) 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) ...@@ -801,14 +807,8 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
acpi_queue_thermal_check(tz); acpi_queue_thermal_check(tz);
break; break;
case ACPI_THERMAL_NOTIFY_THRESHOLDS: case ACPI_THERMAL_NOTIFY_THRESHOLDS:
acpi_thermal_trips_update(tz, ACPI_TRIPS_THRESHOLDS);
acpi_bus_generate_netlink_event(device->pnp.device_class,
dev_name(&device->dev), event, 0);
break;
case ACPI_THERMAL_NOTIFY_DEVICES: case ACPI_THERMAL_NOTIFY_DEVICES:
acpi_thermal_trips_update(tz, ACPI_TRIPS_DEVICES); acpi_thermal_trips_update(tz, event);
acpi_bus_generate_netlink_event(device->pnp.device_class,
dev_name(&device->dev), event, 0);
break; break;
default: default:
acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment