diff options
author | Sudeep Holla <sudeep.holla@arm.com> | 2018-07-06 08:50:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-07 11:20:47 -0400 |
commit | 448a5a552f336bd7b847b1951ffd15eb2e7167a3 (patch) | |
tree | 600f0b44485f18b85c27ea5edafc108382b5b9ff | |
parent | 166126c1e54d927c2e8efa2702d420e0ce301fd9 (diff) |
drivers: base: cacheinfo: use OF property_read_u32 instead of get_property,read_number
of_property_read_u32 searches for a property in a device node and read
a 32-bit value from it. Instead of using of_get_property to get the
property and then read 32-bit value using of_read_number, we can
simplify it by using of_property_read_u32.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/cacheinfo.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 2880e2ab01f5..5d5b5988e88b 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c | |||
@@ -74,52 +74,48 @@ static inline int get_cacheinfo_idx(enum cache_type type) | |||
74 | static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) | 74 | static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) |
75 | { | 75 | { |
76 | const char *propname; | 76 | const char *propname; |
77 | const __be32 *cache_size; | ||
78 | int ct_idx; | 77 | int ct_idx; |
79 | 78 | ||
80 | ct_idx = get_cacheinfo_idx(this_leaf->type); | 79 | ct_idx = get_cacheinfo_idx(this_leaf->type); |
81 | propname = cache_type_info[ct_idx].size_prop; | 80 | propname = cache_type_info[ct_idx].size_prop; |
82 | 81 | ||
83 | cache_size = of_get_property(np, propname, NULL); | 82 | if (of_property_read_u32(np, propname, &this_leaf->size)) |
84 | if (cache_size) | 83 | this_leaf->size = 0; |
85 | this_leaf->size = of_read_number(cache_size, 1); | ||
86 | } | 84 | } |
87 | 85 | ||
88 | /* not cache_line_size() because that's a macro in include/linux/cache.h */ | 86 | /* not cache_line_size() because that's a macro in include/linux/cache.h */ |
89 | static void cache_get_line_size(struct cacheinfo *this_leaf, | 87 | static void cache_get_line_size(struct cacheinfo *this_leaf, |
90 | struct device_node *np) | 88 | struct device_node *np) |
91 | { | 89 | { |
92 | const __be32 *line_size; | ||
93 | int i, lim, ct_idx; | 90 | int i, lim, ct_idx; |
94 | 91 | ||
95 | ct_idx = get_cacheinfo_idx(this_leaf->type); | 92 | ct_idx = get_cacheinfo_idx(this_leaf->type); |
96 | lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props); | 93 | lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props); |
97 | 94 | ||
98 | for (i = 0; i < lim; i++) { | 95 | for (i = 0; i < lim; i++) { |
96 | int ret; | ||
97 | u32 line_size; | ||
99 | const char *propname; | 98 | const char *propname; |
100 | 99 | ||
101 | propname = cache_type_info[ct_idx].line_size_props[i]; | 100 | propname = cache_type_info[ct_idx].line_size_props[i]; |
102 | line_size = of_get_property(np, propname, NULL); | 101 | ret = of_property_read_u32(np, propname, &line_size); |
103 | if (line_size) | 102 | if (!ret) { |
103 | this_leaf->coherency_line_size = line_size; | ||
104 | break; | 104 | break; |
105 | } | ||
105 | } | 106 | } |
106 | |||
107 | if (line_size) | ||
108 | this_leaf->coherency_line_size = of_read_number(line_size, 1); | ||
109 | } | 107 | } |
110 | 108 | ||
111 | static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) | 109 | static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) |
112 | { | 110 | { |
113 | const char *propname; | 111 | const char *propname; |
114 | const __be32 *nr_sets; | ||
115 | int ct_idx; | 112 | int ct_idx; |
116 | 113 | ||
117 | ct_idx = get_cacheinfo_idx(this_leaf->type); | 114 | ct_idx = get_cacheinfo_idx(this_leaf->type); |
118 | propname = cache_type_info[ct_idx].nr_sets_prop; | 115 | propname = cache_type_info[ct_idx].nr_sets_prop; |
119 | 116 | ||
120 | nr_sets = of_get_property(np, propname, NULL); | 117 | if (of_property_read_u32(np, propname, &this_leaf->number_of_sets)) |
121 | if (nr_sets) | 118 | this_leaf->number_of_sets = 0; |
122 | this_leaf->number_of_sets = of_read_number(nr_sets, 1); | ||
123 | } | 119 | } |
124 | 120 | ||
125 | static void cache_associativity(struct cacheinfo *this_leaf) | 121 | static void cache_associativity(struct cacheinfo *this_leaf) |