diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-03-16 18:49:03 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-03-16 18:49:03 -0400 |
commit | ce793486e23e0162a732c605189c8028e0910e86 (patch) | |
tree | bc36cffe7005afecc2f9db436dedd107773108b0 /include/linux | |
parent | 06e5801b8cb3fc057d88cb4dc03c0b64b2744cda (diff) |
driver core / ACPI: Represent ACPI companions using fwnode_handle
Now that we have struct fwnode_handle, we can use that to point to
ACPI companions from struct device objects instead of pointing to
struct acpi_device directly.
There are two benefits from that. First, the somewhat ugly and
hackish struct acpi_dev_node can be dropped and, second, the same
struct fwnode_handle pointer can be used in the future to point
to other (non-ACPI) firmware device node types.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/acpi.h | 5 | ||||
-rw-r--r-- | include/linux/device.h | 13 | ||||
-rw-r--r-- | include/linux/fwnode.h | 25 | ||||
-rw-r--r-- | include/linux/i2c.h | 4 | ||||
-rw-r--r-- | include/linux/platform_device.h | 2 | ||||
-rw-r--r-- | include/linux/property.h | 11 |
6 files changed, 35 insertions, 25 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 24c7aa8b1d20..402ddbdc2da1 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -53,8 +53,9 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) | |||
53 | return adev ? adev->handle : NULL; | 53 | return adev ? adev->handle : NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | #define ACPI_COMPANION(dev) ((dev)->acpi_node.companion) | 56 | #define ACPI_COMPANION(dev) acpi_node((dev)->fwnode) |
57 | #define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev) | 57 | #define ACPI_COMPANION_SET(dev, adev) (dev)->fwnode = (adev) ? \ |
58 | acpi_fwnode_handle(adev) : NULL | ||
58 | #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) | 59 | #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) |
59 | 60 | ||
60 | static inline void acpi_preset_companion(struct device *dev, | 61 | static inline void acpi_preset_companion(struct device *dev, |
diff --git a/include/linux/device.h b/include/linux/device.h index 0eb8ee2dc6d1..badef20b876a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -38,6 +38,7 @@ struct class; | |||
38 | struct subsys_private; | 38 | struct subsys_private; |
39 | struct bus_type; | 39 | struct bus_type; |
40 | struct device_node; | 40 | struct device_node; |
41 | struct fwnode_handle; | ||
41 | struct iommu_ops; | 42 | struct iommu_ops; |
42 | struct iommu_group; | 43 | struct iommu_group; |
43 | 44 | ||
@@ -650,14 +651,6 @@ struct device_dma_parameters { | |||
650 | unsigned long segment_boundary_mask; | 651 | unsigned long segment_boundary_mask; |
651 | }; | 652 | }; |
652 | 653 | ||
653 | struct acpi_device; | ||
654 | |||
655 | struct acpi_dev_node { | ||
656 | #ifdef CONFIG_ACPI | ||
657 | struct acpi_device *companion; | ||
658 | #endif | ||
659 | }; | ||
660 | |||
661 | /** | 654 | /** |
662 | * struct device - The basic device structure | 655 | * struct device - The basic device structure |
663 | * @parent: The device's "parent" device, the device to which it is attached. | 656 | * @parent: The device's "parent" device, the device to which it is attached. |
@@ -703,7 +696,7 @@ struct acpi_dev_node { | |||
703 | * @cma_area: Contiguous memory area for dma allocations | 696 | * @cma_area: Contiguous memory area for dma allocations |
704 | * @archdata: For arch-specific additions. | 697 | * @archdata: For arch-specific additions. |
705 | * @of_node: Associated device tree node. | 698 | * @of_node: Associated device tree node. |
706 | * @acpi_node: Associated ACPI device node. | 699 | * @fwnode: Associated device node supplied by platform firmware. |
707 | * @devt: For creating the sysfs "dev". | 700 | * @devt: For creating the sysfs "dev". |
708 | * @id: device instance | 701 | * @id: device instance |
709 | * @devres_lock: Spinlock to protect the resource of the device. | 702 | * @devres_lock: Spinlock to protect the resource of the device. |
@@ -779,7 +772,7 @@ struct device { | |||
779 | struct dev_archdata archdata; | 772 | struct dev_archdata archdata; |
780 | 773 | ||
781 | struct device_node *of_node; /* associated device tree node */ | 774 | struct device_node *of_node; /* associated device tree node */ |
782 | struct acpi_dev_node acpi_node; /* associated ACPI device node */ | 775 | struct fwnode_handle *fwnode; /* firmware device node */ |
783 | 776 | ||
784 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 777 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
785 | u32 id; /* device instance */ | 778 | u32 id; /* device instance */ |
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h new file mode 100644 index 000000000000..17bb5f039509 --- /dev/null +++ b/include/linux/fwnode.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * fwnode.h - Firmware device node object handle type definition. | ||
3 | * | ||
4 | * Copyright (C) 2015, Intel Corporation | ||
5 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef _LINUX_FWNODE_H_ | ||
13 | #define _LINUX_FWNODE_H_ | ||
14 | |||
15 | enum fwnode_type { | ||
16 | FWNODE_INVALID = 0, | ||
17 | FWNODE_OF, | ||
18 | FWNODE_ACPI, | ||
19 | }; | ||
20 | |||
21 | struct fwnode_handle { | ||
22 | enum fwnode_type type; | ||
23 | }; | ||
24 | |||
25 | #endif | ||
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index f17da50402a4..6d89575361a8 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -278,7 +278,7 @@ static inline int i2c_slave_event(struct i2c_client *client, | |||
278 | * @platform_data: stored in i2c_client.dev.platform_data | 278 | * @platform_data: stored in i2c_client.dev.platform_data |
279 | * @archdata: copied into i2c_client.dev.archdata | 279 | * @archdata: copied into i2c_client.dev.archdata |
280 | * @of_node: pointer to OpenFirmware device node | 280 | * @of_node: pointer to OpenFirmware device node |
281 | * @acpi_node: ACPI device node | 281 | * @fwnode: device node supplied by the platform firmware |
282 | * @irq: stored in i2c_client.irq | 282 | * @irq: stored in i2c_client.irq |
283 | * | 283 | * |
284 | * I2C doesn't actually support hardware probing, although controllers and | 284 | * I2C doesn't actually support hardware probing, although controllers and |
@@ -299,7 +299,7 @@ struct i2c_board_info { | |||
299 | void *platform_data; | 299 | void *platform_data; |
300 | struct dev_archdata *archdata; | 300 | struct dev_archdata *archdata; |
301 | struct device_node *of_node; | 301 | struct device_node *of_node; |
302 | struct acpi_dev_node acpi_node; | 302 | struct fwnode_handle *fwnode; |
303 | int irq; | 303 | int irq; |
304 | }; | 304 | }; |
305 | 305 | ||
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index ae4882ca4a64..58f1e75ba105 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
@@ -59,7 +59,7 @@ extern int platform_add_devices(struct platform_device **, int); | |||
59 | 59 | ||
60 | struct platform_device_info { | 60 | struct platform_device_info { |
61 | struct device *parent; | 61 | struct device *parent; |
62 | struct acpi_dev_node acpi_node; | 62 | struct fwnode_handle *fwnode; |
63 | 63 | ||
64 | const char *name; | 64 | const char *name; |
65 | int id; | 65 | int id; |
diff --git a/include/linux/property.h b/include/linux/property.h index a6a3d98bd7e9..31dfd3db35d6 100644 --- a/include/linux/property.h +++ b/include/linux/property.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #ifndef _LINUX_PROPERTY_H_ | 13 | #ifndef _LINUX_PROPERTY_H_ |
14 | #define _LINUX_PROPERTY_H_ | 14 | #define _LINUX_PROPERTY_H_ |
15 | 15 | ||
16 | #include <linux/fwnode.h> | ||
16 | #include <linux/types.h> | 17 | #include <linux/types.h> |
17 | 18 | ||
18 | struct device; | 19 | struct device; |
@@ -40,16 +41,6 @@ int device_property_read_string_array(struct device *dev, const char *propname, | |||
40 | int device_property_read_string(struct device *dev, const char *propname, | 41 | int device_property_read_string(struct device *dev, const char *propname, |
41 | const char **val); | 42 | const char **val); |
42 | 43 | ||
43 | enum fwnode_type { | ||
44 | FWNODE_INVALID = 0, | ||
45 | FWNODE_OF, | ||
46 | FWNODE_ACPI, | ||
47 | }; | ||
48 | |||
49 | struct fwnode_handle { | ||
50 | enum fwnode_type type; | ||
51 | }; | ||
52 | |||
53 | bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname); | 44 | bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname); |
54 | int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, | 45 | int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, |
55 | const char *propname, u8 *val, | 46 | const char *propname, u8 *val, |