Commit 24dea0c9 authored by Dmitry Eremin-Solenikov's avatar Dmitry Eremin-Solenikov Committed by Artem Bityutskiy

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: default avatarDmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent be0638d9
...@@ -329,7 +329,7 @@ static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word ...@@ -329,7 +329,7 @@ static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word
static inline map_word map_word_load(struct map_info *map, const void *ptr) static inline map_word map_word_load(struct map_info *map, const void *ptr)
{ {
map_word r = {{0} }; map_word r;
if (map_bankwidth_is_1(map)) if (map_bankwidth_is_1(map))
r.x[0] = *(unsigned char *)ptr; 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,6 +343,8 @@ static inline map_word map_word_load(struct map_info *map, const void *ptr)
#endif #endif
else if (map_bankwidth_is_large(map)) else if (map_bankwidth_is_large(map))
memcpy(r.x, ptr, map->bankwidth); memcpy(r.x, ptr, map->bankwidth);
else
BUG();
return r; return r;
} }
...@@ -392,7 +394,7 @@ static inline map_word map_word_ff(struct map_info *map) ...@@ -392,7 +394,7 @@ static inline map_word map_word_ff(struct map_info *map)
static inline map_word inline_map_read(struct map_info *map, unsigned long ofs) static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
{ {
map_word uninitialized_var(r); map_word r;
if (map_bankwidth_is_1(map)) if (map_bankwidth_is_1(map))
r.x[0] = __raw_readb(map->virt + ofs); 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,6 +428,8 @@ static inline void inline_map_write(struct map_info *map, const map_word datum,
#endif #endif
else if (map_bankwidth_is_large(map)) else if (map_bankwidth_is_large(map))
memcpy_toio(map->virt+ofs, datum.x, map->bankwidth); memcpy_toio(map->virt+ofs, datum.x, map->bankwidth);
else
BUG();
mb(); mb();
} }
......
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