lib: Remove fpi_ssm_set_user_data()
And pass the user_data in fpi_ssm_new() instead.
This commit is contained in:
parent
77defa1d8b
commit
d34d7c26de
19 changed files with 77 additions and 136 deletions
|
@ -168,7 +168,6 @@ fpi_ssm_next_state
|
|||
fpi_ssm_jump_to_state
|
||||
fpi_ssm_mark_completed
|
||||
fpi_ssm_mark_failed
|
||||
fpi_ssm_set_user_data
|
||||
fpi_ssm_get_user_data
|
||||
fpi_ssm_get_error
|
||||
fpi_ssm_get_cur_state
|
||||
|
|
|
@ -715,9 +715,8 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
G_DEBUG_HERE();
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, capture_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -768,8 +767,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
{
|
||||
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ACTIVATE_NUM_STATES, dev);
|
||||
aesdev->read_regs_retry_count = 0;
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
return 0;
|
||||
|
|
|
@ -599,9 +599,8 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
aesdev->no_finger_cnt = 0;
|
||||
/* Reset gain */
|
||||
strip_scan_reqs[4].value = AES2501_ADREFHI_MAX_VALUE;
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
G_DEBUG_HERE();
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, capture_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -806,8 +805,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
{
|
||||
struct aes2501_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ACTIVATE_NUM_STATES, dev);
|
||||
aesdev->read_regs_retry_count = 0;
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
return 0;
|
||||
|
|
|
@ -412,9 +412,8 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
}
|
||||
|
||||
aesdev->heartbeat_cnt = 0;
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
G_DEBUG_HERE();
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, capture_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -582,8 +581,7 @@ static void activate_sm_complete(fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ACTIVATE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -247,8 +247,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), finger_det_run_state, FINGER_DET_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), finger_det_run_state, FINGER_DET_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, finger_det_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -427,9 +426,8 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
G_DEBUG_HERE();
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, capture_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -595,8 +593,7 @@ static void activate_sm_complete(fpi_ssm *ssm)
|
|||
int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ACTIVATE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -487,8 +487,7 @@ static void elan_stop_capture(struct fp_img_dev *dev)
|
|||
|
||||
fpi_ssm *ssm =
|
||||
fpi_ssm_new(FP_DEV(dev), stop_capture_run_state,
|
||||
STOP_CAPTURE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
STOP_CAPTURE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, stop_capture_complete);
|
||||
}
|
||||
|
||||
|
@ -579,8 +578,7 @@ static void elan_capture(struct fp_img_dev *dev)
|
|||
|
||||
elan_dev_reset(elandev);
|
||||
fpi_ssm *ssm =
|
||||
fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, capture_complete);
|
||||
}
|
||||
|
||||
|
@ -712,8 +710,7 @@ static void elan_calibrate(struct fp_img_dev *dev)
|
|||
elandev->calib_atts_left = ELAN_CALIBRATION_ATTEMPTS;
|
||||
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), calibrate_run_state,
|
||||
CALIBRATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
CALIBRATE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, calibrate_complete);
|
||||
}
|
||||
|
||||
|
@ -791,8 +788,7 @@ static void elan_activate(struct fp_img_dev *dev)
|
|||
elan_dev_reset(elandev);
|
||||
|
||||
fpi_ssm *ssm =
|
||||
fpi_ssm_new(FP_DEV(dev), activate_run_state, ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_new(FP_DEV(dev), activate_run_state, ACTIVATE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, activate_complete);
|
||||
}
|
||||
|
||||
|
|
|
@ -743,9 +743,8 @@ static void m_exit_complete(fpi_ssm *ssm)
|
|||
static void m_exit_start(struct fp_img_dev *idev)
|
||||
{
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(idev), m_exit_state,
|
||||
EXIT_NUM_STATES);
|
||||
EXIT_NUM_STATES, idev);
|
||||
fp_dbg("Switching device to idle mode");
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
fpi_ssm_start(ssm, m_exit_complete);
|
||||
}
|
||||
|
||||
|
@ -956,8 +955,7 @@ static void m_finger_complete(fpi_ssm *ssm)
|
|||
if (!fpi_ssm_get_error(ssm)) {
|
||||
fpi_ssm *ssm_cap;
|
||||
ssm_cap = fpi_ssm_new(FP_DEV(idev), m_capture_state,
|
||||
CAP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_cap, idev);
|
||||
CAP_NUM_STATES, idev);
|
||||
fpi_ssm_start(ssm_cap, m_capture_complete);
|
||||
} else {
|
||||
if (fpi_imgdev_get_action_state(idev) != IMG_ACQUIRE_STATE_DEACTIVATING) {
|
||||
|
@ -974,8 +972,7 @@ static void m_finger_complete(fpi_ssm *ssm)
|
|||
static void m_start_fingerdetect(struct fp_img_dev *idev)
|
||||
{
|
||||
fpi_ssm *ssmf;
|
||||
ssmf = fpi_ssm_new(FP_DEV(idev), m_finger_state, FGR_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssmf, idev);
|
||||
ssmf = fpi_ssm_new(FP_DEV(idev), m_finger_state, FGR_NUM_STATES, idev);
|
||||
fpi_ssm_start(ssmf, m_finger_complete);
|
||||
}
|
||||
|
||||
|
@ -1265,8 +1262,7 @@ static void m_tunedc_complete(fpi_ssm *ssm)
|
|||
if (!fpi_ssm_get_error(ssm)) {
|
||||
fpi_ssm *ssm_tune;
|
||||
ssm_tune = fpi_ssm_new(FP_DEV(idev), m_tunevrb_state,
|
||||
TUNEVRB_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_tune, idev);
|
||||
TUNEVRB_NUM_STATES, idev);
|
||||
fpi_ssm_start(ssm_tune, m_tunevrb_complete);
|
||||
} else {
|
||||
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
|
||||
|
@ -1385,8 +1381,7 @@ static void m_init_complete(fpi_ssm *ssm)
|
|||
if (!fpi_ssm_get_error(ssm)) {
|
||||
fpi_ssm *ssm_tune;
|
||||
ssm_tune = fpi_ssm_new(FP_DEV(idev), m_tunedc_state,
|
||||
TUNEDC_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_tune, idev);
|
||||
TUNEDC_NUM_STATES, idev);
|
||||
fpi_ssm_start(ssm_tune, m_tunedc_complete);
|
||||
} else {
|
||||
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
|
||||
|
@ -1416,16 +1411,14 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
|
|||
|
||||
if (dev->dcoffset == 0) {
|
||||
fp_dbg("Tuning device...");
|
||||
ssm = fpi_ssm_new(FP_DEV(idev), m_init_state, INIT_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
ssm = fpi_ssm_new(FP_DEV(idev), m_init_state, INIT_NUM_STATES, idev);
|
||||
fpi_ssm_start(ssm, m_init_complete);
|
||||
} else {
|
||||
fp_dbg("Using previous tuning (DCOFFSET=0x%02X,VRT=0x%02X,"
|
||||
"VRB=0x%02X,GAIN=0x%02X).", dev->dcoffset, dev->vrt,
|
||||
dev->vrb, dev->gain);
|
||||
fpi_imgdev_activate_complete(idev, 0);
|
||||
ssm = fpi_ssm_new(FP_DEV(idev), m_finger_state, FGR_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
ssm = fpi_ssm_new(FP_DEV(idev), m_finger_state, FGR_NUM_STATES, idev);
|
||||
fpi_ssm_start(ssm, m_finger_complete);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1143,14 +1143,13 @@ static void loopsm_run_state(fpi_ssm *ssm)
|
|||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
awfsm = fpi_ssm_new(FP_DEV(dev), awfsm_2016_run_state,
|
||||
AWFSM_2016_NUM_STATES);
|
||||
AWFSM_2016_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1000:
|
||||
awfsm = fpi_ssm_new(FP_DEV(dev), awfsm_1000_run_state,
|
||||
AWFSM_1000_NUM_STATES);
|
||||
AWFSM_1000_NUM_STATES, dev);
|
||||
break;
|
||||
}
|
||||
fpi_ssm_set_user_data(awfsm, dev);
|
||||
fpi_ssm_start_subsm(ssm, awfsm);
|
||||
}
|
||||
break;
|
||||
|
@ -1171,18 +1170,17 @@ static void loopsm_run_state(fpi_ssm *ssm)
|
|||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
capsm = fpi_ssm_new(FP_DEV(dev), capsm_2016_run_state,
|
||||
CAPSM_2016_NUM_STATES);
|
||||
CAPSM_2016_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1000:
|
||||
capsm = fpi_ssm_new(FP_DEV(dev), capsm_1000_run_state,
|
||||
CAPSM_1000_NUM_STATES);
|
||||
CAPSM_1000_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1001:
|
||||
capsm = fpi_ssm_new(FP_DEV(dev), capsm_1001_run_state,
|
||||
CAPSM_1001_NUM_STATES);
|
||||
CAPSM_1001_NUM_STATES, dev);
|
||||
break;
|
||||
}
|
||||
fpi_ssm_set_user_data(capsm, dev);
|
||||
fpi_ssm_start_subsm(ssm, capsm);
|
||||
break;
|
||||
case LOOPSM_CAPTURE:
|
||||
|
@ -1192,19 +1190,18 @@ static void loopsm_run_state(fpi_ssm *ssm)
|
|||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
deinitsm = fpi_ssm_new(FP_DEV(dev), deinitsm_2016_run_state,
|
||||
DEINITSM_2016_NUM_STATES);
|
||||
DEINITSM_2016_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1000:
|
||||
deinitsm = fpi_ssm_new(FP_DEV(dev), deinitsm_1000_run_state,
|
||||
DEINITSM_1000_NUM_STATES);
|
||||
DEINITSM_1000_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1001:
|
||||
deinitsm = fpi_ssm_new(FP_DEV(dev), deinitsm_1001_run_state,
|
||||
DEINITSM_1001_NUM_STATES);
|
||||
DEINITSM_1001_NUM_STATES, dev);
|
||||
break;
|
||||
}
|
||||
sdev->capturing = FALSE;
|
||||
fpi_ssm_set_user_data(deinitsm, dev);
|
||||
fpi_ssm_start_subsm(ssm, deinitsm);
|
||||
break;
|
||||
case LOOPSM_FINAL:
|
||||
|
@ -1278,8 +1275,7 @@ static void initsm_complete(fpi_ssm *ssm)
|
|||
if (r != 0)
|
||||
return;
|
||||
|
||||
sdev->loopsm = fpi_ssm_new(FP_DEV(dev), loopsm_run_state, LOOPSM_NUM_STATES);
|
||||
fpi_ssm_set_user_data(sdev->loopsm, dev);
|
||||
sdev->loopsm = fpi_ssm_new(FP_DEV(dev), loopsm_run_state, LOOPSM_NUM_STATES, dev);
|
||||
fpi_ssm_start(sdev->loopsm, loopsm_complete);
|
||||
}
|
||||
|
||||
|
@ -1314,16 +1310,15 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
|
||||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), initsm_2016_run_state, INITSM_2016_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), initsm_2016_run_state, INITSM_2016_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1000:
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), initsm_1000_run_state, INITSM_1000_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), initsm_1000_run_state, INITSM_1000_NUM_STATES, dev);
|
||||
break;
|
||||
case UPEKSONLY_1001:
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), initsm_1001_run_state, INITSM_1001_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), initsm_1001_run_state, INITSM_1001_NUM_STATES, dev);
|
||||
break;
|
||||
}
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, initsm_complete);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -395,9 +395,8 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
G_DEBUG_HERE();
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, capture_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -405,8 +404,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
{
|
||||
struct upektc_dev *upekdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ACTIVATE_NUM_STATES, dev);
|
||||
upekdev->init_idx = 0;
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
return 0;
|
||||
|
|
|
@ -365,8 +365,7 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
|
||||
upekdev->image_size = 0;
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, capture_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -444,8 +443,7 @@ static void start_deactivation(struct fp_img_dev *dev)
|
|||
|
||||
upekdev->image_size = 0;
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), deactivate_run_state, DEACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), deactivate_run_state, DEACTIVATE_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, deactivate_sm_complete);
|
||||
}
|
||||
|
||||
|
@ -581,8 +579,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
{
|
||||
struct upektc_img_dev *upekdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ACTIVATE_NUM_STATES, dev);
|
||||
upekdev->seq = 0;
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
return 0;
|
||||
|
|
|
@ -736,9 +736,10 @@ static void initsm_run_state(fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static fpi_ssm *initsm_new(struct fp_dev *dev)
|
||||
static fpi_ssm *initsm_new(struct fp_dev *dev,
|
||||
void *user_data)
|
||||
{
|
||||
return fpi_ssm_new(dev, initsm_run_state, INITSM_NUM_STATES);
|
||||
return fpi_ssm_new(dev, initsm_run_state, INITSM_NUM_STATES, user_data);
|
||||
}
|
||||
|
||||
enum deinitsm_states {
|
||||
|
@ -818,7 +819,7 @@ static void deinitsm_state_handler(fpi_ssm *ssm)
|
|||
|
||||
static fpi_ssm *deinitsm_new(struct fp_dev *dev)
|
||||
{
|
||||
return fpi_ssm_new(dev, deinitsm_state_handler, DEINITSM_NUM_STATES);
|
||||
return fpi_ssm_new(dev, deinitsm_state_handler, DEINITSM_NUM_STATES, NULL);
|
||||
}
|
||||
|
||||
static int dev_init(struct fp_dev *dev, unsigned long driver_data)
|
||||
|
@ -923,8 +924,7 @@ static void enroll_start_sm_run_state(fpi_ssm *ssm)
|
|||
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case RUN_INITSM: ;
|
||||
fpi_ssm *initsm = initsm_new(dev);
|
||||
fpi_ssm_set_user_data(initsm, ssm);
|
||||
fpi_ssm *initsm = initsm_new(dev, ssm);
|
||||
fpi_ssm_start(initsm, enroll_start_sm_cb_initsm);
|
||||
break;
|
||||
case ENROLL_INIT: ;
|
||||
|
@ -1129,7 +1129,7 @@ static int enroll_start(struct fp_dev *dev)
|
|||
|
||||
/* do_init state machine first */
|
||||
fpi_ssm *ssm = fpi_ssm_new(dev, enroll_start_sm_run_state,
|
||||
ENROLL_START_NUM_STATES);
|
||||
ENROLL_START_NUM_STATES, NULL);
|
||||
|
||||
upekdev->enroll_passed = FALSE;
|
||||
fpi_ssm_start(ssm, enroll_started);
|
||||
|
@ -1208,8 +1208,7 @@ static void verify_start_sm_run_state(fpi_ssm *ssm)
|
|||
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case VERIFY_RUN_INITSM: ;
|
||||
fpi_ssm *initsm = initsm_new(dev);
|
||||
fpi_ssm_set_user_data(initsm, ssm);
|
||||
fpi_ssm *initsm = initsm_new(dev, ssm);
|
||||
fpi_ssm_start(initsm, verify_start_sm_cb_initsm);
|
||||
break;
|
||||
case VERIFY_INIT: ;
|
||||
|
@ -1409,7 +1408,7 @@ static int verify_start(struct fp_dev *dev)
|
|||
{
|
||||
struct upekts_dev *upekdev = FP_INSTANCE_DATA(dev);
|
||||
fpi_ssm *ssm = fpi_ssm_new(dev, verify_start_sm_run_state,
|
||||
VERIFY_NUM_STATES);
|
||||
VERIFY_NUM_STATES, NULL);
|
||||
upekdev->stop_verify = FALSE;
|
||||
fpi_ssm_start(ssm, verify_started);
|
||||
return 0;
|
||||
|
|
|
@ -1076,8 +1076,7 @@ static void init_run_state(fpi_ssm *ssm)
|
|||
break;
|
||||
case INIT_REBOOT_POWER: ;
|
||||
fpi_ssm *rebootsm = fpi_ssm_new(FP_DEV(dev), rebootpwr_run_state,
|
||||
REBOOTPWR_NUM_STATES);
|
||||
fpi_ssm_set_user_data(rebootsm, dev);
|
||||
REBOOTPWR_NUM_STATES, dev);
|
||||
fpi_ssm_start_subsm(ssm, rebootsm);
|
||||
break;
|
||||
case INIT_CHECK_HWSTAT_POWERDOWN:
|
||||
|
@ -1095,8 +1094,7 @@ static void init_run_state(fpi_ssm *ssm)
|
|||
urudev->irq_cb = init_scanpwr_irq_cb;
|
||||
|
||||
fpi_ssm *powerupsm = fpi_ssm_new(FP_DEV(dev), powerup_run_state,
|
||||
POWERUP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(powerupsm, dev);
|
||||
POWERUP_NUM_STATES, dev);
|
||||
fpi_ssm_start_subsm(ssm, powerupsm);
|
||||
break;
|
||||
case INIT_AWAIT_SCAN_POWER:
|
||||
|
@ -1169,8 +1167,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
|
||||
urudev->scanpwr_irq_timeouts = 0;
|
||||
urudev->activate_state = state;
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), init_run_state, INIT_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), init_run_state, INIT_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, activate_initsm_complete);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1223,8 +1220,7 @@ static int execute_state_change(struct fp_img_dev *dev)
|
|||
urudev->img_data = g_malloc(sizeof(struct uru4k_image));
|
||||
urudev->img_enc_seed = rand();
|
||||
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), imaging_run_state, IMAGING_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), imaging_run_state, IMAGING_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, imaging_complete);
|
||||
|
||||
return write_reg(dev, REG_MODE, MODE_CAPTURE,
|
||||
|
|
|
@ -315,8 +315,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
{
|
||||
struct v5s_dev *vdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), loop_run_state,
|
||||
LOOP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
LOOP_NUM_STATES, dev);
|
||||
vdev->deactivating = FALSE;
|
||||
fpi_ssm_start(ssm, loopsm_complete);
|
||||
vdev->loop_running = TRUE;
|
||||
|
|
|
@ -312,8 +312,7 @@ static void clear_ep2(fpi_ssm *ssm)
|
|||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
fpi_ssm *subsm =
|
||||
fpi_ssm_new(FP_DEV(idev), clear_ep2_ssm, SUBSM1_STATES);
|
||||
fpi_ssm_set_user_data(subsm, idev);
|
||||
fpi_ssm_new(FP_DEV(idev), clear_ep2_ssm, SUBSM1_STATES, idev);
|
||||
fpi_ssm_start_subsm(ssm, subsm);
|
||||
}
|
||||
|
||||
|
@ -390,8 +389,7 @@ static void send_control_packet(fpi_ssm *ssm)
|
|||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
fpi_ssm *subsm =
|
||||
fpi_ssm_new(FP_DEV(idev), send_control_packet_ssm, SUBSM2_STATES);
|
||||
fpi_ssm_set_user_data(subsm, idev);
|
||||
fpi_ssm_new(FP_DEV(idev), send_control_packet_ssm, SUBSM2_STATES, idev);
|
||||
fpi_ssm_start_subsm(ssm, subsm);
|
||||
}
|
||||
|
||||
|
@ -691,8 +689,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
|
|||
vdev->need_report = 1;
|
||||
vdev->ssm_active = 1;
|
||||
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(idev), activate_ssm, SSM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(idev), activate_ssm, SSM_STATES, idev);
|
||||
fpi_ssm_start(ssm, dev_activate_callback);
|
||||
return 0;
|
||||
}
|
||||
|
@ -738,8 +735,7 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
|
|||
fp_dev_set_instance_data(FP_DEV(idev), vdev);
|
||||
|
||||
/* Clearing previous device state */
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(idev), activate_ssm, SSM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(idev), activate_ssm, SSM_STATES, idev);
|
||||
fpi_ssm_start(ssm, dev_open_callback);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -536,8 +536,7 @@ static void m_swap(fpi_ssm *ssm, unsigned char *data, size_t length)
|
|||
vdev->length = length;
|
||||
|
||||
/* Start swap ssm */
|
||||
subsm = fpi_ssm_new(FP_DEV(dev), m_swap_state, M_SWAP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(subsm, dev);
|
||||
subsm = fpi_ssm_new(FP_DEV(dev), m_swap_state, M_SWAP_NUM_STATES, dev);
|
||||
fpi_ssm_start_subsm(ssm, subsm);
|
||||
}
|
||||
|
||||
|
@ -1429,8 +1428,7 @@ static void m_init_complete(fpi_ssm *ssm)
|
|||
fpi_imgdev_activate_complete(dev, 0);
|
||||
|
||||
/* Start loop ssm */
|
||||
ssm_loop = fpi_ssm_new(FP_DEV(dev), m_loop_state, M_LOOP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_loop, dev);
|
||||
ssm_loop = fpi_ssm_new(FP_DEV(dev), m_loop_state, M_LOOP_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm_loop, m_loop_complete);
|
||||
}
|
||||
|
||||
|
@ -1464,8 +1462,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
vdev->enroll_stage = 0;
|
||||
|
||||
/* Start init ssm */
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), m_init_state, M_INIT_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), m_init_state, M_INIT_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, m_init_complete);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -191,8 +191,7 @@ static void m_init_complete(fpi_ssm *ssm)
|
|||
fpi_imgdev_activate_complete(dev, 0);
|
||||
|
||||
/* Start loop ssm */
|
||||
ssm_loop = fpi_ssm_new(FP_DEV(dev), m_loop_state, M_LOOP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_loop, dev);
|
||||
ssm_loop = fpi_ssm_new(FP_DEV(dev), m_loop_state, M_LOOP_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm_loop, m_loop_complete);
|
||||
}
|
||||
|
||||
|
@ -206,8 +205,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
fpi_ssm *ssm;
|
||||
|
||||
/* Start init ssm */
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), m_init_state, 1);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), m_init_state, 1, dev);
|
||||
fpi_ssm_start(ssm, m_init_complete);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -238,8 +238,8 @@ static void usb_exchange_async(fpi_ssm *ssm,
|
|||
{
|
||||
fpi_ssm *subsm = fpi_ssm_new(FP_DEV(data->device),
|
||||
usbexchange_loop,
|
||||
data->stepcount);
|
||||
fpi_ssm_set_user_data(subsm, data);
|
||||
data->stepcount,
|
||||
data);
|
||||
fpi_ssm_start_subsm(ssm, subsm);
|
||||
}
|
||||
|
||||
|
@ -830,8 +830,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
|
|||
}
|
||||
|
||||
fpi_ssm *ssm;
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), open_loop, DEV_OPEN_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), open_loop, DEV_OPEN_NUM_STATES, dev);
|
||||
fpi_ssm_start(ssm, open_loop_complete);
|
||||
|
||||
return 0;
|
||||
|
@ -858,8 +857,7 @@ static void start_scan(struct fp_img_dev *dev)
|
|||
data = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||
data->loop_running = TRUE;
|
||||
fp_dbg("creating ssm");
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), activate_loop, DEV_ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
ssm = fpi_ssm_new(FP_DEV(dev), activate_loop, DEV_ACTIVATE_NUM_STATES, dev);
|
||||
fp_dbg("starting ssm");
|
||||
fpi_ssm_start(ssm, activate_loop_complete);
|
||||
fp_dbg("ssm done, getting out");
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
struct fpi_ssm {
|
||||
struct fp_dev *dev;
|
||||
fpi_ssm *parentsm;
|
||||
void *priv;
|
||||
void *user_data;
|
||||
int nr_states;
|
||||
int cur_state;
|
||||
gboolean completed;
|
||||
|
@ -92,14 +92,17 @@ struct fpi_ssm {
|
|||
* @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.
|
||||
*
|
||||
* Returns: a new #fpi_ssm state machine
|
||||
*/
|
||||
fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states)
|
||||
fpi_ssm *fpi_ssm_new(struct fp_dev *dev,
|
||||
ssm_handler_fn handler,
|
||||
int nr_states,
|
||||
void *user_data)
|
||||
{
|
||||
fpi_ssm *machine;
|
||||
BUG_ON(nr_states < 1);
|
||||
|
@ -109,6 +112,7 @@ fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
|||
machine->nr_states = nr_states;
|
||||
machine->dev = dev;
|
||||
machine->completed = TRUE;
|
||||
machine->user_data = user_data;
|
||||
return machine;
|
||||
}
|
||||
|
||||
|
@ -127,34 +131,19 @@ fpi_ssm_get_dev(fpi_ssm *machine)
|
|||
return machine->dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_set_user_data:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
* @user_data: a pointer to user data
|
||||
*
|
||||
* Set a user data pointer in the #fpi_ssm structure, to be
|
||||
* retrieved with fpi_ssm_get_user_data() at a later point.
|
||||
*/
|
||||
void
|
||||
fpi_ssm_set_user_data(fpi_ssm *machine,
|
||||
void *user_data)
|
||||
{
|
||||
machine->priv = user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_get_user_data:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Retrieve the pointer to user data set with
|
||||
* fpi_ssm_set_user_data().
|
||||
* Retrieve the pointer to user data set when fpi_ssm_new()
|
||||
* is called.
|
||||
*
|
||||
* Returns: a pointer
|
||||
*/
|
||||
void *
|
||||
fpi_ssm_get_user_data(fpi_ssm *machine)
|
||||
{
|
||||
return machine->priv;
|
||||
return machine->user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,8 +58,10 @@ typedef void (*ssm_completed_fn)(fpi_ssm *ssm);
|
|||
typedef void (*ssm_handler_fn)(fpi_ssm *ssm);
|
||||
|
||||
/* for library and drivers */
|
||||
fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states);
|
||||
fpi_ssm *fpi_ssm_new(struct fp_dev *dev,
|
||||
ssm_handler_fn handler,
|
||||
int nr_states,
|
||||
void *user_data);
|
||||
void fpi_ssm_free(fpi_ssm *machine);
|
||||
void fpi_ssm_start(fpi_ssm *ssm, ssm_completed_fn callback);
|
||||
void fpi_ssm_start_subsm(fpi_ssm *parent, fpi_ssm *child);
|
||||
|
@ -70,8 +72,6 @@ void fpi_ssm_jump_to_state(fpi_ssm *machine, int state);
|
|||
void fpi_ssm_mark_completed(fpi_ssm *machine);
|
||||
void fpi_ssm_mark_failed(fpi_ssm *machine, int error);
|
||||
struct fp_dev *fpi_ssm_get_dev(fpi_ssm *machine);
|
||||
void fpi_ssm_set_user_data(fpi_ssm *machine,
|
||||
void *user_data);
|
||||
void *fpi_ssm_get_user_data(fpi_ssm *machine);
|
||||
int fpi_ssm_get_error(fpi_ssm *machine);
|
||||
int fpi_ssm_get_cur_state(fpi_ssm *machine);
|
||||
|
|
Loading…
Reference in a new issue