diff options
author | Daniel Starke <daniel.starke@siemens.com> | 2022-08-31 09:37:58 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-09-22 16:04:46 +0200 |
commit | de640bc6b8b1401792aa0ac99b6512411f18a87d (patch) | |
tree | 4e57a4a379791515b4ed4149d7af8f0618e234fd /drivers/tty/n_gsm.c | |
parent | 669609cea1d294f43efdd8d57ab65927df90e6df (diff) | |
download | linux-de640bc6b8b1401792aa0ac99b6512411f18a87d.tar.bz2 |
tty: n_gsm: introduce gsm_control_command() function
Move the content of gsm_control_transmit() to a new function
gsm_control_command() with a more generic signature and analog to
gsm_control_reply(). Use this within gsm_control_transmit().
This is needed to simplify upcoming functional additions.
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
Link: https://lore.kernel.org/r/20220831073800.7459-4-daniel.starke@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_gsm.c')
-rw-r--r-- | drivers/tty/n_gsm.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index c5445d397261..feff205fe131 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1314,6 +1314,31 @@ static void gsm_dlci_data_kick(struct gsm_dlci *dlci) /** + * gsm_control_command - send a command frame to a control + * @gsm: gsm channel + * @cmd: the command to use + * @data: data to follow encoded info + * @dlen: length of data + * + * Encode up and queue a UI/UIH frame containing our command. + */ +static int gsm_control_command(struct gsm_mux *gsm, int cmd, const u8 *data, + int dlen) +{ + struct gsm_msg *msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype); + + if (msg == NULL) + return -ENOMEM; + + msg->data[0] = (cmd << 1) | CR | EA; /* Set C/R */ + msg->data[1] = (dlen << 1) | EA; + memcpy(msg->data + 2, data, dlen); + gsm_data_queue(gsm->dlci[0], msg); + + return 0; +} + +/** * gsm_control_reply - send a response frame to a control * @gsm: gsm channel * @cmd: the command to use @@ -1618,13 +1643,7 @@ static void gsm_control_response(struct gsm_mux *gsm, unsigned int command, static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl) { - struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 2, gsm->ftype); - if (msg == NULL) - return; - msg->data[0] = (ctrl->cmd << 1) | CR | EA; /* command */ - msg->data[1] = (ctrl->len << 1) | EA; - memcpy(msg->data + 2, ctrl->data, ctrl->len); - gsm_data_queue(gsm->dlci[0], msg); + gsm_control_command(gsm, ctrl->cmd, ctrl->data, ctrl->len); } /** |