acpi_tad.c (d0034a7a4ac7fae708146ac0059b9c47a1543f0d) | acpi_tad.c (596ca52a56da1b9370d358c38acf2ba5251687d9) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * ACPI Time and Alarm (TAD) Device Driver 4 * 5 * Copyright (C) 2018 Intel Corporation 6 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 7 * 8 * This driver is based on Section 9.18 of the ACPI 6.2 specification revision. --- 543 unchanged lines hidden (view full) --- 552static int acpi_tad_disable_timer(struct device *dev, u32 timer_id) 553{ 554 return acpi_tad_wake_set(dev, "_STV", timer_id, ACPI_TAD_WAKE_DISABLED); 555} 556 557static int acpi_tad_remove(struct platform_device *pdev) 558{ 559 struct device *dev = &pdev->dev; | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * ACPI Time and Alarm (TAD) Device Driver 4 * 5 * Copyright (C) 2018 Intel Corporation 6 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 7 * 8 * This driver is based on Section 9.18 of the ACPI 6.2 specification revision. --- 543 unchanged lines hidden (view full) --- 552static int acpi_tad_disable_timer(struct device *dev, u32 timer_id) 553{ 554 return acpi_tad_wake_set(dev, "_STV", timer_id, ACPI_TAD_WAKE_DISABLED); 555} 556 557static int acpi_tad_remove(struct platform_device *pdev) 558{ 559 struct device *dev = &pdev->dev; |
560 acpi_handle handle = ACPI_HANDLE(dev); |
|
560 struct acpi_tad_driver_data *dd = dev_get_drvdata(dev); 561 562 device_init_wakeup(dev, false); 563 564 pm_runtime_get_sync(dev); 565 566 if (dd->capabilities & ACPI_TAD_DC_WAKE) 567 sysfs_remove_group(&dev->kobj, &acpi_tad_dc_attr_group); --- 4 unchanged lines hidden (view full) --- 572 acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER); 573 if (dd->capabilities & ACPI_TAD_DC_WAKE) { 574 acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER); 575 acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER); 576 } 577 578 pm_runtime_put_sync(dev); 579 pm_runtime_disable(dev); | 561 struct acpi_tad_driver_data *dd = dev_get_drvdata(dev); 562 563 device_init_wakeup(dev, false); 564 565 pm_runtime_get_sync(dev); 566 567 if (dd->capabilities & ACPI_TAD_DC_WAKE) 568 sysfs_remove_group(&dev->kobj, &acpi_tad_dc_attr_group); --- 4 unchanged lines hidden (view full) --- 573 acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER); 574 if (dd->capabilities & ACPI_TAD_DC_WAKE) { 575 acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER); 576 acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER); 577 } 578 579 pm_runtime_put_sync(dev); 580 pm_runtime_disable(dev); |
581 acpi_remove_cmos_rtc_space_handler(handle); |
|
580 return 0; 581} 582 583static int acpi_tad_probe(struct platform_device *pdev) 584{ 585 struct device *dev = &pdev->dev; 586 acpi_handle handle = ACPI_HANDLE(dev); 587 struct acpi_tad_driver_data *dd; 588 acpi_status status; 589 unsigned long long caps; 590 int ret; 591 | 582 return 0; 583} 584 585static int acpi_tad_probe(struct platform_device *pdev) 586{ 587 struct device *dev = &pdev->dev; 588 acpi_handle handle = ACPI_HANDLE(dev); 589 struct acpi_tad_driver_data *dd; 590 acpi_status status; 591 unsigned long long caps; 592 int ret; 593 |
594 ret = acpi_install_cmos_rtc_space_handler(handle); 595 if (ret < 0) { 596 dev_info(dev, "Unable to install space handler\n"); 597 return -ENODEV; 598 } |
|
592 /* 593 * Initialization failure messages are mostly about firmware issues, so 594 * print them at the "info" level. 595 */ 596 status = acpi_evaluate_integer(handle, "_GCP", NULL, &caps); 597 if (ACPI_FAILURE(status)) { 598 dev_info(dev, "Unable to get capabilities\n"); | 599 /* 600 * Initialization failure messages are mostly about firmware issues, so 601 * print them at the "info" level. 602 */ 603 status = acpi_evaluate_integer(handle, "_GCP", NULL, &caps); 604 if (ACPI_FAILURE(status)) { 605 dev_info(dev, "Unable to get capabilities\n"); |
599 return -ENODEV; | 606 ret = -ENODEV; 607 goto remove_handler; |
600 } 601 602 if (!(caps & ACPI_TAD_AC_WAKE)) { 603 dev_info(dev, "Unsupported capabilities\n"); | 608 } 609 610 if (!(caps & ACPI_TAD_AC_WAKE)) { 611 dev_info(dev, "Unsupported capabilities\n"); |
604 return -ENODEV; | 612 ret = -ENODEV; 613 goto remove_handler; |
605 } 606 607 if (!acpi_has_method(handle, "_PRW")) { 608 dev_info(dev, "Missing _PRW\n"); | 614 } 615 616 if (!acpi_has_method(handle, "_PRW")) { 617 dev_info(dev, "Missing _PRW\n"); |
609 return -ENODEV; | 618 ret = -ENODEV; 619 goto remove_handler; |
610 } 611 612 dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL); | 620 } 621 622 dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL); |
613 if (!dd) 614 return -ENOMEM; | 623 if (!dd) { 624 ret = -ENOMEM; 625 goto remove_handler; 626 } |
615 616 dd->capabilities = caps; 617 dev_set_drvdata(dev, dd); 618 619 /* 620 * Assume that the ACPI PM domain has been attached to the device and 621 * simply enable system wakeup and runtime PM and put the device into 622 * runtime suspend. Everything else should be taken care of by the ACPI --- 25 unchanged lines hidden (view full) --- 648 if (ret) 649 goto fail; 650 } 651 652 return 0; 653 654fail: 655 acpi_tad_remove(pdev); | 627 628 dd->capabilities = caps; 629 dev_set_drvdata(dev, dd); 630 631 /* 632 * Assume that the ACPI PM domain has been attached to the device and 633 * simply enable system wakeup and runtime PM and put the device into 634 * runtime suspend. Everything else should be taken care of by the ACPI --- 25 unchanged lines hidden (view full) --- 660 if (ret) 661 goto fail; 662 } 663 664 return 0; 665 666fail: 667 acpi_tad_remove(pdev); |
668 /* Don't fallthrough because cmos rtc space handler is removed in acpi_tad_remove() */ |
|
656 return ret; | 669 return ret; |
670 671remove_handler: 672 acpi_remove_cmos_rtc_space_handler(handle); 673 return ret; |
|
657} 658 659static const struct acpi_device_id acpi_tad_ids[] = { 660 {"ACPI000E", 0}, 661 {} 662}; 663 664static struct platform_driver acpi_tad_driver = { 665 .driver = { 666 .name = "acpi-tad", 667 .acpi_match_table = acpi_tad_ids, 668 }, 669 .probe = acpi_tad_probe, 670 .remove = acpi_tad_remove, 671}; 672MODULE_DEVICE_TABLE(acpi, acpi_tad_ids); 673 674module_platform_driver(acpi_tad_driver); | 674} 675 676static const struct acpi_device_id acpi_tad_ids[] = { 677 {"ACPI000E", 0}, 678 {} 679}; 680 681static struct platform_driver acpi_tad_driver = { 682 .driver = { 683 .name = "acpi-tad", 684 .acpi_match_table = acpi_tad_ids, 685 }, 686 .probe = acpi_tad_probe, 687 .remove = acpi_tad_remove, 688}; 689MODULE_DEVICE_TABLE(acpi, acpi_tad_ids); 690 691module_platform_driver(acpi_tad_driver); |