mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-12-25 20:00:09 +01:00
ssm: Allow marking an SSM as being critical
This way the SSM cannot be interrupted while it is running.
This commit is contained in:
parent
999bca076c
commit
7b1fe6ec19
3 changed files with 28 additions and 0 deletions
|
|
@ -247,6 +247,7 @@ fpi_ssm_new_full
|
|||
fpi_ssm_free
|
||||
fpi_ssm_start
|
||||
fpi_ssm_start_subsm
|
||||
fpi_ssm_set_critical
|
||||
fpi_ssm_next_state
|
||||
fpi_ssm_next_state_delayed
|
||||
fpi_ssm_jump_to_state
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ struct _FpiSsm
|
|||
int start_cleanup;
|
||||
int cur_state;
|
||||
gboolean completed;
|
||||
gboolean critical;
|
||||
gboolean silence;
|
||||
GSource *timeout;
|
||||
GError *error;
|
||||
|
|
@ -277,6 +278,10 @@ fpi_ssm_start (FpiSsm *ssm, FpiSsmCompletedCallback callback)
|
|||
ssm->cur_state = 0;
|
||||
ssm->completed = FALSE;
|
||||
ssm->error = NULL;
|
||||
|
||||
if (ssm->critical)
|
||||
fpi_device_critical_enter (ssm->dev);
|
||||
|
||||
__ssm_call_handler (ssm, TRUE);
|
||||
}
|
||||
|
||||
|
|
@ -366,6 +371,10 @@ fpi_ssm_mark_completed (FpiSsm *machine)
|
|||
|
||||
machine->callback (machine, machine->dev, error);
|
||||
}
|
||||
|
||||
if (machine->critical)
|
||||
fpi_device_critical_leave (machine->dev);
|
||||
|
||||
fpi_ssm_free (machine);
|
||||
}
|
||||
|
||||
|
|
@ -660,6 +669,23 @@ fpi_ssm_silence_debug (FpiSsm *machine)
|
|||
machine->silence = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_set_critical:
|
||||
* @machine: an #FpiSsm state machine
|
||||
*
|
||||
* Sets up the SSM to hold a critical section in the driver code. See
|
||||
* fpi_device_critical_enter() for more details. This is useful if the SSM must
|
||||
* not be interrupted in order to keep the device in a good state. You can e.g.
|
||||
* guarantee that an image transfer is completed.
|
||||
*
|
||||
* This function must be called before starting the SSM.
|
||||
*/
|
||||
void
|
||||
fpi_ssm_set_critical (FpiSsm *machine)
|
||||
{
|
||||
machine->critical = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_usb_transfer_cb:
|
||||
* @transfer: a #FpiUsbTransfer
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ GError * fpi_ssm_dup_error (FpiSsm *machine);
|
|||
int fpi_ssm_get_cur_state (FpiSsm *machine);
|
||||
|
||||
void fpi_ssm_silence_debug (FpiSsm *machine);
|
||||
void fpi_ssm_set_critical (FpiSsm *machine);
|
||||
|
||||
/* Callbacks to be used by the driver instead of implementing their own
|
||||
* logic.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue