public inbox for ntb@lists.linux.dev
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: ntb@lists.linux.dev, kernel-janitors@vger.kernel.org,
	Allen Hubbe <allenbh@gmail.com>,
	Dave Jiang <dave.jiang@intel.com>, Jon Mason <jdmason@kudzu.us>,
	Max Hawking <maxahawking@sonnenkinder.org>,
	Serge Semin <fancer.lancer@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] ntb_perf: Use common error handling code in perf_copy_chunk()
Date: Mon, 23 Sep 2024 11:16:26 +0200	[thread overview]
Message-ID: <dd95348b-8711-4afe-af8a-62cfb1a1d9f1@web.de> (raw)
In-Reply-To: <c7654504-a455-4972-9861-39800732d0df@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Sep 2024 10:48:17 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ntb/test/ntb_perf.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index dfd175f79e8f..88c5192b81eb 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -816,10 +816,9 @@ static int perf_copy_chunk(struct perf_thread *pthr,
 	unmap->len = len;
 	unmap->addr[0] = dma_map_page(dma_dev, virt_to_page(src),
 		offset_in_page(src), len, DMA_TO_DEVICE);
-	if (dma_mapping_error(dma_dev, unmap->addr[0])) {
-		ret = -EIO;
-		goto err_free_resource;
-	}
+	if (dma_mapping_error(dma_dev, unmap->addr[0]))
+		goto e_io;
+
 	unmap->to_cnt = 1;

 	do {
@@ -829,10 +828,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
 			msleep(DMA_MDELAY);
 	} while (!tx && (try++ < DMA_TRIES));

-	if (!tx) {
-		ret = -EIO;
-		goto err_free_resource;
-	}
+	if (!tx)
+		goto e_io;

 	tx->callback = perf_dma_copy_callback;
 	tx->callback_param = pthr;
@@ -850,6 +847,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
 ret_check_tsync:
 	return likely(atomic_read(&pthr->perf->tsync) > 0) ? 0 : -EINTR;

+e_io:
+	ret = -EIO;
 err_free_resource:
 	dmaengine_unmap_put(unmap);

--
2.46.1


      parent reply	other threads:[~2024-09-23  9:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23  9:11 [PATCH 0/2] ntb_perf: Adjustments for perf_copy_chunk() Markus Elfring
2024-09-23  9:15 ` [PATCH 1/2] ntb_perf: Delete duplicate dmaengine_unmap_put() call in perf_copy_chunk() Markus Elfring
2024-09-23  9:16 ` Markus Elfring [this message]

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=dd95348b-8711-4afe-af8a-62cfb1a1d9f1@web.de \
    --to=markus.elfring@web.de \
    --cc=allenbh@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=fancer.lancer@gmail.com \
    --cc=jdmason@kudzu.us \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxahawking@sonnenkinder.org \
    --cc=ntb@lists.linux.dev \
    /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