Commit 342d550db1bc0b879007a8cdb38645558e839680

Authored by Bjorn Helgaas
Committed by Len Brown
1 parent 8e2c4f2844

ACPI: thermal: use .notify method instead of installing handler directly

This patch adds a .notify() method.  The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
CC: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>

Showing 1 changed file with 4 additions and 23 deletions Side-by-side Diff

drivers/acpi/thermal.c
... ... @@ -98,6 +98,7 @@
98 98 static int acpi_thermal_add(struct acpi_device *device);
99 99 static int acpi_thermal_remove(struct acpi_device *device, int type);
100 100 static int acpi_thermal_resume(struct acpi_device *device);
  101 +static void acpi_thermal_notify(struct acpi_device *device, u32 event);
101 102 static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
102 103 static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
103 104 static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
... ... @@ -123,6 +124,7 @@
123 124 .add = acpi_thermal_add,
124 125 .remove = acpi_thermal_remove,
125 126 .resume = acpi_thermal_resume,
  127 + .notify = acpi_thermal_notify,
126 128 },
127 129 };
128 130  
129 131  
130 132  
... ... @@ -1264,17 +1266,14 @@
1264 1266 Driver Interface
1265 1267 -------------------------------------------------------------------------- */
1266 1268  
1267   -static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
  1269 +static void acpi_thermal_notify(struct acpi_device *device, u32 event)
1268 1270 {
1269   - struct acpi_thermal *tz = data;
1270   - struct acpi_device *device = NULL;
  1271 + struct acpi_thermal *tz = acpi_driver_data(device);
1271 1272  
1272 1273  
1273 1274 if (!tz)
1274 1275 return;
1275 1276  
1276   - device = tz->device;
1277   -
1278 1277 switch (event) {
1279 1278 case ACPI_THERMAL_NOTIFY_TEMPERATURE:
1280 1279 acpi_thermal_check(tz);
... ... @@ -1298,8 +1297,6 @@
1298 1297 "Unsupported event [0x%x]\n", event));
1299 1298 break;
1300 1299 }
1301   -
1302   - return;
1303 1300 }
1304 1301  
1305 1302 static int acpi_thermal_get_info(struct acpi_thermal *tz)
... ... @@ -1337,7 +1334,6 @@
1337 1334 static int acpi_thermal_add(struct acpi_device *device)
1338 1335 {
1339 1336 int result = 0;
1340   - acpi_status status = AE_OK;
1341 1337 struct acpi_thermal *tz = NULL;
1342 1338  
1343 1339  
1344 1340  
... ... @@ -1368,21 +1364,11 @@
1368 1364 if (result)
1369 1365 goto unregister_thermal_zone;
1370 1366  
1371   - status = acpi_install_notify_handler(device->handle,
1372   - ACPI_DEVICE_NOTIFY,
1373   - acpi_thermal_notify, tz);
1374   - if (ACPI_FAILURE(status)) {
1375   - result = -ENODEV;
1376   - goto remove_fs;
1377   - }
1378   -
1379 1367 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
1380 1368 acpi_device_name(device), acpi_device_bid(device),
1381 1369 KELVIN_TO_CELSIUS(tz->temperature));
1382 1370 goto end;
1383 1371  
1384   -remove_fs:
1385   - acpi_thermal_remove_fs(device);
1386 1372 unregister_thermal_zone:
1387 1373 thermal_zone_device_unregister(tz->thermal_zone);
1388 1374 free_memory:
1389 1375  
... ... @@ -1393,17 +1379,12 @@
1393 1379  
1394 1380 static int acpi_thermal_remove(struct acpi_device *device, int type)
1395 1381 {
1396   - acpi_status status = AE_OK;
1397 1382 struct acpi_thermal *tz = NULL;
1398 1383  
1399 1384 if (!device || !acpi_driver_data(device))
1400 1385 return -EINVAL;
1401 1386  
1402 1387 tz = acpi_driver_data(device);
1403   -
1404   - status = acpi_remove_notify_handler(device->handle,
1405   - ACPI_DEVICE_NOTIFY,
1406   - acpi_thermal_notify);
1407 1388  
1408 1389 acpi_thermal_remove_fs(device);
1409 1390 acpi_thermal_unregister_thermal_zone(tz);