linux-stable/drivers/staging/comedi
Ian Abbott 4af8c81951 staging: comedi: jr3_pci: re-work struct jr3_pci_subdev_private range
The `range` member of `struct jr3_pci_subdev_private` is an array of a
tag-less `struct` type whose layout is similar to `struct
comedi_lrange`.  Both `struct` types end with a member also called
`range`.  In the case of tag-less `struct` type, it is a single `struct
comedi_krange`.  In the case of `struct comedi_lrange`, it is a flexible
array of `struct comedi_krange`.

Elements of the `range` array member in `struct jr3_pci_subdev_private`
are pointed to by elements of the `range_table_list` array member, which
are of type `const struct comedi_lrange *`.  This requires some dodgy
type casting.

To avoid the dodgy type casting, change the element type of the `range`
member of `struct jr3_pci_subdev_private` to be a new type `union
jr3_pci_single_range`.  This contains a member `l` of type `struct
comedi_lrange`, and an array member `_reserved` that is large enough to
encompass the `struct comedi_lrange` plus a single `struct
comedi_krange`.  It is the same size as the previous type.  Accesses to
`spriv->range[i].length` and `spriv->range[i].range` are replaced with
`spriv->range[i].l.length` and `spriv->range[i].l.range[0]` respectively
(where `spriv` is a `struct jr3_pci_subdev_private *`, and `i` is an
array index).  Type-casted pointers to `spriv->range[i]` are replaced
with pointers to `spriv->range[i].l`, which do not require the type
casts.  Since we defined a new type, we can define local variables of
the corresponding pointer type to shorten some lines of code.  This is
made use of in `jr3_pci_alloc_spriv()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06 09:16:58 +01:00
..
drivers staging: comedi: jr3_pci: re-work struct jr3_pci_subdev_private range 2017-03-06 09:16:58 +01:00
kcomedilib Staging: comedi: kcomedilib: Add module_init/exit function 2016-12-06 10:08:01 +01:00
comedi.h staging: comedi: make constants slightly more consistent 2016-10-16 10:26:16 +02:00
comedi_buf.c locking/atomic, kref: Add kref_read() 2017-01-14 11:37:18 +01:00
comedi_compat32.c
comedi_compat32.h staging: comedi: comedi_compat32.h: add identifiers to function parameters 2017-01-03 15:27:55 +01:00
comedi_fops.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
comedi_internal.h staging: comedi: comedi_internal.h: add identifiers to function parameters 2017-01-03 15:27:55 +01:00
comedi_pci.c
comedi_pci.h drivers: staging: comedi: fix function prototypes 2017-01-03 15:27:12 +01:00
comedi_pcmcia.c staging: comedi: comedi_pcmcia.[ch]: add identifiers to function parameters 2017-01-03 15:27:55 +01:00
comedi_pcmcia.h staging: comedi: comedi_pcmcia.[ch]: add identifiers to function parameters 2017-01-03 15:27:55 +01:00
comedi_usb.c
comedi_usb.h staging: comedi: comedi_usb.h: add identifiers to function parameters 2017-01-03 15:27:55 +01:00
comedidev.h Staging: comedi: comedidev.h: Drop old style zero-length array 2017-01-03 15:29:06 +01:00
comedilib.h
drivers.c Staging: comedi: Align the * in block comments 2016-10-02 17:29:11 +02:00
Kconfig staging: comedi: ni_pcimio: Support more PXI cards 2017-01-19 10:49:50 +01:00
Makefile
proc.c Staging: comedi: proc: Warn if unable to create proc entry 2017-01-03 15:30:21 +01:00
range.c
TODO