From c995e657f47e6fdb7afe809d4232e6e380255c86 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 3 Oct 2017 18:29:56 -0500 Subject: [PATCH] mbim: Close IO in an idle event --- drivers/mbimmodem/mbim.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/mbimmodem/mbim.c b/drivers/mbimmodem/mbim.c index 019c41d6..1e71a396 100644 --- a/drivers/mbimmodem/mbim.c +++ b/drivers/mbimmodem/mbim.c @@ -215,6 +215,7 @@ struct mbim_device { size_t header_offset; size_t segment_bytes_remaining; struct message_assembly *assembly; + struct l_idle *close_io; bool is_ready : 1; }; @@ -390,6 +391,18 @@ static bool close_write_handler(struct l_io *io, void *user_data) return false; } +static void close_io(struct l_idle *idle, void *user_data) +{ + struct mbim_device *device = user_data; + struct l_io *io = device->io; + + l_idle_remove(idle); + device->close_io = NULL; + + device->io = NULL; + l_io_destroy(io); +} + static bool close_read_handler(struct l_io *io, void *user_data) { struct mbim_device *device = user_data; @@ -439,8 +452,7 @@ static bool close_read_handler(struct l_io *io, void *user_data) device->header_offset = 0; if (type == MBIM_CLOSE_DONE) { - l_io_destroy(io); - device->io = NULL; + device->close_io = l_idle_create(close_io, device, NULL); return false; } @@ -494,6 +506,8 @@ void mbim_device_unref(struct mbim_device *device) if (__sync_sub_and_fetch(&device->ref_count, 1)) return; + l_idle_remove(device->close_io); + if (device->io) { l_io_destroy(device->io); device->io = NULL;