Skip to content

Commit

Permalink
ACPI: NFIT: Install Notify() handler directly
Browse files Browse the repository at this point in the history
Modify the ACPI NFIT driver to install its own Notify() handler directly
instead of providing an ACPI driver .notify() callback.

This will allow the ACPI driver .notify() callback to be eliminated.

Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
[ rjw: Subject and changelog edits, whitespace adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Michal Wilczynski authored and Rafael J. Wysocki committed Jul 14, 2023
1 parent 898ff0f commit dcca12a
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions drivers/acpi/nfit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3282,6 +3282,23 @@ static void acpi_nfit_put_table(void *table)
acpi_put_table(table);
}

static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_device *adev = data;

device_lock(&adev->dev);
__acpi_nfit_notify(&adev->dev, handle, event);
device_unlock(&adev->dev);
}

static void acpi_nfit_remove_notify_handler(void *data)
{
struct acpi_device *adev = data;

acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY,
acpi_nfit_notify);
}

void acpi_nfit_shutdown(void *data)
{
struct acpi_nfit_desc *acpi_desc = data;
Expand Down Expand Up @@ -3368,7 +3385,18 @@ static int acpi_nfit_add(struct acpi_device *adev)

if (rc)
return rc;
return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);

rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
if (rc)
return rc;

rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
acpi_nfit_notify);
if (rc)
return rc;

return devm_add_action_or_reset(dev, acpi_nfit_remove_notify_handler,
adev);
}

static void acpi_nfit_remove(struct acpi_device *adev)
Expand Down Expand Up @@ -3446,13 +3474,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event)
}
EXPORT_SYMBOL_GPL(__acpi_nfit_notify);

static void acpi_nfit_notify(struct acpi_device *adev, u32 event)
{
device_lock(&adev->dev);
__acpi_nfit_notify(&adev->dev, adev->handle, event);
device_unlock(&adev->dev);
}

static const struct acpi_device_id acpi_nfit_ids[] = {
{ "ACPI0012", 0 },
{ "", 0 },
Expand All @@ -3465,7 +3486,6 @@ static struct acpi_driver acpi_nfit_driver = {
.ops = {
.add = acpi_nfit_add,
.remove = acpi_nfit_remove,
.notify = acpi_nfit_notify,
},
};

Expand Down

0 comments on commit dcca12a

Please sign in to comment.