1
0
Fork 0
Commit Graph

562635 Commits (131497acd88a4456d99247cee457baefd2817835)

Author SHA1 Message Date
Ricardo Ribalda Delgado 131497acd8 iio: add ad5761 DAC driver
ad5761 is a 1-channel DAC with configurable output range.
The driver uses the regulator interface for its voltage ref.

It shares its register layout with ad5761r, ad5721 and ad5721r.

Differences:
ad5761* are 16 bit, ad5721* are 12 bits.
ad57*1r have an internal reference.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-24 14:46:21 +00:00
Colin Ian King 7ca6574a7a iio: adc: axp288: remove redundant duplicate const on axp288_adc_channels
duplicate const can be removed, it is redundant. Found by static
analysis using smatch.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-23 16:30:57 +00:00
Martin Kepplinger 244a93f651 iio: mma8452: add support for MMA8451Q
This adds support for this series' 14 bit accelerometer chip, MMA8451Q.
It's datasheet is available at the vendor's website:

https://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf

Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-23 16:28:52 +00:00
Martin Kepplinger 36775d5701 iio: mma8452: whitespace cleanup
Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-23 16:28:27 +00:00
Martin Kepplinger 4b04266abe iio: mma8452: add freefall detection for Freescale's accelerometers
This adds freefall event detection to the supported devices. It adds
the in_accel_x&y&z_mag_falling_en iio event attribute, which activates
freefall mode.

In freefall mode, the current acceleration magnitude (AND combination
of all axis values) is compared to the specified threshold.
If it falls under the threshold (in_accel_mag_falling_value),
the appropriate IIO event code is generated.

This is what the sysfs "events" directory for these devices looks
like after this change:

-rw-r--r--    4096 Oct 23 08:45 in_accel_mag_falling_period
-rw-r--r--    4096 Oct 23 08:45 in_accel_mag_falling_value
-rw-r--r--    4096 Oct 23 08:45 in_accel_mag_rising_period
-rw-r--r--    4096 Oct 23 08:45 in_accel_mag_rising_value
-r--r--r--    4096 Oct 23 08:45 in_accel_scale
-rw-r--r--    4096 Oct 23 08:45 in_accel_x&y&z_mag_falling_en
-rw-r--r--    4096 Oct 23 08:45 in_accel_x_mag_rising_en
-rw-r--r--    4096 Oct 23 08:45 in_accel_y_mag_rising_en
-rw-r--r--    4096 Oct 23 08:45 in_accel_z_mag_rising_en

Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-23 16:27:35 +00:00
Ludovic Desroches 61be8fde63 iio:adc:at91-sama5d2: code cleanup
Use var type for sizeof argument instead of the struct name.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-23 16:17:11 +00:00
Ludovic Desroches d7bdcc3f57 iio:adc:at91-sama5d2: fix vref_uv type
vref_uv has to be an int.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-23 16:15:29 +00:00
Akinobu Mita 4ea71e5cee iio: adc: mcp320x: support more differential voltage measurement
mcp320x driver supports the pseudo-differential mode by
in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (0, 1), (2, 3), ...

mcp320x chips except MCP3X01 can also select swapped IN+ and IN-
pairs in the pseudo-differential mode.
i.e. in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (1, 0),
(3, 2), ...

If the voltage level of IN+ is equal to or less than IN-, the
resultant code will be 000h.  So it is useful to provide these, too.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Oskar Andero <oskar.andero@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-16 13:04:05 +00:00
Ludovic Desroches b9cd7a254d MAINTAINERS: add entry for Atmel SAMA5D2 ADC driver
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-16 11:34:06 +00:00
Ludovic Desroches 27e1771908 iio:adc:at91_adc8xx: introduce new atmel adc driver
This driver supports the new version of the Atmel ADC device introduced
with the SAMA5D2 SoC family.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-16 11:27:02 +00:00
Julia Lawall f78c5f9654 iio: ak8975: constify ak_def structures
The ak_def structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-10 12:35:33 +00:00
Linus Walleij a9fd053b56 iio: st_sensors: support active-low interrupts
Most ST MEMS Sensors that support interrupts can also handle sending
an active low interrupt, i.e. going from high to low on data ready
(or other interrupt) and thus triggering on a falling edge to the
interrupt controller.

