[PATCH 05/12] tty/serial: Employ atomic_fetch_inc()

From: Davidlohr Bueso
Date: Mon Jun 20 2016 - 16:08:26 EST


Now that we have fetch_inc() we can stop using inc_return() - 1.

These are very similar to the existing OP-RETURN primitives we already
have, except they return the value of the atomic variable _before_
modification.

Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Pat Gefre <pfg@xxxxxxx>
Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
---
drivers/tty/serial/ioc4_serial.c | 2 +-
drivers/tty/serial/msm_serial.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index e5c42fef69d2..5982ae159d56 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
|| (type == IOC4_OTHER_INTR_TYPE)));

- i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
+ i = atomic_fetch_inc(&soft-> is_intr_type[type].is_num_intrs);
BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));

/* Save off the lower level interrupt handler */
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index b7d80bd57db9..a6ae591e90d3 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -1585,7 +1585,7 @@ static int msm_serial_probe(struct platform_device *pdev)
line = pdev->id;

if (line < 0)
- line = atomic_inc_return(&msm_uart_next_id) - 1;
+ line = atomic_fetch_inc(&msm_uart_next_id);

if (unlikely(line < 0 || line >= UART_NR))
return -ENXIO;
--
2.6.6