drivers: modem: Port to new timeout API
Port the internal modem API to the new timeout API, using the native k_timeout_t. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
9ba20dd48e
commit
94861a438b
|
@ -75,7 +75,6 @@ config MODEM_IFACE_UART
|
|||
config MODEM_CMD_HANDLER
|
||||
bool "Generic modem command handler"
|
||||
select NET_BUF
|
||||
select LEGACY_TIMEOUT_API
|
||||
help
|
||||
This generic command handler uses a modem interface to process
|
||||
incoming data and hand it back to the modem driver via callbacks
|
||||
|
|
|
@ -98,7 +98,8 @@ static bool starts_with(struct net_buf *buf, const char *str)
|
|||
* Cmd Handler Functions
|
||||
*/
|
||||
|
||||
static inline struct net_buf *read_rx_allocator(s32_t timeout, void *user_data)
|
||||
static inline struct net_buf *read_rx_allocator(k_timeout_t timeout,
|
||||
void *user_data)
|
||||
{
|
||||
return net_buf_alloc((struct net_buf_pool *)user_data, timeout);
|
||||
}
|
||||
|
@ -439,8 +440,8 @@ static int _modem_cmd_send(struct modem_iface *iface,
|
|||
struct modem_cmd_handler *handler,
|
||||
struct modem_cmd *handler_cmds,
|
||||
size_t handler_cmds_len,
|
||||
const u8_t *buf, struct k_sem *sem, int timeout,
|
||||
bool no_tx_lock)
|
||||
const u8_t *buf, struct k_sem *sem,
|
||||
k_timeout_t timeout, bool no_tx_lock)
|
||||
{
|
||||
struct modem_cmd_handler_data *data;
|
||||
int ret;
|
||||
|
@ -477,7 +478,7 @@ static int _modem_cmd_send(struct modem_iface *iface,
|
|||
iface->write(iface, buf, strlen(buf));
|
||||
iface->write(iface, data->eol, data->eol_len);
|
||||
|
||||
if (timeout == K_NO_WAIT) {
|
||||
if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) {
|
||||
ret = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
@ -510,7 +511,8 @@ int modem_cmd_send_nolock(struct modem_iface *iface,
|
|||
struct modem_cmd_handler *handler,
|
||||
struct modem_cmd *handler_cmds,
|
||||
size_t handler_cmds_len,
|
||||
const u8_t *buf, struct k_sem *sem, int timeout)
|
||||
const u8_t *buf, struct k_sem *sem,
|
||||
k_timeout_t timeout)
|
||||
{
|
||||
return _modem_cmd_send(iface, handler, handler_cmds, handler_cmds_len,
|
||||
buf, sem, timeout, true);
|
||||
|
@ -519,7 +521,7 @@ int modem_cmd_send_nolock(struct modem_iface *iface,
|
|||
int modem_cmd_send(struct modem_iface *iface,
|
||||
struct modem_cmd_handler *handler,
|
||||
struct modem_cmd *handler_cmds, size_t handler_cmds_len,
|
||||
const u8_t *buf, struct k_sem *sem, int timeout)
|
||||
const u8_t *buf, struct k_sem *sem, k_timeout_t timeout)
|
||||
{
|
||||
return _modem_cmd_send(iface, handler, handler_cmds, handler_cmds_len,
|
||||
buf, sem, timeout, false);
|
||||
|
@ -529,7 +531,7 @@ int modem_cmd_send(struct modem_iface *iface,
|
|||
int modem_cmd_handler_setup_cmds(struct modem_iface *iface,
|
||||
struct modem_cmd_handler *handler,
|
||||
struct setup_cmd *cmds, size_t cmds_len,
|
||||
struct k_sem *sem, int timeout)
|
||||
struct k_sem *sem, k_timeout_t timeout)
|
||||
{
|
||||
int ret = 0, i;
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ struct modem_cmd_handler_data {
|
|||
|
||||
/* allocation info */
|
||||
struct net_buf_pool *buf_pool;
|
||||
s32_t alloc_timeout;
|
||||
k_timeout_t alloc_timeout;
|
||||
|
||||
/* locks */
|
||||
struct k_sem sem_tx_lock;
|
||||
|
@ -145,7 +145,7 @@ int modem_cmd_handler_update_cmds(struct modem_cmd_handler_data *data,
|
|||
* @param *handler: command handler to use
|
||||
* @param *buf: NULL terminated send buffer
|
||||
* @param *sem: wait for response semaphore
|
||||
* @param timeout: timeout of command (in ms)
|
||||
* @param timeout: timeout of command
|
||||
*
|
||||
* @retval 0 if ok, < 0 if error.
|
||||
*/
|
||||
|
@ -153,7 +153,8 @@ int modem_cmd_send_nolock(struct modem_iface *iface,
|
|||
struct modem_cmd_handler *handler,
|
||||
struct modem_cmd *handler_cmds,
|
||||
size_t handler_cmds_len,
|
||||
const u8_t *buf, struct k_sem *sem, int timeout);
|
||||
const u8_t *buf, struct k_sem *sem,
|
||||
k_timeout_t timeout);
|
||||
|
||||
/**
|
||||
* @brief send AT command to interface w/ a TX lock
|
||||
|
@ -162,14 +163,14 @@ int modem_cmd_send_nolock(struct modem_iface *iface,
|
|||
* @param *handler: command handler to use
|
||||
* @param *buf: NULL terminated send buffer
|
||||
* @param *sem: wait for response semaphore
|
||||
* @param timeout: timeout of command (in ms)
|
||||
* @param timeout: timeout of command
|
||||
*
|
||||
* @retval 0 if ok, < 0 if error.
|
||||
*/
|
||||
int modem_cmd_send(struct modem_iface *iface,
|
||||
struct modem_cmd_handler *handler,
|
||||
struct modem_cmd *handler_cmds, size_t handler_cmds_len,
|
||||
const u8_t *buf, struct k_sem *sem, int timeout);
|
||||
const u8_t *buf, struct k_sem *sem, k_timeout_t timeout);
|
||||
|
||||
/**
|
||||
* @brief send a series of AT commands
|
||||
|
@ -179,14 +180,14 @@ int modem_cmd_send(struct modem_iface *iface,
|
|||
* @param *cmds: array of setup commands to send
|
||||
* @param cmds_len: size of the setup command array
|
||||
* @param *sem: wait for response semaphore
|
||||
* @param timeout: timeout of command (in ms)
|
||||
* @param timeout: timeout of command
|
||||
*
|
||||
* @retval 0 if ok, < 0 if error.
|
||||
*/
|
||||
int modem_cmd_handler_setup_cmds(struct modem_iface *iface,
|
||||
struct modem_cmd_handler *handler,
|
||||
struct setup_cmd *cmds, size_t cmds_len,
|
||||
struct k_sem *sem, int timeout);
|
||||
struct k_sem *sem, k_timeout_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Init command handler
|
||||
|
|
Loading…
Reference in a new issue