aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2017-07-21 07:39:31 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-07-21 18:04:50 -0400
commitdb3e50f3234ba1a477413f56a9e5800a73dca786 (patch)
tree87c3c735dd51f68e77d3189186094ee216204a76 /include/linux
parentb81b729164445cd94c4dd6fc4d6f10487434df4a (diff)
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 'include/linux')
-rw-r--r--include/linux/acpi.h8
-rw-r--r--include/linux/fwnode.h11
-rw-r--r--include/linux/irqdomain.h4
-rw-r--r--include/linux/of.h3
4 files changed, 6 insertions, 20 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index c749eef1daa1..71b763f0bee9 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -57,9 +57,6 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
57 acpi_fwnode_handle(adev) : NULL) 57 acpi_fwnode_handle(adev) : NULL)
58#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 58#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
59 59
60
61extern const struct fwnode_operations acpi_fwnode_ops;
62
63static inline struct fwnode_handle *acpi_alloc_fwnode_static(void) 60static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
64{ 61{
65 struct fwnode_handle *fwnode; 62 struct fwnode_handle *fwnode;
@@ -68,15 +65,14 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
68 if (!fwnode) 65 if (!fwnode)
69 return NULL; 66 return NULL;
70 67
71 fwnode->type = FWNODE_ACPI_STATIC; 68 fwnode->ops = &acpi_static_fwnode_ops;
72 fwnode->ops = &acpi_fwnode_ops;
73 69
74 return fwnode; 70 return fwnode;
75} 71}
76 72
77static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode) 73static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
78{ 74{
79 if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC)) 75 if (WARN_ON(!is_acpi_static_node(fwnode)))
80 return; 76 return;
81 77
82 kfree(fwnode); 78 kfree(fwnode);
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 50893a1646cf..c5dbc48b55dd 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -14,20 +14,9 @@
14 14
15#include <linux/types.h> 15#include <linux/types.h>
16 16
17enum fwnode_type {
18 FWNODE_INVALID = 0,
19 FWNODE_OF,
20 FWNODE_ACPI,
21 FWNODE_ACPI_DATA,
22 FWNODE_ACPI_STATIC,
23 FWNODE_PDATA,
24 FWNODE_IRQCHIP
25};
26
27struct fwnode_operations; 17struct fwnode_operations;
28 18
29struct fwnode_handle { 19struct fwnode_handle {
30 enum fwnode_type type;
31 struct fwnode_handle *secondary; 20 struct fwnode_handle *secondary;
32 const struct fwnode_operations *ops; 21 const struct fwnode_operations *ops;
33}; 22};
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index cac77a5c5555..d24273840b79 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -265,9 +265,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
265 return node ? &node->fwnode : NULL; 265 return node ? &node->fwnode : NULL;
266} 266}
267 267
268extern const struct fwnode_operations irqchip_fwnode_ops;
269
268static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode) 270static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
269{ 271{
270 return fwnode && fwnode->type == FWNODE_IRQCHIP; 272 return fwnode && fwnode->ops == &irqchip_fwnode_ops;
271} 273}
272 274
273extern void irq_domain_update_bus_token(struct irq_domain *domain, 275extern void irq_domain_update_bus_token(struct irq_domain *domain,
diff --git a/include/linux/of.h b/include/linux/of.h
index 4a8a70916237..cfc34117fc92 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -104,7 +104,6 @@ extern const struct fwnode_operations of_fwnode_ops;
104static inline void of_node_init(struct device_node *node) 104static inline void of_node_init(struct device_node *node)
105{ 105{
106 kobject_init(&node->kobj, &of_node_ktype); 106 kobject_init(&node->kobj, &of_node_ktype);
107 node->fwnode.type = FWNODE_OF;
108 node->fwnode.ops = &of_fwnode_ops; 107 node->fwnode.ops = &of_fwnode_ops;
109} 108}
110 109
@@ -152,7 +151,7 @@ void of_core_init(void);
152 151
153static inline bool is_of_node(const struct fwnode_handle *fwnode) 152static inline bool is_of_node(const struct fwnode_handle *fwnode)
154{ 153{
155 return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF; 154 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops;
156} 155}
157 156
158#define to_of_node(__fwnode) \ 157#define to_of_node(__fwnode) \