Skip to content

Commit 7464850

Browse files
Fabrice Gasnierjic23
authored andcommitted
iio: adc: stm32-dfsdm: move dma slave config to start routine
Move DMA slave configuration to start routine: depending on regular or injected mode is in use, DMA needs to read resp. RDATAR or JDATAR. This is precursor patch to introduce injected mode (used for scan). Signed-off-by: Fabrice Gasnier <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent caf9c1e commit 7464850

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

drivers/iio/adc/stm32-dfsdm-adc.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,11 @@ static void stm32_dfsdm_audio_dma_buffer_done(void *data)
556556
static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev)
557557
{
558558
struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
559+
struct dma_slave_config config = {
560+
.src_addr = (dma_addr_t)adc->dfsdm->phys_base +
561+
DFSDM_RDATAR(adc->fl_id),
562+
.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
563+
};
559564
struct dma_async_tx_descriptor *desc;
560565
dma_cookie_t cookie;
561566
int ret;
@@ -566,6 +571,10 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev)
566571
dev_dbg(&indio_dev->dev, "%s size=%d watermark=%d\n", __func__,
567572
adc->buf_sz, adc->buf_sz / 2);
568573

574+
ret = dmaengine_slave_config(adc->dma_chan, &config);
575+
if (ret)
576+
return ret;
577+
569578
/* Prepare a DMA cyclic transaction */
570579
desc = dmaengine_prep_dma_cyclic(adc->dma_chan,
571580
adc->dma_buf,
@@ -925,12 +934,6 @@ static void stm32_dfsdm_dma_release(struct iio_dev *indio_dev)
925934
static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev)
926935
{
927936
struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
928-
struct dma_slave_config config = {
929-
.src_addr = (dma_addr_t)adc->dfsdm->phys_base +
930-
DFSDM_RDATAR(adc->fl_id),
931-
.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
932-
};
933-
int ret;
934937

935938
adc->dma_chan = dma_request_slave_channel(&indio_dev->dev, "rx");
936939
if (!adc->dma_chan)
@@ -940,23 +943,11 @@ static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev)
940943
DFSDM_DMA_BUFFER_SIZE,
941944
&adc->dma_buf, GFP_KERNEL);
942945
if (!adc->rx_buf) {
943-
ret = -ENOMEM;
944-
goto err_release;
946+
dma_release_channel(adc->dma_chan);
947+
return -ENOMEM;
945948
}
946949

947-
ret = dmaengine_slave_config(adc->dma_chan, &config);
948-
if (ret)
949-
goto err_free;
950-
951950
return 0;
952-
953-
err_free:
954-
dma_free_coherent(adc->dma_chan->device->dev, DFSDM_DMA_BUFFER_SIZE,
955-
adc->rx_buf, adc->dma_buf);
956-
err_release:
957-
dma_release_channel(adc->dma_chan);
958-
959-
return ret;
960951
}
961952

962953
static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev,

0 commit comments

Comments
 (0)