Set up logic to inspect the interrupt line we get for a sensor: if
it is triggering on rising edge, leave everything alone, but if it
triggers on falling edges, set up active low, and if unsupported
configurations appear: warn with errors and reconfigure the interrupt
to a rising edge, which all interrupt generating sensors support.

Create a local header for st_sensors_core.h to share functions
between the sensor core and the trigger setup code.

Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-10 12:35:32 +00:00
Shraddha Barke c4f0ebd914 Staging: iio: cdc: ad7150: Fix alignment should match open parenthesis
Fix the checkpatch warning of alignment should match open
parenthesis.

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-04 12:16:25 +00:00
Shraddha Barke c0559ae2fb Staging: iio: cdc: ad7150: Prefer using the BIT macro
Replace bit shifting on 1 with the BIT(x) macro

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-04 12:07:52 +00:00
Matt Ranostay b11a34607d iio: health: max30100: add config for LED current
Allow the current for both RED and IR LEDs to be set via an device tree
property setting.

This is an optional setting that is useful for applications that have a
known glass attenuation factor.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-03 17:59:49 +00:00
Akinobu Mita 35f739679a iio: dac: mcp4725: Add basic support for MCP4726
MCP4726 is a single channel 12-bit DAC.  We can support MCP4726 with
a little changes to mcp4725 driver.  In power-down mode, they have
different selection of VOUT pull-down registers.

MCP4726 also has features:
 - Output gain options: 1x, 2x
 - Voltage reference selection: VDD, VREF (Unbuffered or Buffered)

But these are not supported in this change. (1x gain, VDD is selected)

datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/22272C.pdf

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-03 17:42:59 +00:00
Akinobu Mita 505abf99c7 iio: adc: mcp3422: Add support for MCP3425
The MCP3425 is a single channel up to 16-bit A/D converter which has
features:

- On-Board Programmable Gain Amplifier (PGA):
 - Gains of 1, 2, 4 or 8
- Programmable Data Rate Options:
 - 15 SPS (16 bits), 60 SPS (14 bits), 240 SPS (12 bits)

The mcp3422 driver also supports the MCP3421 which is a single channel.
So we can support MCP3425 with a little changes to mcp3422 driver.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-02 18:32:03 +00:00
Greg Kroah-Hartman 02c34ccc1d Third set of new stuff for IIO in the 4.5 cycle.
New driver features
 - us5182
   * Add interrupt support and rising / falling threshold events.
 
 Cleanups / fixes to new stuff / minor additions
 * Expose the IIO value formatting function for drivers to
   make use of internally.
 - ina2xx
    * Fix wrong channel order
    * Fix incorrect reporting of endianness
    * Adding documentation of ABI unique to this device
 - mma8452
   * Drop an unused register description
   * Use an enum for the channel index to aid readability
 - sca3000
   * Use standard NULL comparison style
 - us5182
   * fix an inconsistency in status of enable (a bug with no real effect until
     above patches are applied)
   * refactor the read_raw function to improve maintainability / readability.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJWeZ3IAAoJEFSFNJnE9BaIT2UP/3+VlQzBFrg1pBqLCR4xqMHB
 9gUBInzgBwmzpmAqD9pkvyG5f9fTz7hSqX2IGkAA1V6I91H2cunEROSGyhFd4VBW
 vhUhpz9WpRyx+8yLE3fQKUU/UmZJWTI7Xyladwrk3k87OOdcfn3wjtUdTuAhD5SW
 OWzW9txC5dAgSEC5yhqD8VdXN6tRL/eEOEFawHlf9f7bBr9DuyhECp6aIP79gKAS
 pynUPe3R5Uk/GuXdKX6zEWim4XZxhQR0oRmtrdCPIbauK6/ENDOWcaAvgS3mcN8i
 KJ/L27hQGc5zjR8VzysZzZw+7Edc4EqY2UvhA19+0RN93064s0qvR8hoEMp0bHP/
 MKGtwHv8MiqKfdCqIdimf6aT2GILTVWWx8WjyrM0O0+h444ba3ETRPGQ4mYNohuN
 Gt7FFv345aiFh2lQw8Rb54H2d19KV2hwUar3CTpRcl9OhOEnD3ulfDvQghzNlbXl
 nUh5dSOK+yDmXPPMEeZU4pYKG8rNaNZ1FxvVFy/yvUgytD1uqQDnWZ3b1gR0DiV9
 56ucUcrSg74LSqC8R/D6BXb+73LPBTmpu60iGvOQsUYcnmJSdnmEobWCnSXGjFXR
 I2e/H/ZOL4+dyHVpoyfQIiDpe6rGgYQHxyQ/kojWn2NxCJpgUufuR6jPTJ9GMF7k
 eckCq5cDb0nmmg45EQq0
 =aiE2
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.5c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Third set of new stuff for IIO in the 4.5 cycle.

