From 50461b4d7d191c43c0a3dd707d93af4aaed4afa5 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 7 Aug 2019 17:26:40 +0200 Subject: [PATCH] lib: Make fp_async_*_stop() not throw warning if already in right state Make it possible to call fp_async_*_stop() multiple times without penalty. --- libfprint/fpi-async.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/libfprint/fpi-async.c b/libfprint/fpi-async.c index ddf5230..6339c9c 100644 --- a/libfprint/fpi-async.c +++ b/libfprint/fpi-async.c @@ -387,9 +387,21 @@ API_EXPORTED int fp_async_verify_stop(struct fp_dev *dev, g_return_val_if_fail(dev != NULL, -ENODEV); + G_DEBUG_HERE(); + + if (dev->state == DEV_STATE_VERIFY_STOPPING) { + fp_dbg ("Already stopping verification, returning -EINPROGRESS"); + return -EINPROGRESS; + } + + if (dev->state == DEV_STATE_INITIALIZED) { + if (callback) + callback(dev, user_data); + return 0; + } + drv = dev->drv; - G_DEBUG_HERE(); BUG_ON(dev->state != DEV_STATE_ERROR && dev->state != DEV_STATE_VERIFYING && dev->state != DEV_STATE_VERIFY_DONE); @@ -511,9 +523,21 @@ API_EXPORTED int fp_async_identify_stop(struct fp_dev *dev, g_return_val_if_fail(dev != NULL, -ENODEV); + G_DEBUG_HERE(); + + if (dev->state == DEV_STATE_IDENTIFY_STOPPING) { + fp_dbg ("Already stopping identification, returning -EINPROGRESS"); + return -EINPROGRESS; + } + + if (dev->state == DEV_STATE_INITIALIZED) { + if (callback) + callback(dev, user_data); + return 0; + } + drv = dev->drv; - G_DEBUG_HERE(); BUG_ON(dev->state != DEV_STATE_IDENTIFYING && dev->state != DEV_STATE_IDENTIFY_DONE);