Skip to content

Commit 448a5a5

Browse files
sudeep-hollagregkh
authored andcommitted
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>
1 parent 166126c commit 448a5a5

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

drivers/base/cacheinfo.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,52 +74,48 @@ static inline int get_cacheinfo_idx(enum cache_type type)
7474
static void cache_size(struct cacheinfo *this_leaf, struct device_node *np)
7575
{
7676
const char *propname;
77-
const __be32 *cache_size;
7877
int ct_idx;
7978

8079
ct_idx = get_cacheinfo_idx(this_leaf->type);
8180
propname = cache_type_info[ct_idx].size_prop;
8281

83-
cache_size = of_get_property(np, propname, NULL);
84-
if (cache_size)
85-
this_leaf->size = of_read_number(cache_size, 1);
82+
if (of_property_read_u32(np, propname, &this_leaf->size))
83+
this_leaf->size = 0;
8684
}
8785

8886
/* not cache_line_size() because that's a macro in include/linux/cache.h */
8987
static void cache_get_line_size(struct cacheinfo *this_leaf,
9088
struct device_node *np)
9189
{
92-
const __be32 *line_size;
9390
int i, lim, ct_idx;
9491

9592
ct_idx = get_cacheinfo_idx(this_leaf->type);
9693
lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props);
9794

9895
for (i = 0; i < lim; i++) {
96+
int ret;
97+
u32 line_size;
9998
const char *propname;
10099

101100
propname = cache_type_info[ct_idx].line_size_props[i];
102-
line_size = of_get_property(np, propname, NULL);
103-
if (line_size)
101+
ret = of_property_read_u32(np, propname, &line_size);
102+
if (!ret) {
103+
this_leaf->coherency_line_size = line_size;
104104
break;
105+
}
105106
}
106-
107-
if (line_size)
108-
this_leaf->coherency_line_size = of_read_number(line_size, 1);
109107
}
110108

111109
static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np)
112110
{
113111
const char *propname;
114-
const __be32 *nr_sets;
115112
int ct_idx;
116113

117114
ct_idx = get_cacheinfo_idx(this_leaf->type);
118115
propname = cache_type_info[ct_idx].nr_sets_prop;
119116

120-
nr_sets = of_get_property(np, propname, NULL);
121-
if (nr_sets)
122-
this_leaf->number_of_sets = of_read_number(nr_sets, 1);
117+
if (of_property_read_u32(np, propname, &this_leaf->number_of_sets))
118+
this_leaf->number_of_sets = 0;
123119
}
124120

125121
static void cache_associativity(struct cacheinfo *this_leaf)

0 commit comments

Comments
 (0)