From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rishi Gupta <gupt21@gmail.com>,
Matti Vaittinen <mazziesaccount@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH v2 2/4] iio: light: veml6030: extend regmap to support caching
Date: Sun, 19 Jan 2025 18:31:59 +0100 [thread overview]
Message-ID: <20250119-veml6030-scale-v2-2-6bfc4062a371@gmail.com> (raw)
In-Reply-To: <20250119-veml6030-scale-v2-0-6bfc4062a371@gmail.com>
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>
---
drivers/iio/light/veml6030.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c
index 8e4eb8b0c19276635567d4eed74f4d402c3205fa..3afd4bb1ad53157f7ec63a35f51e5a96f7b019fd 100644
--- a/drivers/iio/light/veml6030.c
+++ b/drivers/iio/light/veml6030.c
@@ -333,12 +333,43 @@ static const struct iio_chan_spec veml7700_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(VEML6030_SCAN_TIMESTAMP),
};
+static const struct regmap_range veml6030_readable_ranges[] = {
+ regmap_reg_range(VEML6030_REG_ALS_CONF, VEML6030_REG_ALS_INT),
+};
+
+static const struct regmap_access_table veml6030_readable_table = {
+ .yes_ranges = veml6030_readable_ranges,
+ .n_yes_ranges = ARRAY_SIZE(veml6030_readable_ranges),
+};
+
+static const struct regmap_range veml6030_writable_ranges[] = {
+ regmap_reg_range(VEML6030_REG_ALS_CONF, VEML6030_REG_ALS_PSM),
+};
+
+static const struct regmap_access_table veml6030_writable_table = {
+ .yes_ranges = veml6030_writable_ranges,
+ .n_yes_ranges = ARRAY_SIZE(veml6030_writable_ranges),
+};
+
+static const struct regmap_range veml6030_volatile_ranges[] = {
+ regmap_reg_range(VEML6030_REG_ALS_DATA, VEML6030_REG_WH_DATA),
+};
+
+static const struct regmap_access_table veml6030_volatile_table = {
+ .yes_ranges = veml6030_volatile_ranges,
+ .n_yes_ranges = ARRAY_SIZE(veml6030_volatile_ranges),
+};
+
static const struct regmap_config veml6030_regmap_config = {
.name = "veml6030_regmap",
.reg_bits = 8,
.val_bits = 16,
.max_register = VEML6030_REG_ALS_INT,
.val_format_endian = REGMAP_ENDIAN_LITTLE,
+ .rd_table = &veml6030_readable_table,
+ .wr_table = &veml6030_writable_table,
+ .volatile_table = &veml6030_volatile_table,
+ .cache_type = REGCACHE_RBTREE,
};
static int veml6030_get_intgrn_tm(struct iio_dev *indio_dev,
--
2.43.0
next prev parent reply other threads:[~2025-01-19 17:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-19 17:31 [PATCH v2 0/4] iio: light: fix scale in veml6030 Javier Carrasco
2025-01-19 17:31 ` [PATCH v2 1/4] iio: light: veml6030: extend regmap to support regfields Javier Carrasco
2025-01-19 17:31 ` Javier Carrasco [this message]
2025-01-19 17:32 ` [PATCH v2 3/4] iio: gts-helper: export iio_gts_get_total_gain() Javier Carrasco
2025-01-24 8:12 ` Matti Vaittinen
2025-01-25 20:08 ` Javier Carrasco
2025-01-19 17:32 ` [PATCH v2 4/4] iio: light: veml6030: fix scale to conform to ABI Javier Carrasco
2025-01-24 8:24 ` Matti Vaittinen
2025-01-25 12:33 ` [PATCH v2 0/4] iio: light: fix scale in veml6030 Jonathan Cameron
2025-01-25 20:12 ` Javier Carrasco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250119-veml6030-scale-v2-2-6bfc4062a371@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=gupt21@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®