ssm: Make possible to set data via function

Use the same approach of GTask, making possible to set the data from a
function. Givent the fact that a SSM has now a device parameter, it's
generally not needed to pass an extra data value.

In such case make it possible to set it and to define a destroy-notify
function to handle its destruction when freeing the SSM.
This commit is contained in:
Marco Trevisan (Treviño) 2019-11-20 18:05:46 +01:00 committed by Benjamin Berg
parent 1319daba54
commit 7bc62821ee
20 changed files with 277 additions and 330 deletions

View file

@ -218,7 +218,8 @@ fpi_ssm_next_state
fpi_ssm_jump_to_state
fpi_ssm_mark_completed
fpi_ssm_mark_failed
fpi_ssm_get_user_data
fpi_ssm_set_data
fpi_ssm_get_data
fpi_ssm_get_error
fpi_ssm_dup_error
fpi_ssm_get_cur_state

View file

@ -648,9 +648,9 @@ capture_read_strip_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceAes1610 *self = FPI_DEVICE_AES1610 (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -690,10 +690,9 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceAes1610 *self = FPI_DEVICE_AES1610 (_dev);
G_DEBUG_HERE ();
@ -727,7 +726,7 @@ start_capture (FpImageDevice *dev)
}
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
CAPTURE_NUM_STATES);
G_DEBUG_HERE ();
fpi_ssm_start (ssm, capture_sm_complete);
}
@ -750,9 +749,9 @@ enum activate_states {
};
static void
activate_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
/* activation on aes1610 seems much more straightforward compared to aes2501 */
/* verify there's anything missing here */
@ -767,10 +766,9 @@ activate_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
/* jump to finger detection */
static void
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
fpi_image_device_activate_complete (dev, error);
@ -784,7 +782,7 @@ dev_activate (FpImageDevice *dev)
{
FpiDeviceAes1610 *self = FPI_DEVICE_AES1610 (dev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
self->read_regs_retry_count = 0;
fpi_ssm_start (ssm, activate_sm_complete);

View file

@ -505,9 +505,9 @@ capture_read_strip_cb (FpiUsbTransfer *transfer, FpDevice *_dev,
}
static void
capture_run_state (FpiSsm *ssm, FpDevice *device, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *device)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (device);
FpiDeviceAes2501 *self = FPI_DEVICE_AES2501 (device);
switch (fpi_ssm_get_cur_state (ssm))
@ -555,10 +555,9 @@ capture_run_state (FpiSsm *ssm, FpDevice *device, void *user_data)
}
static void
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceAes2501 *self = FPI_DEVICE_AES2501 (_dev);
G_DEBUG_HERE ();
@ -595,7 +594,7 @@ start_capture (FpImageDevice *dev)
/* Reset gain */
strip_scan_reqs[4].value = AES2501_ADREFHI_MAX_VALUE;
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
CAPTURE_NUM_STATES);
G_DEBUG_HERE ();
fpi_ssm_start (ssm, capture_sm_complete);
}
@ -739,9 +738,9 @@ activate_init3_cb (FpImageDevice *dev, GError *error,
}
static void
activate_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
/* This state machine isn't as linear as it may appear. After doing init1
* and init2 register configuration writes, we have to poll a register
@ -801,8 +800,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
activate_sm_complete (FpiSsm *ssm, FpDevice *dev,
void *user_data, GError *error)
activate_sm_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
fpi_image_device_activate_complete (FP_IMAGE_DEVICE (dev), error);
@ -816,7 +814,7 @@ dev_activate (FpImageDevice *dev)
{
FpiDeviceAes2501 *self = FPI_DEVICE_AES2501 (dev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
self->read_regs_retry_count = 0;
fpi_ssm_start (ssm, activate_sm_complete);

View file

@ -121,7 +121,7 @@ finger_det_reqs_cb (FpiUsbTransfer *t, FpDevice *device,
gpointer user_data, GError *error)
{
FpiUsbTransfer *transfer;
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (device);
if (error)
{
@ -321,7 +321,7 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
capture_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -371,11 +371,10 @@ capture_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpiDeviceAes2550 *self = FPI_DEVICE_AES2550 (_dev);
FpImageDevice *dev = FP_IMAGE_DEVICE (self);
fp_dbg ("Capture completed");
@ -408,8 +407,7 @@ start_capture (FpImageDevice *dev)
}
self->heartbeat_cnt = 0;
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE ();
fpi_ssm_start (ssm, capture_sm_complete);
}
@ -471,7 +469,7 @@ calibrate_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -531,10 +529,9 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
fpi_image_device_activate_complete (dev, error);
@ -547,7 +544,7 @@ static void
dev_activate (FpImageDevice *dev)
{
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
fpi_ssm_start (ssm, activate_sm_complete);
}

View file

@ -204,8 +204,7 @@ finger_det_set_idle_cmd_cb (FpiUsbTransfer *transfer,
}
static void
finger_det_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
finger_det_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceAesX660 *self = FPI_DEVICE_AES_X660 (_dev);
@ -233,7 +232,7 @@ finger_det_sm_complete (FpiSsm *ssm, FpDevice *_dev,
}
static void
finger_det_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
finger_det_run_state (FpiSsm *ssm, FpDevice *dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -272,7 +271,7 @@ start_finger_detection (FpImageDevice *dev)
}
ssm = fpi_ssm_new (FP_DEVICE (dev), finger_det_run_state,
FINGER_DET_NUM_STATES, dev);
FINGER_DET_NUM_STATES);
fpi_ssm_start (ssm, finger_det_sm_complete);
}
@ -424,7 +423,7 @@ capture_read_stripe_data_cb (FpiUsbTransfer *transfer,
}
static void
capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpiDeviceAesX660 *self = FPI_DEVICE_AES_X660 (_dev);
FpiDeviceAesX660Private *priv = fpi_device_aes_x660_get_instance_private (self);
@ -458,8 +457,7 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
capture_sm_complete (FpiSsm *ssm, FpDevice *device, void *user_data,
GError *error)
capture_sm_complete (FpiSsm *ssm, FpDevice *device, GError *error)
{
FpiDeviceAesX660 *self = FPI_DEVICE_AES_X660 (device);
FpiDeviceAesX660Private *priv = fpi_device_aes_x660_get_instance_private (self);
@ -496,8 +494,7 @@ start_capture (FpImageDevice *dev)
return;
}
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE ();
fpi_ssm_start (ssm, capture_sm_complete);
}
@ -615,7 +612,7 @@ activate_read_init_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
activate_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpiDeviceAesX660 *self = FPI_DEVICE_AES_X660 (_dev);
FpiDeviceAesX660Private *priv = fpi_device_aes_x660_get_instance_private (self);
@ -666,8 +663,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
fpi_image_device_activate_complete (FP_IMAGE_DEVICE (_dev), error);
fpi_ssm_free (ssm);
@ -680,7 +676,7 @@ static void
aesX660_dev_activate (FpImageDevice *dev)
{
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
fpi_ssm_start (ssm, activate_sm_complete);
}

View file

@ -457,8 +457,7 @@ enum stop_capture_states {
};
static void
stop_capture_run_state (FpiSsm *ssm, FpDevice *dev,
void *user_data)
stop_capture_run_state (FpiSsm *ssm, FpDevice *dev)
{
G_DEBUG_HERE ();
@ -472,10 +471,9 @@ stop_capture_run_state (FpiSsm *ssm, FpDevice *dev,
}
static void
stop_capture_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
stop_capture_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceElan *self = FPI_DEVICE_ELAN (dev);
G_DEBUG_HERE ();
@ -510,8 +508,7 @@ elan_stop_capture (FpDevice *dev)
elan_dev_reset_state (self);
FpiSsm *ssm =
fpi_ssm_new (dev, stop_capture_run_state,
STOP_CAPTURE_NUM_STATES, dev);
fpi_ssm_new (dev, stop_capture_run_state, STOP_CAPTURE_NUM_STATES);
fpi_ssm_start (ssm, stop_capture_complete);
}
@ -524,7 +521,7 @@ enum capture_states {
};
static void
capture_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
FpiDeviceElan *self = FPI_DEVICE_ELAN (dev);
@ -577,10 +574,9 @@ capture_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
capture_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
capture_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceElan *self = FPI_DEVICE_ELAN (_dev);
G_DEBUG_HERE ();
@ -621,8 +617,7 @@ elan_capture (FpDevice *dev)
elan_dev_reset_state (self);
FpiSsm *ssm =
fpi_ssm_new (dev, capture_run_state, CAPTURE_NUM_STATES,
dev);
fpi_ssm_new (dev, capture_run_state, CAPTURE_NUM_STATES);
fpi_ssm_start (ssm, capture_complete);
}
@ -684,7 +679,7 @@ elan_supports_calibration (FpiDeviceElan *elandev)
}
static void
calibrate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
calibrate_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceElan *self = FPI_DEVICE_ELAN (dev);
@ -776,8 +771,7 @@ calibrate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
calibrate_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
calibrate_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceElan *self = FPI_DEVICE_ELAN (dev);
@ -808,7 +802,7 @@ elan_calibrate (FpDevice *dev)
self->calib_atts_left = ELAN_CALIBRATION_ATTEMPTS;
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), calibrate_run_state,
CALIBRATE_NUM_STATES, dev);
CALIBRATE_NUM_STATES);
fpi_ssm_start (ssm, calibrate_complete);
}
@ -822,7 +816,7 @@ enum activate_states {
};
static void
activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceElan *self = FPI_DEVICE_ELAN (dev);
@ -883,8 +877,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
activate_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
activate_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
@ -905,7 +898,7 @@ elan_activate (FpImageDevice *dev)
FpiSsm *ssm =
fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
fpi_ssm_start (ssm, activate_complete);
}

View file

@ -751,7 +751,7 @@ async_tx_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
m_exit_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
m_exit_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -780,8 +780,7 @@ err:
}
static void
m_exit_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_exit_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
@ -797,8 +796,7 @@ static void
m_exit_start (FpImageDevice *idev)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (idev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (idev), m_exit_state,
EXIT_NUM_STATES, idev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (idev), m_exit_state, EXIT_NUM_STATES);
self->is_active = FALSE;
fp_dbg ("Switching device to idle mode");
@ -806,7 +804,7 @@ m_exit_start (FpImageDevice *idev)
}
static void
m_capture_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
m_capture_state (FpiSsm *ssm, FpDevice *dev)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -895,8 +893,7 @@ err:
}
static void
m_capture_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_capture_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -929,7 +926,7 @@ m_capture_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
}
static void
m_finger_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
m_finger_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -1037,8 +1034,7 @@ err:
}
static void
m_finger_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_finger_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -1046,8 +1042,7 @@ m_finger_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
if (!error)
{
FpiSsm *ssm_cap;
ssm_cap = fpi_ssm_new (dev, m_capture_state,
CAP_NUM_STATES, NULL);
ssm_cap = fpi_ssm_new (dev, m_capture_state, CAP_NUM_STATES);
fpi_ssm_start (ssm_cap, m_capture_complete);
}
else
@ -1074,8 +1069,7 @@ m_start_fingerdetect (FpImageDevice *idev)
{
FpiSsm *ssmf;
ssmf = fpi_ssm_new (FP_DEVICE (idev), m_finger_state, FGR_NUM_STATES,
idev);
ssmf = fpi_ssm_new (FP_DEVICE (idev), m_finger_state, FGR_NUM_STATES);
fpi_ssm_start (ssmf, m_finger_complete);
}
@ -1083,7 +1077,7 @@ m_start_fingerdetect (FpImageDevice *idev)
* Tune value of VRT and VRB for contrast and brightness.
*/
static void
m_tunevrb_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
m_tunevrb_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
float hist[5];
@ -1256,8 +1250,7 @@ err:
}
static void
m_tunevrb_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_tunevrb_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
@ -1280,7 +1273,7 @@ m_tunevrb_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
* required.
*/
static void
m_tunedc_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
m_tunedc_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -1394,8 +1387,7 @@ err:
}
static void
m_tunedc_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_tunedc_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
@ -1404,7 +1396,7 @@ m_tunedc_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
{
FpiSsm *ssm_tune;
ssm_tune = fpi_ssm_new (FP_DEVICE (idev), m_tunevrb_state,
TUNEVRB_NUM_STATES, idev);
TUNEVRB_NUM_STATES);
fpi_ssm_start (ssm_tune, m_tunevrb_complete);
}
else
@ -1421,7 +1413,7 @@ m_tunedc_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
}
static void
m_init_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
m_init_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceEtes603 *self = FPI_DEVICE_ETES603 (dev);
@ -1534,8 +1526,7 @@ err:
}
static void
m_init_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_init_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
@ -1543,7 +1534,7 @@ m_init_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
{
FpiSsm *ssm_tune;
ssm_tune = fpi_ssm_new (FP_DEVICE (idev), m_tunedc_state,
TUNEDC_NUM_STATES, idev);
TUNEDC_NUM_STATES);
fpi_ssm_start (ssm_tune, m_tunedc_complete);
}
else
@ -1569,8 +1560,7 @@ dev_activate (FpImageDevice *idev)
if (self->dcoffset == 0)
{
fp_dbg ("Tuning device...");
ssm = fpi_ssm_new (FP_DEVICE (idev), m_init_state,
INIT_NUM_STATES, idev);
ssm = fpi_ssm_new (FP_DEVICE (idev), m_init_state, INIT_NUM_STATES);
fpi_ssm_start (ssm, m_init_complete);
}
else
@ -1579,8 +1569,7 @@ dev_activate (FpImageDevice *idev)
"VRB=0x%02X,GAIN=0x%02X).", self->dcoffset, self->vrt,
self->vrb, self->gain);
fpi_image_device_activate_complete (idev, NULL);
ssm = fpi_ssm_new (FP_DEVICE (idev), m_finger_state,
FGR_NUM_STATES, idev);
ssm = fpi_ssm_new (FP_DEVICE (idev), m_finger_state, FGR_NUM_STATES);
fpi_ssm_start (ssm, m_finger_complete);
}
}

