Replace the call to pwm_get_state() with a call to pwm_get_state_hw() in the ad7606 driver. This allows reading the sampling_frequency attribute to return the rate the hardware is actually running at rather than the rate that was requested. These may differ when the hardware isn't capable of running at exactly the requested frequency. Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx> --- I went ahead and made this patch since it is trivial, but it would be nice to get a Tested-by from Guillaume to make sure it actually works as expected. --- drivers/iio/adc/ad7606.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 8b2046baaa3e..1581eb31b8f9 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -762,11 +762,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, *val = st->oversampling; return IIO_VAL_INT; case IIO_CHAN_INFO_SAMP_FREQ: - /* - * TODO: return the real frequency intead of the requested one once - * pwm_get_state_hw comes upstream. - */ - pwm_get_state(st->cnvst_pwm, &cnvst_pwm_state); + ret = pwm_get_state_hw(st->cnvst_pwm, &cnvst_pwm_state); + if (ret < 0) + return ret; *val = DIV_ROUND_CLOSEST_ULL(NSEC_PER_SEC, cnvst_pwm_state.period); return IIO_VAL_INT; } -- 2.43.0