drivers: Use fpi_ssm_next_state_delayed instead of custom callbacks
As per this fpi_ssm_next_state_timeout_cb can be removed
This commit is contained in:
parent
7ec2df2405
commit
1ba95db379
7 changed files with 16 additions and 70 deletions
|
@ -749,15 +749,10 @@ calibrate_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
}
|
||||
else
|
||||
{
|
||||
GSource *timeout;
|
||||
|
||||
if (self->calib_status == 0x00 &&
|
||||
self->last_read[0] == 0x01)
|
||||
self->calib_status = 0x01;
|
||||
timeout = fpi_device_add_timeout (dev, 50,
|
||||
fpi_ssm_next_state_timeout_cb,
|
||||
ssm, NULL);
|
||||
g_source_set_name (timeout, "calibrate_run_state");
|
||||
fpi_ssm_next_state_delayed (ssm, 50);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -618,8 +618,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
|
|||
clear_data (self);
|
||||
|
||||
/* Wait for probable vdev->active changing */
|
||||
fpi_device_add_timeout (dev, VFS_SSM_TIMEOUT,
|
||||
fpi_ssm_next_state_timeout_cb, ssm, NULL);
|
||||
fpi_ssm_next_state_delayed (ssm, VFS_SSM_TIMEOUT);
|
||||
break;
|
||||
|
||||
case SSM_NEXT_RECEIVE:
|
||||
|
|
|
@ -369,16 +369,6 @@ async_load (FpiSsm *ssm,
|
|||
async_load_cb, NULL);
|
||||
}
|
||||
|
||||
/* Submit asynchronous sleep */
|
||||
static void
|
||||
async_sleep (unsigned int msec,
|
||||
FpiSsm *ssm,
|
||||
FpImageDevice *dev)
|
||||
{
|
||||
fpi_device_add_timeout (FP_DEVICE (dev), msec,
|
||||
fpi_ssm_next_state_timeout_cb, ssm, NULL);
|
||||
}
|
||||
|
||||
/* Swap ssm states */
|
||||
enum {
|
||||
M_SWAP_SEND,
|
||||
|
@ -795,7 +785,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case M_LOOP_0_SLEEP:
|
||||
/* Wait fingerprint scanning */
|
||||
async_sleep (50, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 50);
|
||||
break;
|
||||
|
||||
case M_LOOP_0_GET_STATE:
|
||||
|
@ -838,7 +828,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
img_extract (ssm, dev);
|
||||
|
||||
/* Wait handling image */
|
||||
async_sleep (10, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 10);
|
||||
break;
|
||||
|
||||
case M_LOOP_0_CHECK_ACTION:
|
||||
|
@ -861,7 +851,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
if (vfs_finger_state (self) == VFS_FINGER_PRESENT)
|
||||
{
|
||||
fpi_image_device_report_finger_status (dev, TRUE);
|
||||
async_sleep (250, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 250);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -891,7 +881,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case M_LOOP_1_SLEEP:
|
||||
/* Wait fingerprint scanning */
|
||||
async_sleep (10, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 10);
|
||||
break;
|
||||
|
||||
case M_LOOP_2_ABORT_PRINT:
|
||||
|
@ -927,7 +917,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
{
|
||||
/* Wait aborting */
|
||||
self->counter++;
|
||||
async_sleep (100, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1065,7 +1055,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
{
|
||||
/* Wait aborting */
|
||||
self->counter++;
|
||||
async_sleep (100, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1094,7 +1084,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
{
|
||||
/* Wait removing finger */
|
||||
self->counter++;
|
||||
async_sleep (250, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 250);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -28,17 +28,6 @@ G_DEFINE_TYPE (FpDeviceVfs301, fpi_device_vfs301, FP_TYPE_IMAGE_DEVICE)
|
|||
|
||||
/************************** GENERIC STUFF *************************************/
|
||||
|
||||
/* Submit asynchronous sleep */
|
||||
static void
|
||||
async_sleep (unsigned int msec,
|
||||
FpiSsm *ssm,
|
||||
FpImageDevice *dev)
|
||||
{
|
||||
/* Add timeout */
|
||||
fpi_device_add_timeout (FP_DEVICE (dev), msec,
|
||||
fpi_ssm_next_state_timeout_cb, ssm, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
submit_image (FpiSsm *ssm,
|
||||
FpImageDevice *dev)
|
||||
|
@ -108,7 +97,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case M_WAIT_PRINT:
|
||||
/* Wait fingerprint scanning */
|
||||
async_sleep (200, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 200);
|
||||
break;
|
||||
|
||||
case M_CHECK_PRINT:
|
||||
|
@ -126,7 +115,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case M_READ_PRINT_WAIT:
|
||||
/* Wait fingerprint scanning */
|
||||
async_sleep (200, ssm, dev);
|
||||
fpi_ssm_next_state_delayed (ssm, 200);
|
||||
break;
|
||||
|
||||
case M_READ_PRINT_POLL:
|
||||
|
|
|
@ -704,10 +704,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
|
|||
break;
|
||||
|
||||
case DEV_ACTIVATE_DATA_COMPLETE:
|
||||
fpi_device_add_timeout (_dev, 1,
|
||||
fpi_ssm_next_state_timeout_cb,
|
||||
ssm, NULL);
|
||||
|
||||
fpi_ssm_next_state_delayed (ssm, 1);
|
||||
break;
|
||||
|
||||
case DEV_ACTIVATE_PREPARE_NEXT_CAPTURE:
|
||||
|
|
|
@ -359,7 +359,7 @@ fpi_ssm_next_state_delayed (FpiSsm *machine,
|
|||
g_clear_pointer (&machine->timeout, g_source_destroy);
|
||||
machine->timeout = fpi_device_add_timeout (machine->dev, delay,
|
||||
on_device_timeout_next_state,
|
||||
machine);
|
||||
machine, NULL);
|
||||
|
||||
source_name = g_strdup_printf ("[%s] ssm %p jump to next state %d",
|
||||
fp_device_get_device_id (machine->dev),
|
||||
|
@ -430,9 +430,9 @@ fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
|
|||
data->next_state = state;
|
||||
|
||||
g_clear_pointer (&machine->timeout, g_source_destroy);
|
||||
machine->timeout = fpi_device_add_timeout_full (machine->dev, delay,
|
||||
on_device_timeout_jump_to_state,
|
||||
data, g_free);
|
||||
machine->timeout = fpi_device_add_timeout (machine->dev, delay,
|
||||
on_device_timeout_jump_to_state,
|
||||
data, g_free);
|
||||
|
||||
source_name = g_strdup_printf ("[%s] ssm %p jump to state %d",
|
||||
fp_device_get_device_id (machine->dev),
|
||||
|
@ -486,28 +486,6 @@ fpi_ssm_dup_error (FpiSsm *machine)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_next_state_timeout_cb:
|
||||
* @dev: a struct #fp_dev
|
||||
* @data: a pointer to an #FpiSsm state machine
|
||||
*
|
||||
* Same as fpi_ssm_next_state(), but to be used as a callback
|
||||
* for an fpi_device_add_timeout() callback, when the state
|
||||
* change needs to happen after a timeout.
|
||||
*
|
||||
* Make sure to pass the #FpiSsm as the `ssm_data` argument
|
||||
* for that fpi_device_add_timeout() call.
|
||||
*/
|
||||
void
|
||||
fpi_ssm_next_state_timeout_cb (FpDevice *dev,
|
||||
void *data)
|
||||
{
|
||||
g_return_if_fail (dev != NULL);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
fpi_ssm_next_state (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_usb_transfer_cb:
|
||||
* @transfer: a #FpiUsbTransfer
|
||||
|
|
|
@ -93,8 +93,6 @@ int fpi_ssm_get_cur_state (FpiSsm *machine);
|
|||
/* Callbacks to be used by the driver instead of implementing their own
|
||||
* logic.
|
||||
*/
|
||||
void fpi_ssm_next_state_timeout_cb (FpDevice *dev,
|
||||
void *data);
|
||||
void fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer,
|
||||
FpDevice *device,
|
||||
gpointer unused_data,
|
||||
|
|
Loading…
Reference in a new issue