staging: comedi: adl_pci9118: use 'context' in (*auto_attach)

The pci_device_id 'driver_data' is passed as the 'context' when the (*auto_attach)
mechanism is used to attach this driver. Add a boardid enum and index the boardinfo
so that the "pci9118dg" boardinfo is automatically selected. This allow removing
the pci9118_find_boardinfo() helper.

Unfortunately all the boards supported by this driver have the same device id.
Add commented out entries in the device table for them.

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>
staging: comedi: adl_pci9118: remove 'device_id' from boardinfo

This member of the boardinfo is the same for all entries. Remove it.

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>
staging: comedi: adl_pci9118: remove unnecessary dev->board_name initialization

The (*auto_attach) in this driver will set the dev->board_name and the comedi core
will set it when using the legacy (*attach). Remove the unnecessary initialization
in pci9118_common_attach().

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>
staging: comedi: adl_pci9118: rename boardinfo struct

For aesthetics, rename the struct used for the boardinfo so it has
namespace associated with the driver. Also, rename the local variable
used for the boardinfo pointer to simply 'board'.

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>
staging: comedi: adl_pci9118: allocate private data in pci9118_common_attach()

The (*auto_attach) and legacy (*attach) both allocate the private data but
don't use it. For aesthetics, move the allocation into the common attach
code.

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>
staging: comedi: adl_pci9118: tidy up digital output subdevice init

For aesthetics, add some whitespace to the digital output subdevice init.

Remove the SDF_GROUND and SDF_COMMON subdev_flags. These flags only apply
to analog subdevices.

Remove the 'len_chanlist' init, this subdevice member is only used with
subdevices that support async commands.

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>
staging: comedi: adl_pci9118: tidy up digital input subdevice init

For aesthetics, add some whitespace to the digital input subdevice init.

Remove the SDF_GROUND and SDF_COMMON subdev_flags. These flags only apply
to analog subdevices.

Remove the 'len_chanlist' init, this subdevice member is only used with
subdevices that support async commands.

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>
staging: comedi: adl_pci9118: tidy up analog output subdevice init

For aesthetics, add some whitespace to the analog output subdevice init.

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>
staging: comedi: adl_pci9118: tidy up analog input subdevice init

For aesthetics, add some whitespace to the analog input subdevice init.
Tidy up the subdevice n_chan initialization.

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>
staging: comedi: adl_pci9118: all registers are 32-bit

According to the PCI-9118 User's Manual, all registers are 32-bit. Fix a
couple of read/write operations that use 16-bit access.

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>
staging: comedi: adl_pci9118: introduce pci9118_timer_write()

This driver uses 32-bit instructions to write the 8254 timers so we
can't use the helper functions provided by 8253.h.

To clarify the code introduce a helper function to write to the timers.

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>
staging: comedi: adl_pci9118: introduce pci9118_timer_set_mode()

This driver uses 32-bit instructions to write the 8254 timers so we
can't use the helper functions provided by 8253.h.

To clarify the code introduce a helper function to set the timer mode.

Remove the unnecessary commented out timer mode programming.

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>
staging: comedi: adl_pci9118: tidy up analog input fifo register define

For aesthetics, rename the define used for the analog input fifo register
and tidy up its use in the driver.

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>
staging: comedi: adl_pci9118: tidy up analog output register defines

Replace the current defines with a macro that calculates the correct
register offset based on the channel.

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>
staging: comedi: adl_pci9118: rename PCI9118_ADSTAT define

For aesthetics, rename this define used for the analog input status
register.

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>
staging: comedi: adl_pci9118: tidy up the ai status register bit defines

Rename the CamelCase defines used for the analog input status register
bits and convert them to bit shifts.

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>
staging: comedi: adl_pci9118: rename PCI9118_ADCNTRL define

For aesthetics, rename this define used for the analog input control
register.

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>
staging: comedi: adl_pci9118: tidy up the ai control register bit defines

Rename the CamelCase defines used for the analog input control register
bits and convert them to bit shifts.

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>
staging: comedi: adl_pci9118: clarify the digital I/O register

The same register is used for both the digital inputs and outputs.
Reading the register returns the state of the 4 digtial input channels
and the 4 digital output channels. Writing to the register updates the
digital outputs.

Add some comments to clarify this and use a single define for the register.

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>
staging: comedi: adl_pci9118: introduce pci9118_ai_start_conv()

Writing any value to the "software trigger" register generates a trigger
pulse to start an A/D conversion. Introduce a helper function to clarify
this. For aesthetics, rename the define used for the register.

According to the datasheet the extra delay is not needed after starting
the conversion. Remove it.

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>