OSDN Git Service

iio: adc: stm32-dfsdm: improve sampling frequency accuracy
authorFabrice Gasnier <fabrice.gasnier@st.com>
Mon, 25 Mar 2019 14:24:01 +0000 (15:24 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 4 Apr 2019 19:21:10 +0000 (20:21 +0100)
commit9f57110d2e3de5411730f2cdd160d60f4b59acc5
tree85354d4e3399f7e53fde11d09b44b6f8db5dd96e
parent65500c53aa6d0a6c4e40fcc7788332af9720ad14
iio: adc: stm32-dfsdm: improve sampling frequency accuracy

The sample frequency is driven using the oversampling ratio depending
on the SPI bus frequency.
Currently, oversampling ratio is computed by an entire division:
- spi_freq / sample_freq. This may result in inaccurate value.
Using DIV_ROUND_CLOSEST improves resulting sample frequency, which is
useful for audio that requests fixed rates (such as: 8, 16 or 32 kHz).
BTW, introduce new routine to re-factor sample frequency setting, and
move frequency accuracy message from warning to debug level.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/stm32-dfsdm-adc.c