Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7124: use read_avail() for scale_available

Replace custom attribute with the standard IIO read_avail() callback
to provide in_voltage_scale_available attribute.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
1b4956ca faf7f9e7

+29 -13
+29 -13
drivers/iio/adc/ad7124.c
··· 621 621 .num_resetclks = 64, 622 622 }; 623 623 624 + static const int ad7124_voltage_scales[][2] = { 625 + { 0, 1164 }, 626 + { 0, 2328 }, 627 + { 0, 4656 }, 628 + { 0, 9313 }, 629 + { 0, 18626 }, 630 + { 0, 37252 }, 631 + { 0, 74505 }, 632 + { 0, 149011 }, 633 + { 0, 298023 }, 634 + }; 635 + 636 + static int ad7124_read_avail(struct iio_dev *indio_dev, 637 + struct iio_chan_spec const *chan, 638 + const int **vals, int *type, int *length, long info) 639 + { 640 + switch (info) { 641 + case IIO_CHAN_INFO_SCALE: 642 + *vals = (const int *)ad7124_voltage_scales; 643 + *type = IIO_VAL_INT_PLUS_NANO; 644 + *length = ARRAY_SIZE(ad7124_voltage_scales) * 2; 645 + return IIO_AVAIL_LIST; 646 + default: 647 + return -EINVAL; 648 + } 649 + } 650 + 624 651 static int ad7124_read_raw(struct iio_dev *indio_dev, 625 652 struct iio_chan_spec const *chan, 626 653 int *val, int *val2, long info) ··· 802 775 return ret; 803 776 } 804 777 805 - static IIO_CONST_ATTR(in_voltage_scale_available, 806 - "0.000001164 0.000002328 0.000004656 0.000009313 0.000018626 0.000037252 0.000074505 0.000149011 0.000298023"); 807 - 808 - static struct attribute *ad7124_attributes[] = { 809 - &iio_const_attr_in_voltage_scale_available.dev_attr.attr, 810 - NULL, 811 - }; 812 - 813 - static const struct attribute_group ad7124_attrs_group = { 814 - .attrs = ad7124_attributes, 815 - }; 816 - 817 778 static int ad7124_update_scan_mode(struct iio_dev *indio_dev, 818 779 const unsigned long *scan_mask) 819 780 { ··· 831 816 } 832 817 833 818 static const struct iio_info ad7124_info = { 819 + .read_avail = ad7124_read_avail, 834 820 .read_raw = ad7124_read_raw, 835 821 .write_raw = ad7124_write_raw, 836 822 .debugfs_reg_access = &ad7124_reg_access, 837 823 .validate_trigger = ad_sd_validate_trigger, 838 824 .update_scan_mode = ad7124_update_scan_mode, 839 - .attrs = &ad7124_attrs_group, 840 825 }; 841 826 842 827 /* Only called during probe, so dev_err_probe() can be used */ ··· 1026 1011 BIT(IIO_CHAN_INFO_OFFSET) | 1027 1012 BIT(IIO_CHAN_INFO_SAMP_FREQ) | 1028 1013 BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), 1014 + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE), 1029 1015 .scan_type = { 1030 1016 .sign = 'u', 1031 1017 .realbits = 24,