iio: adc: ti-ads1015: Switch to static const writeable ranges table
authorMarek Vasut <marex@denx.de>
Mon, 28 Mar 2022 19:47:18 +0000 (21:47 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 4 Apr 2022 08:11:26 +0000 (09:11 +0100)
Switch the driver from code implementing test whether a regmap register
is writeable to static const tables describing the test. No functional
change.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Link: https://lore.kernel.org/r/20220328194725.149150-3-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ti-ads1015.c

index 068efbc..85932b9 100644 (file)
@@ -273,23 +273,20 @@ static void ads1015_event_channel_disable(struct ads1015_data *data, int chan)
        data->event_channel = ADS1015_CHANNELS;
 }
 
-static bool ads1015_is_writeable_reg(struct device *dev, unsigned int reg)
-{
-       switch (reg) {
-       case ADS1015_CFG_REG:
-       case ADS1015_LO_THRESH_REG:
-       case ADS1015_HI_THRESH_REG:
-               return true;
-       default:
-               return false;
-       }
-}
+static const struct regmap_range ads1015_writeable_ranges[] = {
+       regmap_reg_range(ADS1015_CFG_REG, ADS1015_HI_THRESH_REG),
+};
+
+static const struct regmap_access_table ads1015_writeable_table = {
+       .yes_ranges = ads1015_writeable_ranges,
+       .n_yes_ranges = ARRAY_SIZE(ads1015_writeable_ranges),
+};
 
 static const struct regmap_config ads1015_regmap_config = {
        .reg_bits = 8,
        .val_bits = 16,
        .max_register = ADS1015_HI_THRESH_REG,
-       .writeable_reg = ads1015_is_writeable_reg,
+       .wr_table = &ads1015_writeable_table,
 };
 
 static const struct iio_chan_spec ads1015_channels[] = {