aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-10-31 15:55:57 +0000
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-11-01 14:15:39 +0000
commitf8b30ca89b3e3a09d96019bf3998255a3f7a4c8a (patch)
tree33abf9143ea20e1fc38f0e968b5664e3cfdfe1fb /include
parentb8a02d53c0b279359a2924fcd37f9d4dc3c46472 (diff)
downloadplatform_external_arm-trusted-firmware-f8b30ca89b3e3a09d96019bf3998255a3f7a4c8a.tar.gz
platform_external_arm-trusted-firmware-f8b30ca89b3e3a09d96019bf3998255a3f7a4c8a.tar.bz2
platform_external_arm-trusted-firmware-f8b30ca89b3e3a09d96019bf3998255a3f7a4c8a.zip
bakery: Fix MISRA defects
Change-Id: I600bc13522ae977db355b6dc5a1695bce39ec130 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/lib/bakery_lock.h40
-rw-r--r--include/lib/spinlock.h6
2 files changed, 32 insertions, 14 deletions
diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h
index c80082e9b..2d1612e17 100644
--- a/include/lib/bakery_lock.h
+++ b/include/lib/bakery_lock.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __BAKERY_LOCK_H__
-#define __BAKERY_LOCK_H__
+#ifndef BAKERY_LOCK_H
+#define BAKERY_LOCK_H
#include <platform_def.h>
@@ -13,21 +13,39 @@
#ifndef __ASSEMBLY__
#include <cdefs.h>
+#include <stdbool.h>
#include <stdint.h>
+#include <utils_def.h>
/*****************************************************************************
- * Internal helper macros used by the bakery lock implementation.
+ * Internal helpers used by the bakery lock implementation.
****************************************************************************/
+
/* Convert a ticket to priority */
-#define PRIORITY(t, pos) (((t) << 8) | (pos))
+static inline unsigned int bakery_get_priority(unsigned int t, unsigned int pos)
+{
+ return (t << 8) | pos;
+}
+
+#define CHOOSING_TICKET U(0x1)
+#define CHOSEN_TICKET U(0x0)
+
+static inline bool bakery_is_choosing(unsigned int info)
+{
+ return (info & 1U) == CHOOSING_TICKET;
+}
+
+static inline unsigned int bakery_ticket_number(unsigned int info)
+{
+ return (info >> 1) & 0x7FFFU;
+}
-#define CHOOSING_TICKET 0x1
-#define CHOSEN_TICKET 0x0
+static inline uint16_t make_bakery_data(unsigned int choosing, unsigned int num)
+{
+ unsigned int val = (choosing & 0x1U) | (num << 1);
-#define bakery_is_choosing(info) (info & 0x1)
-#define bakery_ticket_number(info) ((info >> 1) & 0x7FFF)
-#define make_bakery_data(choosing, number) \
- (((choosing & 0x1) | (number << 1)) & 0xFFFF)
+ return (uint16_t) val;
+}
/*****************************************************************************
* External bakery lock interface.
@@ -83,4 +101,4 @@ void bakery_lock_release(bakery_lock_t *bakery);
#endif /* __ASSEMBLY__ */
-#endif /* __BAKERY_LOCK_H__ */
+#endif /* BAKERY_LOCK_H */
diff --git a/include/lib/spinlock.h b/include/lib/spinlock.h
index 8aec70789..fcd36e856 100644
--- a/include/lib/spinlock.h
+++ b/include/lib/spinlock.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __SPINLOCK_H__
-#define __SPINLOCK_H__
+#ifndef SPINLOCK_H
+#define SPINLOCK_H
#ifndef __ASSEMBLY__
@@ -26,4 +26,4 @@ void spin_unlock(spinlock_t *lock);
#endif
-#endif /* __SPINLOCK_H__ */
+#endif /* SPINLOCK_H */