mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/5] asm-generic: atomic: implement atomic_inc/dec_return stubs
Date: Fri, 21 Apr 2023 12:06:38 +0200	[thread overview]
Message-ID: <20230421100642.2867651-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230421100642.2867651-1-a.fatoum@pengutronix.de>

We don't have forced preemption in barebox, so we can implement these
functions with normal increment/decrement operators.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/asm-generic/atomic.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 6e63b8e8e7b9..45fc5da57594 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -77,16 +77,19 @@ static inline void atomic_sub(int i, volatile atomic_t *v)
 	v->counter -= i;
 }
 
-static inline void atomic_inc(volatile atomic_t *v)
+static inline int atomic_inc_return(volatile atomic_t *v)
 {
-	v->counter += 1;
+	return ++v->counter;
 }
 
-static inline void atomic_dec(volatile atomic_t *v)
+static inline int atomic_dec_return(volatile atomic_t *v)
 {
-	v->counter -= 1;
+	return --v->counter;
 }
 
+#define atomic_inc(v) ((void)atomic_inc_return(v))
+#define atomic_dec(v) ((void)atomic_dec_return(v))
+
 static inline int atomic_dec_and_test(volatile atomic_t *v)
 {
 	int val;
-- 
2.39.2




  reply	other threads:[~2023-04-21 10:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 10:06 [PATCH 0/5] ARM: stm32mp: enable UBS hubs on DKx Ahmad Fatoum
2023-04-21 10:06 ` Ahmad Fatoum [this message]
2023-04-21 10:06 ` [PATCH 2/5] phy: stm32-usphyc: sync with Linux v6.3-rc5 Ahmad Fatoum
2023-04-21 10:06 ` [PATCH 3/5] ARM: stm32mp: defconfig: enable use of DKx USB hubs Ahmad Fatoum
2023-04-21 10:36   ` Marco Felsch
2023-04-21 10:51     ` Ahmad Fatoum
2023-04-21 10:06 ` [PATCH 4/5] clk: bulk: return -EPROBE_DEFER in silence Ahmad Fatoum
2023-04-21 10:06 ` [PATCH 5/5] ARM: stm32mp: dkx: enable deep probe Ahmad Fatoum
2023-05-02 11:36 ` [PATCH 0/5] ARM: stm32mp: enable UBS hubs on DKx Sascha Hauer

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=20230421100642.2867651-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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