Skip to content

Commit 77dd14a

Browse files
committed
ACPI: TAD: Use devres for all driver cleanup
The code in acpi_tad_remove() needs to run after the unregistration of the devres-managed RTC class device so that it doesn't race with the class callbacks of the latter. To make that happen, pass it to devm_add_action_or_reset() before registering the RTC class device. Fixes: 7572dca ("ACPI: TAD: Add alarm support to the RTC class device interface") Fixes: 8a1e7f4 ("ACPI: TAD: Add RTC class device interface") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/14001754.uLZWGnKmhe@rafael.j.wysocki
1 parent 88b2670 commit 77dd14a

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/acpi/acpi_tad.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,9 @@ static int acpi_tad_disable_timer(struct device *dev, u32 timer_id)
792792
return acpi_tad_wake_set(dev, "_STV", timer_id, ACPI_TAD_WAKE_DISABLED);
793793
}
794794

795-
static void acpi_tad_remove(struct platform_device *pdev)
795+
static void acpi_tad_remove(void *data)
796796
{
797-
struct device *dev = &pdev->dev;
797+
struct device *dev = data;
798798
struct acpi_tad_driver_data *dd = dev_get_drvdata(dev);
799799

800800
device_init_wakeup(dev, false);
@@ -821,6 +821,7 @@ static int acpi_tad_probe(struct platform_device *pdev)
821821
struct acpi_tad_driver_data *dd;
822822
acpi_status status;
823823
unsigned long long caps;
824+
int ret;
824825

825826
/*
826827
* Initialization failure messages are mostly about firmware issues, so
@@ -867,6 +868,14 @@ static int acpi_tad_probe(struct platform_device *pdev)
867868
pm_runtime_enable(dev);
868869
pm_runtime_suspend(dev);
869870

871+
/*
872+
* acpi_tad_remove() needs to run after unregistering the RTC class
873+
* device to avoid racing with the latter's callbacks.
874+
*/
875+
ret = devm_add_action_or_reset(&pdev->dev, acpi_tad_remove, &pdev->dev);
876+
if (ret)
877+
return ret;
878+
870879
if (caps & ACPI_TAD_RT)
871880
acpi_tad_register_rtc(dev, caps);
872881

@@ -885,7 +894,6 @@ static struct platform_driver acpi_tad_driver = {
885894
.dev_groups = acpi_tad_groups,
886895
},
887896
.probe = acpi_tad_probe,
888-
.remove = acpi_tad_remove,
889897
};
890898
MODULE_DEVICE_TABLE(acpi, acpi_tad_ids);
891899

0 commit comments

Comments
 (0)