GCC Code Coverage Report


Directory: ./
File: libfprint/fpi-ssm.h
Date: 2025-12-06 02:24:24
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 0 0 -%
Branches: 26 52 50.0%

Line Branch Exec Source
1 /*
2 * Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
3 * Copyright (C) 2018 Bastien Nocera <hadess@hadess.net>
4 * Copyright (C) 2019 Benjamin Berg <bberg@redhat.com>
5 * Copyright (C) 2019 Marco Trevisan <marco.trevisan@canonical.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #pragma once
23
24 #include "fp-device.h"
25
26 /* async drv <--> lib comms */
27
28 /**
29 * FpiSsm:
30 *
31 * Sequential state machine that iterates sequentially over
32 * a predefined series of states. Can be terminated by either completion or
33 * failure error conditions.
34 */
35 typedef struct _FpiSsm FpiSsm;
36
37 /**
38 * FpiSsmCompletedCallback:
39 * @ssm: a #FpiSsm state machine
40 * @dev: the #fp_dev fingerprint device
41 * @error: (transfer full): The #GError or %NULL on successful completion
42 *
43 * The callback called when a state machine completes successfully,
44 * as set when calling fpi_ssm_start().
45 */
46 typedef void (*FpiSsmCompletedCallback)(FpiSsm *ssm,
47 FpDevice *dev,
48 GError *error);
49
50 /**
51 * FpiSsmHandlerCallback:
52 * @ssm: a #FpiSsm state machine
53 * @dev: the #fp_dev fingerprint device
54 *
55 * The callback called when a state machine transitions from one
56 * state to the next, as set when calling fpi_ssm_new ().
57 */
58 typedef void (*FpiSsmHandlerCallback)(FpiSsm *ssm,
59 FpDevice *dev);
60
61 /* for library and drivers */
62 #define fpi_ssm_new(dev, handler, nr_states) \
63 fpi_ssm_new_full (dev, handler, nr_states, nr_states, #nr_states)
64 FpiSsm *fpi_ssm_new_full (FpDevice *dev,
65 FpiSsmHandlerCallback handler,
66 int nr_states,
67 int start_cleanup,
68 const char *machine_name);
69 void fpi_ssm_free (FpiSsm *machine);
70 void fpi_ssm_start (FpiSsm *ssm,
71 FpiSsmCompletedCallback callback);
72 void fpi_ssm_start_subsm (FpiSsm *parent,
73 FpiSsm *child);
74
75 /* for drivers */
76 void fpi_ssm_next_state (FpiSsm *machine);
77 void fpi_ssm_jump_to_state (FpiSsm *machine,
78 int state);
79 void fpi_ssm_next_state_delayed (FpiSsm *machine,
80 int delay);
81 void fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
82 int state,
83 int delay);
84 void fpi_ssm_cancel_delayed_state_change (FpiSsm *machine);
85 void fpi_ssm_mark_completed (FpiSsm *machine);
86 void fpi_ssm_mark_completed_delayed (FpiSsm *machine,
87 int delay);
88 void fpi_ssm_mark_failed (FpiSsm *machine,
89 GError *error);
90 void fpi_ssm_set_data (FpiSsm *machine,
91 gpointer ssm_data,
92 GDestroyNotify ssm_data_destroy);
93 gpointer fpi_ssm_get_data (FpiSsm *machine);
94 FpDevice * fpi_ssm_get_device (FpiSsm *machine);
95 GError * fpi_ssm_get_error (FpiSsm *machine);
96 GError * fpi_ssm_dup_error (FpiSsm *machine);
97 int fpi_ssm_get_cur_state (FpiSsm *machine);
98
99 void fpi_ssm_silence_debug (FpiSsm *machine);
100
101 /* Callbacks to be used by the driver instead of implementing their own
102 * logic.
103 */
104 typedef struct _FpiUsbTransfer FpiUsbTransfer;
105
106 void fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer,
107 FpDevice *device,
108 gpointer unused_data,
109 GError *error);
110 void fpi_ssm_usb_transfer_with_weak_pointer_cb (FpiUsbTransfer *transfer,
111 FpDevice *device,
112 gpointer weak_ptr,
113 GError *error);
114
115 typedef struct _FpiSpiTransfer FpiSpiTransfer;
116
117 void fpi_ssm_spi_transfer_cb (FpiSpiTransfer *transfer,
118 FpDevice *device,
119 gpointer unused_data,
120 GError *error);
121 void fpi_ssm_spi_transfer_with_weak_pointer_cb (FpiSpiTransfer *transfer,
122 FpDevice *device,
123 gpointer weak_ptr,
124 GError *error);
125
126
26/52
✓ Branch 0 (56→57) taken 1 times.
✗ Branch 1 (56→58) not taken.
✓ Branch 2 (55→56) taken 1 times.
✗ Branch 3 (55→57) not taken.
✓ Branch 4 (73→74) taken 1 times.
✗ Branch 5 (73→75) not taken.
✓ Branch 6 (20→21) taken 1 times.
✗ Branch 7 (20→22) not taken.
✓ Branch 8 (41→42) taken 1 times.
✗ Branch 9 (41→43) not taken.
✗ Branch 10 (21→22) not taken.
✓ Branch 11 (21→23) taken 1 times.
✓ Branch 12 (67→68) taken 1 times.
✗ Branch 13 (67→69) not taken.
✓ Branch 14 (37→38) taken 1 times.
✗ Branch 15 (37→39) not taken.
✓ Branch 16 (28→29) taken 1 times.
✗ Branch 17 (28→30) not taken.
✓ Branch 18 (39→40) taken 1 times.
✗ Branch 19 (39→41) not taken.
✓ Branch 20 (57→58) taken 1 times.
✗ Branch 21 (57→59) not taken.
✓ Branch 22 (29→30) taken 1 times.
✗ Branch 23 (29→31) not taken.
✓ Branch 24 (39→40) taken 1 times.
✗ Branch 25 (39→41) not taken.
✓ Branch 26 (37→38) taken 1 times.
✗ Branch 27 (37→39) not taken.
✓ Branch 28 (39→40) taken 1 times.
✗ Branch 29 (39→41) not taken.
✓ Branch 30 (26→27) taken 1 times.
✗ Branch 31 (26→28) not taken.
✓ Branch 32 (33→34) taken 1 times.
✗ Branch 33 (33→35) not taken.
✓ Branch 34 (19→20) taken 1 times.
✗ Branch 35 (19→21) not taken.
✓ Branch 36 (35→36) taken 1 times.
✗ Branch 37 (35→37) not taken.
✓ Branch 38 (33→34) taken 1 times.
✗ Branch 39 (33→35) not taken.
✓ Branch 40 (19→20) taken 1 times.
✗ Branch 41 (19→21) not taken.
✓ Branch 42 (27→28) taken 1 times.
✗ Branch 43 (27→29) not taken.
✓ Branch 44 (16→17) taken 1 times.
✗ Branch 45 (16→18) not taken.
✓ Branch 46 (16→17) taken 1 times.
✗ Branch 47 (16→18) not taken.
✓ Branch 48 (6→7) taken 1 times.
✗ Branch 49 (6→8) not taken.
✓ Branch 50 (5→6) taken 1 times.
✗ Branch 51 (5→7) not taken.
26 G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpiSsm, fpi_ssm_free)
127