Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
trigger.h
Go to the documentation of this file.
1 /* The industrial I/O core, trigger handling functions
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 #include <linux/irq.h>
10 #include <linux/module.h>
11 
12 #ifndef _IIO_TRIGGER_H_
13 #define _IIO_TRIGGER_H_
14 
15 struct iio_subirq {
16  bool enabled;
17 };
18 
32  struct module *owner;
33  int (*set_trigger_state)(struct iio_trigger *trig, bool state);
34  int (*try_reenable)(struct iio_trigger *trig);
35  int (*validate_device)(struct iio_trigger *trig,
36  struct iio_dev *indio_dev);
37 };
38 
39 
56 struct iio_trigger {
57  const struct iio_trigger_ops *ops;
58  int id;
59  const char *name;
60  struct device dev;
61 
62  void *private_data;
63  struct list_head list;
65  int use_count;
66 
69 
70  struct iio_subirq subirqs[CONFIG_IIO_CONSUMERS_PER_TRIGGER];
71  unsigned long pool[BITS_TO_LONGS(CONFIG_IIO_CONSUMERS_PER_TRIGGER)];
72  struct mutex pool_lock;
73 };
74 
75 
76 static inline struct iio_trigger *to_iio_trigger(struct device *d)
77 {
78  return container_of(d, struct iio_trigger, dev);
79 }
80 
81 static inline void iio_trigger_put(struct iio_trigger *trig)
82 {
83  module_put(trig->ops->owner);
84  put_device(&trig->dev);
85 }
86 
87 static inline void iio_trigger_get(struct iio_trigger *trig)
88 {
89  get_device(&trig->dev);
90  __module_get(trig->ops->owner);
91 }
92 
97 int iio_trigger_register(struct iio_trigger *trig_info);
98 
103 void iio_trigger_unregister(struct iio_trigger *trig_info);
104 
112 void iio_trigger_poll(struct iio_trigger *trig, s64 time);
113 void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time);
114 
115 irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private);
116 
119 
120 #endif /* _IIO_TRIGGER_H_ */