diff options
author | Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com> | 2013-01-31 12:06:34 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-02-22 02:22:19 -0500 |
commit | 24dea0c9feccf699749f860fa2f4ccd84d30390d (patch) | |
tree | d2adf3a0478ae150b46462da4293876222d6d8ab /include/linux/mtd | |
parent | be0638d9e4795254e28e39eff61e38f47d240fd2 (diff) |
mtd: map: BUG() in non handled cases
Several map-related functions look like a serie of ifs, checking
widths of map. Those functions do not have any handling for default
case. Instead of fiddling with uninitialized_var in those functions,
let's just add a (correct) BUG() to the default case on those maps. This
will also allow us to catch potential errors in maps setup in future.
Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r-- | include/linux/mtd/map.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h index 8b9bfd7dcaa3..4b02512e421c 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h | |||
@@ -329,7 +329,7 @@ static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word | |||
329 | 329 | ||
330 | static inline map_word map_word_load(struct map_info *map, const void *ptr) | 330 | static inline map_word map_word_load(struct map_info *map, const void *ptr) |
331 | { | 331 | { |
332 | map_word r = {{0} }; | 332 | map_word r; |
333 | 333 | ||
334 | if (map_bankwidth_is_1(map)) | 334 | if (map_bankwidth_is_1(map)) |
335 | r.x[0] = *(unsigned char *)ptr; | 335 | r.x[0] = *(unsigned char *)ptr; |
@@ -343,6 +343,8 @@ static inline map_word map_word_load(struct map_info *map, const void *ptr) | |||
343 | #endif | 343 | #endif |
344 | else if (map_bankwidth_is_large(map)) | 344 | else if (map_bankwidth_is_large(map)) |
345 | memcpy(r.x, ptr, map->bankwidth); | 345 | memcpy(r.x, ptr, map->bankwidth); |
346 | else | ||
347 | BUG(); | ||
346 | 348 | ||
347 | return r; | 349 | return r; |
348 | } | 350 | } |
@@ -392,7 +394,7 @@ static inline map_word map_word_ff(struct map_info *map) | |||
392 | 394 | ||
393 | static inline map_word inline_map_read(struct map_info *map, unsigned long ofs) | 395 | static inline map_word inline_map_read(struct map_info *map, unsigned long ofs) |
394 | { | 396 | { |
395 | map_word uninitialized_var(r); | 397 | map_word r; |
396 | 398 | ||
397 | if (map_bankwidth_is_1(map)) | 399 | if (map_bankwidth_is_1(map)) |
398 | r.x[0] = __raw_readb(map->virt + ofs); | 400 | r.x[0] = __raw_readb(map->virt + ofs); |
@@ -426,6 +428,8 @@ static inline void inline_map_write(struct map_info *map, const map_word datum, | |||
426 | #endif | 428 | #endif |
427 | else if (map_bankwidth_is_large(map)) | 429 | else if (map_bankwidth_is_large(map)) |
428 | memcpy_toio(map->virt+ofs, datum.x, map->bankwidth); | 430 | memcpy_toio(map->virt+ofs, datum.x, map->bankwidth); |
431 | else | ||
432 | BUG(); | ||
429 | mb(); | 433 | mb(); |
430 | } | 434 | } |
431 | 435 | ||