3 * This is a place for code driver writers wish to share between
4 * two or more drivers. These functions are meant to be used only
5 * by drivers, they are NOT part of the kcomedilib API!
7 * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
8 * Copyright (C) 2002 Frank Mori Hess
10 * This program 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.
24 #include "../comedidev.h"
26 static inline unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s,
28 unsigned int num_bytes)
30 return comedi_write_array_to_buffer(s, data, num_bytes);
34 * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
35 * @src: pointer to the trigger source to validate
36 * @flags: bitmask of valid TRIG_* for the trigger
38 * This is used in "step 1" of the do_cmdtest functions of comedi drivers
39 * to vaildate the comedi_cmd triggers. The mask of the @src against the
40 * @flags allows the userspace comedilib to pass all the comedi_cmd
41 * triggers as TRIG_ANY and get back a bitmask of the valid trigger sources.
43 static inline int cfc_check_trigger_src(unsigned int *src, unsigned int flags)
45 unsigned int orig_src = *src;
47 *src = orig_src & flags;
48 if (*src == TRIG_INVALID || *src != orig_src)
54 * cfc_check_trigger_is_unique() - make sure a trigger source is unique
55 * @src: the trigger source to check
57 static inline int cfc_check_trigger_is_unique(unsigned int src)
59 /* this test is true if more than one _src bit is set */
60 if ((src & (src - 1)) != 0)
66 * cfc_check_trigger_arg_is() - trivially validate a trigger argument
67 * @arg: pointer to the trigger arg to validate
68 * @val: the value the argument should be
70 static inline int cfc_check_trigger_arg_is(unsigned int *arg, unsigned int val)
80 * cfc_check_trigger_arg_min() - trivially validate a trigger argument
81 * @arg: pointer to the trigger arg to validate
82 * @val: the minimum value the argument should be
84 static inline int cfc_check_trigger_arg_min(unsigned int *arg,
95 * cfc_check_trigger_arg_max() - trivially validate a trigger argument
96 * @arg: pointer to the trigger arg to validate
97 * @val: the maximum value the argument should be
99 static inline int cfc_check_trigger_arg_max(unsigned int *arg,
109 #endif /* _COMEDI_FC_H */