mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00: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:
@@ -247,6 +247,7 @@ fpi_ssm_new_full
|
|||||||
fpi_ssm_free
|
fpi_ssm_free
|
||||||
fpi_ssm_start
|
fpi_ssm_start
|
||||||
fpi_ssm_start_subsm
|
fpi_ssm_start_subsm
|
||||||
|
fpi_ssm_set_critical
|
||||||
fpi_ssm_next_state
|
fpi_ssm_next_state
|
||||||
fpi_ssm_next_state_delayed
|
fpi_ssm_next_state_delayed
|
||||||
fpi_ssm_jump_to_state
|
fpi_ssm_jump_to_state
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ struct _FpiSsm
|
|||||||
int start_cleanup;
|
int start_cleanup;
|
||||||
int cur_state;
|
int cur_state;
|
||||||
gboolean completed;
|
gboolean completed;
|
||||||
|
gboolean critical;
|
||||||
gboolean silence;
|
gboolean silence;
|
||||||
GSource *timeout;
|
GSource *timeout;
|
||||||
GError *error;
|
GError *error;
|
||||||
@@ -277,6 +278,10 @@ fpi_ssm_start (FpiSsm *ssm, FpiSsmCompletedCallback callback)
|
|||||||
ssm->cur_state = 0;
|
ssm->cur_state = 0;
|
||||||
ssm->completed = FALSE;
|
ssm->completed = FALSE;
|
||||||
ssm->error = NULL;
|
ssm->error = NULL;
|
||||||
|
|
||||||
|
if (ssm->critical)
|
||||||
|
fpi_device_critical_enter (ssm->dev);
|
||||||
|
|
||||||
__ssm_call_handler (ssm, TRUE);
|
__ssm_call_handler (ssm, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +371,10 @@ fpi_ssm_mark_completed (FpiSsm *machine)
|
|||||||
|
|
||||||
machine->callback (machine, machine->dev, error);
|
machine->callback (machine, machine->dev, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (machine->critical)
|
||||||
|
fpi_device_critical_leave (machine->dev);
|
||||||
|
|
||||||
fpi_ssm_free (machine);
|
fpi_ssm_free (machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,6 +669,23 @@ fpi_ssm_silence_debug (FpiSsm *machine)
|
|||||||
machine->silence = TRUE;
|
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:
|
* fpi_ssm_usb_transfer_cb:
|
||||||
* @transfer: a #FpiUsbTransfer
|
* @transfer: a #FpiUsbTransfer
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ GError * fpi_ssm_dup_error (FpiSsm *machine);
|
|||||||
int fpi_ssm_get_cur_state (FpiSsm *machine);
|
int fpi_ssm_get_cur_state (FpiSsm *machine);
|
||||||
|
|
||||||
void fpi_ssm_silence_debug (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
|
/* Callbacks to be used by the driver instead of implementing their own
|
||||||
* logic.
|
* logic.
|
||||||
|
|||||||
Reference in New Issue
Block a user