View file

@ -202,8 +202,7 @@ cmd_interrupt_cb (FpiUsbTransfer *transfer,
static void
synaptics_cmd_run_state (FpiSsm *ssm,
FpDevice *dev,
void *user_data)
FpDevice *dev)
{
g_autoptr(FpiUsbTransfer) transfer = NULL;
FpiDeviceSynaptics *self = FPI_DEVICE_SYNAPTICS (dev);
@ -235,7 +234,7 @@ synaptics_cmd_run_state (FpiSsm *ssm,
5000,
NULL,
cmd_recieve_cb,
user_data);
fpi_ssm_get_data (ssm));
break;
@ -271,13 +270,10 @@ synaptics_cmd_run_state (FpiSsm *ssm,
}
static void
cmd_ssm_done (FpiSsm *ssm,
FpDevice *dev,
void *user_data,
GError *error)
cmd_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceSynaptics *self = FPI_DEVICE_SYNAPTICS (dev);
SynCmdMsgCallback callback = user_data;
SynCmdMsgCallback callback = fpi_ssm_get_data (ssm);
self->cmd_ssm = NULL;
@ -399,8 +395,8 @@ synaptics_sensor_cmd (FpiDeviceSynaptics *self,
self->cmd_ssm = fpi_ssm_new (FP_DEVICE (self),
synaptics_cmd_run_state,
SYNAPTICS_CMD_NUM_STATES,
callback);
SYNAPTICS_CMD_NUM_STATES);
fpi_ssm_set_data (self->cmd_ssm, callback, NULL);
fpi_ssm_start (self->cmd_ssm, cmd_ssm_done);
}

View file

@ -808,10 +808,9 @@ enum awfsm_1000_states {
};
static void
awfsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
awfsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -867,8 +866,7 @@ awfsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
awfsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
awfsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -936,10 +934,9 @@ capsm_fire_bulk (FpiSsm *ssm,
}
static void
capsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
capsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -975,8 +972,7 @@ capsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
capsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
capsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
@ -1005,8 +1001,7 @@ capsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
capsm_1001_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
capsm_1001_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
@ -1068,8 +1063,7 @@ enum deinitsm_1001_states {
};
static void
deinitsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
deinitsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -1080,8 +1074,7 @@ deinitsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
deinitsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
deinitsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -1092,8 +1085,7 @@ deinitsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
deinitsm_1001_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
deinitsm_1001_run_state (FpiSsm *ssm, FpDevice *_dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -1131,10 +1123,9 @@ enum initsm_1001_states {
};
static void
initsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
initsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -1170,8 +1161,7 @@ initsm_2016_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
initsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
initsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -1182,8 +1172,7 @@ initsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
initsm_1001_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
initsm_1001_run_state (FpiSsm *ssm, FpDevice *_dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -1222,9 +1211,9 @@ enum loopsm_states {
};
static void
loopsm_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
loopsm_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -1252,15 +1241,13 @@ loopsm_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
case UPEKSONLY_2016:
awfsm = fpi_ssm_new (FP_DEVICE (dev),
awfsm_2016_run_state,
AWFSM_2016_NUM_STATES,
dev);
AWFSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
awfsm = fpi_ssm_new (FP_DEVICE (dev),
awfsm_1000_run_state,
AWFSM_1000_NUM_STATES,
dev);
AWFSM_1000_NUM_STATES);
break;
}
fpi_ssm_start_subsm (ssm, awfsm);
@ -1289,19 +1276,19 @@ loopsm_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
case UPEKSONLY_2016:
capsm = fpi_ssm_new (FP_DEVICE (dev),
capsm_2016_run_state,
CAPSM_2016_NUM_STATES, dev);
CAPSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
capsm = fpi_ssm_new (FP_DEVICE (dev),
capsm_1000_run_state,
CAPSM_1000_NUM_STATES, dev);
CAPSM_1000_NUM_STATES);
break;
case UPEKSONLY_1001:
capsm = fpi_ssm_new (FP_DEVICE (dev),
capsm_1001_run_state,
CAPSM_1001_NUM_STATES, dev);
CAPSM_1001_NUM_STATES);
break;
}
fpi_ssm_start_subsm (ssm, capsm);
@ -1317,19 +1304,19 @@ loopsm_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
case UPEKSONLY_2016:
deinitsm = fpi_ssm_new (FP_DEVICE (dev),
deinitsm_2016_run_state,
DEINITSM_2016_NUM_STATES, dev);
DEINITSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
deinitsm = fpi_ssm_new (FP_DEVICE (dev),
deinitsm_1000_run_state,
DEINITSM_1000_NUM_STATES, dev);
DEINITSM_1000_NUM_STATES);
break;
case UPEKSONLY_1001:
deinitsm = fpi_ssm_new (FP_DEVICE (dev),
deinitsm_1001_run_state,
DEINITSM_1001_NUM_STATES, dev);
DEINITSM_1001_NUM_STATES);
break;
}
self->capturing = FALSE;
@ -1379,9 +1366,9 @@ dev_deactivate (FpImageDevice *dev)
}
static void
loopsm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data, GError *error)
loopsm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
fpi_ssm_free (ssm);
@ -1400,10 +1387,9 @@ loopsm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data, GError *error)
}
static void
initsm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
initsm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpeksonly *self = FPI_DEVICE_UPEKSONLY (_dev);
fpi_ssm_free (ssm);
@ -1412,7 +1398,7 @@ initsm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
return;
self->loopsm = fpi_ssm_new (FP_DEVICE (dev), loopsm_run_state,
LOOPSM_NUM_STATES, dev);
LOOPSM_NUM_STATES);
fpi_ssm_start (self->loopsm, loopsm_complete);
}
@ -1443,17 +1429,17 @@ dev_activate (FpImageDevice *dev)
{
case UPEKSONLY_2016:
ssm = fpi_ssm_new (FP_DEVICE (dev), initsm_2016_run_state,
INITSM_2016_NUM_STATES, dev);
INITSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
ssm = fpi_ssm_new (FP_DEVICE (dev), initsm_1000_run_state,
INITSM_1000_NUM_STATES, dev);
INITSM_1000_NUM_STATES);
break;
case UPEKSONLY_1001:
ssm = fpi_ssm_new (FP_DEVICE (dev), initsm_1001_run_state,
INITSM_1001_NUM_STATES, dev);
INITSM_1001_NUM_STATES);
break;
}
fpi_ssm_start (ssm, initsm_complete);

