linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Thara Gopinath <thara.gopinath@gmail.com>,
	 Herbert Xu <herbert@gondor.apana.org.au>,
	 "David S. Miller" <davem@davemloft.net>,
	Vinod Koul <vkoul@kernel.org>,  Jonathan Corbet <corbet@lwn.net>,
	Md Sadre Alam <quic_mdalam@quicinc.com>,
	 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	 linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
	 linux-doc@vger.kernel.org,
	 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH v7 4/8] crypto: qce - use devres to allocate the result buffer
Date: Tue, 11 Mar 2025 10:25:35 +0100	[thread overview]
Message-ID: <20250311-qce-cmd-descr-v7-4-db613f5d9c9f@linaro.org> (raw)
In-Reply-To: <20250311-qce-cmd-descr-v7-0-db613f5d9c9f@linaro.org>

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Switch to devm_kmalloc for allocating the result_buf. This allows us to
drop two labels and make the devm action callback for DMA channels
smaller.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/crypto/qce/dma.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c
index 1dec7aea852d..6ac2efb7c2f7 100644
--- a/drivers/crypto/qce/dma.c
+++ b/drivers/crypto/qce/dma.c
@@ -15,7 +15,6 @@ static void qce_dma_release(void *data)
 
 	dma_release_channel(dma->txchan);
 	dma_release_channel(dma->rxchan);
-	kfree(dma->result_buf);
 }
 
 int devm_qce_dma_request(struct device *dev, struct qce_dma_data *dma)
@@ -28,26 +27,23 @@ int devm_qce_dma_request(struct device *dev, struct qce_dma_data *dma)
 
 	dma->rxchan = dma_request_chan(dev, "rx");
 	if (IS_ERR(dma->rxchan)) {
-		ret = PTR_ERR(dma->rxchan);
-		goto error_rx;
+		dma_release_channel(dma->txchan);
+		return PTR_ERR(dma->rxchan);
 	}
 
-	dma->result_buf = kmalloc(QCE_RESULT_BUF_SZ + QCE_IGNORE_BUF_SZ,
-				  GFP_KERNEL);
-	if (!dma->result_buf) {
-		ret = -ENOMEM;
-		goto error_nomem;
-	}
+	ret = devm_add_action_or_reset(dev, qce_dma_release, dma);
+	if (ret)
+		return ret;
+
+	dma->result_buf = devm_kmalloc(dev,
+				       QCE_RESULT_BUF_SZ + QCE_IGNORE_BUF_SZ,
+				       GFP_KERNEL);
+	if (!dma->result_buf)
+		return -ENOMEM;
 
 	dma->ignore_buf = dma->result_buf + QCE_RESULT_BUF_SZ;
 
-	return devm_add_action_or_reset(dev, qce_dma_release, dma);
-
-error_nomem:
-	dma_release_channel(dma->rxchan);
-error_rx:
-	dma_release_channel(dma->txchan);
-	return ret;
+	return 0;
 }
 
 struct scatterlist *

-- 
2.45.2


  parent reply	other threads:[~2025-03-11  9:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11  9:25 [PATCH v7 0/8] dmaengine: qcom: bam_dma: add command descriptor support Bartosz Golaszewski
2025-03-11  9:25 ` [PATCH v7 1/8] dmaengine: add DMA_PREP_LOCK and DMA_PREP_UNLOCK flag Bartosz Golaszewski
2025-03-11 15:59   ` Dmitry Baryshkov
2025-03-30 16:20   ` Vinod Koul
2025-03-11  9:25 ` [PATCH v7 2/8] dmaengine: qcom: bam_dma: extend the driver's device match data Bartosz Golaszewski
2025-03-11 16:00   ` Dmitry Baryshkov
2025-03-11  9:25 ` [PATCH v7 3/8] dmaengine: qcom: bam_dma: add bam_pipe_lock flag support Bartosz Golaszewski
2025-03-11 16:02   ` Dmitry Baryshkov
2025-03-30 16:22   ` Vinod Koul
2025-03-11  9:25 ` Bartosz Golaszewski [this message]
2025-03-11  9:25 ` [PATCH v7 5/8] crypto: qce - Map crypto memory for DMA Bartosz Golaszewski
2025-03-11  9:25 ` [PATCH v7 6/8] crypto: qce - Add BAM DMA support for crypto register I/O Bartosz Golaszewski
2025-03-11  9:25 ` [PATCH v7 7/8] crypto: qce - Switch to using DMA Bartosz Golaszewski
2025-03-11  9:25 ` [PATCH v7 8/8] crypto: qce - Add support for BAM locking Bartosz Golaszewski
2025-03-21  9:06 ` [PATCH v7 0/8] dmaengine: qcom: bam_dma: add command descriptor support Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250311-qce-cmd-descr-v7-4-db613f5d9c9f@linaro.org \
    --to=brgl@bgdev.pl \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dmaengine@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_mdalam@quicinc.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=thara.gopinath@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).