diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-09-10 23:15:26 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2018-09-10 23:17:21 +0200 |
commit | 034192aa71cf7243e70405650f875480aa2f0f1a (patch) | |
tree | cac8db618ea3a16e10e680d2fa267b1004821ba6 | |
parent | 9036ca5ea14a7be548ff644c3acb17ac5712233e (diff) | |
download | ModemManager-034192aa71cf7243e70405650f875480aa2f0f1a.tar.gz |
port-serial: improve logging in mm_port_serial_set_flow_control()
-rw-r--r-- | src/mm-port-serial.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c index d43ea0a0c..38d4e477f 100644 --- a/src/mm-port-serial.c +++ b/src/mm-port-serial.c @@ -1846,20 +1846,40 @@ mm_port_serial_set_flow_control (MMPortSerial *self, GError **error) { struct termios options; + gchar *flow_control_str = NULL; + GError *inner_error = NULL; /* retrieve current settings */ memset (&options, 0, sizeof (struct termios)); if (tcgetattr (self->priv->fd, &options) != 0) { - g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "couldn't get serial port attributes: %s", g_strerror (errno)); - return FALSE; + inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "couldn't get serial port attributes: %s", g_strerror (errno)); + goto out; } + flow_control_str = mm_flow_control_build_string_from_mask (flow_control); + /* Return if current settings are already what we want */ - if (!set_flow_control_termios (self, flow_control, &options)) - return TRUE; + if (!set_flow_control_termios (self, flow_control, &options)) { + mm_dbg ("(%s): no need to change flow control settings: already %s", + mm_port_get_device (MM_PORT (self)), flow_control_str); + goto out; + } - return internal_tcsetattr (self, self->priv->fd, &options, error); + if (!internal_tcsetattr (self, self->priv->fd, &options, &inner_error)) + goto out; + + mm_dbg ("(%s): flow control settings updated to %s", + mm_port_get_device (MM_PORT (self)), flow_control_str); + + out: + g_free (flow_control_str); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + + return TRUE; } MMFlowControl |