View file

@ -109,7 +109,7 @@ read_init_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceUpektc *self = FPI_DEVICE_UPEKTC (dev);
@ -149,8 +149,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
@ -294,7 +293,7 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpiDeviceUpektc *self = FPI_DEVICE_UPEKTC (_dev);
@ -333,10 +332,9 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpektc *self = FPI_DEVICE_UPEKTC (_dev);
fp_dbg ("Capture completed");
@ -362,8 +360,7 @@ start_capture (FpImageDevice *dev)
return;
}
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE ();
fpi_ssm_start (ssm, capture_sm_complete);
}
@ -373,7 +370,7 @@ dev_activate (FpImageDevice *dev)
{
FpiDeviceUpektc *self = FPI_DEVICE_UPEKTC (dev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
self->init_idx = 0;
fpi_ssm_start (ssm, activate_sm_complete);

View file

@ -338,9 +338,9 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
capture_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -382,9 +382,9 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data, GError *error_arg)
capture_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error_arg)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (_dev);
g_autoptr(GError) error = error_arg;
@ -409,7 +409,7 @@ start_capture (FpImageDevice *dev)
self->image_size = 0;
ssm = fpi_ssm_new (FP_DEVICE (dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
CAPTURE_NUM_STATES);
fpi_ssm_start (ssm, capture_sm_complete);
}
@ -443,10 +443,9 @@ deactivate_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
deactivate_run_state (FpiSsm *ssm, FpDevice *_dev,
void *user_data)
deactivate_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -465,10 +464,9 @@ deactivate_run_state (FpiSsm *ssm, FpDevice *_dev,
}
static void
deactivate_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
deactivate_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (_dev);
fp_dbg ("Deactivate completed");
@ -487,7 +485,7 @@ start_deactivation (FpImageDevice *dev)
self->image_size = 0;
ssm = fpi_ssm_new (FP_DEVICE (dev), deactivate_run_state,
DEACTIVATE_NUM_STATES, dev);
DEACTIVATE_NUM_STATES);
fpi_ssm_start (ssm, deactivate_sm_complete);
}
@ -539,10 +537,10 @@ init_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
activate_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpiUsbTransfer *transfer;
FpImageDevice *idev = user_data;
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -599,10 +597,9 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
activate_sm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
fpi_ssm_free (ssm);
fpi_image_device_activate_complete (dev, error);
@ -616,7 +613,7 @@ dev_activate (FpImageDevice *dev)
{
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (dev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), activate_run_state,
ACTIVATE_NUM_STATES, dev);
ACTIVATE_NUM_STATES);
self->seq = 0;
fpi_ssm_start (ssm, activate_sm_complete);

View file

