public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/5 v2] mips: Add arch/mips/include/asm/atomic.h
Date: Fri, 10 Aug 2018 09:48:16 +0200	[thread overview]
Message-ID: <20180810074819.24962-2-sr@denx.de> (raw)
In-Reply-To: <20180810074819.24962-1-sr@denx.de>

This is needed for the UBIFS support. The file is a copy of
arch/xtensa/include/asm/atomic.h

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
---
v2:
- No change

 arch/mips/include/asm/atomic.h | 54 ++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 arch/mips/include/asm/atomic.h

diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
new file mode 100644
index 0000000000..7551bf6e6c
--- /dev/null
+++ b/arch/mips/include/asm/atomic.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2016 Cadence Design Systems Inc.
+ */
+
+#ifndef _MIPS_ATOMIC_H
+#define _MIPS_ATOMIC_H
+
+#include <asm/system.h>
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#define atomic_read(v)		((v)->counter)
+#define atomic_set(v, i)	((v)->counter = (i))
+
+static inline void atomic_add(int i, atomic_t *v)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	v->counter += i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, atomic_t *v)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	v->counter -= i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_inc(atomic_t *v)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	++v->counter;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_dec(atomic_t *v)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	--v->counter;
+	local_irq_restore(flags);
+}
+
+#endif
-- 
2.18.0

  reply	other threads:[~2018-08-10  7:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-10  7:48 [U-Boot] [PATCH 1/5 v2] mips: Add basic MediaTek MT7620/88 support Stefan Roese
2018-08-10  7:48 ` Stefan Roese [this message]
2018-08-10  7:48 ` [U-Boot] [PATCH 3/5 v2] mips: Add LinkIt Smart 7688 support Stefan Roese
2018-08-15 14:30   ` Daniel Schwierzeck
2018-08-15 14:35     ` Stefan Roese
2018-08-15 22:34   ` Daniel Schwierzeck
2018-08-10  7:48 ` [U-Boot] [PATCH 4/5 v2] mips: Add Gardena Smart-Gateway board support Stefan Roese
2018-08-15 14:36   ` Daniel Schwierzeck
2018-08-15 14:39     ` Stefan Roese
2018-08-10  7:48 ` [U-Boot] [PATCH 5/5 v2] mips: mt76xx: Add sysreset support Stefan Roese
2018-08-15 23:09 ` [U-Boot] [PATCH 1/5 v2] mips: Add basic MediaTek MT7620/88 support Daniel Schwierzeck

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=20180810074819.24962-2-sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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