diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2017-07-21 13:39:31 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-07-22 00:04:50 +0200 |
commit | db3e50f3234ba1a477413f56a9e5800a73dca786 (patch) | |
tree | 87c3c735dd51f68e77d3189186094ee216204a76 /drivers/base/property.c | |
parent | ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node() (diff) | |
download | linux-db3e50f3234ba1a477413f56a9e5800a73dca786.tar.xz linux-db3e50f3234ba1a477413f56a9e5800a73dca786.zip |
device property: Get rid of struct fwnode_handle type field
Instead of relying on the struct fwnode_handle type field, define
fwnode_operations structs for all separate types of fwnodes. To find out
the type, compare to the ops field to relevant ops structs.
This change has two benefits:
1. it avoids adding the type field to each and every instance of struct
fwnode_handle, thus saving memory and
2. makes the ops field the single factor that defines both the types of
the fwnode as well as defines the implementation of its operations,
decreasing the possibility of bugs when developing code dealing with
fwnode internals.
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/property.c')
-rw-r--r-- | drivers/base/property.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index edf02c1b5845..857e4d39add6 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -25,9 +25,11 @@ struct property_set { const struct property_entry *properties; }; +static const struct fwnode_operations pset_fwnode_ops; + static inline bool is_pset_node(struct fwnode_handle *fwnode) { - return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_PDATA; + return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &pset_fwnode_ops; } static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode) @@ -900,7 +902,6 @@ int device_add_properties(struct device *dev, if (IS_ERR(p)) return PTR_ERR(p); - p->fwnode.type = FWNODE_PDATA; p->fwnode.ops = &pset_fwnode_ops; set_secondary_fwnode(dev, &p->fwnode); return 0; |