diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/staging/iio/chrdev.h | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/staging/iio/chrdev.h')
-rw-r--r-- | drivers/staging/iio/chrdev.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h new file mode 100644 index 00000000000..3e31ee6220e --- /dev/null +++ b/drivers/staging/iio/chrdev.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* The industrial I/O core - character device related | ||
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 | |||
10 | #ifndef _IIO_CHRDEV_H_ | ||
11 | #define _IIO_CHRDEV_H_ | ||
12 | struct iio_dev; | ||
13 | |||
14 | /** | ||
15 | * struct iio_handler - Structure used to specify file operations | ||
16 | * for a particular chrdev | ||
17 | * @chrdev: character device structure | ||
18 | * @id: the location in the handler table - used for deallocation. | ||
19 | * @flags: file operations related flags including busy flag. | ||
20 | * @private: handler specific data used by the fileops registered with | ||
21 | * the chrdev. | ||
22 | */ | ||
23 | struct iio_handler { | ||
24 | struct cdev chrdev; | ||
25 | int id; | ||
26 | unsigned long flags; | ||
27 | void *private; | ||
28 | }; | ||
29 | |||
30 | #define iio_cdev_to_handler(cd) \ | ||
31 | container_of(cd, struct iio_handler, chrdev) | ||
32 | |||
33 | /** | ||
34 | * struct iio_event_data - The actual event being pushed to userspace | ||
35 | * @id: event identifier | ||
36 | * @timestamp: best estimate of time of event occurrence (often from | ||
37 | * the interrupt handler) | ||
38 | */ | ||
39 | struct iio_event_data { | ||
40 | int id; | ||
41 | s64 timestamp; | ||
42 | }; | ||
43 | |||
44 | /** | ||
45 | * struct iio_detected_event_list - list element for events that have occurred | ||
46 | * @list: linked list header | ||
47 | * @ev: the event itself | ||
48 | */ | ||
49 | struct iio_detected_event_list { | ||
50 | struct list_head list; | ||
51 | struct iio_event_data ev; | ||
52 | }; | ||
53 | |||
54 | /** | ||
55 | * struct iio_event_interface - chrdev interface for an event line | ||
56 | * @dev: device assocated with event interface | ||
57 | * @handler: fileoperations and related control for the chrdev | ||
58 | * @wait: wait queue to allow blocking reads of events | ||
59 | * @event_list_lock: mutex to protect the list of detected events | ||
60 | * @det_events: list of detected events | ||
61 | * @max_events: maximum number of events before new ones are dropped | ||
62 | * @current_events: number of events in detected list | ||
63 | */ | ||
64 | struct iio_event_interface { | ||
65 | struct device dev; | ||
66 | struct iio_handler handler; | ||
67 | wait_queue_head_t wait; | ||
68 | struct mutex event_list_lock; | ||
69 | struct list_head det_events; | ||
70 | int max_events; | ||
71 | int current_events; | ||
72 | struct list_head dev_attr_list; | ||
73 | }; | ||
74 | |||
75 | #endif | ||