[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230118154450.73842-6-andrzej.hajda@intel.com>
Date: Wed, 18 Jan 2023 16:44:49 +0100
From: Andrzej Hajda <andrzej.hajda@...el.com>
To: linux-alpha@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-snps-arc@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org,
linux-hexagon@...r.kernel.org, linux-ia64@...r.kernel.org,
loongarch@...ts.linux.dev, linux-m68k@...ts.linux-m68k.org,
linux-mips@...r.kernel.org, openrisc@...ts.librecores.org,
linux-parisc@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-riscv@...ts.infradead.org, linux-s390@...r.kernel.org,
linux-sh@...r.kernel.org, sparclinux@...r.kernel.org,
linux-xtensa@...ux-xtensa.org, intel-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@...el.com>,
Arnd Bergmann <arnd@...db.de>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>,
Mark Rutland <mark.rutland@....com>
Subject: [PATCH v5 6/7] qed: use __xchg if possible
Recently introduced helper simplifies the code.
Signed-off-by: Andrzej Hajda <andrzej.hajda@...el.com>
---
include/linux/qed/qed_chain.h | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
index a84063492c71ae..6355d558cf01b2 100644
--- a/include/linux/qed/qed_chain.h
+++ b/include/linux/qed/qed_chain.h
@@ -11,6 +11,7 @@
#include <asm/byteorder.h>
#include <linux/kernel.h>
#include <linux/list.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/qed/common_hsi.h>
@@ -368,7 +369,7 @@ static inline void qed_chain_return_produced(struct qed_chain *p_chain)
*/
static inline void *qed_chain_produce(struct qed_chain *p_chain)
{
- void *p_ret = NULL, *p_prod_idx, *p_prod_page_idx;
+ void *p_prod_idx, *p_prod_page_idx;
if (is_chain_u16(p_chain)) {
if ((p_chain->u.chain16.prod_idx &
@@ -390,11 +391,8 @@ static inline void *qed_chain_produce(struct qed_chain *p_chain)
p_chain->u.chain32.prod_idx++;
}
- p_ret = p_chain->p_prod_elem;
- p_chain->p_prod_elem = (void *)(((u8 *)p_chain->p_prod_elem) +
- p_chain->elem_size);
-
- return p_ret;
+ return __xchg(&p_chain->p_prod_elem,
+ (u8 *)p_chain->p_prod_elem + p_chain->elem_size);
}
/**
@@ -439,7 +437,7 @@ static inline void qed_chain_recycle_consumed(struct qed_chain *p_chain)
*/
static inline void *qed_chain_consume(struct qed_chain *p_chain)
{
- void *p_ret = NULL, *p_cons_idx, *p_cons_page_idx;
+ void *p_cons_idx, *p_cons_page_idx;
if (is_chain_u16(p_chain)) {
if ((p_chain->u.chain16.cons_idx &
@@ -461,11 +459,8 @@ static inline void *qed_chain_consume(struct qed_chain *p_chain)
p_chain->u.chain32.cons_idx++;
}
- p_ret = p_chain->p_cons_elem;
- p_chain->p_cons_elem = (void *)(((u8 *)p_chain->p_cons_elem) +
- p_chain->elem_size);
-
- return p_ret;
+ return __xchg(&p_chain->p_cons_elem,
+ (u8 *)p_chain->p_cons_elem + p_chain->elem_size);
}
/**
--
2.34.1
Powered by blists - more mailing lists