Skip to content

Commit 627f3c4

Browse files
javiercarrascocruzjic23
authored andcommitted
iio: light: veml3235: extend regmap to add cache
The configuration and ID registers are not volatile and are not affected by read operations (i.e. not precious), making them suitable to be cached in order to reduce the number of accesses to the device. Signed-off-by: Javier Carrasco <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 1a5a4b8 commit 627f3c4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/iio/light/veml3235.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,43 @@ static const struct iio_chan_spec veml3235_channels[] = {
101101
},
102102
};
103103

104+
static const struct regmap_range veml3235_readable_ranges[] = {
105+
regmap_reg_range(VEML3235_REG_CONF, VEML3235_REG_ID),
106+
};
107+
108+
static const struct regmap_access_table veml3235_readable_table = {
109+
.yes_ranges = veml3235_readable_ranges,
110+
.n_yes_ranges = ARRAY_SIZE(veml3235_readable_ranges),
111+
};
112+
113+
static const struct regmap_range veml3235_writable_ranges[] = {
114+
regmap_reg_range(VEML3235_REG_CONF, VEML3235_REG_CONF),
115+
};
116+
117+
static const struct regmap_access_table veml3235_writable_table = {
118+
.yes_ranges = veml3235_writable_ranges,
119+
.n_yes_ranges = ARRAY_SIZE(veml3235_writable_ranges),
120+
};
121+
122+
static const struct regmap_range veml3235_volatile_ranges[] = {
123+
regmap_reg_range(VEML3235_REG_WH_DATA, VEML3235_REG_ALS_DATA),
124+
};
125+
126+
static const struct regmap_access_table veml3235_volatile_table = {
127+
.yes_ranges = veml3235_volatile_ranges,
128+
.n_yes_ranges = ARRAY_SIZE(veml3235_volatile_ranges),
129+
};
130+
104131
static const struct regmap_config veml3235_regmap_config = {
105132
.name = "veml3235_regmap",
106133
.reg_bits = 8,
107134
.val_bits = 16,
108135
.max_register = VEML3235_REG_ID,
109136
.val_format_endian = REGMAP_ENDIAN_LITTLE,
137+
.rd_table = &veml3235_readable_table,
138+
.wr_table = &veml3235_writable_table,
139+
.volatile_table = &veml3235_volatile_table,
140+
.cache_type = REGCACHE_RBTREE,
110141
};
111142

112143
static int veml3235_get_it(struct veml3235_data *data, int *val, int *val2)

0 commit comments

Comments
 (0)