Commit 448a5a55 authored by Sudeep Holla's avatar Sudeep Holla Committed by Greg Kroah-Hartman

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: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 166126c1
...@@ -74,52 +74,48 @@ static inline int get_cacheinfo_idx(enum cache_type type) ...@@ -74,52 +74,48 @@ static inline int get_cacheinfo_idx(enum cache_type type)
static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) static void cache_size(struct cacheinfo *this_leaf, struct device_node *np)
{ {
const char *propname; const char *propname;
const __be32 *cache_size;
int ct_idx; int ct_idx;
ct_idx = get_cacheinfo_idx(this_leaf->type); ct_idx = get_cacheinfo_idx(this_leaf->type);
propname = cache_type_info[ct_idx].size_prop; propname = cache_type_info[ct_idx].size_prop;
cache_size = of_get_property(np, propname, NULL); if (of_property_read_u32(np, propname, &this_leaf->size))
if (cache_size) this_leaf->size = 0;
this_leaf->size = of_read_number(cache_size, 1);
} }
/* not cache_line_size() because that's a macro in include/linux/cache.h */ /* not cache_line_size() because that's a macro in include/linux/cache.h */
static void cache_get_line_size(struct cacheinfo *this_leaf, static void cache_get_line_size(struct cacheinfo *this_leaf,
struct device_node *np) struct device_node *np)
{ {
const __be32 *line_size;
int i, lim, ct_idx; int i, lim, ct_idx;
ct_idx = get_cacheinfo_idx(this_leaf->type); ct_idx = get_cacheinfo_idx(this_leaf->type);
lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props); lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props);
for (i = 0; i < lim; i++) { for (i = 0; i < lim; i++) {
int ret;
u32 line_size;
const char *propname; const char *propname;
propname = cache_type_info[ct_idx].line_size_props[i]; propname = cache_type_info[ct_idx].line_size_props[i];
line_size = of_get_property(np, propname, NULL); ret = of_property_read_u32(np, propname, &line_size);
if (line_size) if (!ret) {
this_leaf->coherency_line_size = line_size;
break; break;
}
} }
if (line_size)
this_leaf->coherency_line_size = of_read_number(line_size, 1);
} }
static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np)
{ {
const char *propname; const char *propname;
const __be32 *nr_sets;
int ct_idx; int ct_idx;
ct_idx = get_cacheinfo_idx(this_leaf->type); ct_idx = get_cacheinfo_idx(this_leaf->type);
propname = cache_type_info[ct_idx].nr_sets_prop; propname = cache_type_info[ct_idx].nr_sets_prop;
nr_sets = of_get_property(np, propname, NULL); if (of_property_read_u32(np, propname, &this_leaf->number_of_sets))
if (nr_sets) this_leaf->number_of_sets = 0;
this_leaf->number_of_sets = of_read_number(nr_sets, 1);
} }
static void cache_associativity(struct cacheinfo *this_leaf) static void cache_associativity(struct cacheinfo *this_leaf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment