sercomm: introduce osmo_ naming prefix in struct and function names

Change-Id: If4e22f182a47b72b1fe43146716a4fbccceb62e6
This commit is contained in:
Harald Welte 2017-04-30 23:57:55 +02:00
parent cc95f4b06d
commit 1358836282
2 changed files with 28 additions and 28 deletions

View File

@ -21,10 +21,10 @@ enum sercomm_dlci {
_SC_DLCI_MAX _SC_DLCI_MAX
}; };
struct sercomm_inst; struct osmo_sercomm_inst;
typedef void (*dlci_cb_t)(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg); typedef void (*dlci_cb_t)(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg);
struct sercomm_inst { struct osmo_sercomm_inst {
int initialized; int initialized;
int uart_id; int uart_id;
@ -50,35 +50,35 @@ struct sercomm_inst {
#ifndef HOST_BUILD #ifndef HOST_BUILD
#include <uart.h> #include <uart.h>
/* helper functions for target */ /* helper functions for target */
void sercomm_bind_uart(struct sercomm_inst *sercomm, int uart); void osmo_sercomm_bind_uart(struct osmo_sercomm_inst *sercomm, int uart);
int sercomm_get_uart(struct sercomm_inst *sercomm); int osmo_sercomm_get_uart(struct osmo_sercomm_inst *sercomm);
void sercomm_change_speed(struct sercomm_inst *sercomm, enum uart_baudrate bdrt); void osmo_sercomm_change_speed(struct osmo_sercomm_inst *sercomm, enum uart_baudrate bdrt);
#endif #endif
void sercomm_init(struct sercomm_inst *sercomm); void osmo_sercomm_init(struct osmo_sercomm_inst *sercomm);
int sercomm_initialized(struct sercomm_inst *sercomm); int osmo_sercomm_initialized(struct osmo_sercomm_inst *sercomm);
/* User Interface: Tx */ /* User Interface: Tx */
/* user interface for transmitting messages for a given DLCI */ /* user interface for transmitting messages for a given DLCI */
void sercomm_sendmsg(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg); void osmo_sercomm_sendmsg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg);
/* how deep is the Tx queue for a given DLCI */ /* how deep is the Tx queue for a given DLCI */
unsigned int sercomm_tx_queue_depth(struct sercomm_inst *sercomm, uint8_t dlci); unsigned int osmo_sercomm_tx_queue_depth(struct osmo_sercomm_inst *sercomm, uint8_t dlci);
/* User Interface: Rx */ /* User Interface: Rx */
/* receiving messages for a given DLCI */ /* receiving messages for a given DLCI */
int sercomm_register_rx_cb(struct sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb); int osmo_sercomm_register_rx_cb(struct osmo_sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb);
/* Driver Interface */ /* Driver Interface */
/* fetch one octet of to-be-transmitted serial data. returns 0 if no more data */ /* fetch one octet of to-be-transmitted serial data. returns 0 if no more data */
int sercomm_drv_pull(struct sercomm_inst *sercomm, uint8_t *ch); int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch);
/* the driver has received one byte, pass it into sercomm layer. /* the driver has received one byte, pass it into sercomm layer.
returns 1 in case of success, 0 in case of unrecognized char */ returns 1 in case of success, 0 in case of unrecognized char */
int sercomm_drv_rx_char(struct sercomm_inst *sercomm, uint8_t ch); int osmo_sercomm_drv_rx_char(struct osmo_sercomm_inst *sercomm, uint8_t ch);
static inline struct msgb *sercomm_alloc_msgb(unsigned int len) static inline struct msgb *osmo_sercomm_alloc_msgb(unsigned int len)
{ {
return msgb_alloc_headroom(len+4, 4, "sercomm_tx"); return msgb_alloc_headroom(len+4, 4, "sercomm_tx");
} }

View File

@ -69,18 +69,18 @@ enum rx_state {
#ifndef HOST_BUILD #ifndef HOST_BUILD
void sercomm_bind_uart(struct sercomm_inst *sercomm, int uart) void osmo_sercomm_bind_uart(struct osmo_sercomm_inst *sercomm, int uart)
{ {
sercomm->uart_id = uart; sercomm->uart_id = uart;
} }
int sercomm_get_uart(struct sercomm_inst *sercomm) int osmo_sercomm_get_uart(struct osmo_sercomm_inst *sercomm)
{ {
return sercomm->uart_id; return sercomm->uart_id;
} }
#endif #endif
void sercomm_init(struct sercomm_inst *sercomm) void osmo_sercomm_init(struct osmo_sercomm_inst *sercomm)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(sercomm->tx.dlci_queues); i++) for (i = 0; i < ARRAY_SIZE(sercomm->tx.dlci_queues); i++)
@ -90,16 +90,16 @@ void sercomm_init(struct sercomm_inst *sercomm)
sercomm->initialized = 1; sercomm->initialized = 1;
/* set up the echo dlci */ /* set up the echo dlci */
sercomm_register_rx_cb(sercomm, SC_DLCI_ECHO, &sercomm_sendmsg); osmo_sercomm_register_rx_cb(sercomm, SC_DLCI_ECHO, &osmo_sercomm_sendmsg);
} }
int sercomm_initialized(struct sercomm_inst *sercomm) int osmo_sercomm_initialized(struct osmo_sercomm_inst *sercomm)
{ {
return sercomm->initialized; return sercomm->initialized;
} }
/* user interface for transmitting messages for a given DLCI */ /* user interface for transmitting messages for a given DLCI */
void sercomm_sendmsg(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg) void osmo_sercomm_sendmsg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
{ {
unsigned long flags; unsigned long flags;
uint8_t *hdr; uint8_t *hdr;
@ -122,7 +122,7 @@ void sercomm_sendmsg(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *ms
} }
/* how deep is the Tx queue for a given DLCI */ /* how deep is the Tx queue for a given DLCI */
unsigned int sercomm_tx_queue_depth(struct sercomm_inst *sercomm, uint8_t dlci) unsigned int osmo_sercomm_tx_queue_depth(struct osmo_sercomm_inst *sercomm, uint8_t dlci)
{ {
struct llist_head *le; struct llist_head *le;
unsigned int num = 0; unsigned int num = 0;
@ -137,7 +137,7 @@ unsigned int sercomm_tx_queue_depth(struct sercomm_inst *sercomm, uint8_t dlci)
#ifndef HOST_BUILD #ifndef HOST_BUILD
/* wait until everything has been transmitted, then grab the lock and /* wait until everything has been transmitted, then grab the lock and
* change the baud rate as requested */ * change the baud rate as requested */
void sercomm_change_speed(struct sercomm_inst *sercomm, enum uart_baudrate bdrt) void osmo_sercomm_change_speed(struct osmo_sercomm_inst *sercomm, enum uart_baudrate bdrt)
{ {
unsigned int i, count; unsigned int i, count;
unsigned long flags; unsigned long flags;
@ -168,7 +168,7 @@ void sercomm_change_speed(struct sercomm_inst *sercomm, enum uart_baudrate bdrt)
#endif #endif
/* fetch one octet of to-be-transmitted serial data */ /* fetch one octet of to-be-transmitted serial data */
int sercomm_drv_pull(struct sercomm_inst *sercomm, uint8_t *ch) int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch)
{ {
unsigned long flags; unsigned long flags;
@ -230,7 +230,7 @@ int sercomm_drv_pull(struct sercomm_inst *sercomm, uint8_t *ch)
} }
/* register a handler for a given DLCI */ /* register a handler for a given DLCI */
int sercomm_register_rx_cb(struct sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb) int osmo_sercomm_register_rx_cb(struct osmo_sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb)
{ {
if (dlci >= ARRAY_SIZE(sercomm->rx.dlci_handler)) if (dlci >= ARRAY_SIZE(sercomm->rx.dlci_handler))
return -EINVAL; return -EINVAL;
@ -243,7 +243,7 @@ int sercomm_register_rx_cb(struct sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t
} }
/* dispatch an incoming message once it is completely received */ /* dispatch an incoming message once it is completely received */
static void dispatch_rx_msg(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg) static void dispatch_rx_msg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
{ {
if (dlci >= ARRAY_SIZE(sercomm->rx.dlci_handler) || if (dlci >= ARRAY_SIZE(sercomm->rx.dlci_handler) ||
!sercomm->rx.dlci_handler[dlci]) { !sercomm->rx.dlci_handler[dlci]) {
@ -254,7 +254,7 @@ static void dispatch_rx_msg(struct sercomm_inst *sercomm, uint8_t dlci, struct m
} }
/* the driver has received one byte, pass it into sercomm layer */ /* the driver has received one byte, pass it into sercomm layer */
int sercomm_drv_rx_char(struct sercomm_inst *sercomm, uint8_t ch) int osmo_sercomm_drv_rx_char(struct osmo_sercomm_inst *sercomm, uint8_t ch)
{ {
uint8_t *ptr; uint8_t *ptr;
@ -262,12 +262,12 @@ int sercomm_drv_rx_char(struct sercomm_inst *sercomm, uint8_t ch)
* which means that any data structures we use need to be for * which means that any data structures we use need to be for
* our exclusive access */ * our exclusive access */
if (!sercomm->rx.msg) if (!sercomm->rx.msg)
sercomm->rx.msg = sercomm_alloc_msgb(SERCOMM_RX_MSG_SIZE); sercomm->rx.msg = osmo_sercomm_alloc_msgb(SERCOMM_RX_MSG_SIZE);
if (msgb_tailroom(sercomm->rx.msg) == 0) { if (msgb_tailroom(sercomm->rx.msg) == 0) {
//cons_puts("sercomm_drv_rx_char() overflow!\n"); //cons_puts("sercomm_drv_rx_char() overflow!\n");
msgb_free(sercomm->rx.msg); msgb_free(sercomm->rx.msg);
sercomm->rx.msg = sercomm_alloc_msgb(SERCOMM_RX_MSG_SIZE); sercomm->rx.msg = osmo_sercomm_alloc_msgb(SERCOMM_RX_MSG_SIZE);
sercomm->rx.state = RX_ST_WAIT_START; sercomm->rx.state = RX_ST_WAIT_START;
return 0; return 0;
} }