mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
ssm: Add API to silence most state change debug messages
Otherwise tightly looping SSMs (primarily SPI transfers), will flood the logs in inappropriate ways.
This commit is contained in:
@@ -260,6 +260,7 @@ fpi_ssm_get_device
|
|||||||
fpi_ssm_get_error
|
fpi_ssm_get_error
|
||||||
fpi_ssm_dup_error
|
fpi_ssm_dup_error
|
||||||
fpi_ssm_get_cur_state
|
fpi_ssm_get_cur_state
|
||||||
|
fpi_ssm_silence_debug
|
||||||
fpi_ssm_spi_transfer_cb
|
fpi_ssm_spi_transfer_cb
|
||||||
fpi_ssm_spi_transfer_with_weak_pointer_cb
|
fpi_ssm_spi_transfer_with_weak_pointer_cb
|
||||||
fpi_ssm_usb_transfer_cb
|
fpi_ssm_usb_transfer_cb
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ struct _FpiSsm
|
|||||||
int start_cleanup;
|
int start_cleanup;
|
||||||
int cur_state;
|
int cur_state;
|
||||||
gboolean completed;
|
gboolean completed;
|
||||||
|
gboolean silence;
|
||||||
GSource *timeout;
|
GSource *timeout;
|
||||||
GError *error;
|
GError *error;
|
||||||
FpiSsmCompletedCallback callback;
|
FpiSsmCompletedCallback callback;
|
||||||
@@ -245,10 +246,11 @@ fpi_ssm_free (FpiSsm *machine)
|
|||||||
|
|
||||||
/* Invoke the state handler */
|
/* Invoke the state handler */
|
||||||
static void
|
static void
|
||||||
__ssm_call_handler (FpiSsm *machine)
|
__ssm_call_handler (FpiSsm *machine, gboolean force_msg)
|
||||||
{
|
{
|
||||||
fp_dbg ("[%s] %s entering state %d", fp_device_get_driver (machine->dev),
|
if (force_msg || !machine->silence)
|
||||||
machine->name, machine->cur_state);
|
fp_dbg ("[%s] %s entering state %d", fp_device_get_driver (machine->dev),
|
||||||
|
machine->name, machine->cur_state);
|
||||||
machine->handler (machine, machine->dev);
|
machine->handler (machine, machine->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +277,7 @@ 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;
|
||||||
__ssm_call_handler (ssm);
|
__ssm_call_handler (ssm, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -346,7 +348,7 @@ fpi_ssm_mark_completed (FpiSsm *machine)
|
|||||||
if (next_state < machine->nr_states)
|
if (next_state < machine->nr_states)
|
||||||
{
|
{
|
||||||
machine->cur_state = next_state;
|
machine->cur_state = next_state;
|
||||||
__ssm_call_handler (machine);
|
__ssm_call_handler (machine, TRUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,7 +462,7 @@ fpi_ssm_next_state (FpiSsm *machine)
|
|||||||
if (machine->cur_state == machine->nr_states)
|
if (machine->cur_state == machine->nr_states)
|
||||||
fpi_ssm_mark_completed (machine);
|
fpi_ssm_mark_completed (machine);
|
||||||
else
|
else
|
||||||
__ssm_call_handler (machine);
|
__ssm_call_handler (machine, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -537,7 +539,7 @@ fpi_ssm_jump_to_state (FpiSsm *machine, int state)
|
|||||||
if (machine->cur_state == machine->nr_states)
|
if (machine->cur_state == machine->nr_states)
|
||||||
fpi_ssm_mark_completed (machine);
|
fpi_ssm_mark_completed (machine);
|
||||||
else
|
else
|
||||||
__ssm_call_handler (machine);
|
__ssm_call_handler (machine, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -642,6 +644,22 @@ fpi_ssm_dup_error (FpiSsm *machine)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fpi_ssm_silence_debug:
|
||||||
|
* @machine: an #FpiSsm state machine
|
||||||
|
*
|
||||||
|
* Turn off state change debug messages from this SSM. This does not disable
|
||||||
|
* all messages, as e.g. the initial state, SSM completion and cleanup states
|
||||||
|
* are still printed out.
|
||||||
|
*
|
||||||
|
* Use if the SSM loops and would flood the debug log otherwise.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
fpi_ssm_silence_debug (FpiSsm *machine)
|
||||||
|
{
|
||||||
|
machine->silence = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fpi_ssm_usb_transfer_cb:
|
* fpi_ssm_usb_transfer_cb:
|
||||||
* @transfer: a #FpiUsbTransfer
|
* @transfer: a #FpiUsbTransfer
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ GError * fpi_ssm_get_error (FpiSsm *machine);
|
|||||||
GError * fpi_ssm_dup_error (FpiSsm *machine);
|
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);
|
||||||
|
|
||||||
/* 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