serial-port: don't warn when trying to close a port which was forced to be closed
This commit is contained in:
@@ -68,6 +68,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
guint32 open_count;
|
guint32 open_count;
|
||||||
|
gboolean forced_close;
|
||||||
int fd;
|
int fd;
|
||||||
GHashTable *reply_cache;
|
GHashTable *reply_cache;
|
||||||
GIOChannel *channel;
|
GIOChannel *channel;
|
||||||
@@ -952,6 +953,12 @@ mm_serial_port_close (MMSerialPort *self)
|
|||||||
g_return_if_fail (MM_IS_SERIAL_PORT (self));
|
g_return_if_fail (MM_IS_SERIAL_PORT (self));
|
||||||
|
|
||||||
priv = MM_SERIAL_PORT_GET_PRIVATE (self);
|
priv = MM_SERIAL_PORT_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
/* If we forced closing the port, open_count will be 0 already.
|
||||||
|
* Just return without issuing any warning */
|
||||||
|
if (priv->forced_close)
|
||||||
|
return;
|
||||||
|
|
||||||
g_return_if_fail (priv->open_count > 0);
|
g_return_if_fail (priv->open_count > 0);
|
||||||
|
|
||||||
device = mm_port_get_device (MM_PORT (self));
|
device = mm_port_get_device (MM_PORT (self));
|
||||||
@@ -1057,7 +1064,17 @@ mm_serial_port_close_force (MMSerialPort *self)
|
|||||||
g_return_if_fail (MM_IS_SERIAL_PORT (self));
|
g_return_if_fail (MM_IS_SERIAL_PORT (self));
|
||||||
|
|
||||||
priv = MM_SERIAL_PORT_GET_PRIVATE (self);
|
priv = MM_SERIAL_PORT_GET_PRIVATE (self);
|
||||||
g_return_if_fail (priv->open_count > 0);
|
|
||||||
|
mm_info ("(%s) forced to close port",
|
||||||
|
mm_port_get_device (MM_PORT (self)));
|
||||||
|
|
||||||
|
/* Mark as having forced the close, so that we don't warn about incorrect
|
||||||
|
* open counts */
|
||||||
|
priv->forced_close = TRUE;
|
||||||
|
|
||||||
|
/* If already closed, done */
|
||||||
|
if (!priv->open_count)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Force the port to close */
|
/* Force the port to close */
|
||||||
priv->open_count = 1;
|
priv->open_count = 1;
|
||||||
@@ -1640,4 +1657,3 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
|
|||||||
g_cclosure_marshal_VOID__UINT,
|
g_cclosure_marshal_VOID__UINT,
|
||||||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user