4 * @brief Subdevice base class implemention.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
10 * This file is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <linux/slab.h>
31 #include "medefines.h"
35 #include "mesubdevice.h"
37 static int me_subdevice_io_irq_start(struct me_subdevice
*subdevice
,
41 int irq_edge
, int irq_arg
, int flags
)
43 PDEBUG("executed.\n");
44 return ME_ERRNO_NOT_SUPPORTED
;
47 static int me_subdevice_io_irq_wait(struct me_subdevice
*subdevice
,
51 int *value
, int time_out
, int flags
)
53 PDEBUG("executed.\n");
54 return ME_ERRNO_NOT_SUPPORTED
;
57 static int me_subdevice_io_irq_stop(struct me_subdevice
*subdevice
,
58 struct file
*filep
, int channel
, int flags
)
60 PDEBUG("executed.\n");
61 return ME_ERRNO_NOT_SUPPORTED
;
64 static int me_subdevice_io_reset_subdevice(struct me_subdevice
*subdevice
,
65 struct file
*filep
, int flags
)
67 PDEBUG("executed.\n");
68 return ME_ERRNO_NOT_SUPPORTED
;
71 static int me_subdevice_io_single_config(struct me_subdevice
*subdevice
,
78 int trig_edge
, int flags
)
80 PDEBUG("executed.\n");
81 return ME_ERRNO_NOT_SUPPORTED
;
84 static int me_subdevice_io_single_read(struct me_subdevice
*subdevice
,
87 int *value
, int time_out
, int flags
)
89 PDEBUG("executed.\n");
90 return ME_ERRNO_NOT_SUPPORTED
;
93 static int me_subdevice_io_single_write(struct me_subdevice
*subdevice
,
96 int value
, int time_out
, int flags
)
98 PDEBUG("executed.\n");
99 return ME_ERRNO_NOT_SUPPORTED
;
102 static int me_subdevice_io_stream_config(struct me_subdevice
*subdevice
,
104 meIOStreamConfig_t
*config_list
,
106 meIOStreamTrigger_t
*trigger
,
107 int fifo_irq_threshold
, int flags
)
109 PDEBUG("executed.\n");
110 return ME_ERRNO_NOT_SUPPORTED
;
113 static int me_subdevice_io_stream_new_values(struct me_subdevice
*subdevice
,
116 int *count
, int flags
)
118 PDEBUG("executed.\n");
119 return ME_ERRNO_NOT_SUPPORTED
;
122 static int me_subdevice_io_stream_read(struct me_subdevice
*subdevice
,
125 int *values
, int *count
, int flags
)
127 PDEBUG("executed.\n");
128 return ME_ERRNO_NOT_SUPPORTED
;
131 static int me_subdevice_io_stream_start(struct me_subdevice
*subdevice
,
133 int start_mode
, int time_out
, int flags
)
135 PDEBUG("executed.\n");
136 return ME_ERRNO_NOT_SUPPORTED
;
139 static int me_subdevice_io_stream_status(struct me_subdevice
*subdevice
,
142 int *status
, int *count
, int flags
)
144 PDEBUG("executed.\n");
145 return ME_ERRNO_NOT_SUPPORTED
;
148 static int me_subdevice_io_stream_stop(struct me_subdevice
*subdevice
,
150 int stop_mode
, int flags
)
152 PDEBUG("executed.\n");
153 return ME_ERRNO_NOT_SUPPORTED
;
156 static int me_subdevice_io_stream_write(struct me_subdevice
*subdevice
,
159 int *values
, int *count
, int flags
)
161 PDEBUG("executed.\n");
162 return ME_ERRNO_NOT_SUPPORTED
;
165 static int me_subdevice_lock_subdevice(me_subdevice_t
*subdevice
,
166 struct file
*filep
, int lock
, int flags
)
168 PDEBUG("executed.\n");
169 return me_slock_lock(&subdevice
->lock
, filep
, lock
);
172 static int me_subdevice_query_number_channels(struct me_subdevice
*subdevice
,
175 PDEBUG("executed.\n");
176 return ME_ERRNO_NOT_SUPPORTED
;
179 static int me_subdevice_query_number_ranges(struct me_subdevice
*subdevice
,
180 int unit
, int *count
)
182 PDEBUG("executed.\n");
183 return ME_ERRNO_NOT_SUPPORTED
;
186 static int me_subdevice_query_range_by_min_max(struct me_subdevice
*subdevice
,
190 int *maxdata
, int *range
)
192 PDEBUG("executed.\n");
193 return ME_ERRNO_NOT_SUPPORTED
;
196 static int me_subdevice_query_range_info(struct me_subdevice
*subdevice
,
199 int *min
, int *max
, int *maxdata
)
201 PDEBUG("executed.\n");
202 return ME_ERRNO_NOT_SUPPORTED
;
205 static int me_subdevice_query_subdevice_type(struct me_subdevice
*subdevice
,
206 int *type
, int *subtype
)
208 PDEBUG("executed.\n");
209 return ME_ERRNO_NOT_SUPPORTED
;
212 static int me_subdevice_query_subdevice_caps(struct me_subdevice
*subdevice
,
215 PDEBUG("executed.\n");
217 return ME_ERRNO_SUCCESS
;
220 static int me_subdevice_query_subdevice_caps_args(struct me_subdevice
222 int *args
, int count
)
224 PDEBUG("executed.\n");
225 return ME_ERRNO_NOT_SUPPORTED
;
228 static int me_subdevice_query_timer(struct me_subdevice
*subdevice
,
231 long long *min_ticks
, long long *max_ticks
)
233 PDEBUG("executed.\n");
234 return ME_ERRNO_NOT_SUPPORTED
;
237 static int me_subdevice_config_load(struct me_subdevice
*subdevice
,
238 me_cfg_device_entry_t
*config
)
240 PDEBUG("executed.\n");
241 return ME_ERRNO_SUCCESS
;
244 static void me_subdevice_destructor(struct me_subdevice
*subdevice
)
246 PDEBUG("executed.\n");
247 me_subdevice_deinit(subdevice
);
251 int me_subdevice_init(me_subdevice_t
*subdevice
)
255 PDEBUG("executed.\n");
258 INIT_LIST_HEAD(&subdevice
->list
);
260 /* Initialize the subdevice lock instance */
262 err
= me_slock_init(&subdevice
->lock
);
265 PERROR("Cannot initialize subdevice lock instance.\n");
269 /* Subdevice base class methods */
270 subdevice
->me_subdevice_io_irq_start
= me_subdevice_io_irq_start
;
271 subdevice
->me_subdevice_io_irq_wait
= me_subdevice_io_irq_wait
;
272 subdevice
->me_subdevice_io_irq_stop
= me_subdevice_io_irq_stop
;
273 subdevice
->me_subdevice_io_reset_subdevice
=
274 me_subdevice_io_reset_subdevice
;
275 subdevice
->me_subdevice_io_single_config
=
276 me_subdevice_io_single_config
;
277 subdevice
->me_subdevice_io_single_read
= me_subdevice_io_single_read
;
278 subdevice
->me_subdevice_io_single_write
= me_subdevice_io_single_write
;
279 subdevice
->me_subdevice_io_stream_config
=
280 me_subdevice_io_stream_config
;
281 subdevice
->me_subdevice_io_stream_new_values
=
282 me_subdevice_io_stream_new_values
;
283 subdevice
->me_subdevice_io_stream_read
= me_subdevice_io_stream_read
;
284 subdevice
->me_subdevice_io_stream_start
= me_subdevice_io_stream_start
;
285 subdevice
->me_subdevice_io_stream_status
=
286 me_subdevice_io_stream_status
;
287 subdevice
->me_subdevice_io_stream_stop
= me_subdevice_io_stream_stop
;
288 subdevice
->me_subdevice_io_stream_write
= me_subdevice_io_stream_write
;
289 subdevice
->me_subdevice_lock_subdevice
= me_subdevice_lock_subdevice
;
290 subdevice
->me_subdevice_query_number_channels
=
291 me_subdevice_query_number_channels
;
292 subdevice
->me_subdevice_query_number_ranges
=
293 me_subdevice_query_number_ranges
;
294 subdevice
->me_subdevice_query_range_by_min_max
=
295 me_subdevice_query_range_by_min_max
;
296 subdevice
->me_subdevice_query_range_info
=
297 me_subdevice_query_range_info
;
298 subdevice
->me_subdevice_query_subdevice_type
=
299 me_subdevice_query_subdevice_type
;
300 subdevice
->me_subdevice_query_subdevice_caps
=
301 me_subdevice_query_subdevice_caps
;
302 subdevice
->me_subdevice_query_subdevice_caps_args
=
303 me_subdevice_query_subdevice_caps_args
;
304 subdevice
->me_subdevice_query_timer
= me_subdevice_query_timer
;
305 subdevice
->me_subdevice_config_load
= me_subdevice_config_load
;
306 subdevice
->me_subdevice_destructor
= me_subdevice_destructor
;
311 void me_subdevice_deinit(me_subdevice_t
*subdevice
)
313 PDEBUG("executed.\n");
314 me_subdevice_io_reset_subdevice(subdevice
, NULL
,
315 ME_IO_RESET_SUBDEVICE_NO_FLAGS
);
316 me_slock_deinit(&subdevice
->lock
);