libgpiod  1.6.2
Data Structures | Macros | Functions
Operating on multiple lines

Convenience data structures and helper functions for storing and operating on multiple lines at once. More...

Collaboration diagram for Operating on multiple lines:

Data Structures

struct  gpiod_line_bulk
 Helper structure for storing a set of GPIO line objects. More...
 

Macros

#define GPIOD_LINE_BULK_MAX_LINES   64
 Maximum number of GPIO lines that can be requested at once.
 
#define GPIOD_LINE_BULK_INITIALIZER   { { NULL }, 0 }
 Static initializer for GPIO bulk objects. More...
 
#define gpiod_line_bulk_foreach_line(bulk, line, lineptr)
 Iterate over all line handles held by a line bulk object. More...
 
#define gpiod_line_bulk_foreach_line_off(bulk, line, offset)
 Iterate over all line handles held by a line bulk object (integer counter variant). More...
 

Functions

static void gpiod_line_bulk_init (struct gpiod_line_bulk *bulk)
 Initialize a GPIO bulk object. More...
 
static void gpiod_line_bulk_add (struct gpiod_line_bulk *bulk, struct gpiod_line *line)
 Add a single line to a GPIO bulk object. More...
 
static struct gpiod_line * gpiod_line_bulk_get_line (struct gpiod_line_bulk *bulk, unsigned int offset)
 Retrieve the line handle from a line bulk object at given offset. More...
 
static unsigned int gpiod_line_bulk_num_lines (struct gpiod_line_bulk *bulk)
 Retrieve the number of GPIO lines held by this line bulk object. More...
 

Detailed Description

Convenience data structures and helper functions for storing and operating on multiple lines at once.

Macro Definition Documentation

◆ gpiod_line_bulk_foreach_line

#define gpiod_line_bulk_foreach_line (   bulk,
  line,
  lineptr 
)
Value:
for ((lineptr) = (bulk)->lines, (line) = *(lineptr); \
(lineptr) <= (bulk)->lines + ((bulk)->num_lines - 1); \
(lineptr)++, (line) = *(lineptr))

Iterate over all line handles held by a line bulk object.

Parameters
bulkLine bulk object.
lineGPIO line handle. On each iteration, the subsequent line handle is assigned to this pointer.
lineptrPointer to a GPIO line handle used to store the loop state.

Definition at line 788 of file gpiod.h.

◆ gpiod_line_bulk_foreach_line_off

#define gpiod_line_bulk_foreach_line_off (   bulk,
  line,
  offset 
)
Value:
for ((offset) = 0, (line) = (bulk)->lines[0]; \
(offset) < (bulk)->num_lines; \
(offset)++, (line) = (bulk)->lines[(offset)])

Iterate over all line handles held by a line bulk object (integer counter variant).

Parameters
bulkLine bulk object.
lineGPIO line handle. On each iteration, the subsequent line handle is assigned to this pointer.
offsetAn integer variable used to store the loop state.

This is a variant of gpiod_line_bulk_foreach_line which uses an integer variable (either signed or unsigned) to store the loop state. This offset variable is guaranteed to correspond to the offset of the current line in the bulk->lines array.

Definition at line 806 of file gpiod.h.

◆ GPIOD_LINE_BULK_INITIALIZER

#define GPIOD_LINE_BULK_INITIALIZER   { { NULL }, 0 }

Static initializer for GPIO bulk objects.

This macro simply sets the internally held number of lines to 0.

Definition at line 734 of file gpiod.h.

Function Documentation

◆ gpiod_line_bulk_add()

static void gpiod_line_bulk_add ( struct gpiod_line_bulk bulk,
struct gpiod_line *  line 
)
inlinestatic

Add a single line to a GPIO bulk object.

Parameters
bulkLine bulk object.
lineLine to add.

Definition at line 752 of file gpiod.h.

References gpiod_line_bulk::lines, and gpiod_line_bulk::num_lines.

◆ gpiod_line_bulk_get_line()

static struct gpiod_line* gpiod_line_bulk_get_line ( struct gpiod_line_bulk bulk,
unsigned int  offset 
)
inlinestatic

Retrieve the line handle from a line bulk object at given offset.

Parameters
bulkLine bulk object.
offsetLine offset.
Returns
Line handle at given offset.

Definition at line 765 of file gpiod.h.

References gpiod_line_bulk::lines.

◆ gpiod_line_bulk_init()

static void gpiod_line_bulk_init ( struct gpiod_line_bulk bulk)
inlinestatic

Initialize a GPIO bulk object.

Parameters
bulkLine bulk object.

This routine simply sets the internally held number of lines to 0.

Definition at line 742 of file gpiod.h.

References gpiod_line_bulk::num_lines.

◆ gpiod_line_bulk_num_lines()

static unsigned int gpiod_line_bulk_num_lines ( struct gpiod_line_bulk bulk)
inlinestatic

Retrieve the number of GPIO lines held by this line bulk object.

Parameters
bulkLine bulk object.
Returns
Number of lines held by this line bulk.

Definition at line 776 of file gpiod.h.

References gpiod_line_bulk::num_lines.