* The AD4062 in burst averaging mode increases realbits from 16-bits to
* 20-bits, increasing the storagebits from 16-bits to 32-bits.
*/
-static inline size_t ad4062_sizeof_storagebits(struct ad4062_state *st)
+static inline int ad4062_sizeof_storagebits(struct ad4062_state *st)
{
const struct iio_scan_type *scan_type =
iio_get_current_scan_type(st->indio_dev, st->chip->channels);
+ if (IS_ERR(scan_type))
+ return PTR_ERR(scan_type);
+
return BITS_TO_BYTES(scan_type->storagebits);
}
if (ret)
return ret;
- st->conv_sizeof = ad4062_sizeof_storagebits(st);
+ ret = ad4062_sizeof_storagebits(st);
+ if (ret < 0)
+ return ret;
+
+ st->conv_sizeof = ret;
+
st->conv_addr = ad4062_get_conv_addr(st, st->conv_sizeof);
/* CONV_READ requires read to trigger first sample. */
struct i3c_xfer xfer_sample[2] = {