New driver features
- us5182
  * Add interrupt support and rising / falling threshold events.

Cleanups / fixes to new stuff / minor additions
* Expose the IIO value formatting function for drivers to
  make use of internally.
- ina2xx
   * Fix wrong channel order
   * Fix incorrect reporting of endianness
   * Adding documentation of ABI unique to this device
- mma8452
  * Drop an unused register description
  * Use an enum for the channel index to aid readability
- sca3000
  * Use standard NULL comparison style
- us5182
  * fix an inconsistency in status of enable (a bug with no real effect until
    above patches are applied)
  * refactor the read_raw function to improve maintainability / readability.
2015-12-26 17:05:25 -08:00
Greg Kroah-Hartman 35ea984dac Second set of IIO new drivers, functionality and cleanups for the 4.5 cycle.
The big one here is the configfs support which has been a long time in the
 works but should allow for cleaner ways to do instantiation of those elements
 of IIO that aren't directly connected to specific hardware. Lots of cool new
 stuff we can use this for in the works!
 
 New core stuff (basically all configfs support related)
 * Configfs support
   - Core support (was waiting for a configfs patch that went in around 4.4rc2)
   - A little fixlet to add a configfs.h to contain a reference to the
     configfs_subsystem structure.
 * Some infrastructure to simplify handling of software based triggers
   (i.e. ones with no actual hardware associated with them)
 * A high resolution timer based trigger.  This has been around for years
     but until the configfs support was ready we didn't have a sensible way
     of instantiating instances of it (the method used for the sysfs_trigger
     has never been really satisfactory)
 
 New Device Support
 * AMS iAQ Volatile Organic Compounds sensor support.
 * Freescale imx7d ADC driver
 * Maxim MAX30100 oximeter driver (note that for these devices most of the
   smart stuff will be in userspace - effectively they are just light sensors
   with some interesting led synchronization as far as the kernel is concerned).
 * Microchip mcp3421 support added to the mcp3422 driver.
 * TI adc124s021 support added to the adc128s052 driver.
 * TI ina219, inda226 power monitors. Note that there is an existing hwmon driver
   for these parts, the usecase is somewhat different so it is unclear at this
   point if the hwmon driver will eventually be replaced by a bridge from
   this driver.  In the meantime the Kconfig dependencies should prevent both
   from being built.
 
 New driver functionality
 * us8152d power management support.
 
 Cleanups, fixups
 * Use list_for_each_entry_safe instead of list_for_each_safe with the entry
   bit coded longhand.
 * Select IRQ_WORK for IIO_DUMMY_EVGEN.  This is a fix that somehow got lost
   when the driver was moved so lets do it again.
 * st-accel - drop an unused define.
 * vz89x, lidar - optimize i2c transactions by using a single i2c tranfers
   instead of multiple calls where supported (fall back to smbus calls as
   before if not).
 * Use dev_get_platdata() in staging drivers: tsl2x7x, adcs and frequency
   drivers instead of direct access to the structure element.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJWbX6IAAoJEFSFNJnE9BaI6E4QAIvGXHn4ew8ZH+IF3UP+n47C
 WWtgeh7dEvhqpmXN3eWVo9bxA1JdwbE4/purWttszoJjzqowT0qAt6PuIUME+Md4
 3jOQ41Sc99YjttIwkLpWTqq3H5c3Tn3q9guZ3Imiz9rmpgHRePQ8aatMGUpOp53m
 AEY5JQHqCoWHLMEbEy/5w8RJdNf3cy3Re4kjtwrtp7CMynC4ob7dKE7kcZRvywEw
 6m4hVOQusLvygg1j235czwBDnf79qYOo96z93Pk/auQlqKX3ce/7yQW3GXvWl97a
 8FOmse3FNzX3jwWHELOdAZWIQSLBSqP9N4716qa4orVSihzqAZQ5CSEBPB0r2LS2
 cgK4BL6+xjDkwXn9ui4FiyLdUeUjz/zRhvwFZdjwP63hGf5n9ggZO3RuVslc6/8z
 DOHY5mLdg8CFlMlZUCnCc+1BjU8lgf90+a46Vx4ACJJiqIJrvNRxRKGQZyY/C9sO
 O8h0Ep5mWovcK1+SWdQSsfxdcWcdb0nJFG/VQeJVxMeJR+5mD5lCYmIj5xFkOxJU
 WP9xm+7rsCqSPW+vp8hlY3EWunIQB4gWROvLzWCTS2bKW7B12t1UapLZBrI1f6vK
 JuqHrjKkK7RBRAEldKz6cWCToEaHE+I/k+uIRhlp0of2IPEvGpnm3NoPN1XH3RID
 9boPy/eHuShq8EVg0WUt
 =54PR
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.5b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of IIO new drivers, functionality and cleanups for the 4.5 cycle.

