aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/ni_tio.h
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2019-02-25 15:06:11 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-26 11:50:17 +0100
commit97c64322b8dded294fe1f1021946dcad49c0fb4e (patch)
treee9761698506accdf8200c6d9f05e91abf772a709 /drivers/staging/comedi/drivers/ni_tio.h
parentstaging: android: ashmem: Avoid range_alloc() allocation with ashmem_mutex held. (diff)
downloadlinux-dev-97c64322b8dded294fe1f1021946dcad49c0fb4e.tar.xz
linux-dev-97c64322b8dded294fe1f1021946dcad49c0fb4e.zip
staging: comedi: ni_tio: Allocate shadow regs for each counter chip
The "ni_tio" module contains code to allocate, destroy and operate on a `struct ni_gpct_device`, which represents a number of counters spread over one or more blocks (or "chips"). `struct ni_gpct_device` includes an array member `regs` holding shadow copies of register values. Unfortunately, this is currently shared by each block of counters so they interfere with each other. This is a problem for the "ni_660x" module, which has 8 counters spread over 2 blocks. The `regs` storage needs to be two-dimensional, indexed by block (chip) number and register number. (It does not need to be three-dimensional because the registers for individual counters are intermingled within the block.) Change the `regs` member to an array pointer that can be indexed like a two-dimensional array to access the shadow storage for each register in each block. Allocate the storage in `ni_gpct_device_construct()` and free it in `ni_gpct_device_destroy()`. (`ni_gpct_device_construct()` can determine the number of blocks from the `num_counters` and `counters_per_chip` parameters.) Add new member `num_chips` to hold the number of chips. Use that to check that `chip_index` value is in range in the same places that check the register offset is in range. Remove the `counters_per_chip` member of `struct ni_gpct_device` as it is not needed anywhere and could be easily derived from the `num_counters` and `num_chips` members if required. Thanks to GitHub user "raabej" (real name unknown) for an initial implementation of this in the out-of-tree fork of the Comedi drivers. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to '')
-rw-r--r--drivers/staging/comedi/drivers/ni_tio.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h
index 1e85d0a53715..e7b05718df9b 100644
--- a/drivers/staging/comedi/drivers/ni_tio.h
+++ b/drivers/staging/comedi/drivers/ni_tio.h
@@ -107,8 +107,8 @@ struct ni_gpct_device {
enum ni_gpct_variant variant;
struct ni_gpct *counters;
unsigned int num_counters;
- unsigned int counters_per_chip;
- unsigned int regs[NITIO_NUM_REGS];
+ unsigned int num_chips;
+ unsigned int (*regs)[NITIO_NUM_REGS]; /* [num_chips][NITIO_NUM_REGS] */
spinlock_t regs_lock; /* protects 'regs' */
const struct ni_route_tables *routing_tables; /* link to routes */
};