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: Doug Ledford <[email protected]>
Cc: Sean Hefty <[email protected]>
Cc: Hal Rosenstock <[email protected]>
Signed-off-by: Davidlohr Bueso <[email protected]>
---
 drivers/infiniband/hw/cxgb4/device.c | 3 +--
 drivers/infiniband/hw/hfi1/verbs.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index ae2e8b23d2dd..a32959fa2c82 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -111,8 +111,7 @@ void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe)
        if (!wq->rdev->wr_log)
                return;
 
-       idx = (atomic_inc_return(&wq->rdev->wr_log_idx) - 1) &
-               (wq->rdev->wr_log_size - 1);
+       idx = atomic_fetch_inc(&wq->rdev->wr_log_idx) & (wq->rdev->wr_log_size 
- 1);
        le.poll_sge_ts = cxgb4_read_sge_timestamp(wq->rdev->lldi.ports[0]);
        getnstimeofday(&le.poll_host_ts);
        le.valid = 1;
diff --git a/drivers/infiniband/hw/hfi1/verbs.c 
b/drivers/infiniband/hw/hfi1/verbs.c
index 849c4b9399d4..9ba311b53085 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -261,8 +261,7 @@ static void wss_advance_clean_counter(void)
                 * wss.clean_entry.  The table size, wss.num_entries,
                 * is always a power-of-2.
                 */
-               entry = (atomic_inc_return(&wss.clean_entry) - 1)
-                       & (wss.num_entries - 1);
+               entry = atomic_fetch_inc(&wss.clean_entry) & (wss.num_entries - 
1);
 
                /* clear the entry and count the bits */
                bits = xchg(&wss.entries[entry], 0);
-- 
2.6.6

Reply via email to