The big one here is the configfs support which has been a long time in the
works but should allow for cleaner ways to do instantiation of those elements
of IIO that aren't directly connected to specific hardware. Lots of cool new
stuff we can use this for in the works!

New core stuff (basically all configfs support related)
* Configfs support
  - Core support (was waiting for a configfs patch that went in around 4.4rc2)
  - A little fixlet to add a configfs.h to contain a reference to the
    configfs_subsystem structure.
* Some infrastructure to simplify handling of software based triggers
  (i.e. ones with no actual hardware associated with them)
* A high resolution timer based trigger.  This has been around for years
    but until the configfs support was ready we didn't have a sensible way
    of instantiating instances of it (the method used for the sysfs_trigger
    has never been really satisfactory)

New Device Support
* AMS iAQ Volatile Organic Compounds sensor support.
* Freescale imx7d ADC driver
* Maxim MAX30100 oximeter driver (note that for these devices most of the
  smart stuff will be in userspace - effectively they are just light sensors
  with some interesting led synchronization as far as the kernel is concerned).
* Microchip mcp3421 support added to the mcp3422 driver.
* TI adc124s021 support added to the adc128s052 driver.
* TI ina219, inda226 power monitors. Note that there is an existing hwmon driver
  for these parts, the usecase is somewhat different so it is unclear at this
  point if the hwmon driver will eventually be replaced by a bridge from
  this driver.  In the meantime the Kconfig dependencies should prevent both
  from being built.

New driver functionality
* us8152d power management support.

Cleanups, fixups
* Use list_for_each_entry_safe instead of list_for_each_safe with the entry
  bit coded longhand.
* Select IRQ_WORK for IIO_DUMMY_EVGEN.  This is a fix that somehow got lost
  when the driver was moved so lets do it again.
* st-accel - drop an unused define.
* vz89x, lidar - optimize i2c transactions by using a single i2c tranfers
  instead of multiple calls where supported (fall back to smbus calls as
  before if not).
