drivers: Use more fpi_ssm_usb_transfer_cb when possible
Replace all the transfer callbacks where we just switch to the next state or fail with fpi_ssm_usb_transfer_cb.
This commit is contained in:
parent
65d0d5e3e0
commit
587131a6bd
8 changed files with 23 additions and 141 deletions
|
@ -116,18 +116,6 @@ stub_capture_stop_cb (FpImageDevice *dev, GError *error,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* check that read succeeded but ignore all data */
|
||||
static void
|
||||
generic_ignore_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (error)
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
}
|
||||
|
||||
static void
|
||||
generic_write_regv_cb (FpImageDevice *dev, GError *error,
|
||||
void *user_data)
|
||||
|
@ -154,7 +142,7 @@ generic_read_ignore_data (FpiSsm *ssm, FpDevice *dev,
|
|||
transfer->ssm = ssm;
|
||||
transfer->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
generic_ignore_data_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
|
||||
/****** FINGER PRESENCE DETECTION ******/
|
||||
|
|
|
@ -182,19 +182,6 @@ generic_write_regv_cb (FpImageDevice *dev, GError *error,
|
|||
fpi_ssm_mark_failed (ssm, error);
|
||||
}
|
||||
|
||||
/* check that read succeeded but ignore all data */
|
||||
static void
|
||||
generic_ignore_data_cb (FpiUsbTransfer *transfer, FpDevice *dev,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
FpiSsm *ssm = transfer->ssm;
|
||||
|
||||
if (error)
|
||||
fpi_ssm_mark_failed (ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state (ssm);
|
||||
}
|
||||
|
||||
/* read the specified number of bytes from the IN endpoint but throw them
|
||||
* away, then increment the SSM */
|
||||
static void
|
||||
|
@ -208,7 +195,7 @@ generic_read_ignore_data (FpiSsm *ssm, FpDevice *dev,
|
|||
transfer->short_is_error = TRUE;
|
||||
fpi_usb_transfer_fill_bulk (transfer, EP_IN, bytes);
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
generic_ignore_data_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
|
||||
/****** IMAGE PROCESSING ******/
|
||||
|
|
|
@ -216,16 +216,6 @@ process_strip_data (FpiSsm *ssm, FpImageDevice *dev,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
capture_reqs_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
}
|
||||
|
||||
static void
|
||||
capture_set_idle_reqs_cb (FpiUsbTransfer *transfer,
|
||||
FpDevice *device, gpointer user_data,
|
||||
|
@ -332,7 +322,7 @@ capture_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
transfer->ssm = ssm;
|
||||
transfer->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
capture_reqs_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -430,36 +420,13 @@ enum activate_states {
|
|||
ACTIVATE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void
|
||||
init_reqs_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
}
|
||||
|
||||
static void
|
||||
init_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
}
|
||||
|
||||
/* TODO: use calibration table, datasheet is rather terse on that
|
||||
* need more info for implementation */
|
||||
static void
|
||||
calibrate_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
fpi_ssm_usb_transfer_cb (transfer, device, user_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -476,7 +443,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
transfer->ssm = ssm;
|
||||
transfer->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
init_reqs_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -487,7 +454,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
fpi_usb_transfer_fill_bulk (transfer, EP_IN, AES2550_EP_IN_BUF_SIZE);
|
||||
transfer->ssm = ssm;
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
init_read_data_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -501,7 +468,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
transfer->ssm = ssm;
|
||||
transfer->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
init_reqs_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -101,16 +101,6 @@ aesX660_read_response (FpiSsm *ssm,
|
|||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, cancel, callback, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
aesX660_send_cmd_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
}
|
||||
|
||||
static void
|
||||
aesX660_read_calibrate_data_cb (FpiUsbTransfer *transfer,
|
||||
FpDevice *device,
|
||||
|
@ -238,12 +228,12 @@ finger_det_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
{
|
||||
case FINGER_DET_SEND_LED_CMD:
|
||||
aesX660_send_cmd (ssm, dev, led_blink_cmd, sizeof (led_blink_cmd),
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case FINGER_DET_SEND_FD_CMD:
|
||||
aesX660_send_cmd_timeout (ssm, dev, wait_for_finger_cmd, sizeof (wait_for_finger_cmd),
|
||||
aesX660_send_cmd_cb, 0);
|
||||
fpi_ssm_usb_transfer_cb, 0);
|
||||
break;
|
||||
|
||||
case FINGER_DET_READ_FD_DATA:
|
||||
|
@ -433,14 +423,14 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
{
|
||||
case CAPTURE_SEND_LED_CMD:
|
||||
aesX660_send_cmd (ssm, _dev, led_solid_cmd, sizeof (led_solid_cmd),
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case CAPTURE_SEND_CAPTURE_CMD:
|
||||
g_byte_array_set_size (priv->stripe_packet, 0);
|
||||
aesX660_send_cmd (ssm, _dev, cls->start_imaging_cmd,
|
||||
cls->start_imaging_cmd_len,
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case CAPTURE_READ_STRIPE_DATA:
|
||||
|
@ -625,13 +615,13 @@ activate_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
priv->init_seq_idx = 0;
|
||||
fp_dbg ("Activate: set idle\n");
|
||||
aesX660_send_cmd (ssm, _dev, set_idle_cmd, sizeof (set_idle_cmd),
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case ACTIVATE_SEND_READ_ID_CMD:
|
||||
fp_dbg ("Activate: read ID\n");
|
||||
aesX660_send_cmd (ssm, _dev, read_id_cmd, sizeof (read_id_cmd),
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case ACTIVATE_READ_ID:
|
||||
|
@ -645,7 +635,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
aesX660_send_cmd (ssm, _dev,
|
||||
priv->init_seq[priv->init_cmd_idx].cmd,
|
||||
priv->init_seq[priv->init_cmd_idx].len,
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case ACTIVATE_READ_INIT_RESPONSE:
|
||||
|
@ -655,7 +645,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case ACTIVATE_SEND_CALIBRATE_CMD:
|
||||
aesX660_send_cmd (ssm, _dev, calibrate_cmd, sizeof (calibrate_cmd),
|
||||
aesX660_send_cmd_cb);
|
||||
fpi_ssm_usb_transfer_cb);
|
||||
break;
|
||||
|
||||
case ACTIVATE_READ_CALIBRATE_DATA:
|
||||
|
|
|
@ -656,17 +656,6 @@ sm_write_regs (FpiSsm *ssm,
|
|||
write_regs_iterate (wrdata);
|
||||
}
|
||||
|
||||
static void
|
||||
sm_write_reg_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (error)
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
sm_write_reg (FpiSsm *ssm,
|
||||
FpImageDevice *dev,
|
||||
|
@ -686,7 +675,8 @@ sm_write_reg (FpiSsm *ssm,
|
|||
1);
|
||||
transfer->short_is_error = TRUE;
|
||||
transfer->ssm = ssm;
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL, sm_write_reg_cb, NULL);
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL,
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
|
||||
transfer->buffer[0] = value;
|
||||
}
|
||||
|
|
|
@ -256,16 +256,6 @@ enum capture_states {
|
|||
CAPTURE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void
|
||||
capture_cmd_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
}
|
||||
|
||||
static void
|
||||
capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
|
@ -304,7 +294,7 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
transfer->ssm = ssm;
|
||||
transfer->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit (transfer, BULK_TIMEOUT, NULL,
|
||||
capture_cmd_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -501,16 +501,6 @@ enum activate_states {
|
|||
ACTIVATE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void
|
||||
init_reqs_ctrl_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (!error)
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
else
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
}
|
||||
|
||||
static void
|
||||
init_reqs_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
|
@ -554,7 +544,7 @@ activate_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
transfer->buffer[0] = '\0';
|
||||
transfer->ssm = ssm;
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL,
|
||||
init_reqs_ctrl_cb, NULL);
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -76,16 +76,6 @@ enum v5s_cmd {
|
|||
|
||||
/***** REGISTER I/O *****/
|
||||
|
||||
static void
|
||||
sm_write_reg_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (error)
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
}
|
||||
|
||||
static void
|
||||
sm_write_reg (FpiSsm *ssm,
|
||||
FpDevice *dev,
|
||||
|
@ -101,18 +91,8 @@ sm_write_reg (FpiSsm *ssm,
|
|||
G_USB_DEVICE_RECIPIENT_DEVICE,
|
||||
reg, value, 0, 0);
|
||||
transfer->ssm = ssm;
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL, sm_write_reg_cb,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
sm_exec_cmd_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
if (error)
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL,
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -130,8 +110,8 @@ sm_exec_cmd (FpiSsm *ssm,
|
|||
G_USB_DEVICE_RECIPIENT_DEVICE,
|
||||
cmd, param, 0, 0);
|
||||
transfer->ssm = ssm;
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL, sm_exec_cmd_cb,
|
||||
NULL);
|
||||
fpi_usb_transfer_submit (transfer, CTRL_TIMEOUT, NULL,
|
||||
fpi_ssm_usb_transfer_cb, NULL);
|
||||
}
|
||||
|
||||
/***** FINGER DETECTION *****/
|
||||
|
|
Loading…
Reference in a new issue