@ -679,7 +679,7 @@ initsm_send_msg28_handler (FpiSsm *ssm,
}
static void
initsm_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
initsm_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpiDeviceUpekts *upekdev = FPI_DEVICE_UPEKTS (dev);
FpiUsbTransfer *transfer;
@ -763,7 +763,7 @@ initsm_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
static FpiSsm *
initsm_new (FpDevice *dev)
{
return fpi_ssm_new (dev, initsm_run_state, INITSM_NUM_STATES, NULL);
return fpi_ssm_new (dev, initsm_run_state, INITSM_NUM_STATES);
}
enum deinitsm_states {
@ -806,8 +806,7 @@ read_msg01_cb (FpDevice *dev, enum read_msg_type type,
}
static void
deinitsm_state_handler (FpiSsm *ssm, FpDevice *dev,
void *user_data)
deinitsm_state_handler (FpiSsm *ssm, FpDevice *dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -829,7 +828,7 @@ deinitsm_state_handler (FpiSsm *ssm, FpDevice *dev,
}
static void
initsm_done (FpiSsm *ssm, FpDevice *dev, void *user_data, GError *error)
initsm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
if (error)
g_usb_device_release_interface (fpi_device_get_usb_device (dev), 0, 0, NULL);
@ -840,7 +839,7 @@ initsm_done (FpiSsm *ssm, FpDevice *dev, void *user_data, GError *error)
static FpiSsm *
deinitsm_new (FpDevice *dev, void *user_data)
{
return fpi_ssm_new (dev, deinitsm_state_handler, DEINITSM_NUM_STATES, user_data);
return fpi_ssm_new (dev, deinitsm_state_handler, DEINITSM_NUM_STATES);
}
static void
@ -858,12 +857,12 @@ dev_init (FpDevice *dev)
upekdev->seq = 0xf0; /* incremented to 0x00 before first cmd */
ssm = fpi_ssm_new (dev, initsm_run_state, INITSM_NUM_STATES, NULL);
ssm = fpi_ssm_new (dev, initsm_run_state, INITSM_NUM_STATES);
fpi_ssm_start (ssm, initsm_done);
}
static void
deinitsm_done (FpiSsm *ssm, FpDevice *dev, void *user_data, GError *error)
deinitsm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
g_usb_device_release_interface (fpi_device_get_usb_device (dev), 0, 0, NULL);
@ -875,7 +874,7 @@ dev_exit (FpDevice *dev)
{
FpiSsm *ssm;
ssm = fpi_ssm_new (dev, deinitsm_state_handler, DEINITSM_NUM_STATES, NULL);
ssm = fpi_ssm_new (dev, deinitsm_state_handler, DEINITSM_NUM_STATES);
fpi_ssm_start (ssm, deinitsm_done);
}
@ -936,8 +935,7 @@ enroll_start_sm_cb_msg28 (FpDevice *dev,
}
static void
enroll_start_sm_run_state (FpiSsm *ssm, FpDevice *dev,
void *user_data)
enroll_start_sm_run_state (FpiSsm *ssm, FpDevice *dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
@ -973,20 +971,23 @@ typedef struct
} EnrollStopData;
static void
enroll_stop_deinit_cb (FpiSsm *ssm, FpDevice *dev,
void *user_data, GError *error)
enroll_stop_data_free (EnrollStopData *data)
{
EnrollStopData *data = user_data;
g_clear_object (&data->print);
g_clear_error (&data->error);
g_free (data);
}
static void
enroll_stop_deinit_cb (FpiSsm *ssm, FpDevice *dev, GError *error)
{
EnrollStopData *data = fpi_ssm_get_data (ssm);
/* don't really care about errors */
if (error)
{
fp_warn ("Error deinitializing: %s", error->message);
g_error_free (error);
}
fp_warn ("Error deinitializing: %s", error->message);
fpi_device_enroll_complete (dev, data->print, data->error);
g_free (data);
fpi_ssm_free (ssm);
}
@ -996,10 +997,11 @@ do_enroll_stop (FpDevice *dev, FpPrint *print, GError *error)
EnrollStopData *data = g_new0 (EnrollStopData, 1);
FpiSsm *ssm = deinitsm_new (dev, data);
data->print = print;
data->print = g_object_ref (print);
data->error = error;
fpi_ssm_start (ssm, enroll_stop_deinit_cb);
fpi_ssm_set_data (ssm, data, (GDestroyNotify) enroll_stop_data_free);
}
static void enroll_iterate (FpDevice *dev);
@ -1206,8 +1208,7 @@ enroll_iterate (FpDevice *dev)
}
static void
enroll_started (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
enroll_started (FpiSsm *ssm, FpDevice *dev, GError *error)
{
if (error)
do_enroll_stop (dev, NULL, error);
@ -1224,7 +1225,7 @@ enroll (FpDevice *dev)
/* do_init state machine first */
FpiSsm *ssm = fpi_ssm_new (dev, enroll_start_sm_run_state,
ENROLL_START_NUM_STATES, NULL);
ENROLL_START_NUM_STATES);
upekdev->enroll_passed = FALSE;
upekdev->enroll_stage = 0;
@ -1238,19 +1239,21 @@ typedef struct
} VerifyStopData;
static void
verify_stop_deinit_cb (FpiSsm *ssm, FpDevice *dev,
void *user_data, GError *error)
verify_stop_data_free (VerifyStopData *data)
{
VerifyStopData *data = user_data;
g_clear_error (&data->error);
g_free (data);
}
static void
verify_stop_deinit_cb (FpiSsm *ssm, FpDevice *dev, GError *error)
{
VerifyStopData *data = fpi_ssm_get_data (ssm);
if (error)
{
fp_warn ("Error deinitializing: %s", error->message);
g_error_free (error);
}
fp_warn ("Error deinitializing: %s", error->message);
fpi_device_verify_complete (dev, data->res, NULL, data->error);
g_free (data);
fpi_ssm_free (ssm);
}
@ -1264,6 +1267,7 @@ do_verify_stop (FpDevice *dev, FpiMatchResult res, GError *error)
data->error = error;
fpi_ssm_start (ssm, verify_stop_deinit_cb);
fpi_ssm_set_data (ssm, data, (GDestroyNotify) verify_stop_data_free);
}
static const unsigned char verify_hdr[] = {
@ -1279,8 +1283,7 @@ enum {
};
static void
verify_start_sm_run_state (FpiSsm *ssm, FpDevice *dev,
void *user_data)
verify_start_sm_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpPrint *print;
@ -1522,8 +1525,7 @@ verify_iterate (FpDevice *dev)
}
static void
verify_started (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
verify_started (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceUpekts *upekdev = FPI_DEVICE_UPEKTS (dev);
@ -1542,8 +1544,7 @@ verify_started (FpiSsm *ssm, FpDevice *dev, void *user_data,
static void
verify (FpDevice *dev)
{
FpiSsm *ssm = fpi_ssm_new (dev, verify_start_sm_run_state,
VERIFY_NUM_STATES, NULL);
FpiSsm *ssm = fpi_ssm_new (dev, verify_start_sm_run_state, VERIFY_NUM_STATES);
fpi_ssm_start (ssm, verify_started);
}

View file

@ -650,9 +650,9 @@ calc_dev2 (struct uru4k_image *img)
}
static void
imaging_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
imaging_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUru4000 *self = FPI_DEVICE_URU4000 (_dev);
struct uru4k_image *img = self->img_data;
FpImage *fpimg;
@ -785,8 +785,7 @@ imaging_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
imaging_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
imaging_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceUru4000 *self = FPI_DEVICE_URU4000 (dev);
@ -855,9 +854,9 @@ rebootpwr_pause_cb (FpDevice *dev,
}
static void
rebootpwr_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
rebootpwr_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUru4000 *self = FPI_DEVICE_URU4000 (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -946,9 +945,9 @@ powerup_pause_cb (FpDevice *dev,
}
static void
powerup_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
powerup_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUru4000 *self = FPI_DEVICE_URU4000 (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -1073,9 +1072,9 @@ init_scanpwr_timeout (FpDevice *dev,
}
static void
init_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
init_run_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpiDeviceUru4000 *self = FPI_DEVICE_URU4000 (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -1095,7 +1094,7 @@ init_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
case INIT_REBOOT_POWER:;
FpiSsm *rebootsm = fpi_ssm_new (FP_DEVICE (dev),
rebootpwr_run_state,
REBOOTPWR_NUM_STATES, dev);
REBOOTPWR_NUM_STATES);
fpi_ssm_start_subsm (ssm, rebootsm);
break;
@ -1118,7 +1117,7 @@ init_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
FpiSsm *powerupsm = fpi_ssm_new (FP_DEVICE (dev),
powerup_run_state,
POWERUP_NUM_STATES, dev);
POWERUP_NUM_STATES);
fpi_ssm_start_subsm (ssm, powerupsm);
break;
@ -1165,8 +1164,7 @@ init_run_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
activate_initsm_complete (FpiSsm *ssm, FpDevice *dev,
void *user_data, GError *error)
activate_initsm_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
fpi_image_device_activate_complete (FP_IMAGE_DEVICE (dev), error);
}
@ -1180,7 +1178,7 @@ dev_activate (FpImageDevice *dev)
start_irq_handler (dev);
self->scanpwr_irq_timeouts = 0;
ssm = fpi_ssm_new (FP_DEVICE (dev), init_run_state, INIT_NUM_STATES, NULL);
ssm = fpi_ssm_new (FP_DEVICE (dev), init_run_state, INIT_NUM_STATES);
fpi_ssm_start (ssm, activate_initsm_complete);
}
@ -1240,7 +1238,7 @@ execute_state_change (FpImageDevice *dev)
self->irq_cb = NULL;
ssm = fpi_ssm_new (FP_DEVICE (dev), imaging_run_state,
IMAGING_NUM_STATES, dev);
IMAGING_NUM_STATES);
self->img_enc_seed = rand ();
self->img_transfer = fpi_usb_transfer_new (FP_DEVICE (dev));
self->img_transfer->ssm = ssm;