* Use dev_get_platdata() in staging drivers: tsl2x7x, adcs and frequency
  drivers instead of direct access to the structure element.
2015-12-26 17:03:33 -08:00
Jonathan Cameron e8aab48b34 iio: adc: ina2xx: Fix incorrect report of data endianness to userspace.
This was extracted from a reposting of the driver after it had been applied
to the IIO tree.  I have fast tracked it as the driver will be in 4.5 and
it would be nice to fix this trivial issue before it is.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22 18:51:27 +00:00
Adriana Reus 9b1de75b5d iio: light: us5182d: Refactor read_raw function
A bit of refactoring for better readability.
Moved and slightly reorganized all the activity necessary for reading als
and proximity into a different function. This way the switch in read raw
becomes clearer and more compact.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22 18:07:08 +00:00
Adriana Reus b6695254f8 iio: light: us5182d: Add interrupt support and events
Add interrupt support for proximity.
Add two threshold events to signal rising and falling directions.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22 18:07:05 +00:00
Adriana Reus 58e9042f5f iio: light: us5182d: Fix enable status inconcistency
When setting als only or proximity only modes make sure that we mark the
other component as disabled. This fix is in preparation of adding event
support because that will make it possible to switch between one-shot and
continuous modes and not tracking these correctly may cause faulty
behaviour (e.g wrongfully considering px enabled and not setting an
appropriate mode in the chip).

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22 18:00:51 +00:00
Andrew F. Davis 7d2c2acac5 iio: Make IIO value formating function globally available.
Make IIO value formating function globally available to allow IIO drivers
to output values as the core does.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22 17:04:56 +00:00
Geliang Tang e59ac74794 staging: emxx_udc: use list_first_entry_or_null()
Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 18:32:52 -08:00
Arnd Bergmann e7cfb3907d staging/emxx_udc: fix 64-bit warnings
ARCH_SHMOBILE is coming to arm64, which creates new warnings in allmodconfig:

drivers/staging/emxx_udc/emxx_udc.c: In function '_nbu2ss_out_dma':
drivers/staging/emxx_udc/emxx_udc.c:843:45: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  _nbu2ss_writel(&preg->EP_DCR[num].EP_TADR, (u32)pBuffer);

This is clearly a mistake from confusing a dma_addr_t with a pointer,
so the fix is to use the correct types in two places.

The third warning of this kind is a check for an unaligned pointer,
which should be done by casting the pointer to uintptr_t, not int.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 18:32:52 -08:00
Moritz König f6e9b91433 STAGING: COMEDI: Using kernel types in plx9080.h
This patch makes plx9080.h use kernel types.

Signed-off-by: Moritz König <moritz.koenig@fau.de>
Signed-off-by: Fabian Lang <fabian.lang@fau.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Acked-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:02:21 -08:00
Moritz König e0bcce6b3a STAGING: COMEDI: Added spaces around binary operators in plx9080.h
This patch adds spaces around binary operators in plx9080.h.

Signed-off-by: Moritz König <moritz.koenig@fau.de>
Signed-off-by: Fabian Lang <fabian.lang@fau.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:02:21 -08:00
Moritz König e554840c94 STAGING: COMEDI: Fixed format of comments in plx9080.h
This patch fixes the format of comments in plx9080.h.

Signed-off-by: Moritz König <moritz.koenig@fau.de>
Signed-off-by: Fabian Lang <fabian.lang@fau.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:02:21 -08:00
Jitendra Kumar Khasdev 2acc980bc6 staging: comedi: comedilib.h: Coding style warning fix for block comments
This patch is to comedilib.h file that fixes up following warnings
reported by checkpatch.pl :
I) Block comments use * on subsequent lines.

Apart from it I have remove header file path by base file name as
suggested by community.

