staging: comedi: comedi_fc.h: begin migration to comedidev.h
"comedi_fc.h" contains a few inline functions used by the `do_cmdtest` handler functions for comedi subdevices in several low-level comedi drivers for checking asynchronous command trigger sources and arguments. They all use the prefix `cfc_check_trigger_arg`. Copy them over to "../comedidev.h", but change the `cfc_` prefix to `comedi_`. Change the original functions in "comedi_fc.h" into simple wrappers for their replacements. Once the drivers have been changed to call the replacement functions, "comedi_fc.h" can be removed. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
78cff59e88
commit
5e1a61928e
2 changed files with 87 additions and 53 deletions
|
@ -464,6 +464,84 @@ static inline unsigned int comedi_samples_to_bytes(struct comedi_subdevice *s,
|
||||||
return nsamples << comedi_sample_shift(s);
|
return nsamples << comedi_sample_shift(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* comedi_check_trigger_src() - trivially validate a comedi_cmd trigger source
|
||||||
|
* @src: pointer to the trigger source to validate
|
||||||
|
* @flags: bitmask of valid TRIG_* for the trigger
|
||||||
|
*
|
||||||
|
* This is used in "step 1" of the do_cmdtest functions of comedi drivers
|
||||||
|
* to vaildate the comedi_cmd triggers. The mask of the @src against the
|
||||||
|
* @flags allows the userspace comedilib to pass all the comedi_cmd
|
||||||
|
* triggers as TRIG_ANY and get back a bitmask of the valid trigger sources.
|
||||||
|
*/
|
||||||
|
static inline int comedi_check_trigger_src(unsigned int *src,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
unsigned int orig_src = *src;
|
||||||
|
|
||||||
|
*src = orig_src & flags;
|
||||||
|
if (*src == TRIG_INVALID || *src != orig_src)
|
||||||
|
return -EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* comedi_check_trigger_is_unique() - make sure a trigger source is unique
|
||||||
|
* @src: the trigger source to check
|
||||||
|
*/
|
||||||
|
static inline int comedi_check_trigger_is_unique(unsigned int src)
|
||||||
|
{
|
||||||
|
/* this test is true if more than one _src bit is set */
|
||||||
|
if ((src & (src - 1)) != 0)
|
||||||
|
return -EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* comedi_check_trigger_arg_is() - trivially validate a trigger argument
|
||||||
|
* @arg: pointer to the trigger arg to validate
|
||||||
|
* @val: the value the argument should be
|
||||||
|
*/
|
||||||
|
static inline int comedi_check_trigger_arg_is(unsigned int *arg,
|
||||||
|
unsigned int val)
|
||||||
|
{
|
||||||
|
if (*arg != val) {
|
||||||
|
*arg = val;
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* comedi_check_trigger_arg_min() - trivially validate a trigger argument
|
||||||
|
* @arg: pointer to the trigger arg to validate
|
||||||
|
* @val: the minimum value the argument should be
|
||||||
|
*/
|
||||||
|
static inline int comedi_check_trigger_arg_min(unsigned int *arg,
|
||||||
|
unsigned int val)
|
||||||
|
{
|
||||||
|
if (*arg < val) {
|
||||||
|
*arg = val;
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* comedi_check_trigger_arg_max() - trivially validate a trigger argument
|
||||||
|
* @arg: pointer to the trigger arg to validate
|
||||||
|
* @val: the maximum value the argument should be
|
||||||
|
*/
|
||||||
|
static inline int comedi_check_trigger_arg_max(unsigned int *arg,
|
||||||
|
unsigned int val)
|
||||||
|
{
|
||||||
|
if (*arg > val) {
|
||||||
|
*arg = val;
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
|
* Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
|
||||||
* Also useful for retrieving a previously configured hardware device of
|
* Also useful for retrieving a previously configured hardware device of
|
||||||
|
|
|
@ -23,80 +23,36 @@
|
||||||
|
|
||||||
#include "../comedidev.h"
|
#include "../comedidev.h"
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
|
* This file will be removed once drivers have migrated to using the
|
||||||
* @src: pointer to the trigger source to validate
|
* replacement functions in "comedidev.h".
|
||||||
* @flags: bitmask of valid TRIG_* for the trigger
|
|
||||||
*
|
|
||||||
* This is used in "step 1" of the do_cmdtest functions of comedi drivers
|
|
||||||
* to vaildate the comedi_cmd triggers. The mask of the @src against the
|
|
||||||
* @flags allows the userspace comedilib to pass all the comedi_cmd
|
|
||||||
* triggers as TRIG_ANY and get back a bitmask of the valid trigger sources.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline int cfc_check_trigger_src(unsigned int *src, unsigned int flags)
|
static inline int cfc_check_trigger_src(unsigned int *src, unsigned int flags)
|
||||||
{
|
{
|
||||||
unsigned int orig_src = *src;
|
return comedi_check_trigger_src(src, flags);
|
||||||
|
|
||||||
*src = orig_src & flags;
|
|
||||||
if (*src == TRIG_INVALID || *src != orig_src)
|
|
||||||
return -EINVAL;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cfc_check_trigger_is_unique() - make sure a trigger source is unique
|
|
||||||
* @src: the trigger source to check
|
|
||||||
*/
|
|
||||||
static inline int cfc_check_trigger_is_unique(unsigned int src)
|
static inline int cfc_check_trigger_is_unique(unsigned int src)
|
||||||
{
|
{
|
||||||
/* this test is true if more than one _src bit is set */
|
return comedi_check_trigger_is_unique(src);
|
||||||
if ((src & (src - 1)) != 0)
|
|
||||||
return -EINVAL;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cfc_check_trigger_arg_is() - trivially validate a trigger argument
|
|
||||||
* @arg: pointer to the trigger arg to validate
|
|
||||||
* @val: the value the argument should be
|
|
||||||
*/
|
|
||||||
static inline int cfc_check_trigger_arg_is(unsigned int *arg, unsigned int val)
|
static inline int cfc_check_trigger_arg_is(unsigned int *arg, unsigned int val)
|
||||||
{
|
{
|
||||||
if (*arg != val) {
|
return comedi_check_trigger_arg_is(arg, val);
|
||||||
*arg = val;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cfc_check_trigger_arg_min() - trivially validate a trigger argument
|
|
||||||
* @arg: pointer to the trigger arg to validate
|
|
||||||
* @val: the minimum value the argument should be
|
|
||||||
*/
|
|
||||||
static inline int cfc_check_trigger_arg_min(unsigned int *arg,
|
static inline int cfc_check_trigger_arg_min(unsigned int *arg,
|
||||||
unsigned int val)
|
unsigned int val)
|
||||||
{
|
{
|
||||||
if (*arg < val) {
|
return comedi_check_trigger_arg_min(arg, val);
|
||||||
*arg = val;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cfc_check_trigger_arg_max() - trivially validate a trigger argument
|
|
||||||
* @arg: pointer to the trigger arg to validate
|
|
||||||
* @val: the maximum value the argument should be
|
|
||||||
*/
|
|
||||||
static inline int cfc_check_trigger_arg_max(unsigned int *arg,
|
static inline int cfc_check_trigger_arg_max(unsigned int *arg,
|
||||||
unsigned int val)
|
unsigned int val)
|
||||||
{
|
{
|
||||||
if (*arg > val) {
|
return comedi_check_trigger_arg_max(arg, val);
|
||||||
*arg = val;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _COMEDI_FC_H */
|
#endif /* _COMEDI_FC_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue