From adc66edd8dfb95a3ff2fbc02704580fa0504283d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 19 Feb 2024 16:34:33 +0100 Subject: [PATCH] egismoc: Implement suspension properly In case of suspension we can't just cancel the operations but also return when completed, and this may not happen immediately if there are ongoing operations. This is automagically handled by libfprint internals, but in order to make it happen, we need to cancel the ongoing operations and then mark it completed. libfprint will then wait for the task completion before actually marking the device as suspended. --- libfprint/drivers/egismoc/egismoc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libfprint/drivers/egismoc/egismoc.c b/libfprint/drivers/egismoc/egismoc.c index 3bc46b6f..811a817c 100644 --- a/libfprint/drivers/egismoc/egismoc.c +++ b/libfprint/drivers/egismoc/egismoc.c @@ -1494,6 +1494,16 @@ egismoc_cancel (FpDevice *device) self->interrupt_cancellable = g_cancellable_new (); } +static void +egismoc_suspend (FpDevice *device) +{ + fp_dbg ("Suspend"); + + egismoc_cancel (device); + g_cancellable_cancel (fpi_device_get_cancellable (device)); + fpi_device_suspend_complete (device, NULL); +} + static void egismoc_close (FpDevice *device) { @@ -1532,7 +1542,7 @@ fpi_device_egismoc_class_init (FpiDeviceEgisMocClass *klass) dev_class->open = egismoc_open; dev_class->cancel = egismoc_cancel; - dev_class->suspend = egismoc_cancel; + dev_class->suspend = egismoc_suspend; dev_class->close = egismoc_close; dev_class->identify = egismoc_identify_verify; dev_class->verify = egismoc_identify_verify;