From 42dcc0ab8f34197c06c622a43ec39ecba8b27404 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 9 Oct 2024 18:55:11 +0700 Subject: [PATCH 09/10] mm-port-serial.c: move Linux-specific stuff inside macros --- src/mm-port-serial.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c index 7e040e50..9d1f9ddd 100644 --- a/src/mm-port-serial.c +++ b/src/mm-port-serial.c @@ -26,7 +26,9 @@ #include #include #include +#ifdef __linux__ #include +#endif #include @@ -1151,7 +1153,9 @@ mm_port_serial_open (MMPortSerial *self, GError **error) { char *devfile; const char *device; +#ifdef __linux__ struct serial_struct sinfo = { 0 }; +#endif GTimeVal tv_start, tv_end; int errno_save = 0; @@ -1232,6 +1236,7 @@ mm_port_serial_open (MMPortSerial *self, GError **error) /* Flush any waiting IO */ tcflush (self->priv->fd, TCIOFLUSH); + #ifdef __linux__ /* Don't wait for pending data when closing the port; this can cause some * stupid devices that don't respond to URBs on a particular port to hang * for 30 seconds when probing fails. See GNOME bug #630670. @@ -1241,6 +1246,7 @@ mm_port_serial_open (MMPortSerial *self, GError **error) if (ioctl (self->priv->fd, TIOCSSERIAL, &sinfo) < 0) mm_obj_warn (self, "couldn't set serial port closing_wait to none: %s", g_strerror (errno)); } + #endif } g_warn_if_fail (MM_PORT_SERIAL_GET_CLASS (self)->config_fd); @@ -1389,7 +1395,9 @@ _close_internal (MMPortSerial *self, gboolean force) if (self->priv->iochannel || self->priv->socket) { GTimeVal tv_start, tv_end; + #ifdef __linux__ struct serial_struct sinfo = { 0 }; + #endif mm_obj_dbg (self, "closing serial port..."); @@ -1399,6 +1407,7 @@ _close_internal (MMPortSerial *self, gboolean force) /* Serial port specific setup */ if (self->priv->fd >= 0 && mm_port_get_subsys (MM_PORT (self)) == MM_PORT_SUBSYS_TTY) { + #ifdef __linux__ /* Paranoid: ensure our closing_wait value is still set so we ignore * pending data when closing the port. See GNOME bug #630670. */ @@ -1410,6 +1419,7 @@ _close_internal (MMPortSerial *self, gboolean force) mm_obj_warn (self, "couldn't set serial port closing_wait to none: %s", g_strerror (errno)); } } + #endif tcflush (self->priv->fd, TCIOFLUSH); } -- 2.46.1