1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * GPIO tools - utility helpers library for the GPIO tools
5 * Copyright (C) 2015 Linus Walleij
7 * Portions copied from iio_utils and lssio:
8 * Copyright (c) 2010 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
9 * Copyright (c) 2008 Jonathan Cameron
12 #ifndef _GPIO_UTILS_H_
13 #define _GPIO_UTILS_H_
17 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
19 static inline int check_prefix(const char *str
, const char *prefix
)
21 return strlen(str
) > strlen(prefix
) &&
22 strncmp(str
, prefix
, strlen(prefix
)) == 0;
25 int gpiotools_request_linehandle(const char *device_name
, unsigned int *lines
,
26 unsigned int nlines
, unsigned int flag
,
27 struct gpiohandle_data
*data
,
28 const char *consumer_label
);
29 int gpiotools_set_values(const int fd
, struct gpiohandle_data
*data
);
30 int gpiotools_get_values(const int fd
, struct gpiohandle_data
*data
);
31 int gpiotools_release_linehandle(const int fd
);
33 int gpiotools_get(const char *device_name
, unsigned int line
);
34 int gpiotools_gets(const char *device_name
, unsigned int *lines
,
35 unsigned int nlines
, struct gpiohandle_data
*data
);
36 int gpiotools_set(const char *device_name
, unsigned int line
,
38 int gpiotools_sets(const char *device_name
, unsigned int *lines
,
39 unsigned int nlines
, struct gpiohandle_data
*data
);
41 #endif /* _GPIO_UTILS_H_ */