There is absolutely no reason to have them as we can handle it all nicely in property_entry_read_int_array().
Unified · Split
| @@ -131,66 +131,6 @@ static const void *property_entry_find(const struct property_entry *props, · 130 unmodified lines | ||
| 131 | 131 | return pointer; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | −static int property_entry_read_u8_array(const struct property_entry *props, | |
| 135 | − const char *propname, | |
| 136 | − u8 *values, size_t nval) | |
| 137 | −{ | |
| 138 | − const void *pointer; | |
| 139 | − size_t length = nval * sizeof(*values); | |
| 140 | − | |
| 141 | − pointer = property_entry_find(props, propname, length); | |
| 142 | − if (IS_ERR(pointer)) | |
| 143 | − return PTR_ERR(pointer); | |
| 144 | − | |
| 145 | − memcpy(values, pointer, length); | |
| 146 | − return 0; | |
| 147 | −} | |
| 148 | − | |
| 149 | −static int property_entry_read_u16_array(const struct property_entry *props, | |
| 150 | − const char *propname, | |
| 151 | − u16 *values, size_t nval) | |
| 152 | −{ | |
| 153 | − const void *pointer; | |
| 154 | − size_t length = nval * sizeof(*values); | |
| 155 | − | |
| 156 | − pointer = property_entry_find(props, propname, length); | |
| 157 | − if (IS_ERR(pointer)) | |
| 158 | − return PTR_ERR(pointer); | |
| 159 | − | |
| 160 | − memcpy(values, pointer, length); | |
| 161 | − return 0; | |
| 162 | −} | |
| 163 | − | |
| 164 | −static int property_entry_read_u32_array(const struct property_entry *props, | |
| 165 | − const char *propname, | |
| 166 | − u32 *values, size_t nval) | |
| 167 | −{ | |
| 168 | − const void *pointer; | |
| 169 | − size_t length = nval * sizeof(*values); | |
| 170 | − | |
| 171 | − pointer = property_entry_find(props, propname, length); | |
| 172 | − if (IS_ERR(pointer)) | |
| 173 | − return PTR_ERR(pointer); | |
| 174 | − | |
| 175 | − memcpy(values, pointer, length); | |
| 176 | − return 0; | |
| 177 | −} | |
| 178 | − | |
| 179 | −static int property_entry_read_u64_array(const struct property_entry *props, | |
| 180 | − const char *propname, | |
| 181 | − u64 *values, size_t nval) | |
| 182 | −{ | |
| 183 | − const void *pointer; | |
| 184 | − size_t length = nval * sizeof(*values); | |
| 185 | − | |
| 186 | − pointer = property_entry_find(props, propname, length); | |
| 187 | − if (IS_ERR(pointer)) | |
| 188 | − return PTR_ERR(pointer); | |
| 189 | − | |
| 190 | − memcpy(values, pointer, length); | |
| 191 | − return 0; | |
| 192 | −} | |
| 193 | − | |
| 194 | 134 | static int |
| 195 | 135 | property_entry_count_elems_of_size(const struct property_entry *props, |
| 196 | 136 | const char *propname, size_t length) |
| @@ -209,21 +149,24 @@ static int property_entry_read_int_array(const struct property_entry *props, · 12 unmodified lines | ||
| 209 | 149 | unsigned int elem_size, void *val, |
| 210 | 150 | size_t nval) |
| 211 | 151 | { |
| 152 | + const void *pointer; | |
| 153 | + size_t length; | |
| 154 | + | |
| 212 | 155 | if (!val) |
| 213 | 156 | return property_entry_count_elems_of_size(props, name, |
| 214 | 157 | elem_size); |
| 215 | − switch (elem_size) { | |
| 216 | − case sizeof(u8): | |
| 217 | − return property_entry_read_u8_array(props, name, val, nval); | |
| 218 | − case sizeof(u16): | |
| 219 | − return property_entry_read_u16_array(props, name, val, nval); | |
| 220 | − case sizeof(u32): | |
| 221 | − return property_entry_read_u32_array(props, name, val, nval); | |
| 222 | − case sizeof(u64): | |
| 223 | − return property_entry_read_u64_array(props, name, val, nval); | |
| 224 | − } | |
| 225 | 158 | |
| 226 | − return -ENXIO; | |
| 159 | + if (!is_power_of_2(elem_size) || elem_size > sizeof(u64)) | |
| 160 | + return -ENXIO; | |
| 161 | + | |
| 162 | + length = nval * elem_size; | |
| 163 | + | |
| 164 | + pointer = property_entry_find(props, name, length); | |
| 165 | + if (IS_ERR(pointer)) | |
| 166 | + return PTR_ERR(pointer); | |
| 167 | + | |
| 168 | + memcpy(val, pointer, length); | |
| 169 | + return 0; | |
| 227 | 170 | } |
| 228 | 171 | |
| 229 | 172 | static int property_entry_read_string_array(const struct property_entry *props, |