Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: light: veml6030: extend regmap to support caching

The configuration 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.

Add support for caching (RBTREE type).

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20250119-veml6030-scale-v2-2-6bfc4062a371@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Javier Carrasco and committed by
Jonathan Cameron
46e28867 9c7eb1ab

+31
+31
drivers/iio/light/veml6030.c
··· 333 333 IIO_CHAN_SOFT_TIMESTAMP(VEML6030_SCAN_TIMESTAMP), 334 334 }; 335 335 336 + static const struct regmap_range veml6030_readable_ranges[] = { 337 + regmap_reg_range(VEML6030_REG_ALS_CONF, VEML6030_REG_ALS_INT), 338 + }; 339 + 340 + static const struct regmap_access_table veml6030_readable_table = { 341 + .yes_ranges = veml6030_readable_ranges, 342 + .n_yes_ranges = ARRAY_SIZE(veml6030_readable_ranges), 343 + }; 344 + 345 + static const struct regmap_range veml6030_writable_ranges[] = { 346 + regmap_reg_range(VEML6030_REG_ALS_CONF, VEML6030_REG_ALS_PSM), 347 + }; 348 + 349 + static const struct regmap_access_table veml6030_writable_table = { 350 + .yes_ranges = veml6030_writable_ranges, 351 + .n_yes_ranges = ARRAY_SIZE(veml6030_writable_ranges), 352 + }; 353 + 354 + static const struct regmap_range veml6030_volatile_ranges[] = { 355 + regmap_reg_range(VEML6030_REG_ALS_DATA, VEML6030_REG_WH_DATA), 356 + }; 357 + 358 + static const struct regmap_access_table veml6030_volatile_table = { 359 + .yes_ranges = veml6030_volatile_ranges, 360 + .n_yes_ranges = ARRAY_SIZE(veml6030_volatile_ranges), 361 + }; 362 + 336 363 static const struct regmap_config veml6030_regmap_config = { 337 364 .name = "veml6030_regmap", 338 365 .reg_bits = 8, 339 366 .val_bits = 16, 340 367 .max_register = VEML6030_REG_ALS_INT, 341 368 .val_format_endian = REGMAP_ENDIAN_LITTLE, 369 + .rd_table = &veml6030_readable_table, 370 + .wr_table = &veml6030_writable_table, 371 + .volatile_table = &veml6030_volatile_table, 372 + .cache_type = REGCACHE_RBTREE, 342 373 }; 343 374 344 375 static int veml6030_get_intgrn_tm(struct iio_dev *indio_dev,