aboutsummaryrefslogtreecommitdiff
path: root/src/mm-serial-port.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2009-11-26 13:54:47 -0800
committerDan Williams <dcbw@redhat.com>2009-11-26 13:54:47 -0800
commitaea0be5b9a02926a1f8f72104ce32c7dabae3f84 (patch)
tree75c6790f50539e73576477318661221e43725005 /src/mm-serial-port.c
parent15595b33dc88724253a147b7894c953a5d3110e6 (diff)
nozomi: fix detection (lp:425312)
Nozomi devices aren't quite ready when the ports show up, so we have to keep trying to open the port for a few seconds and eventually it'll succeed. Should really be fixed in the driver (ie, don't create the ttys until they can actually be used) but whatever.
Diffstat (limited to 'src/mm-serial-port.c')
-rw-r--r--src/mm-serial-port.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index 250e00be..ad955008 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -791,11 +791,18 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
g_message ("(%s) opening serial device...", device);
devfile = g_strdup_printf ("/dev/%s", device);
+ errno = 0;
priv->fd = open (devfile, O_RDWR | O_EXCL | O_NONBLOCK | O_NOCTTY);
g_free (devfile);
if (priv->fd < 0) {
- g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_OPEN_FAILED,
+ /* nozomi isn't ready yet when the port appears, and it'll return
+ * ENODEV when open(2) is called on it. Make sure we can handle this
+ * by returning a special error in that case.
+ */
+ g_set_error (error,
+ MM_SERIAL_ERROR,
+ (errno == ENODEV) ? MM_SERIAL_OPEN_FAILED_NO_DEVICE : MM_SERIAL_OPEN_FAILED,
"Could not open serial device %s: %s", device, strerror (errno));
return FALSE;
}