From df8e89f06696a35da98a4ae0e4c14e3ba6cbcb16 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 14 May 2017 21:46:08 +0200 Subject: sercomm: Rename sercomm_lock() to sercomm_drv_lock() The user of the code is supposed to provide a "driver" implementing those calls according to the specific target architecture/hardware. This only applies to non-host (i.e. embedded) builds Change-Id: I9a6848f23b70fc32f4de10149d857374f76f000d --- src/sercomm.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/sercomm.c') diff --git a/src/sercomm.c b/src/sercomm.c index d33db911..ff6a5a36 100644 --- a/src/sercomm.c +++ b/src/sercomm.c @@ -25,31 +25,28 @@ #include #include +#include #include +#include #ifdef HOST_BUILD # define DEFAULT_RX_MSG_SIZE 2048 -# ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -# endif - -static inline void sercomm_lock(unsigned long __attribute__((unused)) *flags) {} -static inline void sercomm_unlock(unsigned long __attribute__((unused)) *flags) {} +static inline void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags) {} +static inline void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags) {} #else # define DEFAULT_RX_MSG_SIZE 256 # include -# include # include -static inline void sercomm_lock(unsigned long *flags) +static inline void sercomm_drv_lock(unsigned long *flags) { local_firq_save(*flags); } -static inline void sercomm_unlock(unsigned long *flags) +static inline void sercomm_drv_unlock(unsigned long *flags) { local_irq_restore(*flags); } @@ -106,9 +103,9 @@ void osmo_sercomm_sendmsg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struc /* This functiion can be called from any context: FIQ, IRQ * and supervisor context. Proper locking is important! */ - sercomm_lock(&flags); + sercomm_drv_lock(&flags); msgb_enqueue(&sercomm->tx.dlci_queues[dlci], msg); - sercomm_unlock(&flags); + sercomm_drv_unlock(&flags); #ifndef HOST_BUILD /* tell UART that we have something to send */ @@ -150,14 +147,14 @@ void osmo_sercomm_change_speed(struct osmo_sercomm_inst *sercomm, enum uart_baud while (1) { /* no messages in the queue, grab the lock to ensure it * stays that way */ - sercomm_lock(&flags); + sercomm_drv_lock(&flags); if (!sercomm->tx.msg && !sercomm->tx.next_char) { /* change speed */ uart_baudrate(sercomm->uart_id, bdrt); - sercomm_unlock(&flags); + sercomm_drv_unlock(&flags); break; } - sercomm_unlock(&flags); + sercomm_drv_unlock(&flags); } } #endif @@ -173,7 +170,7 @@ int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch) /* we may be called from interrupt context, but we stiff need to lock * because sercomm could be accessed from a FIQ context ... */ - sercomm_lock(&flags); + sercomm_drv_lock(&flags); if (!sercomm->tx.msg) { unsigned int i; @@ -187,11 +184,11 @@ int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch) /* start of a new message, send start flag octet */ *ch = HDLC_FLAG; sercomm->tx.next_char = sercomm->tx.msg->data; - sercomm_unlock(&flags); + sercomm_drv_unlock(&flags); return 1; } else { /* no more data avilable */ - sercomm_unlock(&flags); + sercomm_drv_unlock(&flags); return 0; } } @@ -223,7 +220,7 @@ int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch) *ch = *sercomm->tx.next_char++; } - sercomm_unlock(&flags); + sercomm_drv_unlock(&flags); return 1; } -- cgit v1.2.3