Commit 2e035a7f authored by Bastien Nocera's avatar Bastien Nocera

lib: Make fpi_ssm opaque for drivers

We shouldn't access fpi_ssm struct fields directly in drivers, so add
accessor and setter functions for the common uses.
parent 17577175
......@@ -130,6 +130,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
struct fp_dev *dev;
int r;
if (!transfer) {
......@@ -138,7 +139,8 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
}
data = g_malloc(bytes);
libusb_fill_bulk_transfer(transfer, ssm->dev->udev, EP_IN, data, bytes,
dev = fpi_ssm_get_dev(ssm);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, bytes,
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
......@@ -556,7 +558,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
{
unsigned char *stripdata;
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int sum, i;
......@@ -643,11 +645,11 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS:
fp_dbg("write reqs");
aes_write_regv(dev, capture_reqs, G_N_ELEMENTS(capture_reqs),
......@@ -690,14 +692,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
G_DEBUG_HERE();
if (aesdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
......@@ -715,7 +717,7 @@ static void start_capture(struct fp_img_dev *dev)
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
......@@ -738,11 +740,11 @@ enum activate_states {
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
/* activation on aes1610 seems much more straightforward compared to aes2501 */
/* verify theres anything missing here */
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT:
fp_dbg("write init");
aes_write_regv(dev, init, G_N_ELEMENTS(init), generic_write_regv_cb, ssm);
......@@ -753,11 +755,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
/* jump to finger detection */
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
......@@ -767,7 +769,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct aes1610_dev *aesdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
aesdev->read_regs_retry_count = 0;
fpi_ssm_start(ssm, activate_sm_complete);
return 0;
......
......@@ -209,6 +209,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
if (!transfer) {
......@@ -217,7 +218,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
}
data = g_malloc(bytes);
libusb_fill_bulk_transfer(transfer, ssm->dev->udev, EP_IN, data, bytes,
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, bytes,
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
......@@ -436,7 +437,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
{
unsigned char *stripdata;
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int sum;
......@@ -521,11 +522,11 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS_1:
aes_write_regv(dev, capture_reqs_1, G_N_ELEMENTS(capture_reqs_1),
generic_write_regv_cb, ssm);
......@@ -572,14 +573,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
G_DEBUG_HERE();
if (aesdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
......@@ -600,7 +601,7 @@ static void start_capture(struct fp_img_dev *dev)
strip_scan_reqs[4].value = AES2501_ADREFHI_MAX_VALUE;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
......@@ -738,7 +739,7 @@ static void activate_init3_cb(struct fp_img_dev *dev, int result,
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
/* 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
......@@ -759,7 +760,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
aes_write_regv(init_4);
*/
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT_1:
aes_write_regv(dev, init_1, G_N_ELEMENTS(init_1),
generic_write_regv_cb, ssm);
......@@ -792,11 +793,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
......@@ -806,7 +807,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct aes2501_dev *aesdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
aesdev->read_regs_retry_count = 0;
fpi_ssm_start(ssm, activate_sm_complete);
return 0;
......
......@@ -203,7 +203,7 @@ enum capture_states {
static int process_strip_data(struct fpi_ssm *ssm, unsigned char *data)
{
unsigned char *stripdata;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
struct fpi_frame *stripe;
int len;
......@@ -245,7 +245,7 @@ static void capture_reqs_cb(struct libusb_transfer *transfer)
static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
......@@ -273,7 +273,7 @@ static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
static void capture_read_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int r;
......@@ -325,10 +325,10 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS:
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
......@@ -388,14 +388,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
fp_dbg("Capture completed");
if (aesdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
......@@ -414,7 +414,7 @@ static void start_capture(struct fp_img_dev *dev)
aesdev->heartbeat_cnt = 0;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
......@@ -485,10 +485,10 @@ static void calibrate_read_data_cb(struct libusb_transfer *transfer)
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT:
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
......@@ -570,11 +570,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
......@@ -583,7 +583,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_sm_complete);
return 0;
}
......
......@@ -40,7 +40,7 @@ static void complete_deactivation(struct fp_img_dev *dev);
static void aesX660_send_cmd_timeout(struct fpi_ssm *ssm, const unsigned char *cmd,
size_t cmd_len, libusb_transfer_cb_fn callback, int timeout)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
int r;
......@@ -69,7 +69,7 @@ static void aesX660_send_cmd(struct fpi_ssm *ssm, const unsigned char *cmd,
static void aesX660_read_response(struct fpi_ssm *ssm, size_t buf_len,
libusb_transfer_cb_fn callback)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
......@@ -144,7 +144,7 @@ enum finger_det_states {
static void finger_det_read_fd_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
......@@ -197,9 +197,9 @@ static void finger_det_set_idle_cmd_cb(struct libusb_transfer *transfer)
static void finger_det_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
int err = ssm->error;
int err = fpi_ssm_get_error(ssm);
fp_dbg("Finger detection completed");
fpi_imgdev_report_finger_status(dev, TRUE);
......@@ -217,7 +217,7 @@ static void finger_det_sm_complete(struct fpi_ssm *ssm)
static void finger_det_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case FINGER_DET_SEND_LED_CMD:
aesX660_send_cmd(ssm, led_blink_cmd, sizeof(led_blink_cmd),
aesX660_send_cmd_cb);
......@@ -248,7 +248,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
}
ssm = fpi_ssm_new(dev->dev, finger_det_run_state, FINGER_DET_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, finger_det_sm_complete);
}
......@@ -267,7 +267,7 @@ static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data)
{
struct fpi_frame *stripe;
unsigned char *stripdata;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
stripe = g_malloc(aesdev->assembling_ctx->frame_width * FRAME_HEIGHT / 2 + sizeof(struct fpi_frame)); /* 4 bpp */
......@@ -295,7 +295,7 @@ static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data)
static void capture_set_idle_cmd_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
......@@ -321,7 +321,7 @@ static void capture_set_idle_cmd_cb(struct libusb_transfer *transfer)
static void capture_read_stripe_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int finger_missing = 0;
......@@ -373,10 +373,10 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_SEND_LED_CMD:
aesX660_send_cmd(ssm, led_solid_cmd, sizeof(led_solid_cmd),
aesX660_send_cmd_cb);
......@@ -402,9 +402,9 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
int err = ssm->error;
int err = fpi_ssm_get_error(ssm);
fp_dbg("Capture completed");
fpi_ssm_free(ssm);
......@@ -429,7 +429,7 @@ static void start_capture(struct fp_img_dev *dev)
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
......@@ -449,7 +449,7 @@ enum activate_states {
static void activate_read_id_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
......@@ -500,7 +500,7 @@ out:
static void activate_read_init_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
......@@ -536,10 +536,10 @@ out:
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_SET_IDLE:
aesdev->init_seq_idx = 0;
fp_dbg("Activate: set idle\n");
......@@ -582,8 +582,8 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
int err = ssm->error;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int err = fpi_ssm_get_error(ssm);
fp_dbg("status %d", err);
fpi_imgdev_activate_complete(dev, err);
fpi_ssm_free(ssm);
......@@ -596,7 +596,7 @@ int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_sm_complete);
return 0;
}
......
......@@ -161,7 +161,7 @@ static void elan_submit_image(struct fp_img_dev *dev)
static void elan_cmd_done(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
......@@ -176,7 +176,7 @@ static void elan_cmd_done(struct fpi_ssm *ssm)
static void elan_cmd_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
......@@ -218,7 +218,7 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
static void elan_cmd_read(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
int response_len = elandev->cmds[elandev->cmd_idx].response_len;
......@@ -251,7 +251,7 @@ static void elan_cmd_read(struct fpi_ssm *ssm)
static void elan_run_next_cmd(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
......@@ -278,7 +278,7 @@ static void elan_run_next_cmd(struct fpi_ssm *ssm)
static void elan_run_cmds(struct fpi_ssm *ssm, const struct elan_cmd *cmds,
size_t cmds_len, int cmd_timeout)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
......@@ -298,7 +298,7 @@ enum deactivate_states {
static void elan_deactivate_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEACTIVATE:
elan_run_cmds(ssm, deactivate_cmds, deactivate_cmds_len,
ELAN_CMD_TIMEOUT);
......@@ -308,7 +308,7 @@ static void elan_deactivate_run_state(struct fpi_ssm *ssm)
static void deactivate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fpi_imgdev_deactivate_complete(dev);
}
......@@ -323,7 +323,7 @@ static void elan_deactivate(struct fp_img_dev *dev)
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, elan_deactivate_run_state,
DEACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, deactivate_complete);
}
......@@ -337,10 +337,10 @@ enum capture_states {
static void elan_capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_START:
elan_run_cmds(ssm, capture_start_cmds, capture_start_cmds_len,
ELAN_CMD_TIMEOUT);
......@@ -377,7 +377,7 @@ static void elan_capture_async(void *data)
static void capture_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
......@@ -386,9 +386,9 @@ static void capture_complete(struct fpi_ssm *ssm)
elan_deactivate(dev);
/* either max frames captured or timed out waiting for the next frame */
else if (!ssm->error
|| (ssm->error == -ETIMEDOUT
&& ssm->cur_state == CAPTURE_WAIT_FINGER))
else if (!fpi_ssm_get_error(ssm)
|| (fpi_ssm_get_error(ssm) == -ETIMEDOUT
&& fpi_ssm_get_cur_state(ssm) == CAPTURE_WAIT_FINGER))
if (elandev->num_frames >= ELAN_MIN_FRAMES) {
elan_submit_image(dev);
fpi_imgdev_report_finger_status(dev, FALSE);
......@@ -422,7 +422,7 @@ static void elan_capture(struct fp_img_dev *dev)
elan_dev_reset(elandev);
struct fpi_ssm *ssm =
fpi_ssm_new(dev->dev, elan_capture_run_state, CAPTURE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_complete);
}
......@@ -438,7 +438,7 @@ enum calibrate_states {
static void elan_calibrate_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CALIBRATE_START_1:
case CALIBRATE_START_2:
elan_run_cmds(ssm, calibrate_start_cmds,
......@@ -457,17 +457,17 @@ static void elan_calibrate_run_state(struct fpi_ssm *ssm)
static void calibrate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
if (elandev->deactivating)
elan_deactivate(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else {
fpi_imgdev_activate_complete(dev, ssm->error);
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
elan_capture(dev);
}
fpi_ssm_free(ssm);
......@@ -482,7 +482,7 @@ static void elan_calibrate(struct fp_img_dev *dev)
elan_dev_reset(elandev);
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, elan_calibrate_run_state,
CALIBRATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, calibrate_complete);
}
......@@ -497,10 +497,10 @@ enum activate_states {
static void elan_activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_GET_SENSOR_DIM:
elan_run_cmds(ssm, get_sensor_dim_cmds, get_sensor_dim_cmds_len,
ELAN_CMD_TIMEOUT);
......@@ -527,15 +527,15 @@ static void elan_activate_run_state(struct fpi_ssm *ssm)
static void activate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
if (elandev->deactivating)
elan_deactivate(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
elan_calibrate(dev);
fpi_ssm_free(ssm);
......@@ -550,7 +550,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
elan_dev_reset(elandev);
struct fpi_ssm *ssm =
fpi_ssm_new(dev->dev, elan_activate_run_state, ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_complete);
return 0;
......
......@@ -670,7 +670,7 @@ static int async_tx(struct fp_img_dev *idev, unsigned int ep, void *cb,
static void async_tx_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
......@@ -701,10 +701,10 @@ static void async_tx_cb(struct libusb_transfer *transfer)
static void m_exit_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case EXIT_SET_REGS_REQ:
msg_set_regs(dev, 4, REG_VCO_CONTROL, REG_VCO_IDLE,
REG_MODE_CONTROL, REG_MODE_SLEEP);
......@@ -717,7 +717,7 @@ static void m_exit_state(struct fpi_ssm *ssm)
fpi_ssm_mark_completed(ssm);
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
......@@ -729,9 +729,9 @@ err:
static void m_exit_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
if (ssm->error) {
if (fpi_ssm_get_error(ssm)) {
fp_err("Error switching the device to idle state");
} else {
fp_dbg("The device is now in idle state");
......@@ -745,13 +745,13 @@ static void m_exit_start(struct fp_img_dev *idev)
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, m_exit_state,
EXIT_NUM_STATES);
fp_dbg("Switching device to idle mode");
ssm->priv = idev;
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, m_exit_complete);
}
static void m_capture_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (dev->is_active == FALSE) {
......@@ -759,7 +759,7 @@ static void m_capture_state(struct fpi_ssm *ssm)
return;