quoted
+static void ad7768_fill_scale_tbl(struct iio_dev *dev)
+{
+ struct ad7768_state *st = iio_priv(dev);
+ const struct iio_scan_type *scan_type;
+ int val, val2, tmp0, tmp1, i;
+ struct u64_fract fract;
+ unsigned long n, d;
+ u64 tmp2;
+
+ scan_type = iio_get_current_scan_type(dev, &dev->channels[0]);
Is it usual patter in IIO? Otherwise it can be written as
scan_type = iio_get_current_scan_type(dev, dev->channels);
From a semantic / readability point of view I'd keep it referencing
the first element. We are querying the scan type of one specific
channel, rather than the array that is behind dev->channels.
quoted
+ if (scan_type->sign == 's')
+ val2 = scan_type->realbits - 1;
+ else
+ val2 = scan_type->realbits;