port-mbim: use qmi_device_close_async()
The qmi_device_close() synchronous operation is deprecated.
This commit is contained in:
@@ -441,6 +441,23 @@ mm_port_mbim_is_open (MMPortMbim *self)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MbimDevice *mbim_device;
|
||||||
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
QmiDevice *qmi_device;
|
||||||
|
#endif
|
||||||
|
} PortMbimCloseContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
port_mbim_close_context_free (PortMbimCloseContext *ctx)
|
||||||
|
{
|
||||||
|
g_clear_object (&ctx->mbim_device);
|
||||||
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
g_clear_object (&ctx->qmi_device);
|
||||||
|
#endif
|
||||||
|
g_slice_free (PortMbimCloseContext, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_port_mbim_close_finish (MMPortMbim *self,
|
mm_port_mbim_close_finish (MMPortMbim *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -450,7 +467,7 @@ mm_port_mbim_close_finish (MMPortMbim *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mbim_device_close_ready (MbimDevice *device,
|
mbim_device_close_ready (MbimDevice *mbim_device,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
@@ -458,22 +475,56 @@ mbim_device_close_ready (MbimDevice *device,
|
|||||||
MMPortMbim *self;
|
MMPortMbim *self;
|
||||||
|
|
||||||
self = g_task_get_source_object (task);
|
self = g_task_get_source_object (task);
|
||||||
self->priv->in_progress = FALSE;
|
|
||||||
g_clear_object (&self->priv->mbim_device);
|
|
||||||
|
|
||||||
if (!mbim_device_close_finish (device, res, &error))
|
g_assert (!self->priv->mbim_device);
|
||||||
|
self->priv->in_progress = FALSE;
|
||||||
|
|
||||||
|
if (!mbim_device_close_finish (mbim_device, res, &error))
|
||||||
g_task_return_error (task, error);
|
g_task_return_error (task, error);
|
||||||
else
|
else
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
|
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
port_mbim_device_close (GTask *task)
|
||||||
|
{
|
||||||
|
PortMbimCloseContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
g_assert (ctx->mbim_device);
|
||||||
|
mbim_device_close (ctx->mbim_device,
|
||||||
|
5,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)mbim_device_close_ready,
|
||||||
|
task);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
|
||||||
|
static void
|
||||||
|
qmi_device_close_ready (QmiDevice *qmi_device,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!qmi_device_close_finish (qmi_device, res, &error)) {
|
||||||
|
mm_warn ("Couldn't properly close QMI device: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
port_mbim_device_close (task);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_port_mbim_close (MMPortMbim *self,
|
mm_port_mbim_close (MMPortMbim *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
PortMbimCloseContext *ctx;
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_PORT_MBIM (self));
|
g_return_if_fail (MM_IS_PORT_MBIM (self));
|
||||||
@@ -497,9 +548,13 @@ mm_port_mbim_close (MMPortMbim *self,
|
|||||||
|
|
||||||
self->priv->in_progress = TRUE;
|
self->priv->in_progress = TRUE;
|
||||||
|
|
||||||
|
/* Store device(s) to close in the context */
|
||||||
|
ctx = g_slice_new0 (PortMbimCloseContext);
|
||||||
|
ctx->mbim_device = g_steal_pointer (&self->priv->mbim_device);
|
||||||
|
g_task_set_task_data (task, ctx, (GDestroyNotify)port_mbim_close_context_free);
|
||||||
|
|
||||||
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
if (self->priv->qmi_device) {
|
if (self->priv->qmi_device) {
|
||||||
GError *error = NULL;
|
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
/* Release all allocated clients */
|
/* Release all allocated clients */
|
||||||
@@ -515,20 +570,17 @@ mm_port_mbim_close (MMPortMbim *self,
|
|||||||
g_list_free_full (self->priv->qmi_clients, g_object_unref);
|
g_list_free_full (self->priv->qmi_clients, g_object_unref);
|
||||||
self->priv->qmi_clients = NULL;
|
self->priv->qmi_clients = NULL;
|
||||||
|
|
||||||
if (!qmi_device_close (self->priv->qmi_device, &error)) {
|
ctx->qmi_device = g_steal_pointer (&self->priv->qmi_device);
|
||||||
mm_warn ("Couldn't properly close QMI device: %s", error->message);
|
qmi_device_close_async (ctx->qmi_device,
|
||||||
g_error_free (error);
|
5,
|
||||||
}
|
NULL,
|
||||||
g_clear_object (&self->priv->qmi_device);
|
(GAsyncReadyCallback)qmi_device_close_ready,
|
||||||
|
task);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mbim_device_close (self->priv->mbim_device,
|
port_mbim_device_close (task);
|
||||||
5,
|
|
||||||
NULL,
|
|
||||||
(GAsyncReadyCallback)mbim_device_close_ready,
|
|
||||||
task);
|
|
||||||
g_clear_object (&self->priv->mbim_device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user