diff options
author | Lan Tianyu <tianyu.lan@intel.com> | 2014-05-20 08:59:21 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-26 19:19:54 -0400 |
commit | 72013795a73f8536d3346fa90379c987bcad0cc8 (patch) | |
tree | 1ca55d541d6569cdf6e824ecea1edb9498c6abf3 | |
parent | c7208164e66f63e3ec1759b98087849286410741 (diff) |
ACPI: Add acpi_bus_attach_private_data() to attach data to ACPI handle
There is already acpi_bus_get_private_data() to get ACPI handle data
which is associated with acpi_bus_private_data_handler(). This patch
is to add acpi_bus_attach_private_data() to make a pair and facilitate
to attach and get data to/from ACPI handle.
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/bus.c | 28 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 2 |
2 files changed, 26 insertions, 4 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index cf925c4f36b7..8445d570f60a 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -132,6 +132,21 @@ void acpi_bus_private_data_handler(acpi_handle handle, | |||
132 | } | 132 | } |
133 | EXPORT_SYMBOL(acpi_bus_private_data_handler); | 133 | EXPORT_SYMBOL(acpi_bus_private_data_handler); |
134 | 134 | ||
135 | int acpi_bus_attach_private_data(acpi_handle handle, void *data) | ||
136 | { | ||
137 | acpi_status status; | ||
138 | |||
139 | status = acpi_attach_data(handle, | ||
140 | acpi_bus_private_data_handler, data); | ||
141 | if (ACPI_FAILURE(status)) { | ||
142 | acpi_handle_debug(handle, "Error attaching device data\n"); | ||
143 | return -ENODEV; | ||
144 | } | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | EXPORT_SYMBOL_GPL(acpi_bus_attach_private_data); | ||
149 | |||
135 | int acpi_bus_get_private_data(acpi_handle handle, void **data) | 150 | int acpi_bus_get_private_data(acpi_handle handle, void **data) |
136 | { | 151 | { |
137 | acpi_status status; | 152 | acpi_status status; |
@@ -140,15 +155,20 @@ int acpi_bus_get_private_data(acpi_handle handle, void **data) | |||
140 | return -EINVAL; | 155 | return -EINVAL; |
141 | 156 | ||
142 | status = acpi_get_data(handle, acpi_bus_private_data_handler, data); | 157 | status = acpi_get_data(handle, acpi_bus_private_data_handler, data); |
143 | if (ACPI_FAILURE(status) || !*data) { | 158 | if (ACPI_FAILURE(status)) { |
144 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", | 159 | acpi_handle_debug(handle, "No context for object\n"); |
145 | handle)); | ||
146 | return -ENODEV; | 160 | return -ENODEV; |
147 | } | 161 | } |
148 | 162 | ||
149 | return 0; | 163 | return 0; |
150 | } | 164 | } |
151 | EXPORT_SYMBOL(acpi_bus_get_private_data); | 165 | EXPORT_SYMBOL_GPL(acpi_bus_get_private_data); |
166 | |||
167 | void acpi_bus_detach_private_data(acpi_handle handle) | ||
168 | { | ||
169 | acpi_detach_data(handle, acpi_bus_private_data_handler); | ||
170 | } | ||
171 | EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data); | ||
152 | 172 | ||
153 | void acpi_bus_no_hotplug(acpi_handle handle) | 173 | void acpi_bus_no_hotplug(acpi_handle handle) |
154 | { | 174 | { |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 84a2e29a2314..d2006ca31dba 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -406,6 +406,8 @@ extern struct kobject *acpi_kobj; | |||
406 | extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); | 406 | extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); |
407 | void acpi_bus_private_data_handler(acpi_handle, void *); | 407 | void acpi_bus_private_data_handler(acpi_handle, void *); |
408 | int acpi_bus_get_private_data(acpi_handle, void **); | 408 | int acpi_bus_get_private_data(acpi_handle, void **); |
409 | int acpi_bus_attach_private_data(acpi_handle, void *); | ||
410 | void acpi_bus_detach_private_data(acpi_handle); | ||
409 | void acpi_bus_no_hotplug(acpi_handle handle); | 411 | void acpi_bus_no_hotplug(acpi_handle handle); |
410 | extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); | 412 | extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); |
411 | extern int register_acpi_notifier(struct notifier_block *); | 413 | extern int register_acpi_notifier(struct notifier_block *); |