Signed-off-by: Jitendra Kumar Khasdev <jkhasdev@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:01:12 -08:00
Ian Abbott e5417e4996 staging: comedi: s526: add macros for counter control reg values
The driver writes a couple of literal values to the counter
control/status register, 0x8000 to reset the counter, and 0x4000 to load
the counter from preload register 0.  Add a bunch of macros to define
these values and other values for the register, based on the Sensoray
526 manual.

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>
2015-12-21 16:00:12 -08:00
Ian Abbott 479bd5edab staging: comedi: s526: replace counter mode bitfield struct
The driver uses `struct counter_mode_register_t` to describe the 16-bit
counter mode register as a sequence of bitfield members.  The struct
appears as the type of one of the members of `union cmReg`, the other
member of which is of type `unsigned short`, so the driver can
manipulate the register value as a whole, or as individual fields.
Although this is fairly convenient, it's not that conventional.  The
code also needs to define the bitfield members in ascending or
descending order of the physical bits, depending on whether bitfields
are little- or big-endian.

Rip all that out and replace it with a bunch of macros to set and mask
out bits of the register value, as that's the more conventional way to
do it.  A bonus is that we get rid of a load of CamelCase definitions in
the process.

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>
2015-12-21 16:00:12 -08:00
Ian Abbott 28a60c456b staging: comedi: check for more errors for zero-length write
If the "write" file operation handler, `comedi_write()` is passed 0 for
the amount to write, some error conditions are currently skipped and the
function just returns 0.  Change it to check those error conditions and
return an error value if appropriate.  The trickiest case is the check
for when the previously set up asynchronous command has terminated with
an error.  In that case, `-EPIPE` is returned (as it is for a write of
non-zero length) and the subdevice gets marked as non-busy.

A zero-length write that returns 0 has no other effects, in particular,
it does not cause the subdevice to be marked as non-busy.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 3318c7add8 staging: comedi: simplify returned errors for comedi_write()
In order to perform a "write" file operation, an asynchronous COMEDI
command in the "write" direction needs to have been set up by the
current file object on the COMEDI "write" subdevice associated with the
file object.  If there is a "write" subdevice, but a command has not
been set up by the file object (or is has been set-up in the wrong
direction), `comedi_write()` currently returns one of two error values
`-EINVAL` or `-EACCES`.  `-EACCES` is returned if the command was set up
by a different subdevice, or somewhat randomly, if a COMEDI
"instruction" is currently being processed.  `-EINVAL` is returned in
other cases.  Simplify it by returning `-EINVAL` for all these cases.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 40d0e80e08 staging: comedi: return error on "write" if no command set up
The "write" file operation handler, `comedi_write()` returns an error
for pretty much any condition that prevents a "write" going ahead.  One
of the conditions that prevents a "write" going ahead is that no
asynchronous command has been set up, but that currently results in a
return value of 0 (unless COMEDI instructions are being processed or an
asynchronous command has been set up by a different file object).
Change it to return `-EINVAL` in this case.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 35a7475dc8 staging: comedi: allow buffer wraparound in comedi_write()
`comedi_write()` copies data from the user buffer to the acquisition
data buffer, which is cyclic, using a single call to `copy_from_user()`.
It currently avoids having to deal with wraparound of the cyclic buffer
by limiting the amount it copies (and the amount returned to the user).
Change it to deal with the wraparound using two calls to
`copy_from_user()` if necessary.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 591c5f8a59 staging: comedi: avoid bad truncation of a size_t in comedi_write()
At one point in `comedi_write()`, the variable `n` gets assigned to the
minimum of the parameter `nbytes` and the amount of writeable buffer
space.  The way that is done currently is unsafe in the unlikely case
that `nbytes` exceeds `UINT_MAX`, so fix it.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 84a185ec42 staging: comedi: make some variables unsigned in comedi_write()
In `comedi_write()`, the `n` and `m` variables are of type `int`.
Change them to `unsigned int` as they are used to measure a positive
number of bytes.  The `count` variable is also of type `int` and holds
the returned number of bytes written.  Change it to type `ssize_t` to
match the function's return type.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott ed65bba31b staging: comedi: do extra checks for becoming non-busy for "write"
`comedi_write()` is the handler for the "write" file operation for
COMEDI devices.  It mostly runs without using the main mutex of the
COMEDI device, but uses the `attach_lock` rw_semaphore to protect
against the COMEDI device becoming "detached".  A file object can write
data for a COMEDI asynchonous command if it initiated the command.  The
COMEDI subdevice is marked as busy when the command is started.  At some
point, the "write" handler detects that the command has terminated and
so marks the subdevice as non-busy.

