blob: cf37f13f3dcbcdeaf9b4cb219077f9bd04788153 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Walleij6d591c42015-10-21 15:45:54 +02002/*
3 * GPIO tools - utility helpers library for the GPIO tools
4 *
5 * Copyright (C) 2015 Linus Walleij
6 *
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
10 * *
Linus Walleij6d591c42015-10-21 15:45:54 +020011 */
12#ifndef _GPIO_UTILS_H_
13#define _GPIO_UTILS_H_
14
15#include <string.h>
16
Linus Walleij521a2ad2016-02-12 22:25:22 +010017#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
18
Linus Walleij6d591c42015-10-21 15:45:54 +020019static inline int check_prefix(const char *str, const char *prefix)
20{
21 return strlen(str) > strlen(prefix) &&
22 strncmp(str, prefix, strlen(prefix)) == 0;
23}
24
Bamvor Jian Zhange1acec0e2016-10-14 10:48:25 +080025int 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);
29int gpiotools_set_values(const int fd, struct gpiohandle_data *data);
30int gpiotools_get_values(const int fd, struct gpiohandle_data *data);
31int gpiotools_release_linehandle(const int fd);
32
33int gpiotools_get(const char *device_name, unsigned int line);
34int gpiotools_gets(const char *device_name, unsigned int *lines,
35 unsigned int nlines, struct gpiohandle_data *data);
36int gpiotools_set(const char *device_name, unsigned int line,
37 unsigned int value);
38int gpiotools_sets(const char *device_name, unsigned int *lines,
39 unsigned int nlines, struct gpiohandle_data *data);
40
Linus Walleij6d591c42015-10-21 15:45:54 +020041#endif /* _GPIO_UTILS_H_ */