mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
ACPI: thermal: Switch over to devres-based resource management
Switch over the ACPI thermal zone driver to devres-based resource management by making the following changes: * Turn acpi_thermal_zone_free() into a devm action added from acpi_thermal_probe() after allocating the struct acpi_thermal object. * Rename acpi_thermal_unregister_thermal_zone() to acpi_thermal_zone_unregister(), add acpi_thermal_pm_queue flushing to it, and turn it into a devm action added by acpi_thermal_probe() after calling acpi_thermal_register_thermal_zone(). * Use the newly introduced devm_acpi_install_notify_handler() for installing an ACPI notify handler. * Drop acpi_thermal_remove() that is not necessary any more. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3698719.iIbC2pHGDl@rafael.j.wysocki
This commit is contained in:
parent
3159c5fcdd
commit
d3f13e75bf
|
|
@ -655,8 +655,12 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
|
|||
return result;
|
||||
}
|
||||
|
||||
static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
|
||||
static void acpi_thermal_zone_unregister(void *data)
|
||||
{
|
||||
struct acpi_thermal *tz = data;
|
||||
|
||||
flush_workqueue(acpi_thermal_pm_queue);
|
||||
|
||||
thermal_zone_device_disable(tz->thermal_zone);
|
||||
acpi_thermal_zone_sysfs_remove(tz);
|
||||
thermal_zone_device_unregister(tz->thermal_zone);
|
||||
|
|
@ -765,8 +769,9 @@ static void acpi_thermal_check_fn(struct work_struct *work)
|
|||
mutex_unlock(&tz->thermal_check_lock);
|
||||
}
|
||||
|
||||
static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz)
|
||||
static void acpi_thermal_zone_free(void *data)
|
||||
{
|
||||
struct acpi_thermal *tz = data;
|
||||
int i;
|
||||
|
||||
acpi_handle_list_free(&tz->trips.passive.trip.devices);
|
||||
|
|
@ -779,7 +784,8 @@ static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz)
|
|||
static int acpi_thermal_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct thermal_trip trip_table[ACPI_THERMAL_MAX_NR_TRIPS] = { 0 };
|
||||
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
|
||||
struct device *dev = &pdev->dev;
|
||||
struct acpi_device *device = ACPI_COMPANION(dev);
|
||||
struct acpi_thermal_trip *acpi_trip;
|
||||
struct thermal_trip *trip;
|
||||
struct acpi_thermal *tz;
|
||||
|
|
@ -795,6 +801,10 @@ static int acpi_thermal_probe(struct platform_device *pdev)
|
|||
if (!tz)
|
||||
return -ENOMEM;
|
||||
|
||||
result = devm_add_action_or_reset(dev, acpi_thermal_zone_free, tz);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
platform_set_drvdata(pdev, tz);
|
||||
|
||||
tz->device = device;
|
||||
|
|
@ -817,7 +827,7 @@ static int acpi_thermal_probe(struct platform_device *pdev)
|
|||
/* Get temperature [_TMP] (required). */
|
||||
result = acpi_thermal_get_temperature(tz);
|
||||
if (result)
|
||||
goto free_memory;
|
||||
return result;
|
||||
|
||||
/* Determine the default polling frequency [_TZP]. */
|
||||
if (tzp)
|
||||
|
|
@ -870,7 +880,11 @@ static int acpi_thermal_probe(struct platform_device *pdev)
|
|||
trip - trip_table,
|
||||
passive_delay);
|
||||
if (result)
|
||||
goto free_memory;
|
||||
return result;
|
||||
|
||||
result = devm_add_action_or_reset(dev, acpi_thermal_zone_unregister, tz);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
refcount_set(&tz->thermal_check_count, 3);
|
||||
mutex_init(&tz->thermal_check_lock);
|
||||
|
|
@ -879,32 +893,8 @@ static int acpi_thermal_probe(struct platform_device *pdev)
|
|||
pr_info("Thermal Zone [%s] (%ld C)\n", acpi_device_bid(device),
|
||||
deci_kelvin_to_celsius(tz->temp_dk));
|
||||
|
||||
result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
|
||||
acpi_thermal_notify, tz);
|
||||
if (result)
|
||||
goto flush_wq;
|
||||
|
||||
return 0;
|
||||
|
||||
flush_wq:
|
||||
flush_workqueue(acpi_thermal_pm_queue);
|
||||
acpi_thermal_unregister_thermal_zone(tz);
|
||||
free_memory:
|
||||
acpi_thermal_free_thermal_zone(tz);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void acpi_thermal_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct acpi_thermal *tz = platform_get_drvdata(pdev);
|
||||
|
||||
acpi_dev_remove_notify_handler(tz->device, ACPI_DEVICE_NOTIFY,
|
||||
acpi_thermal_notify);
|
||||
|
||||
flush_workqueue(acpi_thermal_pm_queue);
|
||||
acpi_thermal_unregister_thermal_zone(tz);
|
||||
acpi_thermal_free_thermal_zone(tz);
|
||||
return devm_acpi_install_notify_handler(dev, ACPI_DEVICE_NOTIFY,
|
||||
acpi_thermal_notify, tz);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
|
@ -937,7 +927,6 @@ MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
|
|||
|
||||
static struct platform_driver acpi_thermal_driver = {
|
||||
.probe = acpi_thermal_probe,
|
||||
.remove = acpi_thermal_remove,
|
||||
.driver = {
|
||||
.name = "acpi-thermal",
|
||||
.acpi_match_table = thermal_device_ids,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user