refactor(lib/granule): Move granule_set_state() to granule.c
We're about to complicate this function, so move it out of the header.
Change-Id: I16cfdfc5c955f52ae74f6132de67bfd3a13f7a2b
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
diff --git a/lib/granule/include/granule.h b/lib/granule/include/granule.h
index 932a11c..2460c5e 100644
--- a/lib/granule/include/granule.h
+++ b/lib/granule/include/granule.h
@@ -141,26 +141,6 @@
return STATE(g);
}
-/* Must be called with granule lock held */
-static inline void granule_set_state(struct granule *g, unsigned char state)
-{
- unsigned short val;
-
- assert((g != NULL) && LOCKED(g));
-
- /* NOLINTNEXTLINE(clang-analyzer-core.NullDereference) */
- val = g->descriptor & STATE_MASK;
-
- /* cppcheck-suppress misra-c2012-10.3 */
- val ^= (unsigned short)state << GRN_STATE_SHIFT;
-
- /*
- * Atomically EOR val while keeping the bits for refcount and
- * bitlock as 0 which would preserve their values in memory.
- */
- (void)atomic_eor_16(&g->descriptor, val);
-}
-
/*
* Acquire the bitlock and then check expected state
* Fails if unexpected locking sequence detected.
@@ -198,6 +178,8 @@
granule_bitlock_release(g);
}
+void granule_set_state(struct granule *g, unsigned char state);
+
/* Transtion state to @new_state and unlock the granule */
static inline void granule_unlock_transition(struct granule *g,
unsigned char new_state)
diff --git a/lib/granule/src/granule.c b/lib/granule/src/granule.c
index 6382123..3d8922f 100644
--- a/lib/granule/src/granule.c
+++ b/lib/granule/src/granule.c
@@ -264,3 +264,22 @@
dsb(ish);
}
+/* Must be called with granule lock held */
+void granule_set_state(struct granule *g, unsigned char state)
+{
+ unsigned short val;
+
+ assert((g != NULL) && LOCKED(g));
+
+ /* NOLINTNEXTLINE(clang-analyzer-core.NullDereference) */
+ val = g->descriptor & STATE_MASK;
+
+ /* cppcheck-suppress misra-c2012-10.3 */
+ val ^= (unsigned short)state << GRN_STATE_SHIFT;
+
+ /*
+ * Atomically EOR val while keeping the bits for refcount and
+ * bitlock as 0 which would preserve their values in memory.
+ */
+ (void)atomic_eor_16(&g->descriptor, val);
+}