drivers: modem: cmd_handler: split cmd_handler_process() implementation
cmd_handler_process() does two major things: - reads data from modem interface and fills data->rx_buf, - processes data in data->rx_buf. Split implementation accordingly to two separate functions, which improves readability (less automatic variables to follow at once) and simplifies refactoring of each action. No functional change was intended in this commit. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
parent
783155ad99
commit
3d659a35bb
1 changed files with 28 additions and 14 deletions
|
@ -256,22 +256,11 @@ static struct modem_cmd *find_cmd_direct_match(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_handler_process(struct modem_cmd_handler *cmd_handler,
|
static void cmd_handler_process_iface_data(struct modem_cmd_handler_data *data,
|
||||||
struct modem_iface *iface)
|
struct modem_iface *iface)
|
||||||
{
|
{
|
||||||
struct modem_cmd_handler_data *data;
|
size_t rx_len, bytes_read = 0;
|
||||||
struct modem_cmd *cmd;
|
|
||||||
struct net_buf *frag = NULL;
|
|
||||||
size_t match_len, rx_len, bytes_read = 0;
|
|
||||||
int ret;
|
int ret;
|
||||||
uint16_t offset, len;
|
|
||||||
|
|
||||||
if (!cmd_handler || !cmd_handler->cmd_handler_data ||
|
|
||||||
!iface || !iface->read) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = (struct modem_cmd_handler_data *)(cmd_handler->cmd_handler_data);
|
|
||||||
|
|
||||||
/* read all of the data from modem iface */
|
/* read all of the data from modem iface */
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -303,6 +292,15 @@ static void cmd_handler_process(struct modem_cmd_handler *cmd_handler,
|
||||||
rx_len, bytes_read);
|
rx_len, bytes_read);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_handler_process_rx_buf(struct modem_cmd_handler_data *data)
|
||||||
|
{
|
||||||
|
struct modem_cmd *cmd;
|
||||||
|
struct net_buf *frag = NULL;
|
||||||
|
size_t match_len;
|
||||||
|
int ret;
|
||||||
|
uint16_t offset, len;
|
||||||
|
|
||||||
/* process all of the data in the net_buf */
|
/* process all of the data in the net_buf */
|
||||||
while (data->rx_buf) {
|
while (data->rx_buf) {
|
||||||
|
@ -400,6 +398,22 @@ static void cmd_handler_process(struct modem_cmd_handler *cmd_handler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cmd_handler_process(struct modem_cmd_handler *cmd_handler,
|
||||||
|
struct modem_iface *iface)
|
||||||
|
{
|
||||||
|
struct modem_cmd_handler_data *data;
|
||||||
|
|
||||||
|
if (!cmd_handler || !cmd_handler->cmd_handler_data ||
|
||||||
|
!iface || !iface->read) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (struct modem_cmd_handler_data *)(cmd_handler->cmd_handler_data);
|
||||||
|
|
||||||
|
cmd_handler_process_iface_data(data, iface);
|
||||||
|
cmd_handler_process_rx_buf(data);
|
||||||
|
}
|
||||||
|
|
||||||
int modem_cmd_handler_get_error(struct modem_cmd_handler_data *data)
|
int modem_cmd_handler_get_error(struct modem_cmd_handler_data *data)
|
||||||
{
|
{
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue