Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp830899img; Thu, 21 Mar 2019 09:49:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2BmhdWFQsNc5Fda5iF2VneETcJn4X9DvGSp5SRVHITkxRE6E1F/HO5JamnW06pjNE5Vgj X-Received: by 2002:a63:2747:: with SMTP id n68mr2703535pgn.317.1553186944701; Thu, 21 Mar 2019 09:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553186944; cv=none; d=google.com; s=arc-20160816; b=FcFO6HemzJksMXhb57nJayXnmwOeQy2ZoK/sJGQx54yN+IH4OaF46Fv3wWxyAR36r+ naoWLhGoZh1WYJtJ90jAZ4GCHCRFMDIar0XOS5YPripBfAMzUm5W8rsSqYGeqAaDgWZ2 co+f3n7QmDECvdCjFvwNLfC9EiWG1q/L91YWdoaO9Fm7D07VOUb46Gml750S8evwCqLO l8xncxM23eb3XT7DHTqME/Ekf1JX+l/7wKSBEJm5XF7NTUtTmLhke36lPjQNPy0DvbmX p1BH+twNv4Y26Q7WeWUGSeR+0C8yKWvd0Z9WcPmjAAIcXWttsx71kWCZ4Gf8/tD5r/4u D3Qw== 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=AYzUUu7loi8xkRTR2hdSb02TFno5vHZbWCB0mTU68CilIe/Xm3qCuK79OTZlSTGoZQ SVauhs07Nm8VHUU2/2+cvE0STQNfQV3hYgdx3WxKsuSabeu5/HDSxedXG172fuVDVA6n qWunsGf4pjNpVVTfXDk6IyQO9AtViDqDcO7NIbVdbwSOxD0PmtM8LoDjx/+fEXp3r2i/ Qbw3cCPh7A2h0LlySgzxNEYURp4ScnayvA658/RIiPNw7SNnmjD3LYfuQlUp0JktHqmO eeVBRnL43lfyrynhnJCrVERxSPXWF9+wE0Q5F6UYBkCQE5PjVLmclLT6AyycRJyxDE2z e3YA== 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 60si5255329plf.122.2019.03.21.09.48.47; Thu, 21 Mar 2019 09:49:04 -0700 (PDT) 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 S1728592AbfCUQr7 (ORCPT + 99 others); Thu, 21 Mar 2019 12:47:59 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52952 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727829AbfCUQr7 (ORCPT ); Thu, 21 Mar 2019 12:47:59 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2LGkq7k008000; Thu, 21 Mar 2019 17:47:39 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2r8rwkek1p-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 21 Mar 2019 17:47:39 +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 2BDA53F; Thu, 21 Mar 2019 16:47:39 +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 F11335672; Thu, 21 Mar 2019 16:47:38 +0000 (GMT) Received: from localhost (10.75.127.47) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 21 Mar 2019 17:47:38 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , , Subject: [PATCH v2 4/8] iio: adc: stm32-dfsdm: move dma slave config to start routine Date: Thu, 21 Mar 2019 17:47:25 +0100 Message-ID: <1553186849-6261-5-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553186849-6261-1-git-send-email-fabrice.gasnier@st.com> References: <1553186849-6261-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-21_07:,, 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