aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-04-12 18:35:54 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-04-12 18:35:54 -0400
commit9a9ca16e7a36a9daa93f6d2cf912170091d91ed6 (patch)
treee3c8abf8249d8f6967679510132943454bc19fc6
parent34a1b99b9b4d81b0d835c08239c1180e83703bb7 (diff)
parent16ba08d5c9ec44f89ec03c67ecf7a9c5e2d204fd (diff)
Merge branch 'device-properties'
* device-properties: device property: Introduce firmware node type for platform data device property: Make it possible to use secondary firmware nodes driver core: Implement device property accessors through fwnode ones driver core: property: Update fwnode_property_read_string_array() driver core: Add comments about returning array counts ACPI: Introduce has_acpi_companion() driver core / ACPI: Represent ACPI companions using fwnode_handle
-rw-r--r--drivers/acpi/acpi_platform.c2
-rw-r--r--drivers/acpi/dock.c2
-rw-r--r--drivers/acpi/glue.c4
-rw-r--r--drivers/base/core.c51
-rw-r--r--drivers/base/platform.c2
-rw-r--r--drivers/base/property.c198
-rw-r--r--drivers/gpio/gpiolib.h2
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c4
-rw-r--r--drivers/i2c/i2c-core.c4
-rw-r--r--drivers/iommu/intel-iommu.c2
-rw-r--r--include/acpi/acpi_bus.h3
-rw-r--r--include/linux/acpi.h15
-rw-r--r--include/linux/device.h16
-rw-r--r--include/linux/fwnode.h27
-rw-r--r--include/linux/i2c.h4
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/property.h44
17 files changed, 292 insertions, 90 deletions
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 1284138e42ab..4bf75597f732 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -102,7 +102,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
102 pdevinfo.id = -1; 102 pdevinfo.id = -1;
103 pdevinfo.res = resources; 103 pdevinfo.res = resources;
104 pdevinfo.num_res = count; 104 pdevinfo.num_res = count;
105 pdevinfo.acpi_node.companion = adev; 105 pdevinfo.fwnode = acpi_fwnode_handle(adev);
106 pdevinfo.dma_mask = DMA_BIT_MASK(32); 106 pdevinfo.dma_mask = DMA_BIT_MASK(32);
107 pdev = platform_device_register_full(&pdevinfo); 107 pdev = platform_device_register_full(&pdevinfo);
108 if (IS_ERR(pdev)) 108 if (IS_ERR(pdev))
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index d9339b442a4e..a688aa243f6c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -615,7 +615,7 @@ void acpi_dock_add(struct acpi_device *adev)
615 memset(&pdevinfo, 0, sizeof(pdevinfo)); 615 memset(&pdevinfo, 0, sizeof(pdevinfo));
616 pdevinfo.name = "dock"; 616 pdevinfo.name = "dock";
617 pdevinfo.id = dock_station_count; 617 pdevinfo.id = dock_station_count;
618 pdevinfo.acpi_node.companion = adev; 618 pdevinfo.fwnode = acpi_fwnode_handle(adev);
619 pdevinfo.data = &ds; 619 pdevinfo.data = &ds;
620 pdevinfo.size_data = sizeof(ds); 620 pdevinfo.size_data = sizeof(ds);
621 dd = platform_device_register_full(&pdevinfo); 621 dd = platform_device_register_full(&pdevinfo);
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f774c65ecb8b..39c485b0c25c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
168 unsigned int node_id; 168 unsigned int node_id;
169 int retval = -EINVAL; 169 int retval = -EINVAL;
170 170
171 if (ACPI_COMPANION(dev)) { 171 if (has_acpi_companion(dev)) {
172 if (acpi_dev) { 172 if (acpi_dev) {
173 dev_warn(dev, "ACPI companion already set\n"); 173 dev_warn(dev, "ACPI companion already set\n");
174 return -EINVAL; 174 return -EINVAL;
@@ -220,7 +220,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
220 list_add(&physical_node->node, physnode_list); 220 list_add(&physical_node->node, physnode_list);
221 acpi_dev->physical_node_count++; 221 acpi_dev->physical_node_count++;
222 222
223 if (!ACPI_COMPANION(dev)) 223 if (!has_acpi_companion(dev))
224 ACPI_COMPANION_SET(dev, acpi_dev); 224 ACPI_COMPANION_SET(dev, acpi_dev);
225 225
226 acpi_physnode_link_name(physical_node_name, node_id); 226 acpi_physnode_link_name(physical_node_name, node_id);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 07304a3b9ee2..c7e2a9a70865 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fwnode.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
@@ -2133,3 +2134,53 @@ define_dev_printk_level(dev_notice, KERN_NOTICE);
2133define_dev_printk_level(_dev_info, KERN_INFO); 2134define_dev_printk_level(_dev_info, KERN_INFO);
2134 2135
2135#endif 2136#endif
2137
2138static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
2139{
2140 return fwnode && !IS_ERR(fwnode->secondary);
2141}
2142
2143/**
2144 * set_primary_fwnode - Change the primary firmware node of a given device.
2145 * @dev: Device to handle.
2146 * @fwnode: New primary firmware node of the device.
2147 *
2148 * Set the device's firmware node pointer to @fwnode, but if a secondary
2149 * firmware node of the device is present, preserve it.
2150 */
2151void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
2152{
2153 if (fwnode) {
2154 struct fwnode_handle *fn = dev->fwnode;
2155
2156 if (fwnode_is_primary(fn))
2157 fn = fn->secondary;
2158
2159 fwnode->secondary = fn;
2160 dev->fwnode = fwnode;
2161 } else {
2162 dev->fwnode = fwnode_is_primary(dev->fwnode) ?
2163 dev->fwnode->secondary : NULL;
2164 }
2165}
2166EXPORT_SYMBOL_GPL(set_primary_fwnode);
2167
2168/**
2169 * set_secondary_fwnode - Change the secondary firmware node of a given device.
2170 * @dev: Device to handle.
2171 * @fwnode: New secondary firmware node of the device.
2172 *
2173 * If a primary firmware node of the device is present, set its secondary
2174 * pointer to @fwnode. Otherwise, set the device's firmware node pointer to
2175 * @fwnode.
2176 */
2177void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
2178{
2179 if (fwnode)
2180 fwnode->secondary = ERR_PTR(-ENODEV);
2181
2182 if (fwnode_is_primary(dev->fwnode))
2183 dev->fwnode->secondary = fwnode;
2184 else
2185 dev->fwnode = fwnode;
2186}
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9421fed40905..17f0204fabef 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -454,7 +454,7 @@ struct platform_device *platform_device_register_full(
454 goto err_alloc; 454 goto err_alloc;
455 455
456 pdev->dev.parent = pdevinfo->parent; 456 pdev->dev.parent = pdevinfo->parent;
457 ACPI_COMPANION_SET(&pdev->dev, pdevinfo->acpi_node.companion); 457 pdev->dev.fwnode = pdevinfo->fwnode;
458 458
459 if (pdevinfo->dma_mask) { 459 if (pdevinfo->dma_mask) {
460 /* 460 /*
diff --git a/drivers/base/property.c b/drivers/base/property.c
index c45845874d4f..6a3f7d8af341 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -10,10 +10,102 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/property.h>
14#include <linux/export.h>
15#include <linux/acpi.h> 13#include <linux/acpi.h>
14#include <linux/export.h>
15#include <linux/kernel.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/property.h>
18
19/**
20 * device_add_property_set - Add a collection of properties to a device object.
21 * @dev: Device to add properties to.
22 * @pset: Collection of properties to add.
23 *
24 * Associate a collection of device properties represented by @pset with @dev
25 * as its secondary firmware node.
26 */
27void device_add_property_set(struct device *dev, struct property_set *pset)
28{
29 if (pset)
30 pset->fwnode.type = FWNODE_PDATA;
31
32 set_secondary_fwnode(dev, &pset->fwnode);
33}
34EXPORT_SYMBOL_GPL(device_add_property_set);
35
36static inline bool is_pset(struct fwnode_handle *fwnode)
37{
38 return fwnode && fwnode->type == FWNODE_PDATA;
39}
40
41static inline struct property_set *to_pset(struct fwnode_handle *fwnod