libgpiod  1.6.2
Functions
Misc line functions

Functions that didn't fit anywhere else. More...

Collaboration diagram for Misc line functions:

Functions

struct gpiod_line * gpiod_line_get (const char *device, unsigned int offset) GPIOD_API
 Get a GPIO line handle by GPIO chip description and offset. More...
 
struct gpiod_line * gpiod_line_find (const char *name) GPIOD_API
 Find a GPIO line by its name. More...
 
void gpiod_line_close_chip (struct gpiod_line *line) GPIOD_API
 Close a GPIO chip owning this line and release all resources. More...
 
struct gpiod_chip * gpiod_line_get_chip (struct gpiod_line *line) GPIOD_API
 Get the handle to the GPIO chip controlling this line. More...
 

Detailed Description

Functions that didn't fit anywhere else.

Function Documentation

◆ gpiod_line_close_chip()

void gpiod_line_close_chip ( struct gpiod_line *  line)

Close a GPIO chip owning this line and release all resources.

Parameters
lineGPIO line object

After this function returns, the line must no longer be used.

◆ gpiod_line_find()

struct gpiod_line* gpiod_line_find ( const char *  name)

Find a GPIO line by its name.

Parameters
nameName of the GPIO line.
Returns
Returns the GPIO line handle if the line exists in the system or NULL if it couldn't be located or an error occurred.
Attention
GPIO lines are not unique in the linux kernel, neither globally nor within a single chip. This function finds the first line with given name.

If this routine succeeds, the user must manually close the GPIO chip owning this line to avoid memory leaks. If the line could not be found, this functions sets errno to ENOENT.

◆ gpiod_line_get()

struct gpiod_line* gpiod_line_get ( const char *  device,
unsigned int  offset 
)

Get a GPIO line handle by GPIO chip description and offset.

Parameters
deviceString describing the gpiochip.
offsetThe offset of the GPIO line.
Returns
GPIO line handle or NULL if an error occurred.

This routine provides a shorter alternative to calling gpiod_chip_open_lookup and gpiod_chip_get_line.

If this function succeeds, the caller is responsible for closing the associated GPIO chip.

◆ gpiod_line_get_chip()

struct gpiod_chip* gpiod_line_get_chip ( struct gpiod_line *  line)

Get the handle to the GPIO chip controlling this line.

Parameters
lineThe GPIO line object.
Returns
Pointer to the GPIO chip handle controlling this line.