int regmap_read(struct regmap *map, uint offset, uint *valp)
{
- return regmap_raw_read(map, offset, valp, map->width);
+ union {
+ u8 v8;
+ u16 v16;
+ u32 v32;
+ u64 v64;
+ } u;
+ int res;
+
+ res = regmap_raw_read(map, offset, &u, map->width);
+ if (res)
+ return res;
+
+ switch (map->width) {
+ case REGMAP_SIZE_8:
+ *valp = u.v8;
+ break;
+ case REGMAP_SIZE_16:
+ *valp = u.v16;
+ break;
+ case REGMAP_SIZE_32:
+ *valp = u.v32;
+ break;
+ case REGMAP_SIZE_64:
+ *valp = u.v64;
+ break;
+ default:
+ unreachable();
+ }
+
+ return 0;
}
static inline void __write_8(u8 *addr, const u8 *val,
int regmap_write(struct regmap *map, uint offset, uint val)
{
- return regmap_raw_write(map, offset, &val, map->width);
+ union {
+ u8 v8;
+ u16 v16;
+ u32 v32;
+ u64 v64;
+ } u;
+
+ switch (map->width) {
+ case REGMAP_SIZE_8:
+ u.v8 = val;
+ break;
+ case REGMAP_SIZE_16:
+ u.v16 = val;
+ break;
+ case REGMAP_SIZE_32:
+ u.v32 = val;
+ break;
+ case REGMAP_SIZE_64:
+ u.v64 = val;
+ break;
+ default:
+ debug("%s: regmap size %zu unknown\n", __func__,
+ (size_t)map->width);
+ return -EINVAL;
+ }
+
+ return regmap_raw_write(map, offset, &u, map->width);
}
int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val)