staging: comedi: amplc_pci230: rewrite shared resource handling
authorIan Abbott <abbotti@mev.co.uk>
Mon, 1 Sep 2014 11:03:54 +0000 (12:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Sep 2014 18:21:32 +0000 (11:21 -0700)
commitbeafb60389773e13152c7f67e05ba05111eef0f4
tree5f1114278c5b85a239989d81f45abe2275f69d9a
parent4b0ff3dc5e3d86ada66afcaab46a766d326facd4
staging: comedi: amplc_pci230: rewrite shared resource handling

Some counter channels may be required for AI commands and AO commands.
Depending on how the commands are set up, it may not be possible to run
both at the same time, so we keep some state and code to find out if the
required resources are busy or not.

The existing code is a bit unwieldy - the code for claiming resources
involves two `for` loops for example.  Rewrite it to make it simpler.

The new code just has a bit-mask value for each shared resource (counter
channels), and an array indexed by resource "owners" (AI and AO
commands), so the code for claiming resources now just has a single loop
that checks that none of the other owners have claimed the wanted
resources.

Rename the functions involved, because the old names involving 'put' and
'get' suggested some sort of usage counting.

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>
drivers/staging/comedi/drivers/amplc_pci230.c
This page took 0.024746 seconds and 5 git commands to generate.