fpi-device: Make possible to set a DestroyNotify for timeout data
Since GSource data can be automatically cleaned up on source destruction, we can mimic this for the devices timeout easily as well. Add an extra parameter, and let's use this cocci file to adapt all the drivers like magic: @@ expression e1, e2, e3, e4; @@ fpi_device_add_timeout (e1, e2, e3, e4 + , NULL )
This commit is contained in:
parent
0241617713
commit
3ed73aa17c
8 changed files with 23 additions and 21 deletions
|
@ -756,7 +756,7 @@ calibrate_run_state (FpiSsm *ssm, FpDevice *dev)
|
|||
self->calib_status = 0x01;
|
||||
timeout = fpi_device_add_timeout (dev, 50,
|
||||
fpi_ssm_next_state_timeout_cb,
|
||||
ssm);
|
||||
ssm, NULL);
|
||||
g_source_set_name (timeout, "calibrate_run_state");
|
||||
}
|
||||
break;
|
||||
|
@ -1020,7 +1020,7 @@ dev_change_state (FpImageDevice *dev, FpImageDeviceState state)
|
|||
self->dev_state_next = state;
|
||||
timeout = fpi_device_add_timeout (FP_DEVICE (dev), 10,
|
||||
elan_change_state_async,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
|
||||
name = g_strdup_printf ("dev_change_state to %d", state);
|
||||
g_source_set_name (timeout, name);
|
||||
|
|
|
@ -875,7 +875,7 @@ rebootpwr_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
break;
|
||||
|
||||
case REBOOTPWR_PAUSE:
|
||||
fpi_device_add_timeout (_dev, 10, rebootpwr_pause_cb, ssm);
|
||||
fpi_device_add_timeout (_dev, 10, rebootpwr_pause_cb, ssm, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ powerup_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
break;
|
||||
|
||||
case POWERUP_PAUSE:
|
||||
fpi_device_add_timeout (_dev, 10, powerup_pause_cb, ssm);
|
||||
fpi_device_add_timeout (_dev, 10, powerup_pause_cb, ssm, NULL);
|
||||
break;
|
||||
|
||||
case POWERUP_CHALLENGE_RESPONSE:
|
||||
|
@ -1130,7 +1130,7 @@ init_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
self->scanpwr_irq_timeout = fpi_device_add_timeout (_dev,
|
||||
300,
|
||||
init_scanpwr_timeout,
|
||||
ssm);
|
||||
ssm, NULL);
|
||||
break;
|
||||
|
||||
case INIT_DONE:
|
||||
|
|
|
@ -619,7 +619,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
|
|||
|
||||
/* Wait for probable vdev->active changing */
|
||||
fpi_device_add_timeout (dev, VFS_SSM_TIMEOUT,
|
||||
fpi_ssm_next_state_timeout_cb, ssm);
|
||||
fpi_ssm_next_state_timeout_cb, ssm, NULL);
|
||||
break;
|
||||
|
||||
case SSM_NEXT_RECEIVE:
|
||||
|
@ -639,7 +639,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
|
|||
case SSM_WAIT_ANOTHER_SCAN:
|
||||
/* Orange light is on now */
|
||||
fpi_device_add_timeout (dev, VFS_SSM_ORANGE_TIMEOUT,
|
||||
another_scan, ssm);
|
||||
another_scan, ssm, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -376,7 +376,7 @@ async_sleep (unsigned int msec,
|
|||
FpImageDevice *dev)
|
||||
{
|
||||
fpi_device_add_timeout (FP_DEVICE (dev), msec,
|
||||
fpi_ssm_next_state_timeout_cb, ssm);
|
||||
fpi_ssm_next_state_timeout_cb, ssm, NULL);
|
||||
}
|
||||
|
||||
/* Swap ssm states */
|
||||
|
|
|
@ -36,7 +36,7 @@ async_sleep (unsigned int msec,
|
|||
{
|
||||
/* Add timeout */
|
||||
fpi_device_add_timeout (FP_DEVICE (dev), msec,
|
||||
fpi_ssm_next_state_timeout_cb, ssm);
|
||||
fpi_ssm_next_state_timeout_cb, ssm, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -706,7 +706,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
|
|||
case DEV_ACTIVATE_DATA_COMPLETE:
|
||||
fpi_device_add_timeout (_dev, 1,
|
||||
fpi_ssm_next_state_timeout_cb,
|
||||
ssm);
|
||||
ssm, NULL);
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
@ -1475,7 +1475,8 @@ fpi_device_set_scan_type (FpDevice *device,
|
|||
* @device: The #FpDevice
|
||||
* @interval: The interval in milliseconds
|
||||
* @func: The #FpTimeoutFunc to call on timeout
|
||||
* @user_data: User data to pass to the callback
|
||||
* @user_data: (nullable): User data to pass to the callback
|
||||
* @destroy_notify: (nullable): #GDestroyNotify for @user_data
|
||||
*
|
||||
* Register a timeout to run. Drivers should always make sure that timers are
|
||||
* cancelled when appropriate.
|
||||
|
@ -1483,10 +1484,11 @@ fpi_device_set_scan_type (FpDevice *device,
|
|||
* Returns: (transfer none): A newly created and attached #GSource
|
||||
*/
|
||||
GSource *
|
||||
fpi_device_add_timeout (FpDevice *device,
|
||||
gint interval,
|
||||
FpTimeoutFunc func,
|
||||
gpointer user_data)
|
||||
fpi_device_add_timeout (FpDevice *device,
|
||||
gint interval,
|
||||
FpTimeoutFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_notify)
|
||||
{
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
FpDeviceTimeoutSource *source;
|
||||
|
@ -1497,7 +1499,7 @@ fpi_device_add_timeout (FpDevice *device,
|
|||
source->user_data = user_data;
|
||||
|
||||
g_source_attach (&source->source, NULL);
|
||||
g_source_set_callback (&source->source, (GSourceFunc) func, user_data, NULL);
|
||||
g_source_set_callback (&source->source, (GSourceFunc) func, user_data, destroy_notify);
|
||||
g_source_set_ready_time (&source->source,
|
||||
g_source_get_time (&source->source) + interval * (guint64) 1000);
|
||||
priv->sources = g_slist_prepend (priv->sources, source);
|
||||
|
|
|
@ -203,11 +203,11 @@ void fpi_device_get_delete_data (FpDevice *device,
|
|||
GCancellable *fpi_device_get_cancellable (FpDevice *device);
|
||||
|
||||
|
||||
|
||||
GSource * fpi_device_add_timeout (FpDevice *device,
|
||||
gint interval,
|
||||
FpTimeoutFunc func,
|
||||
gpointer user_data);
|
||||
GSource * fpi_device_add_timeout (FpDevice *device,
|
||||
gint interval,
|
||||
FpTimeoutFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_notify);
|
||||
|
||||
void fpi_device_set_nr_enroll_stages (FpDevice *device,
|
||||
gint enroll_stages);
|
||||
|
|
Loading…
Reference in a new issue