summaryrefslogtreecommitdiff
path: root/include/linux/seqlock.h
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-05-12 21:22:28 -0700
committerOlof Johansson <olof@lixom.net>2012-05-12 21:22:28 -0700
commit81f96172d609bea39dcbe9fa010978caa81e58f7 (patch)
treec720bac684b1c949f9fc2a820b137e980b86ab93 /include/linux/seqlock.h
parentff658f46d4641ac023b0d807d7e946822c925829 (diff)
parent8823e2b38bd0ee45346ebd3613f47ddb2a3a208a (diff)
Merge branch 'board' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/renesas into next/boards
* 'board' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/renesas: ARM: mach-shmobile: bonito: make sure static function ARM: mach-shmobile: sh7372 CEU supports up to 8188x8188 images ARM: mach-shmobile: mackerel: Add FSI DMAEngine support
Diffstat (limited to 'include/linux/seqlock.h')
-rw-r--r--include/linux/seqlock.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index c6db9fb33c44..600060e25ec6 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -141,7 +141,7 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s)
unsigned ret;
repeat:
- ret = s->sequence;
+ ret = ACCESS_ONCE(s->sequence);
if (unlikely(ret & 1)) {
cpu_relax();
goto repeat;
@@ -166,6 +166,27 @@ static inline unsigned read_seqcount_begin(const seqcount_t *s)
}
/**
+ * raw_seqcount_begin - begin a seq-read critical section
+ * @s: pointer to seqcount_t
+ * Returns: count to be passed to read_seqcount_retry
+ *
+ * raw_seqcount_begin opens a read critical section of the given seqcount.
+ * Validity of the critical section is tested by checking read_seqcount_retry
+ * function.
+ *
+ * Unlike read_seqcount_begin(), this function will not wait for the count
+ * to stabilize. If a writer is active when we begin, we will fail the
+ * read_seqcount_retry() instead of stabilizing at the beginning of the
+ * critical section.
+ */
+static inline unsigned raw_seqcount_begin(const seqcount_t *s)
+{
+ unsigned ret = ACCESS_ONCE(s->sequence);
+ smp_rmb();
+ return ret & ~1;
+}
+
+/**
* __read_seqcount_retry - end a seq-read critical section (without barrier)
* @s: pointer to seqcount_t
* @start: count, from read_seqcount_begin