Commit c8633465 authored by Marek Vasut's avatar Marek Vasut Committed by Jonathan Cameron
Browse files

iio: adc: ti-ads1015: Switch to static const writeable ranges table



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: default avatarMarek Vasut <marex@denx.de>
Reviewed-by: default avatarAndy 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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 94d9f3cb
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -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[] = {