Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /**
  2  * @file mesubdevice.h
  3  *
  4  * @brief Provides the subdevice base class.
  5  * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
  6  * @author Guenter Gebhardt
  7  */
  8 
  9 #ifndef _MESUBDEVICE_H_
 10 #define _MESUBDEVICE_H_
 11 
 12 #include <linux/list.h>
 13 
 14 #include "metypes.h"
 15 #include "meioctl.h"
 16 #include "meslock.h"
 17 
 18 # include <linux/workqueue.h>
 19 
 20 #ifdef __KERNEL__
 21 
 22 /**
 23  * @brief Macro used to enter a subdevice.
 24  */
 25 #define ME_SUBDEVICE_ENTER      \
 26 { \
 27         int err; \
 28         err = me_slock_enter(&instance->base.lock, filep); \
 29         if(err){ \
 30                 PERROR("Cannot enter subdevice.\n"); \
 31                 return err; \
 32         } \
 33 }
 34 
 35 /**
 36  * @brief Macro used to exit a subdevice.
 37  */
 38 #define ME_SUBDEVICE_EXIT       \
 39 {\
 40         int err; \
 41         err = me_slock_exit(&instance->base.lock, filep); \
 42         if(err){ \
 43                 PERROR("Cannot exit subdevice.\n"); \
 44                 return err; \
 45         } \
 46 }
 47 
 48 /**
 49  * @brief The subdevice base class.
 50  */
 51 typedef struct me_subdevice {
 52         /* Attributes */
 53         struct list_head list;          /**< Enables the subdevice to be added to a dynamic list. */
 54         me_slock_t lock;                /**< Used by user application in order to lock the subdevice for exclusive usage. */
 55 
 56         /* Methods */
 57         int (*me_subdevice_io_irq_start) (struct me_subdevice * subdevice,
 58                                           struct file * filep,
 59                                           int channel,
 60                                           int irq_source,
 61                                           int irq_edge, int irq_arg, int flags);
 62 
 63         int (*me_subdevice_io_irq_wait) (struct me_subdevice * subdevice,
 64                                          struct file * filep,
 65                                          int channel,
 66                                          int *irq_count,
 67                                          int *value, int time_out, int flags);
 68 
 69         int (*me_subdevice_io_irq_stop) (struct me_subdevice * subdevice,
 70                                          struct file * filep,
 71                                          int channel, int flags);
 72 
 73         int (*me_subdevice_io_reset_subdevice) (struct me_subdevice * subdevice,
 74                                                 struct file * filep, int flags);
 75 
 76         int (*me_subdevice_io_single_config) (struct me_subdevice * subdevice,
 77                                               struct file * filep,
 78                                               int channel,
 79                                               int single_config,
 80                                               int ref,
 81                                               int trig_chan,
 82                                               int trig_type,
 83                                               int trig_edge, int flags);
 84 
 85         int (*me_subdevice_io_single_read) (struct me_subdevice * subdevice,
 86                                             struct file * filep,
 87                                             int channel,
 88                                             int *value,
 89                                             int time_out, int flags);
 90 
 91         int (*me_subdevice_io_single_write) (struct me_subdevice * subdevice,
 92                                              struct file * filep,
 93                                              int channel,
 94                                              int value,
 95                                              int time_out, int flags);
 96 
 97         int (*me_subdevice_io_stream_config) (struct me_subdevice * subdevice,
 98                                               struct file * filep,
 99                                               meIOStreamConfig_t * config_list,
100                                               int count,
101                                               meIOStreamTrigger_t * trigger,
102                                               int fifo_irq_threshold,
103                                               int flags);
104 
105         int (*me_subdevice_io_stream_new_values) (struct me_subdevice *
106                                                   subdevice,
107                                                   struct file * filep,
108                                                   int time_out, int *count,
109                                                   int flags);
110 
111         int (*me_subdevice_io_stream_read) (struct me_subdevice * subdevice,
112                                             struct file * filep,
113                                             int read_mode,
114                                             int *values, int *count, int flags);
115 
116         int (*me_subdevice_io_stream_start) (struct me_subdevice * subdevice,
117                                              struct file * filep,
118                                              int start_mode,
119                                              int time_out, int flags);
120 
121         int (*me_subdevice_io_stream_status) (struct me_subdevice * subdevice,
122                                               struct file * filep,
123                                               int wait,
124                                               int *status,
125                                               int *count, int flags);
126 
127         int (*me_subdevice_io_stream_stop) (struct me_subdevice * subdevice,
128                                             struct file * filep,
129                                             int stop_mode, int flags);
130 
131         int (*me_subdevice_io_stream_write) (struct me_subdevice * subdevice,
132                                              struct file * filep,
133                                              int write_mode,
134                                              int *values,
135                                              int *count, int flags);
136 
137         int (*me_subdevice_lock_subdevice) (struct me_subdevice * subdevice,
138                                             struct file * filep,
139                                             int lock, int flags);
140 
141         int (*me_subdevice_query_number_channels) (struct me_subdevice *
142                                                    subdevice, int *number);
143 
144         int (*me_subdevice_query_number_ranges) (struct me_subdevice *
145                                                  subdevice, int unit,
146                                                  int *count);
147 
148         int (*me_subdevice_query_range_by_min_max) (struct me_subdevice *
149                                                     subdevice, int unit,
150                                                     int *min, int *max,
151                                                     int *maxdata, int *range);
152 
153         int (*me_subdevice_query_range_info) (struct me_subdevice * subdevice,
154                                               int range,
155                                               int *unit,
156                                               int *min, int *max, int *maxdata);
157 
158         int (*me_subdevice_query_subdevice_type) (struct me_subdevice *
159                                                   subdevice, int *type,
160                                                   int *subtype);
161 
162         int (*me_subdevice_query_subdevice_caps) (struct me_subdevice *
163                                                   subdevice, int *caps);
164 
165         int (*me_subdevice_query_subdevice_caps_args) (struct me_subdevice *
166                                                        subdevice, int cap,
167                                                        int *args, int count);
168 
169         int (*me_subdevice_query_timer) (struct me_subdevice * subdevice,
170                                          int timer,
171                                          int *base_frequency,
172                                          long long *min_ticks,
173                                          long long *max_ticks);
174 
175         int (*me_subdevice_config_load) (struct me_subdevice * subdevice,
176                                          me_cfg_device_entry_t * config);
177 
178         void (*me_subdevice_destructor) (struct me_subdevice * subdevice);
179 } me_subdevice_t;
180 
181 /**
182  * @brief Initializes a subdevice structure.
183  *
184  * @param subdevice The subdevice structure to initialize.
185  * @return 0 on success.
186  */
187 int me_subdevice_init(me_subdevice_t * subdevice);
188 
189 /**
190  * @brief Deinitializes a subdevice structure.
191  *
192  * @param subdevice The subdevice structure to initialize.
193  */
194 void me_subdevice_deinit(me_subdevice_t * subdevice);
195 
196 #endif
197 #endif
198 
  This page was automatically generated by the LXR engine.