#include <linux/kmod.h>
#include <linux/reboot.h>
#include <linux/device.h>
+#include <linux/platform_device.h>
#include <linux/thermal.h>
#include <linux/acpi.h>
#include <linux/workqueue.h>
kfree(tz);
}
-static int acpi_thermal_add(struct acpi_device *device)
+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 acpi_thermal_trip *acpi_trip;
struct thermal_trip *trip;
struct acpi_thermal *tz;
if (!tz)
return -ENOMEM;
+ platform_set_drvdata(pdev, tz);
+
tz->device = device;
strscpy(tz->name, device->pnp.bus_id);
strscpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
- device->driver_data = tz;
acpi_thermal_aml_dependency_fix(tz);
return result;
}
-static void acpi_thermal_remove(struct acpi_device *device)
+static void acpi_thermal_remove(struct platform_device *pdev)
{
- struct acpi_thermal *tz;
-
- if (!device || !acpi_driver_data(device))
- return;
+ struct acpi_thermal *tz = platform_get_drvdata(pdev);
- tz = acpi_driver_data(device);
-
- acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
+ acpi_dev_remove_notify_handler(tz->device, ACPI_DEVICE_NOTIFY,
acpi_thermal_notify);
flush_workqueue(acpi_thermal_pm_queue);
static int acpi_thermal_resume(struct device *dev)
{
- struct acpi_thermal *tz;
+ struct acpi_thermal *tz = dev_get_drvdata(dev);
int i, j;
- if (!dev)
- return -EINVAL;
-
- tz = acpi_driver_data(to_acpi_device(dev));
- if (!tz)
- return -EINVAL;
-
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip;
};
MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
-static struct acpi_driver acpi_thermal_driver = {
- .name = "thermal",
- .class = ACPI_THERMAL_CLASS,
- .ids = thermal_device_ids,
- .ops = {
- .add = acpi_thermal_add,
- .remove = acpi_thermal_remove,
- },
- .drv.pm = &acpi_thermal_pm,
+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,
+ .pm = &acpi_thermal_pm,
+ },
};
static int thermal_act(const struct dmi_system_id *d)
if (!acpi_thermal_pm_queue)
return -ENODEV;
- result = acpi_bus_register_driver(&acpi_thermal_driver);
+ result = platform_driver_register(&acpi_thermal_driver);
if (result < 0) {
destroy_workqueue(acpi_thermal_pm_queue);
return -ENODEV;
static void __exit acpi_thermal_exit(void)
{
- acpi_bus_unregister_driver(&acpi_thermal_driver);
+ platform_driver_unregister(&acpi_thermal_driver);
destroy_workqueue(acpi_thermal_pm_queue);
}