@@ -621,6 +621,33 @@ static const struct ad_sigma_delta_info ad7124_sigma_delta_info = {
621621 .num_resetclks = 64 ,
622622};
623623
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+
624651static int ad7124_read_raw (struct iio_dev * indio_dev ,
625652 struct iio_chan_spec const * chan ,
626653 int * val , int * val2 , long info )
@@ -775,18 +802,6 @@ static int ad7124_reg_access(struct iio_dev *indio_dev,
775802 return ret ;
776803}
777804
778- static IIO_CONST_ATTR (in_voltage_scale_available ,
779- "0.000001164 0.000002328 0.000004656 0.000009313 0.000018626 0.000037252 0.000074505 0.000149011 0.000298023" );
780-
781- static struct attribute * ad7124_attributes [] = {
782- & iio_const_attr_in_voltage_scale_available .dev_attr .attr ,
783- NULL ,
784- };
785-
786- static const struct attribute_group ad7124_attrs_group = {
787- .attrs = ad7124_attributes ,
788- };
789-
790805static int ad7124_update_scan_mode (struct iio_dev * indio_dev ,
791806 const unsigned long * scan_mask )
792807{
@@ -816,12 +831,12 @@ static int ad7124_update_scan_mode(struct iio_dev *indio_dev,
816831}
817832
818833static const struct iio_info ad7124_info = {
834+ .read_avail = ad7124_read_avail ,
819835 .read_raw = ad7124_read_raw ,
820836 .write_raw = ad7124_write_raw ,
821837 .debugfs_reg_access = & ad7124_reg_access ,
822838 .validate_trigger = ad_sd_validate_trigger ,
823839 .update_scan_mode = ad7124_update_scan_mode ,
824- .attrs = & ad7124_attrs_group ,
825840};
826841
827842/* Only called during probe, so dev_err_probe() can be used */
@@ -1011,6 +1026,7 @@ static const struct iio_chan_spec ad7124_channel_template = {
10111026 BIT (IIO_CHAN_INFO_OFFSET ) |
10121027 BIT (IIO_CHAN_INFO_SAMP_FREQ ) |
10131028 BIT (IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY ),
1029+ .info_mask_shared_by_type_available = BIT (IIO_CHAN_INFO_SCALE ),
10141030 .scan_type = {
10151031 .sign = 'u' ,
10161032 .realbits = 24 ,
0 commit comments