In order to mark the subdevice as non-busy, the "write" handler needs to
release the `attach_lock` rw_semaphore and `acquire the main `mutex`.
There is a vulnerable point between the two, so it checks that the
device is still attached after acquiring the mutex.  However, it does
not currently check that the conditions for becoming non-busy still
hold.  Add some more checks that the subdevice is still busy with a
command initiated by the same file object, and that the command is in
the correct direction (in case the subdevice supports both "read" and
"write").

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 06181de14f staging: comedi: rearrange comedi_write() code
Rearrange the code in `comedi_write()` to reduce the amount of
indentation.  The code never reiterates the `while` loop once `count`
has become non-zero, so we can check that in the `while` condition to
save an indentation level.  (Note that `nbytes` has been checked to be
non-zero before entering the loop, so we can remove that check.)  Move
the code that makes the subdevice "become non-busy" outside the `while`
loop, using a new flag variable `become_nonbusy` to decide whether it
needs to be done.  This simplifies the wait queue handling so there is a
single place where the task is removed from the wait queue, and we can
remove the `on_wait_queue` flag variable.

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>
2015-12-21 15:58:54 -08:00
H Hartley Sweeten b4717ff608 staging: comedi: adv_pci_dio: update the MODULE_DESCRIPTION
Change the MODULE_DESCRIPTION to something more useful than the
generic "Comedi low-level 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten bb263fd5d3 staging: comedi: adv_pci_dio: tidy up the comedi comment block
The Description is a bit long winded and the same information is in
the Devices. Shorten the Description and tidy up the Devices.

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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten d97e1552fd staging: comedi: adv_pci_dio: move pci_dio_override_cardtype()
This function is called as part of the pci_driver (*probe) before
doing the (*auto_attach) of the comedi driver. For aesthetics, move
the function to a more logical place 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten a54b6e60f3 staging: comedi: adv_pci_dio: move and rename the MAX_*_SUBDEV[SG] defines
For aesthetics, move these defines after the register defines and rename
them to have namespace associated with 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 2b60bbde04 staging: comedi: adv_pci_dio: move and rename enum hw_cards_id
For aesthetics, move this enum after the register defines and rename
it to have namespace associated with 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten bcae0adaf4 staging: comedi: adv_pci_dio: remove boardinfo 'cardtype'
This member of the boardinfo is identical to the offset of the boardinfo
in the boardtypes array. It's also passed as the 'context' to the driver
(*auto_attach).

The 'cardtype' is only needed by the (*auto_attach) to determine which
PCI BAR to use and in pci_dio_reset() to handle the board specific code.

Remove the 'cardtype' member and use the 'context' value instead.

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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten d0b5860c27 staging: comedi: adv_pci_dio: cleanup PCI-1762 interrupt registers
For aesthetics, use a common define for the interrupt control and status
registers.

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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 6a1c0149a4 staging: comedi: adv_pci_dio: rename PCI1752_6_CFC define
For aesthetics, rename this define and fix the alignment.

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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 008342ebfd staging: comedi: adv_pci_dio: cleanup PCI-175[46] interrupt registers
For aesthetics, replace these defines with a macro.

Refactor the switch in pci_dio_reset() to use common 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 774a8c57b1 staging: comedi: adv_pci_dio: cleanup PCI-1753 interrupt register defines
For aesthetics, replace these defines with some macros.

Refactor the switch in pci_dio_reset() to not require the fallthrough
comment.

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>
2015-12-21 15:57:40 -08:00