All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/6 v3] mips: Add arch/mips/include/asm/atomic.h
Date: Thu, 16 Aug 2018 15:27:29 +0200	[thread overview]
Message-ID: <20180816132733.19408-2-sr@denx.de> (raw)
In-Reply-To: <20180816132733.19408-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>
---
v3:
- No change

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-16 13:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16 13:27 [U-Boot] [PATCH 1/6 v3] mips: Add basic MediaTek MT7620/88 support Stefan Roese
2018-08-16 13:27 ` Stefan Roese [this message]
2018-08-16 13:27 ` [U-Boot] [PATCH 3/6 v3] mips: Add LinkIt Smart 7688 support Stefan Roese
2018-08-16 13:27 ` [U-Boot] [PATCH 4/6 v3] mips: Add Gardena Smart-Gateway board support Stefan Roese
2018-08-16 13:27 ` [U-Boot] [PATCH 5/6 v3] mips: mt76xx: Add sysreset support Stefan Roese
2018-08-16 13:27 ` [U-Boot] [PATCH 6/6 v3] mips: mt7628a.dtsi: Add SPI clock-frequency property Stefan Roese
2018-09-05 11:45 ` [U-Boot] [PATCH 1/6 v3] mips: Add basic MediaTek MT7620/88 support Daniel Schwierzeck
2018-09-05 13:05   ` Stefan

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=20180816132733.19408-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.