-static const struct iio_chan_spec adc081c_channel = {
- .type = IIO_VOLTAGE,
- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-};
the patch would look cleaner/shorter if adc081c_channel won't get moved
around
+static irqreturn_t adc081c_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct adc081c *data = iio_priv(indio_dev);
+ s64 ts;
+ u16 buf[8];
comment: 2 bytes data + 6 bytes padding + 8 bytes timestamp
+ int ret;
+
+ /* Otherwise iio_push_to_buffers will corrupt the stack. */
+ if (indio_dev->scan_bytes > sizeof(buf)) {
+ dev_crit_once(&indio_dev->dev, "Bad iio_scan_bytes=%d > %d\n",
+ indio_dev->scan_bytes, (int)sizeof(buf));
rather than casting sizeof(buf), use the correct printf length modifier,
i.e. %z
not sure if this check is needed
+ ret = i2c_smbus_read_word_swapped(data->i2c, REG_CONV_RES);
REG_CONV_RES should be called ADC081C_REG_CONV_RES, but that's a separate
issue
+ ts = iio_get_time_ns();
why is the timestamp taken here?, seems strange
often this is done together with iio_push_to_buffers_with_timestamp()
- iio->channels = &adc081c_channel;
- iio->num_channels = 1;
+ iio->channels = model->channels;
+ iio->num_channels = 2;
the number of channels could go into the adcxx1c_info struct