diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-09-10 23:15:26 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-09-12 17:15:46 +0000 |
commit | fc1beefe927adb8d9bed3f554ddfb73a09593630 (patch) | |
tree | b2f0eeb7b5a9b52d0112321b5411f1bb2a9fdb79 | |
parent | 727567cf581f9126b5af6aff2944f3734877d999 (diff) | |
download | ModemManager-fc1beefe927adb8d9bed3f554ddfb73a09593630.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 |