On Tue, 07 Jan 2025 21:50:21 +0100 Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx> wrote: > 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 regfields as well to simplify register operations, > taking into account the different fields for the veml6030/veml7700 and > veml6035. > > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx> > --- > drivers/iio/light/veml6030.c | 141 +++++++++++++++++++++++++++++++++++-------- > 1 file changed, 116 insertions(+), 25 deletions(-) > > diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c > index 9b71825eea9bee2146be17ed2f30f5a8f7ad37e3..a6385c6d3fba59a6b22845a3c5e252b619faed65 100644 > --- a/drivers/iio/light/veml6030.c > +++ b/drivers/iio/light/veml6030.c > @@ -65,6 +65,11 @@ enum veml6030_scan { > VEML6030_SCAN_TIMESTAMP, > }; > > +struct veml6030_rf { > + struct regmap_field *it; > + struct regmap_field *gain; > +}; > + > struct veml603x_chip { > const char *name; > const int(*scale_vals)[][2]; > @@ -75,6 +80,7 @@ struct veml603x_chip { > int (*set_info)(struct iio_dev *indio_dev); > int (*set_als_gain)(struct iio_dev *indio_dev, int val, int val2); > int (*get_als_gain)(struct iio_dev *indio_dev, int *val, int *val2); > + int (*regfield_init)(struct iio_dev *indio_dev); With only two fields, why use a callback rather than just adding the two const struct reg_field into this structure directly? I'd also be tempted to do the caching and regfield changes as separate patches. Jonathan