Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sudeep Holla and committed by
Greg Kroah-Hartman
448a5a55 166126c1

+10 -14
+10 -14
drivers/base/cacheinfo.c
··· 74 74 static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) 75 75 { 76 76 const char *propname; 77 - const __be32 *cache_size; 78 77 int ct_idx; 79 78 80 79 ct_idx = get_cacheinfo_idx(this_leaf->type); 81 80 propname = cache_type_info[ct_idx].size_prop; 82 81 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; 86 84 } 87 85 88 86 /* not cache_line_size() because that's a macro in include/linux/cache.h */ 89 87 static void cache_get_line_size(struct cacheinfo *this_leaf, 90 88 struct device_node *np) 91 89 { 92 - const __be32 *line_size; 93 90 int i, lim, ct_idx; 94 91 95 92 ct_idx = get_cacheinfo_idx(this_leaf->type); 96 93 lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props); 97 94 98 95 for (i = 0; i < lim; i++) { 96 + int ret; 97 + u32 line_size; 99 98 const char *propname; 100 99 101 100 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; 104 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 109 static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) 112 110 { 113 111 const char *propname; 114 - const __be32 *nr_sets; 115 112 int ct_idx; 116 113 117 114 ct_idx = get_cacheinfo_idx(this_leaf->type); 118 115 propname = cache_type_info[ct_idx].nr_sets_prop; 119 116 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; 123 119 } 124 120 125 121 static void cache_associativity(struct cacheinfo *this_leaf)