1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Architecture-specific ACPI-based support for suspend-to-idle. 4 * 5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 6 * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> 7 * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> 8 * 9 * On platforms supporting the Low Power S0 Idle interface there is an ACPI 10 * device object with the PNP0D80 compatible device ID (System Power Management 11 * Controller) and a specific _DSM method under it. That method, if present, 12 * can be used to indicate to the platform that the OS is transitioning into a 13 * low-power state in which certain types of activity are not desirable or that 14 * it is leaving such a state, which allows the platform to adjust its operation 15 * mode accordingly. 16 */ 17 18 #include <linux/acpi.h> 19 #include <linux/device.h> 20 #include <linux/dmi.h> 21 #include <linux/suspend.h> 22 23 #include "../sleep.h" 24 25 #ifdef CONFIG_SUSPEND 26 27 static bool sleep_no_lps0 __read_mostly; 28 module_param(sleep_no_lps0, bool, 0644); 29 MODULE_PARM_DESC(sleep_no_lps0, "Do not use the special LPS0 device interface"); 30 31 static bool check_lps0_constraints __read_mostly; 32 module_param(check_lps0_constraints, bool, 0644); 33 MODULE_PARM_DESC(check_lps0_constraints, "Check LPS0 device constraints"); 34 35 static const struct acpi_device_id lps0_device_ids[] = { 36 {"PNP0D80", }, 37 {"", }, 38 }; 39 40 /* Microsoft platform agnostic UUID */ 41 #define ACPI_LPS0_DSM_UUID_MICROSOFT "11e00d56-ce64-47ce-837b-1f898f9aa461" 42 43 #define ACPI_LPS0_DSM_UUID "c4eb40a0-6cd2-11e2-bcfd-0800200c9a66" 44 45 #define ACPI_LPS0_GET_DEVICE_CONSTRAINTS 1 46 #define ACPI_LPS0_SCREEN_OFF 3 47 #define ACPI_LPS0_SCREEN_ON 4 48 #define ACPI_LPS0_ENTRY 5 49 #define ACPI_LPS0_EXIT 6 50 #define ACPI_LPS0_MS_ENTRY 7 51 #define ACPI_LPS0_MS_EXIT 8 52 53 /* AMD */ 54 #define ACPI_LPS0_DSM_UUID_AMD "e3f32452-febc-43ce-9039-932122d37721" 55 #define ACPI_LPS0_ENTRY_AMD 2 56 #define ACPI_LPS0_EXIT_AMD 3 57 #define ACPI_LPS0_SCREEN_OFF_AMD 4 58 #define ACPI_LPS0_SCREEN_ON_AMD 5 59 60 static acpi_handle lps0_device_handle; 61 static guid_t lps0_dsm_guid; 62 static int lps0_dsm_func_mask; 63 64 static guid_t lps0_dsm_guid_microsoft; 65 static int lps0_dsm_func_mask_microsoft; 66 static int lps0_dsm_state; 67 68 /* Device constraint entry structure */ 69 struct lpi_device_info { 70 char *name; 71 int enabled; 72 union acpi_object *package; 73 }; 74 75 /* Constraint package structure */ 76 struct lpi_device_constraint { 77 int uid; 78 int min_dstate; 79 int function_states; 80 }; 81 82 struct lpi_constraints { 83 acpi_handle handle; 84 int min_dstate; 85 }; 86 87 /* AMD Constraint package structure */ 88 struct lpi_device_constraint_amd { 89 char *name; 90 int enabled; 91 int function_states; 92 int min_dstate; 93 }; 94 95 static LIST_HEAD(lps0_s2idle_devops_head); 96 97 static struct lpi_constraints *lpi_constraints_table; 98 static int lpi_constraints_table_size; 99 static int rev_id; 100 101 #define for_each_lpi_constraint(entry) \ 102 for (int i = 0; \ 103 entry = &lpi_constraints_table[i], i < lpi_constraints_table_size; \ 104 i++) 105 106 static void lpi_device_get_constraints_amd(void) 107 { 108 union acpi_object *out_obj; 109 int i, j, k; 110 111 out_obj = acpi_evaluate_dsm_typed(lps0_device_handle, &lps0_dsm_guid, 112 rev_id, ACPI_LPS0_GET_DEVICE_CONSTRAINTS, 113 NULL, ACPI_TYPE_PACKAGE); 114 115 acpi_handle_debug(lps0_device_handle, "_DSM function 1 eval %s\n", 116 out_obj ? "successful" : "failed"); 117 118 if (!out_obj) 119 return; 120 121 for (i = 0; i < out_obj->package.count; i++) { 122 union acpi_object *package = &out_obj->package.elements[i]; 123 124 if (package->type == ACPI_TYPE_PACKAGE) { 125 if (lpi_constraints_table) { 126 acpi_handle_err(lps0_device_handle, 127 "Duplicate constraints list\n"); 128 goto free_acpi_buffer; 129 } 130 131 lpi_constraints_table = kcalloc(package->package.count, 132 sizeof(*lpi_constraints_table), 133 GFP_KERNEL); 134 135 if (!lpi_constraints_table) 136 goto free_acpi_buffer; 137 138 acpi_handle_debug(lps0_device_handle, 139 "LPI: constraints list begin:\n"); 140 141 for (j = 0; j < package->package.count; j++) { 142 union acpi_object *info_obj = &package->package.elements[j]; 143 struct lpi_device_constraint_amd dev_info = {}; 144 struct lpi_constraints *list; 145 acpi_status status; 146 147 list = &lpi_constraints_table[lpi_constraints_table_size]; 148 149 for (k = 0; k < info_obj->package.count; k++) { 150 union acpi_object *obj = &info_obj->package.elements[k]; 151 152 switch (k) { 153 case 0: 154 dev_info.enabled = obj->integer.value; 155 break; 156 case 1: 157 dev_info.name = obj->string.pointer; 158 break; 159 case 2: 160 dev_info.function_states = obj->integer.value; 161 break; 162 case 3: 163 dev_info.min_dstate = obj->integer.value; 164 break; 165 } 166 } 167 168 acpi_handle_debug(lps0_device_handle, 169 "Name:%s, Enabled: %d, States: %d, MinDstate: %d\n", 170 dev_info.name, 171 dev_info.enabled, 172 dev_info.function_states, 173 dev_info.min_dstate); 174 175 if (!dev_info.enabled || !dev_info.name || 176 !dev_info.min_dstate) 177 continue; 178 179 status = acpi_get_handle(NULL, dev_info.name, &list->handle); 180 if (ACPI_FAILURE(status)) 181 continue; 182 183 list->min_dstate = dev_info.min_dstate; 184 185 lpi_constraints_table_size++; 186 } 187 } 188 } 189 190 acpi_handle_debug(lps0_device_handle, "LPI: constraints list end\n"); 191 192 free_acpi_buffer: 193 ACPI_FREE(out_obj); 194 } 195 196 static void lpi_device_get_constraints(void) 197 { 198 union acpi_object *out_obj; 199 int i; 200 201 out_obj = acpi_evaluate_dsm_typed(lps0_device_handle, &lps0_dsm_guid, 202 1, ACPI_LPS0_GET_DEVICE_CONSTRAINTS, 203 NULL, ACPI_TYPE_PACKAGE); 204 205 acpi_handle_debug(lps0_device_handle, "_DSM function 1 eval %s\n", 206 out_obj ? "successful" : "failed"); 207 208 if (!out_obj) 209 return; 210 211 lpi_constraints_table = kcalloc(out_obj->package.count, 212 sizeof(*lpi_constraints_table), 213 GFP_KERNEL); 214 if (!lpi_constraints_table) 215 goto free_acpi_buffer; 216 217 acpi_handle_debug(lps0_device_handle, "LPI: constraints list begin:\n"); 218 219 for (i = 0; i < out_obj->package.count; i++) { 220 struct lpi_constraints *constraint; 221 acpi_status status; 222 union acpi_object *package = &out_obj->package.elements[i]; 223 struct lpi_device_info info = { }; 224 int package_count = 0, j; 225 226 if (!package) 227 continue; 228 229 for (j = 0; j < package->package.count; j++) { 230 union acpi_object *element = 231 &(package->package.elements[j]); 232 233 switch (element->type) { 234 case ACPI_TYPE_INTEGER: 235 info.enabled = element->integer.value; 236 break; 237 case ACPI_TYPE_STRING: 238 info.name = element->string.pointer; 239 break; 240 case ACPI_TYPE_PACKAGE: 241 package_count = element->package.count; 242 info.package = element->package.elements; 243 break; 244 } 245 } 246 247 if (!info.enabled || !info.package || !info.name) 248 continue; 249 250 constraint = &lpi_constraints_table[lpi_constraints_table_size]; 251 252 status = acpi_get_handle(NULL, info.name, &constraint->handle); 253 if (ACPI_FAILURE(status)) 254 continue; 255 256 acpi_handle_debug(lps0_device_handle, 257 "index:%d Name:%s\n", i, info.name); 258 259 constraint->min_dstate = -1; 260 261 for (j = 0; j < package_count; j++) { 262 union acpi_object *info_obj = &info.package[j]; 263 union acpi_object *cnstr_pkg; 264 union acpi_object *obj; 265 struct lpi_device_constraint dev_info; 266 267 switch (info_obj->type) { 268 case ACPI_TYPE_INTEGER: 269 /* version */ 270 break; 271 case ACPI_TYPE_PACKAGE: 272 if (info_obj->package.count < 2) 273 break; 274 275 cnstr_pkg = info_obj->package.elements; 276 obj = &cnstr_pkg[0]; 277 dev_info.uid = obj->integer.value; 278 obj = &cnstr_pkg[1]; 279 dev_info.min_dstate = obj->integer.value; 280 281 acpi_handle_debug(lps0_device_handle, 282 "uid:%d min_dstate:%s\n", 283 dev_info.uid, 284 acpi_power_state_string(dev_info.min_dstate)); 285 286 constraint->min_dstate = dev_info.min_dstate; 287 break; 288 } 289 } 290 291 if (constraint->min_dstate < 0) { 292 acpi_handle_debug(lps0_device_handle, 293 "Incomplete constraint defined\n"); 294 continue; 295 } 296 297 lpi_constraints_table_size++; 298 } 299 300 acpi_handle_debug(lps0_device_handle, "LPI: constraints list end\n"); 301 302 free_acpi_buffer: 303 ACPI_FREE(out_obj); 304 } 305 306 static void lpi_check_constraints(void) 307 { 308 struct lpi_constraints *entry; 309 310 if (IS_ERR_OR_NULL(lpi_constraints_table)) 311 return; 312 313 for_each_lpi_constraint(entry) { 314 struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle); 315 316 if (!adev) 317 continue; 318 319 acpi_handle_debug(entry->handle, 320 "LPI: required min power state:%s current power state:%s\n", 321 acpi_power_state_string(entry->min_dstate), 322 acpi_power_state_string(adev->power.state)); 323 324 if (!adev->flags.power_manageable) { 325 acpi_handle_info(entry->handle, "LPI: Device not power manageable\n"); 326 entry->handle = NULL; 327 continue; 328 } 329 330 if (adev->power.state < entry->min_dstate) 331 acpi_handle_info(entry->handle, 332 "LPI: Constraint not met; min power state:%s current power state:%s\n", 333 acpi_power_state_string(entry->min_dstate), 334 acpi_power_state_string(adev->power.state)); 335 } 336 } 337 338 static bool acpi_s2idle_vendor_amd(void) 339 { 340 return boot_cpu_data.x86_vendor == X86_VENDOR_AMD; 341 } 342 343 static const char *acpi_sleep_dsm_state_to_str(unsigned int state) 344 { 345 if (lps0_dsm_func_mask_microsoft || !acpi_s2idle_vendor_amd()) { 346 switch (state) { 347 case ACPI_LPS0_SCREEN_OFF: 348 return "screen off"; 349 case ACPI_LPS0_SCREEN_ON: 350 return "screen on"; 351 case ACPI_LPS0_ENTRY: 352 return "lps0 entry"; 353 case ACPI_LPS0_EXIT: 354 return "lps0 exit"; 355 case ACPI_LPS0_MS_ENTRY: 356 return "lps0 ms entry"; 357 case ACPI_LPS0_MS_EXIT: 358 return "lps0 ms exit"; 359 } 360 } else { 361 switch (state) { 362 case ACPI_LPS0_SCREEN_ON_AMD: 363 return "screen on"; 364 case ACPI_LPS0_SCREEN_OFF_AMD: 365 return "screen off"; 366 case ACPI_LPS0_ENTRY_AMD: 367 return "lps0 entry"; 368 case ACPI_LPS0_EXIT_AMD: 369 return "lps0 exit"; 370 } 371 } 372 373 return "unknown"; 374 } 375 376 static void acpi_sleep_run_lps0_dsm(unsigned int func, unsigned int func_mask, guid_t dsm_guid) 377 { 378 union acpi_object *out_obj; 379 380 if (!(func_mask & (1 << func))) 381 return; 382 383 out_obj = acpi_evaluate_dsm(lps0_device_handle, &dsm_guid, 384 rev_id, func, NULL); 385 ACPI_FREE(out_obj); 386 387 lps0_dsm_state = func; 388 if (pm_debug_messages_on) { 389 acpi_handle_info(lps0_device_handle, 390 "%s transitioned to state %s\n", 391 out_obj ? "Successfully" : "Failed to", 392 acpi_sleep_dsm_state_to_str(lps0_dsm_state)); 393 } 394 } 395 396 397 static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *dsm_guid) 398 { 399 union acpi_object *obj; 400 int ret = -EINVAL; 401 402 guid_parse(uuid, dsm_guid); 403 404 /* Check if the _DSM is present and as expected. */ 405 obj = acpi_evaluate_dsm_typed(handle, dsm_guid, rev, 0, NULL, ACPI_TYPE_BUFFER); 406 if (!obj || obj->buffer.length == 0 || obj->buffer.length > sizeof(u32)) { 407 acpi_handle_debug(handle, 408 "_DSM UUID %s rev %d function 0 evaluation failed\n", uuid, rev); 409 goto out; 410 } 411 412 ret = *(int *)obj->buffer.pointer; 413 acpi_handle_debug(handle, "_DSM UUID %s rev %d function mask: 0x%x\n", uuid, rev, ret); 414 415 out: 416 ACPI_FREE(obj); 417 return ret; 418 } 419 420 struct amd_lps0_hid_device_data { 421 const bool check_off_by_one; 422 }; 423 424 static const struct amd_lps0_hid_device_data amd_picasso = { 425 .check_off_by_one = true, 426 }; 427 428 static const struct amd_lps0_hid_device_data amd_cezanne = { 429 .check_off_by_one = false, 430 }; 431 432 static const struct acpi_device_id amd_hid_ids[] = { 433 {"AMD0004", (kernel_ulong_t)&amd_picasso, }, 434 {"AMD0005", (kernel_ulong_t)&amd_picasso, }, 435 {"AMDI0005", (kernel_ulong_t)&amd_picasso, }, 436 {"AMDI0006", (kernel_ulong_t)&amd_cezanne, }, 437 {} 438 }; 439 440 static int lps0_device_attach(struct acpi_device *adev, 441 const struct acpi_device_id *not_used) 442 { 443 if (lps0_device_handle) 444 return 0; 445 446 lps0_dsm_func_mask_microsoft = validate_dsm(adev->handle, 447 ACPI_LPS0_DSM_UUID_MICROSOFT, 0, 448 &lps0_dsm_guid_microsoft); 449 if (acpi_s2idle_vendor_amd()) { 450 static const struct acpi_device_id *dev_id; 451 const struct amd_lps0_hid_device_data *data; 452 453 for (dev_id = &amd_hid_ids[0]; dev_id->id[0]; dev_id++) 454 if (acpi_dev_hid_uid_match(adev, dev_id->id, NULL)) 455 break; 456 if (dev_id->id[0]) 457 data = (const struct amd_lps0_hid_device_data *) dev_id->driver_data; 458 else 459 data = &amd_cezanne; 460 lps0_dsm_func_mask = validate_dsm(adev->handle, 461 ACPI_LPS0_DSM_UUID_AMD, rev_id, &lps0_dsm_guid); 462 if (lps0_dsm_func_mask > 0x3 && data->check_off_by_one) { 463 lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1; 464 acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n", 465 ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask); 466 } else if (lps0_dsm_func_mask_microsoft > 0 && rev_id) { 467 lps0_dsm_func_mask_microsoft = -EINVAL; 468 acpi_handle_debug(adev->handle, "_DSM Using AMD method\n"); 469 } 470 } else { 471 rev_id = 1; 472 lps0_dsm_func_mask = validate_dsm(adev->handle, 473 ACPI_LPS0_DSM_UUID, rev_id, &lps0_dsm_guid); 474 if (lps0_dsm_func_mask > 0 && lps0_dsm_func_mask_microsoft > 0) { 475 unsigned int func_mask; 476 477 /* 478 * Log a message if the _DSM function sets for two 479 * different UUIDs overlap. 480 */ 481 func_mask = lps0_dsm_func_mask & lps0_dsm_func_mask_microsoft; 482 if (func_mask) 483 acpi_handle_info(adev->handle, 484 "Duplicate LPS0 _DSM functions (mask: 0x%x)\n", 485 func_mask); 486 } 487 } 488 489 if (lps0_dsm_func_mask < 0 && lps0_dsm_func_mask_microsoft < 0) 490 return 0; //function evaluation failed 491 492 lps0_device_handle = adev->handle; 493 494 /* 495 * Use suspend-to-idle by default if ACPI_FADT_LOW_POWER_S0 is set in 496 * the FADT and the default suspend mode was not set from the command 497 * line. 498 */ 499 if ((acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) && 500 mem_sleep_default > PM_SUSPEND_MEM && !acpi_sleep_default_s3) { 501 mem_sleep_current = PM_SUSPEND_TO_IDLE; 502 pr_info("Low-power S0 idle used by default for system suspend\n"); 503 } 504 505 /* 506 * Some LPS0 systems, like ASUS Zenbook UX430UNR/i7-8550U, require the 507 * EC GPE to be enabled while suspended for certain wakeup devices to 508 * work, so mark it as wakeup-capable. 509 */ 510 acpi_ec_mark_gpe_for_wake(); 511 512 return 0; 513 } 514 515 static struct acpi_scan_handler lps0_handler = { 516 .ids = lps0_device_ids, 517 .attach = lps0_device_attach, 518 }; 519 520 static int acpi_s2idle_begin_lps0(void) 521 { 522 if (lps0_device_handle && !sleep_no_lps0 && check_lps0_constraints && 523 !lpi_constraints_table) { 524 if (acpi_s2idle_vendor_amd()) 525 lpi_device_get_constraints_amd(); 526 else 527 lpi_device_get_constraints(); 528 529 /* 530 * Try to retrieve the constraints only once because failures 531 * to do so usually are sticky. 532 */ 533 if (!lpi_constraints_table) 534 lpi_constraints_table = ERR_PTR(-ENODATA); 535 } 536 537 return acpi_s2idle_begin(); 538 } 539 540 static int acpi_s2idle_prepare_late_lps0(void) 541 { 542 struct acpi_s2idle_dev_ops *handler; 543 544 if (!lps0_device_handle || sleep_no_lps0) 545 return 0; 546 547 if (check_lps0_constraints) 548 lpi_check_constraints(); 549 550 /* Screen off */ 551 if (lps0_dsm_func_mask > 0) 552 acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? 553 ACPI_LPS0_SCREEN_OFF_AMD : 554 ACPI_LPS0_SCREEN_OFF, 555 lps0_dsm_func_mask, lps0_dsm_guid); 556 557 if (lps0_dsm_func_mask_microsoft > 0) 558 acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF, 559 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 560 561 /* LPS0 entry */ 562 if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd()) 563 acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD, 564 lps0_dsm_func_mask, lps0_dsm_guid); 565 566 if (lps0_dsm_func_mask_microsoft > 0) { 567 /* Modern Standby entry */ 568 acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_ENTRY, 569 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 570 acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY, 571 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 572 } 573 574 if (lps0_dsm_func_mask > 0 && !acpi_s2idle_vendor_amd()) 575 acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY, 576 lps0_dsm_func_mask, lps0_dsm_guid); 577 578 list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) { 579 if (handler->prepare) 580 handler->prepare(); 581 } 582 583 return 0; 584 } 585 586 static void acpi_s2idle_check_lps0(void) 587 { 588 struct acpi_s2idle_dev_ops *handler; 589 590 if (!lps0_device_handle || sleep_no_lps0) 591 return; 592 593 list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) { 594 if (handler->check) 595 handler->check(); 596 } 597 } 598 599 static void acpi_s2idle_restore_early_lps0(void) 600 { 601 struct acpi_s2idle_dev_ops *handler; 602 603 if (!lps0_device_handle || sleep_no_lps0) 604 return; 605 606 list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) 607 if (handler->restore) 608 handler->restore(); 609 610 /* LPS0 exit */ 611 if (lps0_dsm_func_mask > 0) 612 acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? 613 ACPI_LPS0_EXIT_AMD : 614 ACPI_LPS0_EXIT, 615 lps0_dsm_func_mask, lps0_dsm_guid); 616 617 if (lps0_dsm_func_mask_microsoft > 0) { 618 acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT, 619 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 620 /* Modern Standby exit */ 621 acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, 622 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 623 } 624 625 /* Screen on */ 626 if (lps0_dsm_func_mask_microsoft > 0) 627 acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON, 628 lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); 629 if (lps0_dsm_func_mask > 0) 630 acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? 631 ACPI_LPS0_SCREEN_ON_AMD : 632 ACPI_LPS0_SCREEN_ON, 633 lps0_dsm_func_mask, lps0_dsm_guid); 634 } 635 636 static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = { 637 .begin = acpi_s2idle_begin_lps0, 638 .prepare = acpi_s2idle_prepare, 639 .prepare_late = acpi_s2idle_prepare_late_lps0, 640 .check = acpi_s2idle_check_lps0, 641 .wake = acpi_s2idle_wake, 642 .restore_early = acpi_s2idle_restore_early_lps0, 643 .restore = acpi_s2idle_restore, 644 .end = acpi_s2idle_end, 645 }; 646 647 void __init acpi_s2idle_setup(void) 648 { 649 acpi_scan_add_handler(&lps0_handler); 650 s2idle_set_ops(&acpi_s2idle_ops_lps0); 651 } 652 653 int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg) 654 { 655 unsigned int sleep_flags; 656 657 if (!lps0_device_handle || sleep_no_lps0) 658 return -ENODEV; 659 660 sleep_flags = lock_system_sleep(); 661 list_add(&arg->list_node, &lps0_s2idle_devops_head); 662 unlock_system_sleep(sleep_flags); 663 664 return 0; 665 } 666 EXPORT_SYMBOL_GPL(acpi_register_lps0_dev); 667 668 void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg) 669 { 670 unsigned int sleep_flags; 671 672 if (!lps0_device_handle || sleep_no_lps0) 673 return; 674 675 sleep_flags = lock_system_sleep(); 676 list_del(&arg->list_node); 677 unlock_system_sleep(sleep_flags); 678 } 679 EXPORT_SYMBOL_GPL(acpi_unregister_lps0_dev); 680 681 #endif /* CONFIG_SUSPEND */ 682