gpio-utils.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <string.h>
  15. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  16. static inline int check_prefix(const char *str, const char *prefix)
  17. {
  18. return strlen(str) > strlen(prefix) &&
  19. strncmp(str, prefix, strlen(prefix)) == 0;
  20. }
  21. int gpiotools_request_linehandle(const char *device_name, unsigned int *lines,
  22. unsigned int nlines, unsigned int flag,
  23. struct gpiohandle_data *data,
  24. const char *consumer_label);
  25. int gpiotools_set_values(const int fd, struct gpiohandle_data *data);
  26. int gpiotools_get_values(const int fd, struct gpiohandle_data *data);
  27. int gpiotools_release_linehandle(const int fd);
  28. int gpiotools_get(const char *device_name, unsigned int line);
  29. int gpiotools_gets(const char *device_name, unsigned int *lines,
  30. unsigned int nlines, struct gpiohandle_data *data);
  31. int gpiotools_set(const char *device_name, unsigned int line,
  32. unsigned int value);
  33. int gpiotools_sets(const char *device_name, unsigned int *lines,
  34. unsigned int nlines, struct gpiohandle_data *data);
  35. #endif /* _GPIO_UTILS_H_ */