aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-11 16:41:56 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-14 17:14:43 -0500
commit7b1998116bbb2f3e5dd6cb9a8ee6db479b0b50a9 (patch)
tree7c84d3fe84a28e8e4368570c72e5c13ffef21f1a /include/linux
parent2f466d33f5f60542d3d82c0477de5863b22c94b9 (diff)
ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node
Modify struct acpi_dev_node to contain a pointer to struct acpi_device associated with the given device object (that is, its ACPI companion device) instead of an ACPI handle corresponding to it. Introduce two new macros for manipulating that pointer in a CONFIG_ACPI-safe way, ACPI_COMPANION() and ACPI_COMPANION_SET(), and rework the ACPI_HANDLE() macro to take the above changes into account. Drop the ACPI_HANDLE_SET() macro entirely and rework its users to use ACPI_COMPANION_SET() instead. For some of them who used to pass the result of acpi_get_child() directly to ACPI_HANDLE_SET() introduce a helper routine acpi_preset_companion() doing an equivalent thing. The main motivation for doing this is that there are things represented by struct acpi_device objects that don't have valid ACPI handles (so called fixed ACPI hardware features, such as power and sleep buttons) and we would like to create platform device objects for them and "glue" them to their ACPI companions in the usual way (which currently is impossible due to the lack of valid ACPI handles). However, there are more reasons why it may be useful. First, struct acpi_device pointers allow of much better type checking than void pointers which are ACPI handles, so it should be more difficult to write buggy code using modified struct acpi_dev_node and the new macros. Second, the change should help to reduce (over time) the number of places in which the result of ACPI_HANDLE() is passed to acpi_bus_get_device() in order to obtain a pointer to the struct acpi_device associated with the given "physical" device, because now that pointer is returned by ACPI_COMPANION() directly. Finally, the change should make it easier to write generic code that will build both for CONFIG_ACPI set and unset without adding explicit compiler directives to it. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> # on Haswell Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Aaron Lu <aaron.lu@intel.com> # for ATA and SDIO part
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/acpi.h15
-rw-r--r--include/linux/device.h12
2 files changed, 18 insertions, 9 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index b0972c4ce81c..47369aadb1d1 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -44,6 +44,15 @@
44#include <acpi/acpi_numa.h> 44#include <acpi/acpi_numa.h>
45#include <asm/acpi.h> 45#include <asm/acpi.h>
46 46
47static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
48{
49 return adev ? adev->handle : NULL;
50}
51
52#define ACPI_COMPANION(dev) ((dev)->acpi_node.companion)
53#define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev)
54#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
55
47enum acpi_irq_model_id { 56enum acpi_irq_model_id {
48 ACPI_IRQ_MODEL_PIC = 0, 57 ACPI_IRQ_MODEL_PIC = 0,
49 ACPI_IRQ_MODEL_IOAPIC, 58 ACPI_IRQ_MODEL_IOAPIC,
@@ -401,6 +410,10 @@ static inline bool acpi_driver_match_device(struct device *dev,
401 410
402#define acpi_disabled 1 411#define acpi_disabled 1
403 412
413#define ACPI_COMPANION(dev) (NULL)
414#define ACPI_COMPANION_SET(dev, adev) do { } while (0)
415#define ACPI_HANDLE(dev) (NULL)
416
404static inline void acpi_early_init(void) { } 417static inline void acpi_early_init(void) { }
405 418
406static inline int early_acpi_boot_init(void) 419static inline int early_acpi_boot_init(void)
@@ -469,6 +482,8 @@ static inline bool acpi_driver_match_device(struct device *dev,
469 482
470#endif /* !CONFIG_ACPI */ 483#endif /* !CONFIG_ACPI */
471 484
485#define DEVICE_ACPI_HANDLE(dev) ACPI_HANDLE(dev)
486
472#ifdef CONFIG_ACPI 487#ifdef CONFIG_ACPI
473void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, 488void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
474 u32 pm1a_ctrl, u32 pm1b_ctrl)); 489 u32 pm1a_ctrl, u32 pm1b_ctrl));
diff --git a/include/linux/device.h b/include/linux/device.h
index b025925df7f7..952b01033c32 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -644,9 +644,11 @@ struct device_dma_parameters {
644 unsigned long segment_boundary_mask; 644 unsigned long segment_boundary_mask;
645}; 645};
646 646
647struct acpi_device;
648
647struct acpi_dev_node { 649struct acpi_dev_node {
648#ifdef CONFIG_ACPI 650#ifdef CONFIG_ACPI
649 void *handle; 651 struct acpi_device *companion;
650#endif 652#endif
651}; 653};
652 654
@@ -790,14 +792,6 @@ static inline struct device *kobj_to_dev(struct kobject *kobj)
790 return container_of(kobj, struct device, kobj); 792 return container_of(kobj, struct device, kobj);
791} 793}
792 794
793#ifdef CONFIG_ACPI
794#define ACPI_HANDLE(dev) ((dev)->acpi_node.handle)
795#define ACPI_HANDLE_SET(dev, _handle_) (dev)->acpi_node.handle = (_handle_)
796#else
797#define ACPI_HANDLE(dev) (NULL)
798#define ACPI_HANDLE_SET(dev, _handle_) do { } while (0)
799#endif
800
801/* Get the wakeup routines, which depend on struct device */ 795/* Get the wakeup routines, which depend on struct device */
802#include <linux/pm_wakeup.h> 796#include <linux/pm_wakeup.h>
803 797