[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8e491117-241f-4000-2909-9d4db00ab6a9@kernel.org>
Date: Thu, 13 Oct 2022 08:24:00 +0200
From: Jiri Slaby <jirislaby@...nel.org>
To: xu.panda668@...il.com, macro@...am.me.uk
Cc: linux-kernel@...r.kernel.org, Xu Panda <xu.panda@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH linux-next] serial: dz: use atomic_inc and atomic_dec
instead of atomic_add
On 12. 10. 22, 12:09, xu.panda668@...il.com wrote:
> From: Xu Panda <xu.panda@....com.cn>
>
> There is a better way for atomic_dec_return and atomic_inc.
While the patch below looks fine, I don't understand this sentence ^^^.
Care to reformulate? And please append () when writing about function names.
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: Xu Panda <xu.panda@....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;
--
js
suse labs
Powered by blists - more mailing lists