Timeouts

Timeouts — Timeout handling helpers

Functions

Types and Values

typedef fpi_timeout

Includes

#include <fpi-poll.h>

Description

Helper functions to schedule a function call to be made after a timeout. This is useful to avoid making blocking calls while waiting for hardware to answer for example.

Functions

fpi_timeout_fn ()

void
(*fpi_timeout_fn) (struct fp_dev *dev,
                   void *data);

The prototype of the callback function for fpi_timeout_add(). Note that after the callback is called, the fpi_timeout structure will be freed.

Parameters

dev

the struct fp_dev passed to fpi_timeout_add()

 

data

the data passed to fpi_timeout_add()

 

fpi_timeout_add ()

fpi_timeout *
fpi_timeout_add (unsigned int msec,
                 fpi_timeout_fn callback,
                 struct fp_dev *dev,
                 void *data);

A timeout is the asynchronous equivalent of sleeping. You create a timeout saying that you'd like to have a function invoked at a certain time in the future.

Note that you should hold onto the return value of this function to cancel it use fpi_timeout_cancel(), otherwise the callback could be called while the driver is being torn down.

This function can be considered to never fail.

Parameters

msec

the time before calling the function, in milliseconds (1/1000ths of a second)

 

callback

function to callback

 

dev

a struct fp_dev

 

data

data to pass to callback , or NULL

 

Returns

an fpi_timeout structure


fpi_timeout_set_name ()

void
fpi_timeout_set_name (fpi_timeout *timeout,
                      const char *name);

Sets a name for a timeout, allowing that name to be printed along with any timeout related debug.

Parameters

timeout

a fpi_timeout

 

name

the name to give the timeout

 

fpi_timeout_cancel ()

void
fpi_timeout_cancel (fpi_timeout *timeout);

Cancels a timeout scheduled with fpi_timeout_add(), and frees the timeout structure.

Parameters

timeout

an fpi_timeout structure

 

Types and Values

fpi_timeout

typedef struct fpi_timeout fpi_timeout;

An opaque structure representing a scheduled function call, created with fpi_timeout_add().