mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 01:02:08 +00:00
Merge branch 'fixes-togreg' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
This commit is contained in:
commit
3d7ad880d6
@ -91,7 +91,7 @@ examples:
|
||||
vrefn-supply = <&dac_vrefn>;
|
||||
reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>;
|
||||
clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>;
|
||||
ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>;
|
||||
ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
...
|
||||
|
@ -65,6 +65,7 @@ properties:
|
||||
- st,lsm9ds0-gyro
|
||||
- description: STMicroelectronics Magnetometers
|
||||
enum:
|
||||
- st,iis2mdc
|
||||
- st,lis2mdl
|
||||
- st,lis3mdl-magn
|
||||
- st,lsm303agr-magn
|
||||
|
@ -91,6 +91,7 @@
|
||||
#define AD4695_T_WAKEUP_SW_MS 3
|
||||
#define AD4695_T_REFBUF_MS 100
|
||||
#define AD4695_T_REGCONFIG_NS 20
|
||||
#define AD4695_T_SCK_CNV_DELAY_NS 80
|
||||
#define AD4695_REG_ACCESS_SCLK_HZ (10 * MEGA)
|
||||
|
||||
/* Max number of voltage input channels. */
|
||||
@ -132,8 +133,13 @@ struct ad4695_state {
|
||||
unsigned int vref_mv;
|
||||
/* Common mode input pin voltage. */
|
||||
unsigned int com_mv;
|
||||
/* 1 per voltage and temperature chan plus 1 xfer to trigger 1st CNV */
|
||||
struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS + 2];
|
||||
/*
|
||||
* 2 per voltage and temperature chan plus 1 xfer to trigger 1st
|
||||
* CNV. Excluding the trigger xfer, every 2nd xfer only serves
|
||||
* to control CS and add a delay between the last SCLK and next
|
||||
* CNV rising edges.
|
||||
*/
|
||||
struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3];
|
||||
struct spi_message buf_read_msg;
|
||||
/* Raw conversion data received. */
|
||||
u8 buf[ALIGN((AD4695_MAX_CHANNELS + 2) * AD4695_MAX_CHANNEL_SIZE,
|
||||
@ -423,7 +429,7 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
|
||||
u8 temp_chan_bit = st->chip_info->num_voltage_inputs;
|
||||
u32 bit, num_xfer, num_slots;
|
||||
u32 temp_en = 0;
|
||||
int ret;
|
||||
int ret, rx_buf_offset = 0;
|
||||
|
||||
/*
|
||||
* We are using the advanced sequencer since it is the only way to read
|
||||
@ -449,11 +455,9 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
|
||||
iio_for_each_active_channel(indio_dev, bit) {
|
||||
xfer = &st->buf_read_xfer[num_xfer];
|
||||
xfer->bits_per_word = 16;
|
||||
xfer->rx_buf = &st->buf[(num_xfer - 1) * 2];
|
||||
xfer->rx_buf = &st->buf[rx_buf_offset];
|
||||
xfer->len = 2;
|
||||
xfer->cs_change = 1;
|
||||
xfer->cs_change_delay.value = AD4695_T_CONVERT_NS;
|
||||
xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
|
||||
rx_buf_offset += xfer->len;
|
||||
|
||||
if (bit == temp_chan_bit) {
|
||||
temp_en = 1;
|
||||
@ -468,21 +472,44 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
|
||||
}
|
||||
|
||||
num_xfer++;
|
||||
|
||||
/*
|
||||
* We need to add a blank xfer in data reads, to meet the timing
|
||||
* requirement of a minimum delay between the last SCLK rising
|
||||
* edge and the CS deassert.
|
||||
*/
|
||||
xfer = &st->buf_read_xfer[num_xfer];
|
||||
xfer->delay.value = AD4695_T_SCK_CNV_DELAY_NS;
|
||||
xfer->delay.unit = SPI_DELAY_UNIT_NSECS;
|
||||
xfer->cs_change = 1;
|
||||
xfer->cs_change_delay.value = AD4695_T_CONVERT_NS;
|
||||
xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
|
||||
|
||||
num_xfer++;
|
||||
}
|
||||
|
||||
/*
|
||||
* The advanced sequencer requires that at least 2 slots are enabled.
|
||||
* Since slot 0 is always used for other purposes, we need only 1
|
||||
* enabled voltage channel to meet this requirement. If the temperature
|
||||
* channel is the only enabled channel, we need to add one more slot
|
||||
* in the sequence but not read from it.
|
||||
* enabled voltage channel to meet this requirement. If the temperature
|
||||
* channel is the only enabled channel, we need to add one more slot in
|
||||
* the sequence but not read from it. This is because the temperature
|
||||
* sensor is sampled at the end of the channel sequence in advanced
|
||||
* sequencer mode (see datasheet page 38).
|
||||
*
|
||||
* From the iio_for_each_active_channel() block above, we now have an
|
||||
* xfer with data followed by a blank xfer to allow us to meet the
|
||||
* timing spec, so move both of those up before adding an extra to
|
||||
* handle the temperature-only case.
|
||||
*/
|
||||
if (num_slots < 2) {
|
||||
/* move last xfer so we can insert one more xfer before it */
|
||||
st->buf_read_xfer[num_xfer] = *xfer;
|
||||
/* Move last two xfers */
|
||||
st->buf_read_xfer[num_xfer] = st->buf_read_xfer[num_xfer - 1];
|
||||
st->buf_read_xfer[num_xfer - 1] = st->buf_read_xfer[num_xfer - 2];
|
||||
num_xfer++;
|
||||
|
||||
/* modify 2nd to last xfer for extra slot */
|
||||
/* Modify inserted xfer for extra slot. */
|
||||
xfer = &st->buf_read_xfer[num_xfer - 3];
|
||||
memset(xfer, 0, sizeof(*xfer));
|
||||
xfer->cs_change = 1;
|
||||
xfer->delay.value = st->chip_info->t_acq_ns;
|
||||
@ -499,6 +526,12 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
|
||||
return ret;
|
||||
|
||||
num_slots++;
|
||||
|
||||
/*
|
||||
* We still want to point at the last xfer when finished, so
|
||||
* update the pointer.
|
||||
*/
|
||||
xfer = &st->buf_read_xfer[num_xfer - 1];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -583,8 +616,20 @@ static irqreturn_t ad4695_trigger_handler(int irq, void *p)
|
||||
*/
|
||||
static int ad4695_read_one_sample(struct ad4695_state *st, unsigned int address)
|
||||
{
|
||||
struct spi_transfer xfer[2] = { };
|
||||
int ret, i = 0;
|
||||
struct spi_transfer xfers[2] = {
|
||||
{
|
||||
.speed_hz = AD4695_REG_ACCESS_SCLK_HZ,
|
||||
.bits_per_word = 16,
|
||||
.tx_buf = &st->cnv_cmd,
|
||||
.len = 2,
|
||||
},
|
||||
{
|
||||
/* Required delay between last SCLK and CNV/CS */
|
||||
.delay.value = AD4695_T_SCK_CNV_DELAY_NS,
|
||||
.delay.unit = SPI_DELAY_UNIT_NSECS,
|
||||
}
|
||||
};
|
||||
int ret;
|
||||
|
||||
ret = ad4695_set_single_cycle_mode(st, address);
|
||||
if (ret)
|
||||
@ -592,29 +637,22 @@ static int ad4695_read_one_sample(struct ad4695_state *st, unsigned int address)
|
||||
|
||||
/*
|
||||
* Setting the first channel to the temperature channel isn't supported
|
||||
* in single-cycle mode, so we have to do an extra xfer to read the
|
||||
* temperature.
|
||||
* in single-cycle mode, so we have to do an extra conversion to read
|
||||
* the temperature.
|
||||
*/
|
||||
if (address == AD4695_CMD_TEMP_CHAN) {
|
||||
/* We aren't reading, so we can make this a short xfer. */
|
||||
st->cnv_cmd2 = AD4695_CMD_TEMP_CHAN << 3;
|
||||
xfer[0].tx_buf = &st->cnv_cmd2;
|
||||
xfer[0].len = 1;
|
||||
xfer[0].cs_change = 1;
|
||||
xfer[0].cs_change_delay.value = AD4695_T_CONVERT_NS;
|
||||
xfer[0].cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
|
||||
st->cnv_cmd = AD4695_CMD_TEMP_CHAN << 11;
|
||||
|
||||
i = 1;
|
||||
ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Then read the result and exit conversion mode. */
|
||||
st->cnv_cmd = AD4695_CMD_EXIT_CNV_MODE << 11;
|
||||
xfer[i].bits_per_word = 16;
|
||||
xfer[i].tx_buf = &st->cnv_cmd;
|
||||
xfer[i].rx_buf = &st->raw_data;
|
||||
xfer[i].len = 2;
|
||||
xfers[0].rx_buf = &st->raw_data;
|
||||
|
||||
return spi_sync_transfer(st->spi, xfer, i + 1);
|
||||
return spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
|
||||
}
|
||||
|
||||
static int ad4695_read_raw(struct iio_dev *indio_dev,
|
||||
|
@ -917,6 +917,9 @@ static int ad7124_setup(struct ad7124_state *st)
|
||||
* set all channels to this default value.
|
||||
*/
|
||||
ad7124_set_channel_odr(st, i, 10);
|
||||
|
||||
/* Disable all channels to prevent unintended conversions. */
|
||||
ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0);
|
||||
}
|
||||
|
||||
ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);
|
||||
|
@ -200,6 +200,7 @@ struct ad7173_channel {
|
||||
|
||||
struct ad7173_state {
|
||||
struct ad_sigma_delta sd;
|
||||
struct ad_sigma_delta_info sigma_delta_info;
|
||||
const struct ad7173_device_info *info;
|
||||
struct ad7173_channel *channels;
|
||||
struct regulator_bulk_data regulators[3];
|
||||
@ -753,7 +754,7 @@ static int ad7173_disable_one(struct ad_sigma_delta *sd, unsigned int chan)
|
||||
return ad_sd_write_reg(sd, AD7173_REG_CH(chan), 2, 0);
|
||||
}
|
||||
|
||||
static struct ad_sigma_delta_info ad7173_sigma_delta_info = {
|
||||
static const struct ad_sigma_delta_info ad7173_sigma_delta_info = {
|
||||
.set_channel = ad7173_set_channel,
|
||||
.append_status = ad7173_append_status,
|
||||
.disable_all = ad7173_disable_all,
|
||||
@ -1403,7 +1404,7 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev)
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n");
|
||||
|
||||
ad7173_sigma_delta_info.irq_line = ret;
|
||||
st->sigma_delta_info.irq_line = ret;
|
||||
|
||||
return ad7173_fw_parse_channel_config(indio_dev);
|
||||
}
|
||||
@ -1436,8 +1437,9 @@ static int ad7173_probe(struct spi_device *spi)
|
||||
spi->mode = SPI_MODE_3;
|
||||
spi_setup(spi);
|
||||
|
||||
ad7173_sigma_delta_info.num_slots = st->info->num_configs;
|
||||
ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7173_sigma_delta_info);
|
||||
st->sigma_delta_info = ad7173_sigma_delta_info;
|
||||
st->sigma_delta_info.num_slots = st->info->num_configs;
|
||||
ret = ad_sd_init(&st->sd, indio_dev, spi, &st->sigma_delta_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -175,17 +175,17 @@ static const struct iio_chan_spec ad7616_channels[] = {
|
||||
AD7606_CHANNEL(15, 16),
|
||||
};
|
||||
|
||||
static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7607_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7607_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7608_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7608_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7609_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7609_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
|
||||
const struct ad7606_chip_info ad7605_4_info = {
|
||||
@ -323,9 +323,10 @@ int ad7606_reset(struct ad7606_state *st)
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(ad7606_reset, "IIO_AD7606");
|
||||
|
||||
static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
if (!st->sw_mode_en) {
|
||||
@ -345,10 +346,12 @@ static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
|
||||
static int ad7606_get_chan_config(struct iio_dev *indio_dev, int ch,
|
||||
bool *bipolar, bool *differential)
|
||||
{
|
||||
unsigned int num_channels = st->chip_info->num_channels - 1;
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
unsigned int num_channels = st->chip_info->num_adc_channels;
|
||||
unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels;
|
||||
struct device *dev = st->dev;
|
||||
int ret;
|
||||
|
||||
@ -364,7 +367,7 @@ static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
|
||||
continue;
|
||||
|
||||
/* channel number (here) is from 1 to num_channels */
|
||||
if (reg == 0 || reg > num_channels) {
|
||||
if (reg < offset || reg > num_channels) {
|
||||
dev_warn(dev,
|
||||
"Invalid channel number (ignoring): %d\n", reg);
|
||||
continue;
|
||||
@ -399,9 +402,10 @@ static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
bool bipolar, differential;
|
||||
int ret;
|
||||
@ -413,7 +417,7 @@ static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ad7606_get_chan_config(st, ch, &bipolar, &differential);
|
||||
ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -455,9 +459,10 @@ static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
bool bipolar, differential;
|
||||
int ret;
|
||||
@ -469,7 +474,7 @@ static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ad7606_get_chan_config(st, ch, &bipolar, &differential);
|
||||
ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -512,9 +517,10 @@ static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7607_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7607_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
cs->range = 0;
|
||||
@ -523,9 +529,10 @@ static int ad7607_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7608_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7608_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
cs->range = 0;
|
||||
@ -534,9 +541,10 @@ static int ad7608_chan_scale_setup(struct ad7606_state *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7609_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7609_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
cs->range = 0;
|
||||
@ -1146,8 +1154,8 @@ static int ad7606_sw_mode_setup(struct iio_dev *indio_dev)
|
||||
|
||||
static int ad7606_chan_scales_setup(struct iio_dev *indio_dev)
|
||||
{
|
||||
unsigned int num_channels = indio_dev->num_channels - 1;
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels;
|
||||
struct iio_chan_spec *chans;
|
||||
size_t size;
|
||||
int ch, ret;
|
||||
@ -1161,8 +1169,8 @@ static int ad7606_chan_scales_setup(struct iio_dev *indio_dev)
|
||||
memcpy(chans, indio_dev->channels, size);
|
||||
indio_dev->channels = chans;
|
||||
|
||||
for (ch = 0; ch < num_channels; ch++) {
|
||||
ret = st->chip_info->scale_setup_cb(st, &chans[ch + 1], ch);
|
||||
for (ch = 0; ch < st->chip_info->num_adc_channels; ch++) {
|
||||
ret = st->chip_info->scale_setup_cb(indio_dev, &chans[ch + offset], ch);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@
|
||||
|
||||
struct ad7606_state;
|
||||
|
||||
typedef int (*ad7606_scale_setup_cb_t)(struct ad7606_state *st,
|
||||
typedef int (*ad7606_scale_setup_cb_t)(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
|
||||
/**
|
||||
|
@ -895,7 +895,7 @@ static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct iio_info ad9467_info = {
|
||||
static const struct iio_info ad9467_info = {
|
||||
.read_raw = ad9467_read_raw,
|
||||
.write_raw = ad9467_write_raw,
|
||||
.update_scan_mode = ad9467_update_scan_mode,
|
||||
@ -903,6 +903,14 @@ static struct iio_info ad9467_info = {
|
||||
.read_avail = ad9467_read_avail,
|
||||
};
|
||||
|
||||
/* Same as above, but without .read_avail */
|
||||
static const struct iio_info ad9467_info_no_read_avail = {
|
||||
.read_raw = ad9467_read_raw,
|
||||
.write_raw = ad9467_write_raw,
|
||||
.update_scan_mode = ad9467_update_scan_mode,
|
||||
.debugfs_reg_access = ad9467_reg_access,
|
||||
};
|
||||
|
||||
static int ad9467_scale_fill(struct ad9467_state *st)
|
||||
{
|
||||
const struct ad9467_chip_info *info = st->info;
|
||||
@ -1214,11 +1222,12 @@ static int ad9467_probe(struct spi_device *spi)
|
||||
}
|
||||
|
||||
if (st->info->num_scales > 1)
|
||||
ad9467_info.read_avail = ad9467_read_avail;
|
||||
indio_dev->info = &ad9467_info;
|
||||
else
|
||||
indio_dev->info = &ad9467_info_no_read_avail;
|
||||
indio_dev->name = st->info->name;
|
||||
indio_dev->channels = st->info->channels;
|
||||
indio_dev->num_channels = st->info->num_channels;
|
||||
indio_dev->info = &ad9467_info;
|
||||
|
||||
ret = ad9467_iio_backend_get(st);
|
||||
if (ret)
|
||||
|
@ -979,7 +979,7 @@ static int at91_ts_register(struct iio_dev *idev,
|
||||
return ret;
|
||||
|
||||
err:
|
||||
input_free_device(st->ts_input);
|
||||
input_free_device(input);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -368,6 +368,8 @@ static irqreturn_t rockchip_saradc_trigger_handler(int irq, void *p)
|
||||
int ret;
|
||||
int i, j = 0;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
mutex_lock(&info->lock);
|
||||
|
||||
iio_for_each_active_channel(i_dev, i) {
|
||||
|
@ -691,11 +691,14 @@ static int stm32_dfsdm_generic_channel_parse_of(struct stm32_dfsdm *dfsdm,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = fwnode_property_read_string(node, "label", &ch->datasheet_name);
|
||||
if (ret < 0) {
|
||||
dev_err(&indio_dev->dev,
|
||||
" Error parsing 'label' for idx %d\n", ch->channel);
|
||||
return ret;
|
||||
if (fwnode_property_present(node, "label")) {
|
||||
/* label is optional */
|
||||
ret = fwnode_property_read_string(node, "label", &ch->datasheet_name);
|
||||
if (ret < 0) {
|
||||
dev_err(&indio_dev->dev,
|
||||
" Error parsing 'label' for idx %d\n", ch->channel);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
df_ch = &dfsdm->ch_list[ch->channel];
|
||||
|
@ -500,12 +500,14 @@ static irqreturn_t ads1119_trigger_handler(int irq, void *private)
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct ads1119_state *st = iio_priv(indio_dev);
|
||||
struct {
|
||||
unsigned int sample;
|
||||
s16 sample;
|
||||
s64 timestamp __aligned(8);
|
||||
} scan;
|
||||
unsigned int index;
|
||||
int ret;
|
||||
|
||||
memset(&scan, 0, sizeof(scan));
|
||||
|
||||
if (!iio_trigger_using_own(indio_dev)) {
|
||||
index = find_first_bit(indio_dev->active_scan_mask,
|
||||
iio_get_masklength(indio_dev));
|
||||
|
@ -183,9 +183,9 @@ static int ads124s_reset(struct iio_dev *indio_dev)
|
||||
struct ads124s_private *priv = iio_priv(indio_dev);
|
||||
|
||||
if (priv->reset_gpio) {
|
||||
gpiod_set_value(priv->reset_gpio, 0);
|
||||
gpiod_set_value_cansleep(priv->reset_gpio, 0);
|
||||
udelay(200);
|
||||
gpiod_set_value(priv->reset_gpio, 1);
|
||||
gpiod_set_value_cansleep(priv->reset_gpio, 1);
|
||||
} else {
|
||||
return ads124s_write_cmd(indio_dev, ADS124S08_CMD_RESET);
|
||||
}
|
||||
|
@ -613,6 +613,8 @@ static int ads1298_init(struct iio_dev *indio_dev)
|
||||
}
|
||||
indio_dev->name = devm_kasprintf(dev, GFP_KERNEL, "ads129%u%s",
|
||||
indio_dev->num_channels, suffix);
|
||||
if (!indio_dev->name)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Enable internal test signal, double amplitude, double frequency */
|
||||
ret = regmap_write(priv->regmap, ADS1298_REG_CONFIG2,
|
||||
|
@ -381,7 +381,7 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p)
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
/* Ensure naturally aligned timestamp */
|
||||
u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8);
|
||||
u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8) = { };
|
||||
int i, j = 0;
|
||||
|
||||
iio_for_each_active_channel(indio_dev, i) {
|
||||
|
@ -48,7 +48,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
|
||||
int i = 0, j;
|
||||
u16 *data;
|
||||
|
||||
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
|
||||
data = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
|
||||
if (!data)
|
||||
goto done;
|
||||
|
||||
|
@ -730,14 +730,21 @@ static irqreturn_t fxas21002c_trigger_handler(int irq, void *p)
|
||||
int ret;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB,
|
||||
data->buffer, CHANNEL_SCAN_MAX * sizeof(s16));
|
||||
ret = fxas21002c_pm_get(data);
|
||||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
|
||||
ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB,
|
||||
data->buffer, CHANNEL_SCAN_MAX * sizeof(s16));
|
||||
if (ret < 0)
|
||||
goto out_pm_put;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
|
||||
data->timestamp);
|
||||
|
||||
out_pm_put:
|
||||
fxas21002c_pm_put(data);
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&data->lock);
|
||||
|
||||
|
@ -403,6 +403,7 @@ struct inv_icm42600_sensor_state {
|
||||
typedef int (*inv_icm42600_bus_setup)(struct inv_icm42600_state *);
|
||||
|
||||
extern const struct regmap_config inv_icm42600_regmap_config;
|
||||
extern const struct regmap_config inv_icm42600_spi_regmap_config;
|
||||
extern const struct dev_pm_ops inv_icm42600_pm_ops;
|
||||
|
||||
const struct iio_mount_matrix *
|
||||
|
@ -87,6 +87,21 @@ const struct regmap_config inv_icm42600_regmap_config = {
|
||||
};
|
||||
EXPORT_SYMBOL_NS_GPL(inv_icm42600_regmap_config, "IIO_ICM42600");
|
||||
|
||||
/* define specific regmap for SPI not supporting burst write */
|
||||
const struct regmap_config inv_icm42600_spi_regmap_config = {
|
||||
.name = "inv_icm42600",
|
||||
.reg_bits = 8,
|
||||
.val_bits = 8,
|
||||
.max_register = 0x4FFF,
|
||||
.ranges = inv_icm42600_regmap_ranges,
|
||||
.num_ranges = ARRAY_SIZE(inv_icm42600_regmap_ranges),
|
||||
.volatile_table = inv_icm42600_regmap_volatile_accesses,
|
||||
.rd_noinc_table = inv_icm42600_regmap_rd_noinc_accesses,
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
.use_single_write = true,
|
||||
};
|
||||
EXPORT_SYMBOL_NS_GPL(inv_icm42600_spi_regmap_config, "IIO_ICM42600");
|
||||
|
||||
struct inv_icm42600_hw {
|
||||
uint8_t whoami;
|
||||
const char *name;
|
||||
@ -814,6 +829,8 @@ static int inv_icm42600_suspend(struct device *dev)
|
||||
static int inv_icm42600_resume(struct device *dev)
|
||||
{
|
||||
struct inv_icm42600_state *st = dev_get_drvdata(dev);
|
||||
struct inv_icm42600_sensor_state *gyro_st = iio_priv(st->indio_gyro);
|
||||
struct inv_icm42600_sensor_state *accel_st = iio_priv(st->indio_accel);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
@ -834,9 +851,12 @@ static int inv_icm42600_resume(struct device *dev)
|
||||
goto out_unlock;
|
||||
|
||||
/* restore FIFO data streaming */
|
||||
if (st->fifo.on)
|
||||
if (st->fifo.on) {
|
||||
inv_sensors_timestamp_reset(&gyro_st->ts);
|
||||
inv_sensors_timestamp_reset(&accel_st->ts);
|
||||
ret = regmap_write(st->map, INV_ICM42600_REG_FIFO_CONFIG,
|
||||
INV_ICM42600_FIFO_CONFIG_STREAM);
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&st->lock);
|
||||
|
@ -59,7 +59,8 @@ static int inv_icm42600_probe(struct spi_device *spi)
|
||||
return -EINVAL;
|
||||
chip = (uintptr_t)match;
|
||||
|
||||
regmap = devm_regmap_init_spi(spi, &inv_icm42600_regmap_config);
|
||||
/* use SPI specific regmap */
|
||||
regmap = devm_regmap_init_spi(spi, &inv_icm42600_spi_regmap_config);
|
||||
if (IS_ERR(regmap))
|
||||
return PTR_ERR(regmap);
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ static irqreturn_t kmx61_trigger_handler(int irq, void *p)
|
||||
struct kmx61_data *data = kmx61_get_data(indio_dev);
|
||||
int bit, ret, i = 0;
|
||||
u8 base;
|
||||
s16 buffer[8];
|
||||
s16 buffer[8] = { };
|
||||
|
||||
if (indio_dev == data->acc_indio_dev)
|
||||
base = KMX61_ACC_XOUT_L;
|
||||
|
@ -500,7 +500,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
|
||||
return_ptr(chans);
|
||||
|
||||
error_free_chans:
|
||||
for (i = 0; i < nummaps; i++)
|
||||
for (i = 0; i < mapind; i++)
|
||||
iio_device_put(chans[i].indio_dev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
@ -177,6 +177,12 @@ struct as73211_data {
|
||||
BIT(AS73211_SCAN_INDEX_TEMP) | \
|
||||
AS73211_SCAN_MASK_COLOR)
|
||||
|
||||
static const unsigned long as73211_scan_masks[] = {
|
||||
AS73211_SCAN_MASK_COLOR,
|
||||
AS73211_SCAN_MASK_ALL,
|
||||
0
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec as73211_channels[] = {
|
||||
{
|
||||
.type = IIO_TEMP,
|
||||
@ -672,9 +678,12 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
|
||||
|
||||
/* AS73211 starts reading at address 2 */
|
||||
ret = i2c_master_recv(data->client,
|
||||
(char *)&scan.chan[1], 3 * sizeof(scan.chan[1]));
|
||||
(char *)&scan.chan[0], 3 * sizeof(scan.chan[0]));
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
/* Avoid pushing uninitialized data */
|
||||
scan.chan[3] = 0;
|
||||
}
|
||||
|
||||
if (data_result) {
|
||||
@ -682,9 +691,15 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
|
||||
* Saturate all channels (in case of overflows). Temperature channel
|
||||
* is not affected by overflows.
|
||||
*/
|
||||
scan.chan[1] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[2] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[3] = cpu_to_le16(U16_MAX);
|
||||
if (*indio_dev->active_scan_mask == AS73211_SCAN_MASK_ALL) {
|
||||
scan.chan[1] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[2] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[3] = cpu_to_le16(U16_MAX);
|
||||
} else {
|
||||
scan.chan[0] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[1] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[2] = cpu_to_le16(U16_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
|
||||
@ -758,6 +773,7 @@ static int as73211_probe(struct i2c_client *client)
|
||||
indio_dev->channels = data->spec_dev->channels;
|
||||
indio_dev->num_channels = data->spec_dev->num_channels;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->available_scan_masks = as73211_scan_masks;
|
||||
|
||||
ret = i2c_smbus_read_byte_data(data->client, AS73211_REG_OSR);
|
||||
if (ret < 0)
|
||||
|
@ -746,6 +746,8 @@ static irqreturn_t bh1745_trigger_handler(int interrupt, void *p)
|
||||
int i;
|
||||
int j = 0;
|
||||
|
||||
memset(&scan, 0, sizeof(scan));
|
||||
|
||||
iio_for_each_active_channel(indio_dev, i) {
|
||||
ret = regmap_bulk_read(data->regmap, BH1745_RED_LSB + 2 * i,
|
||||
&value, 2);
|
||||
|
@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
|
||||
*val2 = 0;
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
case IIO_CHAN_INFO_PROCESSED:
|
||||
if (chan->scan_index >= prox_state->num_channels)
|
||||
return -EINVAL;
|
||||
address = prox_state->channel2usage[chan->scan_index];
|
||||
|
@ -105,7 +105,7 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct vcnl4035_data *data = iio_priv(indio_dev);
|
||||
/* Ensure naturally aligned timestamp */
|
||||
u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8);
|
||||
u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8) = { };
|
||||
int ret;
|
||||
|
||||
ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer);
|
||||
|
@ -586,6 +586,8 @@ static int zpa2326_fill_sample_buffer(struct iio_dev *indio_dev,
|
||||
} sample;
|
||||
int err;
|
||||
|
||||
memset(&sample, 0, sizeof(sample));
|
||||
|
||||
if (test_bit(0, indio_dev->active_scan_mask)) {
|
||||
/* Get current pressure from hardware FIFO. */
|
||||
err = zpa2326_dequeue_pressure(indio_dev, &sample.pressure);
|
||||
|
@ -252,6 +252,8 @@ static irqreturn_t tmp006_trigger_handler(int irq, void *p)
|
||||
} scan;
|
||||
s32 ret;
|
||||
|
||||
memset(&scan, 0, sizeof(scan));
|
||||
|
||||
ret = i2c_smbus_read_word_data(data->client, TMP006_VOBJECT);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
# Keep in alphabetical order
|
||||
config IIO_GTS_KUNIT_TEST
|
||||
tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS
|
||||
tristate "Test IIO gain-time-scale helpers" if !KUNIT_ALL_TESTS
|
||||
depends on KUNIT
|
||||
select IIO_GTS_HELPER
|
||||
select TEST_KUNIT_DEVICE_HELPERS
|
||||
|
@ -652,6 +652,8 @@ static void iio_rescale_test_scale(struct kunit *test)
|
||||
int rel_ppm;
|
||||
int ret;
|
||||
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff);
|
||||
|
||||
rescale.numerator = t->numerator;
|
||||
rescale.denominator = t->denominator;
|
||||
rescale.offset = t->offset;
|
||||
@ -681,6 +683,8 @@ static void iio_rescale_test_offset(struct kunit *test)
|
||||
int values[2];
|
||||
int ret;
|
||||
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff_off);
|
||||
|
||||
rescale.numerator = t->numerator;
|
||||
rescale.denominator = t->denominator;
|
||||
rescale.offset = t->offset;
|
||||
|
@ -158,7 +158,7 @@ static int ad9832_write_frequency(struct ad9832_state *st,
|
||||
static int ad9832_write_phase(struct ad9832_state *st,
|
||||
unsigned long addr, unsigned long phase)
|
||||
{
|
||||
if (phase > BIT(AD9832_PHASE_BITS))
|
||||
if (phase >= BIT(AD9832_PHASE_BITS))
|
||||
return -EINVAL;
|
||||
|
||||
st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
|
||||
|
@ -131,7 +131,7 @@ static int ad9834_write_frequency(struct ad9834_state *st,
|
||||
static int ad9834_write_phase(struct ad9834_state *st,
|
||||
unsigned long addr, unsigned long phase)
|
||||
{
|
||||
if (phase > BIT(AD9834_PHASE_BITS))
|
||||
if (phase >= BIT(AD9834_PHASE_BITS))
|
||||
return -EINVAL;
|
||||
st->data = cpu_to_be16(addr | phase);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user