1 /* SPDX-License-Identifier: GPL-2.0-only */ 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 * * 11 */ 12 #ifndef _GPIO_UTILS_H_ 13 #define _GPIO_UTILS_H_ 14 15 #include <string.h> 16 17 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 18 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 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 41 #endif /* _GPIO_UTILS_H_ */ 42