iio_core.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* The industrial I/O core function defs.
  2. *
  3. * Copyright (c) 2008 Jonathan Cameron
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * These definitions are meant for use only within the IIO core, not individual
  10. * drivers.
  11. */
  12. #ifndef _IIO_CORE_H_
  13. #define _IIO_CORE_H_
  14. #include <linux/kernel.h>
  15. #include <linux/device.h>
  16. struct iio_chan_spec;
  17. struct iio_dev;
  18. extern struct device_type iio_device_type;
  19. int __iio_add_chan_devattr(const char *postfix,
  20. struct iio_chan_spec const *chan,
  21. ssize_t (*func)(struct device *dev,
  22. struct device_attribute *attr,
  23. char *buf),
  24. ssize_t (*writefunc)(struct device *dev,
  25. struct device_attribute *attr,
  26. const char *buf,
  27. size_t len),
  28. u64 mask,
  29. enum iio_shared_by shared_by,
  30. struct device *dev,
  31. struct list_head *attr_list);
  32. void iio_free_chan_devattr_list(struct list_head *attr_list);
  33. ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
  34. /* Event interface flags */
  35. #define IIO_BUSY_BIT_POS 1
  36. #ifdef CONFIG_IIO_BUFFER
  37. struct poll_table_struct;
  38. unsigned int iio_buffer_poll(struct file *filp,
  39. struct poll_table_struct *wait);
  40. ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
  41. size_t n, loff_t *f_ps);
  42. int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
  43. void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev);
  44. #define iio_buffer_poll_addr (&iio_buffer_poll)
  45. #define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer)
  46. void iio_disable_all_buffers(struct iio_dev *indio_dev);
  47. void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
  48. #else
  49. #define iio_buffer_poll_addr NULL
  50. #define iio_buffer_read_first_n_outer_addr NULL
  51. static inline int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
  52. {
  53. return 0;
  54. }
  55. static inline void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
  56. static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
  57. static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}
  58. #endif
  59. int iio_device_register_eventset(struct iio_dev *indio_dev);
  60. void iio_device_unregister_eventset(struct iio_dev *indio_dev);
  61. void iio_device_wakeup_eventset(struct iio_dev *indio_dev);
  62. int iio_event_getfd(struct iio_dev *indio_dev);
  63. struct iio_event_interface;
  64. bool iio_event_enabled(const struct iio_event_interface *ev_int);
  65. #endif