mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 14:56:54 -04:00
staging: comedi: ni_tio: export and fix ni_tio_get_soft_copy()
Move the inline function from the header and export it instead.
For the checkpatch.pl issues:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code
rather than BUG() or BUG_ON()
The 'unsigned' vars can safely be changed to 'unsigned int'.
The BUG_ON() is overkill. All the drivers that call this function pass
'register_index' values that are valid. Just check the 'register_index'
and return 0 if it's not valid.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c9813d50a5
commit
85bfafa81f
@@ -228,6 +228,31 @@ static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
|
||||
return clock_period_ps;
|
||||
}
|
||||
|
||||
/**
|
||||
* ni_tio_get_soft_copy() - Safely read the software copy of a counter register.
|
||||
* @counter: struct ni_gpct counter.
|
||||
* @reg: the register to read.
|
||||
*
|
||||
* Used to get the software copy of a register whose bits might be modified
|
||||
* in interrupt context, or whose software copy might need to be read in
|
||||
* interrupt context.
|
||||
*/
|
||||
unsigned int ni_tio_get_soft_copy(const struct ni_gpct *counter,
|
||||
enum ni_gpct_register reg)
|
||||
{
|
||||
struct ni_gpct_device *counter_dev = counter->counter_dev;
|
||||
unsigned int value = 0;
|
||||
unsigned long flags;
|
||||
|
||||
if (reg < NITIO_NUM_REGS) {
|
||||
spin_lock_irqsave(&counter_dev->regs_lock, flags);
|
||||
value = counter_dev->regs[reg];
|
||||
spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ni_tio_get_soft_copy);
|
||||
|
||||
static unsigned ni_tio_clock_src_modifiers(const struct ni_gpct *counter)
|
||||
{
|
||||
struct ni_gpct_device *counter_dev = counter->counter_dev;
|
||||
|
||||
@@ -224,25 +224,8 @@ static inline void ni_tio_set_bits(struct ni_gpct *counter,
|
||||
0x0);
|
||||
}
|
||||
|
||||
/*
|
||||
* ni_tio_get_soft_copy( ) is for safely reading the software copy of a
|
||||
* register whose bits might be modified in interrupt context, or whose
|
||||
* software copy might need to be read in interrupt context.
|
||||
*/
|
||||
static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter,
|
||||
enum ni_gpct_register
|
||||
register_index)
|
||||
{
|
||||
struct ni_gpct_device *counter_dev = counter->counter_dev;
|
||||
unsigned long flags;
|
||||
unsigned value;
|
||||
|
||||
BUG_ON(register_index >= NITIO_NUM_REGS);
|
||||
spin_lock_irqsave(&counter_dev->regs_lock, flags);
|
||||
value = counter_dev->regs[register_index];
|
||||
spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
|
||||
return value;
|
||||
}
|
||||
unsigned int ni_tio_get_soft_copy(const struct ni_gpct *,
|
||||
enum ni_gpct_register reg);
|
||||
|
||||
int ni_tio_arm(struct ni_gpct *, bool arm, unsigned int start_trigger);
|
||||
int ni_tio_set_gate_src(struct ni_gpct *, unsigned int gate, unsigned int src);
|
||||
|
||||
Reference in New Issue
Block a user