View file

@ -256,7 +256,7 @@ enum loop_states {
};
static void
loop_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
loop_run_state (FpiSsm *ssm, FpDevice *dev)
{
FpDeviceVcom5s *self = FPI_DEVICE_VCOM5S (dev);
@ -296,8 +296,7 @@ loop_run_state (FpiSsm *ssm, FpDevice *dev, void *user_data)
}
static void
loopsm_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
loopsm_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpImageDevice *imgdev = FP_IMAGE_DEVICE (dev);
FpDeviceVcom5s *self = FPI_DEVICE_VCOM5S (dev);
@ -320,8 +319,7 @@ static void
dev_activate (FpImageDevice *dev)
{
FpDeviceVcom5s *self = FPI_DEVICE_VCOM5S (dev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), loop_run_state,
LOOP_NUM_STATES, dev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (dev), loop_run_state, LOOP_NUM_STATES);
self->deactivating = FALSE;
fpi_ssm_start (ssm, loopsm_complete);

View file

@ -278,7 +278,7 @@ submit_image (FpDeviceVfs0050 *self)
/* SSM loop for clear_ep2 */
static void
clear_ep2_ssm (FpiSsm *ssm, FpDevice *dev, void *user_data)
clear_ep2_ssm (FpiSsm *ssm, FpDevice *dev)
{
char command04 = 0x04;
@ -307,15 +307,13 @@ static void
clear_ep2 (FpDevice *dev,
FpiSsm *ssm)
{
FpiSsm *subsm =
fpi_ssm_new (dev, clear_ep2_ssm, SUBSM1_STATES, NULL);
FpiSsm *subsm = fpi_ssm_new (dev, clear_ep2_ssm, SUBSM1_STATES);
fpi_ssm_start_subsm (ssm, subsm);
}
static void
send_control_packet_ssm (FpiSsm *ssm, FpDevice *dev,
void *user_data)
send_control_packet_ssm (FpiSsm *ssm, FpDevice *dev)
{
FpDeviceVfs0050 *self = FPI_DEVICE_VFS0050 (dev);
@ -384,8 +382,7 @@ send_control_packet (FpiSsm *ssm,
FpDevice *dev)
{
FpiSsm *subsm =
fpi_ssm_new (dev, send_control_packet_ssm,
SUBSM2_STATES, NULL);
fpi_ssm_new (dev, send_control_packet_ssm, SUBSM2_STATES);
fpi_ssm_start_subsm (ssm, subsm);
}
@ -497,7 +494,7 @@ another_scan (FpDevice *dev,
/* Main SSM loop */
static void
activate_ssm (FpiSsm *ssm, FpDevice *dev, void *user_data)
activate_ssm (FpiSsm *ssm, FpDevice *dev)
{
FpImageDevice *idev = FP_IMAGE_DEVICE (dev);
FpDeviceVfs0050 *self = FPI_DEVICE_VFS0050 (dev);
@ -660,8 +657,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev, void *user_data)
/* Callback for dev_activate ssm */
static void
dev_activate_callback (FpiSsm *ssm, FpDevice *dev,
void *user_data, GError *error)
dev_activate_callback (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpDeviceVfs0050 *self = FPI_DEVICE_VFS0050 (dev);
@ -687,8 +683,7 @@ dev_activate (FpImageDevice *idev)
self->need_report = 1;
self->ssm_active = 1;
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (idev), activate_ssm, SSM_STATES,
idev);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (idev), activate_ssm, SSM_STATES);
fpi_ssm_start (ssm, dev_activate_callback);
}
@ -711,8 +706,7 @@ dev_deactivate (FpImageDevice *idev)
/* Callback for dev_open ssm */
static void
dev_open_callback (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
dev_open_callback (FpiSsm *ssm, FpDevice *dev, GError *error)
{
/* Notify open complete */
fpi_image_device_open_complete (FP_IMAGE_DEVICE (dev), error);
@ -733,7 +727,7 @@ dev_open (FpImageDevice *idev)
}
/* Clearing previous device state */
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (idev), activate_ssm, SSM_STATES, NULL);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (idev), activate_ssm, SSM_STATES);
fpi_ssm_start (ssm, dev_open_callback);
}

View file

@ -391,18 +391,18 @@ enum {
/* Exec swap sequential state machine */
static void
m_swap_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
m_swap_state (FpiSsm *ssm, FpDevice *dev)
{
switch (fpi_ssm_get_cur_state (ssm))
{
case M_SWAP_SEND:
/* Send data */
async_send (ssm, user_data);
async_send (ssm, FP_IMAGE_DEVICE (dev));
break;
case M_SWAP_RECV:
/* Recv response */
async_recv (ssm, user_data);
async_recv (ssm, FP_IMAGE_DEVICE (dev));
break;
}
}
@ -423,8 +423,7 @@ m_swap (FpiSsm *ssm,
self->length = length;
/* Start swap ssm */
subsm = fpi_ssm_new (FP_DEVICE (dev), m_swap_state, M_SWAP_NUM_STATES,
dev);
subsm = fpi_ssm_new (FP_DEVICE (dev), m_swap_state, M_SWAP_NUM_STATES);
fpi_ssm_start_subsm (ssm, subsm);
}
@ -778,9 +777,9 @@ enum {
/* Exec loop sequential state machine */
static void
m_loop_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
m_loop_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs101 *self = FPI_DEVICE_VFS101 (_dev);
/* Complete if deactivation was requested */
@ -950,8 +949,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
/* Complete loop sequential state machine */
static void
m_loop_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_loop_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpDeviceVfs101 *self = FPI_DEVICE_VFS101 (dev);
@ -1015,9 +1013,9 @@ enum {
/* Exec init sequential state machine */
static void
m_init_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
m_init_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs101 *self = FPI_DEVICE_VFS101 (_dev);
/* Mark as cancelled when activation collides with deactivation. */
@ -1253,10 +1251,9 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
/* Complete init sequential state machine */
static void
m_init_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
m_init_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
/* Notify activate complete */
fpi_image_device_activate_complete (dev, error);
@ -1266,8 +1263,7 @@ m_init_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
FpiSsm *ssm_loop;
/* Start loop ssm */
ssm_loop = fpi_ssm_new (FP_DEVICE (dev), m_loop_state,
M_LOOP_NUM_STATES, dev);
ssm_loop = fpi_ssm_new (FP_DEVICE (dev), m_loop_state, M_LOOP_NUM_STATES);
fpi_ssm_start (ssm_loop, m_loop_complete);
}
@ -1297,7 +1293,7 @@ dev_activate (FpImageDevice *dev)
self->counter = 0;
/* Start init ssm */
ssm = fpi_ssm_new (FP_DEVICE (dev), m_init_state, M_INIT_NUM_STATES, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), m_init_state, M_INIT_NUM_STATES);
fpi_ssm_start (ssm, m_init_complete);
}

View file

@ -94,9 +94,9 @@ enum {
/* Exec loop sequential state machine */
static void
m_loop_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
m_loop_state (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs301 *self = FPI_DEVICE_VFS301 (_dev);
switch (fpi_ssm_get_cur_state (ssm))
@ -160,8 +160,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
/* Complete loop sequential state machine */
static void
m_loop_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
m_loop_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
if (error)
{
@ -174,7 +173,7 @@ m_loop_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
/* Exec init sequential state machine */
static void
m_init_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
m_init_state (FpiSsm *ssm, FpDevice *_dev)
{
FpDeviceVfs301 *self = FPI_DEVICE_VFS301 (_dev);
@ -187,8 +186,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev, void *user_data)
/* Complete init sequential state machine */
static void
m_init_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
GError *error)
m_init_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiSsm *ssm_loop;
@ -198,8 +196,7 @@ m_init_complete (FpiSsm *ssm, FpDevice *dev, void *user_data,
/* Notify activate complete */
/* Start loop ssm */
ssm_loop = fpi_ssm_new (dev, m_loop_state,
M_LOOP_NUM_STATES, dev);
ssm_loop = fpi_ssm_new (dev, m_loop_state, M_LOOP_NUM_STATES);
fpi_ssm_start (ssm_loop, m_loop_complete);
}
@ -214,7 +211,7 @@ dev_activate (FpImageDevice *dev)
FpiSsm *ssm;
/* Start init ssm */
ssm = fpi_ssm_new (FP_DEVICE (dev), m_init_state, 1, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), m_init_state, 1);
fpi_ssm_start (ssm, m_init_complete);
}

View file

