···105105106106 bool defer_caching;107107108108- u8 read_flag_mask;109109- u8 write_flag_mask;108108+ unsigned long read_flag_mask;109109+ unsigned long write_flag_mask;110110111111 /* number of bits to (left) shift the reg value when formatting*/112112 int reg_shift;···173173 int (*drop)(struct regmap *map, unsigned int min, unsigned int max);174174};175175176176+bool regmap_cached(struct regmap *map, unsigned int reg);176177bool regmap_writeable(struct regmap *map, unsigned int reg);177178bool regmap_readable(struct regmap *map, unsigned int reg);178179bool regmap_volatile(struct regmap *map, unsigned int reg);
+13-3
drivers/base/regmap/regmap-debugfs.c
···7777 }7878}79798080+static bool regmap_printable(struct regmap *map, unsigned int reg)8181+{8282+ if (regmap_precious(map, reg))8383+ return false;8484+8585+ if (!regmap_readable(map, reg) && !regmap_cached(map, reg))8686+ return false;8787+8888+ return true;8989+}9090+8091/*8192 * Work out where the start offset maps into register numbers, bearing8293 * in mind that we suppress hidden registers.···116105 if (list_empty(&map->debugfs_off_cache)) {117106 for (; i <= map->max_register; i += map->reg_stride) {118107 /* Skip unprinted registers, closing off cache entry */119119- if (!regmap_readable(map, i) ||120120- regmap_precious(map, i)) {108108+ if (!regmap_printable(map, i)) {121109 if (c) {122110 c->max = p - 1;123111 c->max_reg = i - map->reg_stride;···214204 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);215205216206 for (i = start_reg; i <= to; i += map->reg_stride) {217217- if (!regmap_readable(map, i))207207+ if (!regmap_readable(map, i) && !regmap_cached(map, i))218208 continue;219209220210 if (regmap_precious(map, i))
+51-13
drivers/base/regmap/regmap.c
···9393 return true;9494}95959696+bool regmap_cached(struct regmap *map, unsigned int reg)9797+{9898+ int ret;9999+ unsigned int val;100100+101101+ if (map->cache == REGCACHE_NONE)102102+ return false;103103+104104+ if (!map->cache_ops)105105+ return false;106106+107107+ if (map->max_register && reg > map->max_register)108108+ return false;109109+110110+ map->lock(map->lock_arg);111111+ ret = regcache_read(map, reg, &val);112112+ map->unlock(map->lock_arg);113113+ if (ret)114114+ return false;115115+116116+ return true;117117+}118118+96119bool regmap_readable(struct regmap *map, unsigned int reg)97120{98121 if (!map->reg_read)···772749 case REGMAP_ENDIAN_BIG:773750 map->format.format_reg = regmap_format_16_be;774751 break;752752+ case REGMAP_ENDIAN_LITTLE:753753+ map->format.format_reg = regmap_format_16_le;754754+ break;775755 case REGMAP_ENDIAN_NATIVE:776756 map->format.format_reg = regmap_format_16_native;777757 break;···794768 case REGMAP_ENDIAN_BIG:795769 map->format.format_reg = regmap_format_32_be;796770 break;771771+ case REGMAP_ENDIAN_LITTLE:772772+ map->format.format_reg = regmap_format_32_le;773773+ break;797774 case REGMAP_ENDIAN_NATIVE:798775 map->format.format_reg = regmap_format_32_native;799776 break;···810781 switch (reg_endian) {811782 case REGMAP_ENDIAN_BIG:812783 map->format.format_reg = regmap_format_64_be;784784+ break;785785+ case REGMAP_ENDIAN_LITTLE:786786+ map->format.format_reg = regmap_format_64_le;813787 break;814788 case REGMAP_ENDIAN_NATIVE:815789 map->format.format_reg = regmap_format_64_native;···13281296 return 0;13291297}1330129812991299+static void regmap_set_work_buf_flag_mask(struct regmap *map, int max_bytes,13001300+ unsigned long mask)13011301+{13021302+ u8 *buf;13031303+ int i;13041304+13051305+ if (!mask || !map->work_buf)13061306+ return;13071307+13081308+ buf = map->work_buf;13091309+13101310+ for (i = 0; i < max_bytes; i++)13111311+ buf[i] |= (mask >> (8 * i)) & 0xff;13121312+}13131313+13311314int _regmap_raw_write(struct regmap *map, unsigned int reg,13321315 const void *val, size_t val_len)13331316{13341317 struct regmap_range_node *range;13351318 unsigned long flags;13361336- u8 *u8 = map->work_buf;13371319 void *work_val = map->work_buf + map->format.reg_bytes +13381320 map->format.pad_bytes;13391321 void *buf;···14161370 }1417137114181372 map->format.format_reg(map->work_buf, reg, map->reg_shift);14191419-14201420- u8[0] |= map->write_flag_mask;13731373+ regmap_set_work_buf_flag_mask(map, map->format.reg_bytes,13741374+ map->write_flag_mask);1421137514221376 /*14231377 * Essentially all I/O mechanisms will be faster with a single···22972251 unsigned int val_len)22982252{22992253 struct regmap_range_node *range;23002300- u8 *u8 = map->work_buf;23012254 int ret;2302225523032256 WARN_ON(!map->bus);···23132268 }2314226923152270 map->format.format_reg(map->work_buf, reg, map->reg_shift);23162316-23172317- /*23182318- * Some buses or devices flag reads by setting the high bits in the23192319- * register address; since it's always the high bits for all23202320- * current formats we can do this here rather than in23212321- * formatting. This may break if we get interesting formats.23222322- */23232323- u8[0] |= map->read_flag_mask;23242324-22712271+ regmap_set_work_buf_flag_mask(map, map->format.reg_bytes,22722272+ map->read_flag_mask);23252273 trace_regmap_hw_read_start(map, reg, val_len / map->format.val_bytes);2326227423272275 ret = map->bus->read(map->bus_context, map->work_buf,
+4-4
include/linux/regmap.h
···241241 * register cache support).242242 * @num_reg_defaults: Number of elements in reg_defaults.243243 *244244- * @read_flag_mask: Mask to be set in the top byte of the register when doing244244+ * @read_flag_mask: Mask to be set in the top bytes of the register when doing245245 * a read.246246- * @write_flag_mask: Mask to be set in the top byte of the register when doing246246+ * @write_flag_mask: Mask to be set in the top bytes of the register when doing247247 * a write. If both read_flag_mask and write_flag_mask are248248 * empty the regmap_bus default masks are used.249249 * @use_single_rw: If set, converts the bulk read and write operations into···299299 const void *reg_defaults_raw;300300 unsigned int num_reg_defaults_raw;301301302302- u8 read_flag_mask;303303- u8 write_flag_mask;302302+ unsigned long read_flag_mask;303303+ unsigned long write_flag_mask;304304305305 bool use_single_rw;306306 bool can_multi_write;