summaryrefslogtreecommitdiff
path: root/drivers/base/property.c
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2017-12-13 18:16:19 -0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2017-12-21 15:01:33 +0100
commitfb2d2dee504a963efdcb76517b5cdf25444cf535 (patch)
treef1b58594ba11c6c41c3acddde35890f68c42ea9e /drivers/base/property.c
parenteffee16e4c0cc8b570d372e33633e9f9bc8359c7 (diff)
parentd9f7e5584f0e3e34a2c14825657a6b31e7184171 (diff)
Merge pull request #21 from falstaff84/4.9-1.0.x-imx-fixes-stable-merge
4.9-1.0.x-imx stable 4.9.67 merge
Diffstat (limited to 'drivers/base/property.c')
-rw-r--r--drivers/base/property.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 43a36d68c3fd..7b313b567f4c 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -20,6 +20,7 @@
#include <linux/phy.h>
struct property_set {
+ struct device *dev;
struct fwnode_handle fwnode;
struct property_entry *properties;
};
@@ -182,11 +183,12 @@ static int pset_prop_read_string(struct property_set *pset,
return 0;
}
-static inline struct fwnode_handle *dev_fwnode(struct device *dev)
+struct fwnode_handle *dev_fwnode(struct device *dev)
{
return IS_ENABLED(CONFIG_OF) && dev->of_node ?
&dev->of_node->fwnode : dev->fwnode;
}
+EXPORT_SYMBOL_GPL(dev_fwnode);
/**
* device_property_present - check if a property of a device is present
@@ -816,6 +818,7 @@ static struct property_set *pset_copy_set(const struct property_set *pset)
void device_remove_properties(struct device *dev)
{
struct fwnode_handle *fwnode;
+ struct property_set *pset;
fwnode = dev_fwnode(dev);
if (!fwnode)
@@ -825,16 +828,16 @@ void device_remove_properties(struct device *dev)
* the pset. If there is no real firmware node (ACPI/DT) primary
* will hold the pset.
*/
- if (is_pset_node(fwnode)) {
+ pset = to_pset_node(fwnode);
+ if (pset) {
set_primary_fwnode(dev, NULL);
- pset_free_set(to_pset_node(fwnode));
} else {
- fwnode = fwnode->secondary;
- if (!IS_ERR(fwnode) && is_pset_node(fwnode)) {
+ pset = to_pset_node(fwnode->secondary);
+ if (pset && dev == pset->dev)
set_secondary_fwnode(dev, NULL);
- pset_free_set(to_pset_node(fwnode));
- }
}
+ if (pset && dev == pset->dev)
+ pset_free_set(pset);
}
EXPORT_SYMBOL_GPL(device_remove_properties);
@@ -862,6 +865,7 @@ int device_add_properties(struct device *dev, struct property_entry *properties)
p->fwnode.type = FWNODE_PDATA;
set_secondary_fwnode(dev, &p->fwnode);
+ p->dev = dev;
return 0;
}
EXPORT_SYMBOL_GPL(device_add_properties);