Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 2 | /* |
| 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 Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 11 | */ |
| 12 | #ifndef _GPIO_UTILS_H_ |
| 13 | #define _GPIO_UTILS_H_ |
| 14 | |
| 15 | #include <string.h> |
| 16 | |
Linus Walleij | 521a2ad | 2016-02-12 22:25:22 +0100 | [diff] [blame] | 17 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
| 18 | |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 19 | static 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 Zhang | e1acec0e | 2016-10-14 10:48:25 +0800 | [diff] [blame] | 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); |
| 32 | |
| 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, |
| 37 | unsigned int value); |
| 38 | int gpiotools_sets(const char *device_name, unsigned int *lines, |
| 39 | unsigned int nlines, struct gpiohandle_data *data); |
| 40 | |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 41 | #endif /* _GPIO_UTILS_H_ */ |