Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3936961imb; Wed, 6 Mar 2019 00:59:45 -0800 (PST) X-Google-Smtp-Source: APXvYqw3KkHky6JdrWppTSqCpzxIPB/m6JmkJbHPwFnYe01vHkgRs3HwImR0jjjkSzQjikLeY27u X-Received: by 2002:a63:2c7:: with SMTP id 190mr5011955pgc.367.1551862784936; Wed, 06 Mar 2019 00:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551862784; cv=none; d=google.com; s=arc-20160816; b=oC2tcZIQXPJkEOEKtCiVeMCkaHLUnuMuw05pwr/OXCWVJYusMsFFBLZhv6oPhL11QZ 5DhDMYlXQ90T8RABeUyTq78jRNxBTPC8p1LhJTskIc3afXpO4upDIng7gWx1ZT+W0T8h rwtrnQBCBhh5GYsf1qYHeuhC6keLNzUvALj41O+xyb1AwEBtMXZye3tIIV0j5DDQFp4u TgcM0NSDPKmw/6t/lXXZYUXwviC6P05yIEUy+LmKY7lNOP9kp3pTo1KykcVE10d1H8vT XXFB3lqXrp0990qimP0bpJUpq4pUuZ4wyOSaFoxugp9u1l6V5KDVTkVHIijSWKV2Dfa/ 6gFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=LDTjguHVSZHGf6PnD1psQDpWTcCburL9deMKMy22ulM=; b=bmOD/WnSb1MEGAadPAl09DDiWXnVdwd3EOI3Jim5qchlG1L8hhic+E0vaBVV6/3tOE lCk3GfTb7Sez1wXbnpNVKaief8bSI3Rrgp+ecTaixIgKQ/bWGQK0iNEBaLsmoMkZJqgz CJO283POrOV3gVyY/7yiftnfaR1FQGUu4v2TGEefvTu1ZpSD+2oyS4pxxBIxtJsm+9HC G5lkpuLq+hrAUhFEbv4lRS+JOvhi9IWVHuCUMDl5H9mZOJTu9QnL8e5vBERrMO7xq8kq u8XmtAN7HWgRWpLVB0QMsbIqLq6u+F7HLlxv5pQWRAGaP0kh6XuzrlAEmaJAMi/rdVkM wCEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9si956279pgs.212.2019.03.06.00.59.30; Wed, 06 Mar 2019 00:59:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729668AbfCFI4n (ORCPT + 99 others); Wed, 6 Mar 2019 03:56:43 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:47805 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbfCFI4X (ORCPT ); Wed, 6 Mar 2019 03:56:23 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x268pquq028239; Wed, 6 Mar 2019 09:55:51 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2qygfxpr7w-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 06 Mar 2019 09:55:51 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 85D273D; Wed, 6 Mar 2019 08:55:50 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6540923F7; Wed, 6 Mar 2019 08:55:50 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 6 Mar 2019 09:55:49 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , , Subject: [PATCH 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Date: Wed, 6 Mar 2019 09:55:20 +0100 Message-ID: <1551862524-25098-5-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551862524-25098-1-git-send-email-fabrice.gasnier@st.com> References: <1551862524-25098-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG4NODE2.st.com (10.75.127.11) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-06_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/iio/adc/stm32-dfsdm-adc.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 818627f..66e2ea0 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -556,6 +556,11 @@ static void stm32_dfsdm_audio_dma_buffer_done(void *data) static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + struct dma_slave_config config = { + .src_addr = (dma_addr_t)adc->dfsdm->phys_base + + DFSDM_RDATAR(adc->fl_id), + .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, + }; struct dma_async_tx_descriptor *desc; dma_cookie_t cookie; int ret; @@ -566,6 +571,10 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) dev_dbg(&indio_dev->dev, "%s size=%d watermark=%d\n", __func__, adc->buf_sz, adc->buf_sz / 2); + ret = dmaengine_slave_config(adc->dma_chan, &config); + if (ret) + return ret; + /* Prepare a DMA cyclic transaction */ desc = dmaengine_prep_dma_cyclic(adc->dma_chan, adc->dma_buf, @@ -925,12 +934,6 @@ static void stm32_dfsdm_dma_release(struct iio_dev *indio_dev) static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); - struct dma_slave_config config = { - .src_addr = (dma_addr_t)adc->dfsdm->phys_base + - DFSDM_RDATAR(adc->fl_id), - .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, - }; - int ret; adc->dma_chan = dma_request_slave_channel(&indio_dev->dev, "rx"); if (!adc->dma_chan) @@ -940,23 +943,11 @@ static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev) DFSDM_DMA_BUFFER_SIZE, &adc->dma_buf, GFP_KERNEL); if (!adc->rx_buf) { - ret = -ENOMEM; - goto err_release; + dma_release_channel(adc->dma_chan); + return -ENOMEM; } - ret = dmaengine_slave_config(adc->dma_chan, &config); - if (ret) - goto err_free; - return 0; - -err_free: - dma_free_coherent(adc->dma_chan->device->dev, DFSDM_DMA_BUFFER_SIZE, - adc->rx_buf, adc->dma_buf); -err_release: - dma_release_channel(adc->dma_chan); - - return ret; } static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, -- 2.7.4