GCC Code Coverage Report


Directory: ./
File: libfprint/fpi-ssm.h
Date: 2024-09-16 14:36:32
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 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 39 taken 1 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 51 taken 1 times.
✗ Branch 52 not taken.
✓ Branch 54 taken 1 times.
✗ Branch 55 not taken.
✓ Branch 57 taken 1 times.
✗ Branch 58 not taken.
✓ Branch 60 taken 1 times.
✗ Branch 61 not taken.
✓ Branch 63 taken 1 times.
✗ Branch 64 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 69 taken 1 times.
✗ Branch 70 not taken.
✓ Branch 72 taken 1 times.
✗ Branch 73 not taken.
✓ Branch 75 taken 1 times.
✗ Branch 76 not taken.
26 G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpiSsm, fpi_ssm_free)
127