summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2016-03-29 07:52:23 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-04-08 21:10:50 -0400
commitf4d05266032346531b9f889e26aa31a0cf2a9822 (patch)
tree505a1b118968395ab85a39f37ae0e6c0a4d6c342 /drivers/base
parent9735a22799b9214d17d3c231fe377fc852f042e9 (diff)
device property: don't bother the drivers with struct property_set
Since device_add_property_set() now always takes a copy of the property_set, and also since the fwnode type is always hard coded to be FWNODE_PDATA, there is no need for the drivers to deliver the entire struct property_set. The function can just create the instance of it on its own and bind the properties from the drivers to it on the spot. This renames device_add_property_set() to device_add_properties(). The function now takes struct property_entry as its parameter instead of struct property_set. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Thierry Reding <treding@nvidia.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/platform.c19
-rw-r--r--drivers/base/property.c34
2 files changed, 31 insertions, 22 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f437afa17f2b..6482d47deb50 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -322,16 +322,16 @@ EXPORT_SYMBOL_GPL(platform_device_add_data);
322/** 322/**
323 * platform_device_add_properties - add built-in properties to a platform device 323 * platform_device_add_properties - add built-in properties to a platform device
324 * @pdev: platform device to add properties to 324 * @pdev: platform device to add properties to
325 * @pset: properties to add 325 * @properties: null terminated array of properties to add
326 * 326 *
327 * The function will take deep copy of the properties in @pset and attach 327 * The function will take deep copy of @properties and attach the copy to the
328 * the copy to the platform device. The memory associated with properties 328 * platform device. The memory associated with properties will be freed when the
329 * will be freed when the platform device is released. 329 * platform device is released.
330 */ 330 */
331int platform_device_add_properties(struct platform_device *pdev, 331int platform_device_add_properties(struct platform_device *pdev,
332 const struct property_set *pset) 332 struct property_entry *properties)
333{ 333{
334 return device_add_property_set(&pdev->dev, pset); 334 return device_add_properties(&pdev->dev, properties);
335} 335}
336EXPORT_SYMBOL_GPL(platform_device_add_properties); 336EXPORT_SYMBOL_GPL(platform_device_add_properties);
337 337
@@ -447,7 +447,7 @@ void platform_device_del(struct platform_device *pdev)
447 release_resource(r); 447 release_resource(r);
448 } 448 }
449 449
450 device_remove_property_set(&pdev->dev); 450 device_remove_properties(&pdev->dev);
451 } 451 }
452} 452}
453EXPORT_SYMBOL_GPL(platform_device_del); 453EXPORT_SYMBOL_GPL(platform_device_del);
@@ -526,8 +526,9 @@ struct platform_device *platform_device_register_full(
526 if (ret) 526 if (ret)
527 goto err; 527 goto err;
528 528
529 if (pdevinfo->pset) { 529 if (pdevinfo->properties) {
530 ret = platform_device_add_properties(pdev, pdevinfo->pset); 530 ret = platform_device_add_properties(pdev,
531 pdevinfo->properties);
531 if (ret) 532 if (ret)
532 goto err; 533 goto err;
533 } 534 }
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 9b1a65debd49..210423d00d78 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -19,6 +19,11 @@
19#include <linux/etherdevice.h> 19#include <linux/etherdevice.h>
20#include <linux/phy.h> 20#include <linux/phy.h>
21 21
22struct property_set {
23 struct fwnode_handle fwnode;
24 struct property_entry *properties;
25};
26
22static inline bool is_pset_node(struct fwnode_handle *fwnode) 27static inline bool is_pset_node(struct fwnode_handle *fwnode)
23{ 28{
24 return fwnode && fwnode->type == FWNODE_PDATA; 29 return fwnode && fwnode->type == FWNODE_PDATA;
@@ -801,14 +806,14 @@ static struct property_set *pset_copy_set(const struct property_set *pset)
801} 806}
802 807
803/** 808/**
804 * device_remove_property_set - Remove properties from a device object. 809 * device_remove_properties - Remove properties from a device object.
805 * @dev: Device whose properties to remove. 810 * @dev: Device whose properties to remove.
806 * 811 *
807 * The function removes properties previously associated to the device 812 * The function removes properties previously associated to the device
808 * secondary firmware node with device_add_property_set(). Memory allocated 813 * secondary firmware node with device_add_properties(). Memory allocated
809 * to the properties will also be released. 814 * to the properties will also be released.
810 */ 815 */
811void device_remove_property_set(struct device *dev) 816void device_remove_properties(struct device *dev)
812{ 817{
813 struct fwnode_handle *fwnode; 818 struct fwnode_handle *fwnode;
814 819
@@ -831,24 +836,27 @@ void device_remove_property_set(struct device *dev)
831 } 836 }
832 } 837 }
833} 838}
834EXPORT_SYMBOL_GPL(device_remove_property_set); 839EXPORT_SYMBOL_GPL(device_remove_properties);
835 840
836/** 841/**
837 * device_add_property_set - Add a collection of properties to a device object. 842 * device_add_properties - Add a collection of properties to a device object.
838 * @dev: Device to add properties to. 843 * @dev: Device to add properties to.
839 * @pset: Collection of properties to add. 844 * @properties: Collection of properties to add.
840 * 845 *
841 * Associate a collection of device properties represented by @pset with @dev 846 * Associate a collection of device properties represented by @properties with
842 * as its secondary firmware node. The function takes a copy of @pset. 847 * @dev as its secondary firmware node. The function takes a copy of
848 * @properties.
843 */ 849 */
844int device_add_property_set(struct device *dev, const struct property_set *pset) 850int device_add_properties(struct device *dev, struct property_entry *properties)
845{ 851{
846 struct property_set *p; 852 struct property_set *p, pset;
847 853
848 if (!pset) 854 if (!properties)
849 return -EINVAL; 855 return -EINVAL;
850 856
851 p = pset_copy_set(pset); 857 pset.properties = properties;
858
859 p = pset_copy_set(&pset);
852 if (IS_ERR(p)) 860 if (IS_ERR(p))
853 return PTR_ERR(p); 861 return PTR_ERR(p);
854 862
@@ -856,7 +864,7 @@ int device_add_property_set(struct device *dev, const struct property_set *pset)
856 set_secondary_fwnode(dev, &p->fwnode); 864 set_secondary_fwnode(dev, &p->fwnode);
857 return 0; 865 return 0;
858} 866}
859EXPORT_SYMBOL_GPL(device_add_property_set); 867EXPORT_SYMBOL_GPL(device_add_properties);
860 868
861/** 869/**
862 * device_get_next_child_node - Return the next child node handle for a device 870 * device_get_next_child_node - Return the next child node handle for a device