@ -81,7 +81,7 @@ static void
async_send_cb (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{
struct usbexchange_data *data = fpi_ssm_get_user_data (transfer->ssm);
struct usbexchange_data *data = fpi_ssm_get_data (transfer->ssm);
struct usb_action *action;
g_assert (!(fpi_ssm_get_cur_state (transfer->ssm) >= data->stepcount));
@ -104,7 +104,7 @@ static void
async_recv_cb (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{
struct usbexchange_data *data = fpi_ssm_get_user_data (transfer->ssm);
struct usbexchange_data *data = fpi_ssm_get_data (transfer->ssm);
struct usb_action *action;
if (error)
@ -148,9 +148,9 @@ async_recv_cb (FpiUsbTransfer *transfer, FpDevice *device,
}
static void
usbexchange_loop (FpiSsm *ssm, FpDevice *_dev, void *user_data)
usbexchange_loop (FpiSsm *ssm, FpDevice *_dev)
{
struct usbexchange_data *data = user_data;
struct usbexchange_data *data = fpi_ssm_get_data (ssm);
struct usb_action *action = &data->actions[fpi_ssm_get_cur_state (ssm)];
FpiUsbTransfer *transfer;
@ -196,9 +196,9 @@ usb_exchange_async (FpiSsm *ssm,
{
FpiSsm *subsm = fpi_ssm_new (FP_DEVICE (data->device),
usbexchange_loop,
data->stepcount,
data);
data->stepcount);
fpi_ssm_set_data (subsm, data, NULL);
fpi_ssm_start_subsm (ssm, subsm);
}
@ -658,11 +658,11 @@ struct usb_action vfs5011_initiate_capture[] = {
/* ====================== lifprint interface ======================= */
static void
activate_loop (FpiSsm *ssm, FpDevice *_dev, void *user_data)
activate_loop (FpiSsm *ssm, FpDevice *_dev)
{
enum {READ_TIMEOUT = 0};
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs5011 *self;
self = FPI_DEVICE_VFS5011 (_dev);
@ -729,10 +729,9 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
activate_loop_complete (FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
activate_loop_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs5011 *self;
self = FPI_DEVICE_VFS5011 (_dev);
@ -760,9 +759,9 @@ activate_loop_complete (FpiSsm *ssm, FpDevice *_dev,
static void
open_loop (FpiSsm *ssm, FpDevice *_dev, void *user_data)
open_loop (FpiSsm *ssm, FpDevice *_dev)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs5011 *self;
self = FPI_DEVICE_VFS5011 (_dev);
@ -784,10 +783,9 @@ open_loop (FpiSsm *ssm, FpDevice *_dev, void *user_data)
}
static void
open_loop_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
open_loop_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpImageDevice *dev = user_data;
FpImageDevice *dev = FP_IMAGE_DEVICE (_dev);
FpDeviceVfs5011 *self;
self = FPI_DEVICE_VFS5011 (_dev);
@ -814,7 +812,7 @@ dev_open (FpImageDevice *dev)
return;
}
ssm = fpi_ssm_new (FP_DEVICE (dev), open_loop, DEV_OPEN_NUM_STATES, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), open_loop, DEV_OPEN_NUM_STATES);
fpi_ssm_start (ssm, open_loop_complete);
}
@ -844,8 +842,7 @@ start_scan (FpImageDevice *dev)
self = FPI_DEVICE_VFS5011 (dev);
self->loop_running = TRUE;
fp_dbg ("creating ssm");
ssm = fpi_ssm_new (FP_DEVICE (dev), activate_loop,
DEV_ACTIVATE_NUM_STATES, dev);
ssm = fpi_ssm_new (FP_DEVICE (dev), activate_loop, DEV_ACTIVATE_NUM_STATES);
fp_dbg ("starting ssm");
fpi_ssm_start (ssm, activate_loop_complete);
fp_dbg ("ssm done, getting out");

View file

@ -45,7 +45,7 @@
* implicit edges linking one state to every other state.
*
* To create an #fpi_ssm, you pass a state handler function and the total number of
* states (4 in the above example) to fpi_ssm_new(). Note that the state numbers
* states (4 in the above example) to fpi_ssm_new (). Note that the state numbers
* start at zero, making them match the first value in a C enumeration.
*
* To start a ssm, you pass in a completion callback function to fpi_ssm_start()
@ -79,7 +79,8 @@ struct _FpiSsm
{
FpDevice *dev;
FpiSsm *parentsm;
void *user_data;
gpointer ssm_data;
GDestroyNotify ssm_data_destroy;
int nr_states;
int cur_state;
gboolean completed;
@ -93,7 +94,6 @@ struct _FpiSsm
* @dev: a #fp_dev fingerprint device
* @handler: the callback function
* @nr_states: the number of states
* @user_data: the user data to pass to callbacks
*
* Allocate a new ssm, with @nr_states states. The @handler callback
* will be called after each state transition.
@ -103,8 +103,7 @@ struct _FpiSsm
FpiSsm *
fpi_ssm_new (FpDevice *dev,
FpiSsmHandlerCallback handler,
int nr_states,
void *user_data)
int nr_states)
{
FpiSsm *machine;
@ -115,23 +114,42 @@ fpi_ssm_new (FpDevice *dev,
machine->nr_states = nr_states;
machine->dev = dev;
machine->completed = TRUE;
machine->user_data = user_data;
return machine;
}
/**
* fpi_ssm_get_user_data:
* fpi_ssm_set_data:
* @machine: an #FpiSsm state machine
* @ssm_data: (nullable): a pointer to machine data
* @ssm_data_destroy: (nullable): #GDestroyNotify for @ssm_data
*
* Sets @machine's data (freeing the existing data, if any).
*
*/
void
fpi_ssm_set_data (FpiSsm *machine,
gpointer ssm_data,
GDestroyNotify ssm_data_destroy)
{
if (machine->ssm_data_destroy && machine->ssm_data)
machine->ssm_data_destroy (machine->ssm_data);
machine->ssm_data = ssm_data;
machine->ssm_data_destroy = ssm_data_destroy;
}
/**
* fpi_ssm_get_data:
* @machine: an #FpiSsm state machine
*
* Retrieve the pointer to user data set when fpi_ssm_new()
* is called.
* Retrieve the pointer to SSM data set with fpi_ssm_set_ssm_data()
*
* Returns: a pointer
*/
void *
fpi_ssm_get_user_data (FpiSsm *machine)
fpi_ssm_get_data (FpiSsm *machine)
{
return machine->user_data;
return machine->ssm_data;
}
/**
@ -147,6 +165,8 @@ fpi_ssm_free (FpiSsm *machine)
if (!machine)
return;
if (machine->ssm_data_destroy)
g_clear_pointer (&machine->ssm_data, machine->ssm_data_destroy);
g_clear_pointer (&machine->error, g_error_free);
g_free (machine);
}
@ -156,7 +176,7 @@ static void
__ssm_call_handler (FpiSsm *machine)
{
fp_dbg ("%p entering state %d", machine, machine->cur_state);
machine->handler (machine, machine->dev, machine->user_data);
machine->handler (machine, machine->dev);
}
/**
@ -180,7 +200,7 @@ fpi_ssm_start (FpiSsm *ssm, FpiSsmCompletedCallback callback)
}
static void
__subsm_complete (FpiSsm *ssm, FpDevice *_dev, void *user_data, GError *error)
__subsm_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
{
FpiSsm *parent = ssm->parentsm;
@ -215,7 +235,7 @@ fpi_ssm_start_subsm (FpiSsm *parent, FpiSsm *child)
* @machine: an #FpiSsm state machine
*
* Mark a ssm as completed successfully. The callback set when creating
* the state machine with fpi_ssm_new() will be called synchronously.
* the state machine with fpi_ssm_new () will be called synchronously.
*/
void
fpi_ssm_mark_completed (FpiSsm *machine)
@ -230,7 +250,7 @@ fpi_ssm_mark_completed (FpiSsm *machine)
{
GError *error = machine->error ? g_error_copy (machine->error) : NULL;
machine->callback (machine, machine->dev, machine->user_data, error);
machine->callback (machine, machine->dev, error);
}
}
@ -349,7 +369,7 @@ fpi_ssm_dup_error (FpiSsm *machine)
* for an fpi_timeout_add() callback, when the state change needs
* to happen after a timeout.
*
* Make sure to pass the #FpiSsm as the `user_data` argument
* Make sure to pass the #FpiSsm as the `ssm_data` argument
* for that fpi_timeout_add() call.
*/
void
@ -366,7 +386,7 @@ fpi_ssm_next_state_timeout_cb (FpDevice *dev,
* fpi_ssm_usb_transfer_cb:
* @transfer: a #FpiUsbTransfer
* @device: a #FpDevice
* @user_data: User data (unused)
* @ssm_data: User data (unused)
* @error: The #GError or %NULL
*
* Can be used in as a #FpiUsbTransfer callback handler to automatically
@ -376,7 +396,7 @@ fpi_ssm_next_state_timeout_cb (FpDevice *dev,
*/
void
fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
gpointer ssm_data, GError *error)
{
g_return_if_fail (transfer->ssm);

View file

@ -38,7 +38,6 @@ typedef struct _FpiSsm FpiSsm;
* FpiSsmCompletedCallback:
* @ssm: a #FpiSsm state machine
* @dev: the #fp_dev fingerprint device
* @user_data: the user data passed to fpi_ssm_new()
* @error: The #GError or %NULL on successful completion
*
* The callback called when a state machine completes successfully,
@ -46,27 +45,23 @@ typedef struct _FpiSsm FpiSsm;
*/
typedef void (*FpiSsmCompletedCallback)(FpiSsm *ssm,
FpDevice *dev,
void *user_data,
GError *error);
/**
* FpiSsmHandlerCallback:
* @ssm: a #FpiSsm state machine
* @dev: the #fp_dev fingerprint device
* @user_data: the user data passed to fpi_ssm_new()
*
* The callback called when a state machine transitions from one
* state to the next, as set when calling fpi_ssm_new().
* state to the next, as set when calling fpi_ssm_new ().
*/
typedef void (*FpiSsmHandlerCallback)(FpiSsm *ssm,
FpDevice *dev,
void *user_data);
FpDevice *dev);
/* for library and drivers */
FpiSsm *fpi_ssm_new (FpDevice *dev,
FpiSsmHandlerCallback handler,
int nr_states,
void *user_data);
int nr_states);
void fpi_ssm_free (FpiSsm *machine);
void fpi_ssm_start (FpiSsm *ssm,
FpiSsmCompletedCallback callback);
@ -80,7 +75,10 @@ void fpi_ssm_jump_to_state (FpiSsm *machine,
void fpi_ssm_mark_completed (FpiSsm *machine);
void fpi_ssm_mark_failed (FpiSsm *machine,
GError *error);
void *fpi_ssm_get_user_data (FpiSsm *machine);
void fpi_ssm_set_data (FpiSsm *machine,
gpointer ssm_data,
GDestroyNotify ssm_data_destroy);
gpointer fpi_ssm_get_data (FpiSsm *machine);
GError * fpi_ssm_get_error (FpiSsm *machine);
GError * fpi_ssm_dup_error (FpiSsm *machine);
int fpi_ssm_get_cur_state (FpiSsm *machine);