diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2011-06-25 22:38:20 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2011-06-25 22:38:20 +0200 |
commit | 301eb4753a189b058cbb7221e52e0ec6bf0856a7 (patch) | |
tree | 7b4089dbe297f1d038ed87f6893183deaaa8c569 /src/target/firmware/comm | |
parent | 5907bfd39ac3fe7e7b7e94e03d8d43ee99852e86 (diff) |
fw/sercomm: Fix up the locking using an 'abstraction' layer
Not _that_ abstract but a long is enough to store a ptr if need
be :p
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/target/firmware/comm')
-rw-r--r-- | src/target/firmware/comm/sercomm.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/target/firmware/comm/sercomm.c b/src/target/firmware/comm/sercomm.c index f9d5bfa9..8fa03475 100644 --- a/src/target/firmware/comm/sercomm.c +++ b/src/target/firmware/comm/sercomm.c @@ -27,23 +27,36 @@ #include <osmocom/core/msgb.h> #ifdef HOST_BUILD -#define SERCOMM_RX_MSG_SIZE 2048 -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#endif -#include <sercomm.h> -#define local_irq_save(x) (void) x -#define local_fiq_disable() -#define local_irq_restore(x) (void) x + +# define SERCOMM_RX_MSG_SIZE 2048 +# ifndef ARRAY_SIZE +# define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +# endif +# include <sercomm.h> + +static inline void sercomm_lock(unsigned long __attribute__((unused)) *flags) {} +static inline void sercomm_unlock(unsigned long __attribute__((unused)) *flags) {} #else -#define SERCOMM_RX_MSG_SIZE 256 -#include <debug.h> -#include <osmocom/core/linuxlist.h> -#include <asm/system.h> -#include <comm/sercomm.h> -#include <uart.h> +# define SERCOMM_RX_MSG_SIZE 256 +# include <debug.h> +# include <osmocom/core/linuxlist.h> +# include <asm/system.h> + +static inline void sercomm_lock(unsigned long *flags) +{ + local_firq_save(*flags); +} + +static inline void sercomm_unlock(unsigned long *flags) +{ + local_irq_restore(*flags); +} + +# include <comm/sercomm.h> +# include <uart.h> + #endif @@ -108,10 +121,9 @@ void sercomm_sendmsg(uint8_t dlci, struct msgb *msg) /* This functiion can be called from any context: FIQ, IRQ * and supervisor context. Proper locking is important! */ - local_irq_save(flags); - local_fiq_disable(); + sercomm_lock(&flags); msgb_enqueue(&sercomm.tx.dlci_queues[dlci], msg); - local_irq_restore(flags); + sercomm_unlock(&flags); #ifndef HOST_BUILD /* tell UART that we have something to send */ |