mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: xu.panda668@gmail.com
To: macro@orcam.me.uk
Cc: jirislaby@kernel.org, linux-kernel@vger.kernel.org,
	Xu Panda <xu.panda@zte.com.cn>, Zeal Robot <zealci@zte.com.cn>
Subject: [PATCH linux-next v2] serial: dz: use atomic_inc and atomic_dec instead of atomic_add
Date: Thu, 13 Oct 2022 08:12:22 +0000	[thread overview]
Message-ID: <20221013081220.351415-1-xu.panda668@gmail.com> (raw)

From: Xu Panda <xu.panda@zte.com.cn>

It's better to use atomic_dec_return() etc. instead of 
atomic_add_return().

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
---
 drivers/tty/serial/dz.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 829b452daee9..84476cef3278 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -404,14 +404,14 @@ static int dz_startup(struct uart_port *uport)
 	int ret;
 	u16 tmp;
 
-	irq_guard = atomic_add_return(1, &mux->irq_guard);
+	irq_guard = atomic_inc_return(&mux->irq_guard);
 	if (irq_guard != 1)
 		return 0;
 
 	ret = request_irq(dport->port.irq, dz_interrupt,
 			  IRQF_SHARED, "dz", mux);
 	if (ret) {
-		atomic_add(-1, &mux->irq_guard);
+		atomic_dec(&mux->irq_guard);
 		printk(KERN_ERR "dz: Cannot get IRQ %d!\n", dport->port.irq);
 		return ret;
 	}
@@ -448,7 +448,7 @@ static void dz_shutdown(struct uart_port *uport)
 	dz_stop_tx(&dport->port);
 	spin_unlock_irqrestore(&dport->port.lock, flags);
 
-	irq_guard = atomic_add_return(-1, &mux->irq_guard);
+	irq_guard = atomic_dec_return(&mux->irq_guard);
 	if (!irq_guard) {
 		/* Disable interrupts.  */
 		tmp = dz_in(dport, DZ_CSR);
@@ -668,7 +668,7 @@ static void dz_release_port(struct uart_port *uport)
 	iounmap(uport->membase);
 	uport->membase = NULL;
 
-	map_guard = atomic_add_return(-1, &mux->map_guard);
+	map_guard = atomic_dec_return(&mux->map_guard);
 	if (!map_guard)
 		release_mem_region(uport->mapbase, dec_kn_slot_size);
 }
@@ -691,11 +691,11 @@ static int dz_request_port(struct uart_port *uport)
 	int map_guard;
 	int ret;
 
-	map_guard = atomic_add_return(1, &mux->map_guard);
+	map_guard = atomic_inc_return(&mux->map_guard);
 	if (map_guard == 1) {
 		if (!request_mem_region(uport->mapbase, dec_kn_slot_size,
 					"dz")) {
-			atomic_add(-1, &mux->map_guard);
+			atomic_dec(&mux->map_guard);
 			printk(KERN_ERR
 			       "dz: Unable to reserve MMIO resource\n");
 			return -EBUSY;
@@ -703,7 +703,7 @@ static int dz_request_port(struct uart_port *uport)
 	}
 	ret = dz_map_port(uport);
 	if (ret) {
-		map_guard = atomic_add_return(-1, &mux->map_guard);
+		map_guard = atomic_dec_return(&mux->map_guard);
 		if (!map_guard)
 			release_mem_region(uport->mapbase, dec_kn_slot_size);
 		return ret;
-- 
2.15.2

                 reply	other threads:[~2022-10-13  8:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221013081220.351415-1-xu.panda668@gmail.com \
    --to=xu.panda668@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=xu.panda@zte.com.cn \
    --cc=zealci@zte.com.cn \
    /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

all inboxes | Powered by JetHome®