Skip to content

Commit

Permalink
ACPI / glue: Add acpi_platform_notify() function
Browse files Browse the repository at this point in the history
Instead of relying on the "platform_notify" callback hook,
introducing separate notification function
acpi_platform_notify() and calling that directly from
drivers core when device entries are added and removed.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Heikki Krogerus authored and Rafael J. Wysocki committed Nov 26, 2018
1 parent 07de0e8 commit 7847a14
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
1 change: 0 additions & 1 deletion drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,6 @@ static int __init acpi_init(void)
acpi_kobj = NULL;
}

init_acpi_device_notify();
result = acpi_bus_init();
if (result) {
disable_acpi();
Expand Down
21 changes: 13 additions & 8 deletions drivers/acpi/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ int acpi_unbind_one(struct device *dev)
}
EXPORT_SYMBOL_GPL(acpi_unbind_one);

static int acpi_platform_notify(struct device *dev)
static int acpi_device_notify(struct device *dev)
{
struct acpi_bus_type *type = acpi_get_bus_type(dev);
struct acpi_device *adev;
Expand Down Expand Up @@ -343,7 +343,7 @@ static int acpi_platform_notify(struct device *dev)
return ret;
}

static int acpi_platform_notify_remove(struct device *dev)
static int acpi_device_notify_remove(struct device *dev)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
struct acpi_bus_type *type;
Expand All @@ -361,12 +361,17 @@ static int acpi_platform_notify_remove(struct device *dev)
return 0;
}

void __init init_acpi_device_notify(void)
int acpi_platform_notify(struct device *dev, enum kobject_action action)
{
if (platform_notify || platform_notify_remove) {
printk(KERN_ERR PREFIX "Can't use platform_notify\n");
return;
switch (action) {
case KOBJ_ADD:
acpi_device_notify(dev);
break;
case KOBJ_REMOVE:
acpi_device_notify_remove(dev);
break;
default:
break;
}
platform_notify = acpi_platform_notify;
platform_notify_remove = acpi_platform_notify_remove;
return 0;
}
1 change: 0 additions & 1 deletion drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
int early_acpi_osi_init(void);
int acpi_osi_init(void);
acpi_status acpi_os_initialize1(void);
void init_acpi_device_notify(void);
int acpi_scan_init(void);
void acpi_pci_root_init(void);
void acpi_pci_link_init(void);
Expand Down
7 changes: 7 additions & 0 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Copyright (c) 2006 Novell, Inc.
*/

#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/fwnode.h>
Expand Down Expand Up @@ -731,6 +732,12 @@ static inline int device_is_not_partition(struct device *dev)
static int
device_platform_notify(struct device *dev, enum kobject_action action)
{
int ret;

ret = acpi_platform_notify(dev, action);
if (ret)
return ret;

if (platform_notify && action == KOBJ_ADD)
platform_notify(dev);
else if (platform_notify_remove && action == KOBJ_REMOVE)
Expand Down
10 changes: 10 additions & 0 deletions include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1313,4 +1313,14 @@ static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
}
#endif

#ifdef CONFIG_ACPI
extern int acpi_platform_notify(struct device *dev, enum kobject_action action);
#else
static inline int
acpi_platform_notify(struct device *dev, enum kobject_action action)
{
return 0;
}
#endif

#endif /*_LINUX_ACPI_H*/

0 comments on commit 7847a14

Please sign in to comment.