blob: 344ea041f8d4bcaead536d53b3d25ba68ad0dbba [file] [log] [blame]
Linus Walleij6d591c42015-10-21 15:45:54 +02001/*
2 * GPIO tools - utility helpers library for the GPIO tools
3 *
4 * Copyright (C) 2015 Linus Walleij
5 *
6 * Portions copied from iio_utils and lssio:
7 * Copyright (c) 2010 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
8 * Copyright (c) 2008 Jonathan Cameron
9 * *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
13 */
14#ifndef _GPIO_UTILS_H_
15#define _GPIO_UTILS_H_
16
17#include <string.h>
18
Linus Walleij521a2ad2016-02-12 22:25:22 +010019#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
20
Linus Walleij6d591c42015-10-21 15:45:54 +020021static inline int check_prefix(const char *str, const char *prefix)
22{
23 return strlen(str) > strlen(prefix) &&
24 strncmp(str, prefix, strlen(prefix)) == 0;
25}
26
Bamvor Jian Zhange1acec0e2016-10-14 10:48:25 +080027int gpiotools_request_linehandle(const char *device_name, unsigned int *lines,
28 unsigned int nlines, unsigned int flag,
29 struct gpiohandle_data *data,
30 const char *consumer_label);
31int gpiotools_set_values(const int fd, struct gpiohandle_data *data);
32int gpiotools_get_values(const int fd, struct gpiohandle_data *data);
33int gpiotools_release_linehandle(const int fd);
34
35int gpiotools_get(const char *device_name, unsigned int line);
36int gpiotools_gets(const char *device_name, unsigned int *lines,
37 unsigned int nlines, struct gpiohandle_data *data);
38int gpiotools_set(const char *device_name, unsigned int line,
39 unsigned int value);
40int gpiotools_sets(const char *device_name, unsigned int *lines,
41 unsigned int nlines, struct gpiohandle_data *data);
42
Linus Walleij6d591c42015-10-21 15:45:54 +020043#endif /* _GPIO_UTILS_H_ */