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:
Marco Trevisan (Treviño) 2019-11-22 18:22:50 +01:00
parent 7ec2df2405
commit 1ba95db379
7 changed files with 16 additions and 70 deletions

View file

@ -749,15 +749,10 @@ calibrate_run_state (FpiSsm *ssm, FpDevice *dev)
} }
else else
{ {
GSource *timeout;
if (self->calib_status == 0x00 && if (self->calib_status == 0x00 &&
self->last_read[0] == 0x01) self->last_read[0] == 0x01)
self->calib_status = 0x01; self->calib_status = 0x01;
timeout = fpi_device_add_timeout (dev, 50, fpi_ssm_next_state_delayed (ssm, 50);
fpi_ssm_next_state_timeout_cb,
ssm, NULL);
g_source_set_name (timeout, "calibrate_run_state");
} }
break; break;

View file

@ -618,8 +618,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
clear_data (self); clear_data (self);
/* Wait for probable vdev->active changing */ /* Wait for probable vdev->active changing */
fpi_device_add_timeout (dev, VFS_SSM_TIMEOUT, fpi_ssm_next_state_delayed (ssm, VFS_SSM_TIMEOUT);
fpi_ssm_next_state_timeout_cb, ssm, NULL);
break; break;
case SSM_NEXT_RECEIVE: case SSM_NEXT_RECEIVE:

View file

@ -369,16 +369,6 @@ async_load (FpiSsm *ssm,
async_load_cb, NULL); 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 */ /* Swap ssm states */
enum { enum {
M_SWAP_SEND, M_SWAP_SEND,
@ -795,7 +785,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
case M_LOOP_0_SLEEP: case M_LOOP_0_SLEEP:
/* Wait fingerprint scanning */ /* Wait fingerprint scanning */
async_sleep (50, ssm, dev); fpi_ssm_next_state_delayed (ssm, 50);
break; break;
case M_LOOP_0_GET_STATE: case M_LOOP_0_GET_STATE:
@ -838,7 +828,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
img_extract (ssm, dev); img_extract (ssm, dev);
/* Wait handling image */ /* Wait handling image */
async_sleep (10, ssm, dev); fpi_ssm_next_state_delayed (ssm, 10);
break; break;
case M_LOOP_0_CHECK_ACTION: 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) if (vfs_finger_state (self) == VFS_FINGER_PRESENT)
{ {
fpi_image_device_report_finger_status (dev, TRUE); fpi_image_device_report_finger_status (dev, TRUE);
async_sleep (250, ssm, dev); fpi_ssm_next_state_delayed (ssm, 250);
} }
else else
{ {
@ -891,7 +881,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
case M_LOOP_1_SLEEP: case M_LOOP_1_SLEEP:
/* Wait fingerprint scanning */ /* Wait fingerprint scanning */
async_sleep (10, ssm, dev); fpi_ssm_next_state_delayed (ssm, 10);
break; break;
case M_LOOP_2_ABORT_PRINT: case M_LOOP_2_ABORT_PRINT:
@ -927,7 +917,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
{ {
/* Wait aborting */ /* Wait aborting */
self->counter++; self->counter++;
async_sleep (100, ssm, dev); fpi_ssm_next_state_delayed (ssm, 100);
} }
else else
{ {
@ -1065,7 +1055,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev)
{ {
/* Wait aborting */ /* Wait aborting */
self->counter++; self->counter++;
async_sleep (100, ssm, dev); fpi_ssm_next_state_delayed (ssm, 100);
} }
else else
{ {
@ -1094,7 +1084,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev)
{ {
/* Wait removing finger */ /* Wait removing finger */
self->counter++; self->counter++;
async_sleep (250, ssm, dev); fpi_ssm_next_state_delayed (ssm, 250);
} }
else else
{ {

View file

@ -28,17 +28,6 @@ G_DEFINE_TYPE (FpDeviceVfs301, fpi_device_vfs301, FP_TYPE_IMAGE_DEVICE)
/************************** GENERIC STUFF *************************************/ /************************** 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 static int
submit_image (FpiSsm *ssm, submit_image (FpiSsm *ssm,
FpImageDevice *dev) FpImageDevice *dev)
@ -108,7 +97,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
case M_WAIT_PRINT: case M_WAIT_PRINT:
/* Wait fingerprint scanning */ /* Wait fingerprint scanning */
async_sleep (200, ssm, dev); fpi_ssm_next_state_delayed (ssm, 200);
break; break;
case M_CHECK_PRINT: case M_CHECK_PRINT:
@ -126,7 +115,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
case M_READ_PRINT_WAIT: case M_READ_PRINT_WAIT:
/* Wait fingerprint scanning */ /* Wait fingerprint scanning */
async_sleep (200, ssm, dev); fpi_ssm_next_state_delayed (ssm, 200);
break; break;
case M_READ_PRINT_POLL: case M_READ_PRINT_POLL:

View file

@ -704,10 +704,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
break; break;
case DEV_ACTIVATE_DATA_COMPLETE: case DEV_ACTIVATE_DATA_COMPLETE:
fpi_device_add_timeout (_dev, 1, fpi_ssm_next_state_delayed (ssm, 1);
fpi_ssm_next_state_timeout_cb,
ssm, NULL);
break; break;
case DEV_ACTIVATE_PREPARE_NEXT_CAPTURE: case DEV_ACTIVATE_PREPARE_NEXT_CAPTURE:

View file

@ -359,7 +359,7 @@ fpi_ssm_next_state_delayed (FpiSsm *machine,
g_clear_pointer (&machine->timeout, g_source_destroy); g_clear_pointer (&machine->timeout, g_source_destroy);
machine->timeout = fpi_device_add_timeout (machine->dev, delay, machine->timeout = fpi_device_add_timeout (machine->dev, delay,
on_device_timeout_next_state, on_device_timeout_next_state,
machine); machine, NULL);
source_name = g_strdup_printf ("[%s] ssm %p jump to next state %d", source_name = g_strdup_printf ("[%s] ssm %p jump to next state %d",
fp_device_get_device_id (machine->dev), fp_device_get_device_id (machine->dev),
@ -430,9 +430,9 @@ fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
data->next_state = state; data->next_state = state;
g_clear_pointer (&machine->timeout, g_source_destroy); g_clear_pointer (&machine->timeout, g_source_destroy);
machine->timeout = fpi_device_add_timeout_full (machine->dev, delay, machine->timeout = fpi_device_add_timeout (machine->dev, delay,
on_device_timeout_jump_to_state, on_device_timeout_jump_to_state,
data, g_free); data, g_free);
source_name = g_strdup_printf ("[%s] ssm %p jump to state %d", source_name = g_strdup_printf ("[%s] ssm %p jump to state %d",
fp_device_get_device_id (machine->dev), fp_device_get_device_id (machine->dev),
@ -486,28 +486,6 @@ fpi_ssm_dup_error (FpiSsm *machine)
return NULL; 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: * fpi_ssm_usb_transfer_cb:
* @transfer: a #FpiUsbTransfer * @transfer: a #FpiUsbTransfer

View file

@ -93,8 +93,6 @@ int fpi_ssm_get_cur_state (FpiSsm *machine);
/* Callbacks to be used by the driver instead of implementing their own /* Callbacks to be used by the driver instead of implementing their own
* logic. * logic.
*/ */
void fpi_ssm_next_state_timeout_cb (FpDevice *dev,
void *data);
void fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer, void fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer,
FpDevice *device, FpDevice *device,
gpointer unused_data, gpointer unused_data,