diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-25 11:12:07 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-25 11:12:07 +0300 |
commit | 3ceefa3ffd17daacef3e09f895f67721fb1f6b79 (patch) | |
tree | 4c027e6925b8287cf24cc2015fccdea495d744d5 /drivers/iio/adc/ti-ads7950.c | |
parent | 4a965c5f89decd636129cddc47e5f2c61e8f13e6 (diff) | |
parent | c5b974bee9d2ceae4c441ae5a01e498c2674e100 (diff) | |
download | linux-3ceefa3ffd17daacef3e09f895f67721fb1f6b79.tar.xz |
Merge tag 'iio-for-4.19b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
Second set of IIO new device support, features and cleanups.
There are also a couple of fixes that can wait for the coming merge
window.
Core new features
* Support for phase channels (used in time of flight sensors amongst
other things)
* Support for deep UV light channel modifier.
New Device Support
* AD4758 DAC
- New driver and dt bindings.
* adxl345
- Support the adxl375 +-200g part which is register compatible.
* isl29501 Time of flight sensor.
- New driver
* meson-saradc
- Support the Meson8m2 Socs - right now this is just an ID, but there will
be additional difference in future.
* mpu6050
- New ID for 6515 variant.
* si1133 UV sensor.
- New driver
* Spreadtrum SC27xx PMIC ADC
- New driver and dt bindings.
Features
* adxl345
- Add calibration offset readback and writing.
- Add sampling frequency control.
Fixes and Cleanups
* ad5933
- Use a macro for the channel definition to reduce duplication.
* ad9523
- Replace use of core mlock with a local lock. Part of ongoing efforts
to avoid confusing the purpose of mlock which is only about iio core
state changes.
- Fix displayed phase which was out by a factor of 10.
* adxl345
- Add a link to the datasheet.
- Rework the use of the address field in the chan_spec structures to
allow addition of more per channel information.
* adis imu
- Mark switch fall throughs.
* at91-sama5d2
- Fix some casting on big endian systems.
* bmp280
- Drop some DT elements that aren't used and should mostly be done from
userspace rather than in DT.
* hx711
- add clock-frequency dt binding and resulting delay to deal with capacitance
issue on some boards.
- fix a spurious unit-address in the example.
* ina2xx
- Avoid a possible kthread_stop with a stale task_struct.
* ltc2632
- Remove some unused local variables (assigned but value never used).
* max1363
- Use device_get_match_data to remove some boilerplate.
* mma8452
- Mark switch fall throughs.
* sca3000
- Fix a missing return in a switch statement (a bad fallthrough
previously!)
* sigma-delta-modulator
- Drop incorrect unit address from the DT example.
* st_accel
- Use device_get_match_data to drop some boiler plate.
- Move to probe_new for i2c driver as second parameter not used.
* st_sensors library
- Use a strlcpy (safe in this case).
* st_lsm6dsx
- Add some error logging.
* ti-ads7950
- SPDX
- Allow simultaneous buffered and polled reads. Needed on a Lego Mindstorms
EV3 where some channels are used for power supply monitoring at a very low
rate.
* ti-dac5571
- Remove an unused variable.
* xadc
- Drop some dead code.
Diffstat (limited to 'drivers/iio/adc/ti-ads7950.c')
-rw-r--r-- | drivers/iio/adc/ti-ads7950.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index 0225c1b333ab..a5bd5944bc66 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Texas Instruments ADS7950 SPI ADC driver * @@ -10,15 +11,6 @@ * And also on hwmon/ads79xx.c * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ * Nishanth Menon - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include <linux/acpi.h> @@ -76,6 +68,9 @@ struct ti_ads7950_state { __be16 rx_buf[TI_ADS7950_MAX_CHAN + TI_ADS7950_TIMESTAMP_SIZE] ____cacheline_aligned; __be16 tx_buf[TI_ADS7950_MAX_CHAN]; + __be16 single_tx; + __be16 single_rx; + }; struct ti_ads7950_chip_info { @@ -295,18 +290,26 @@ out: return IRQ_HANDLED; } -static int ti_ads7950_scan_direct(struct ti_ads7950_state *st, unsigned int ch) +static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch) { + struct ti_ads7950_state *st = iio_priv(indio_dev); int ret, cmd; + mutex_lock(&indio_dev->mlock); + cmd = TI_ADS7950_CR_WRITE | TI_ADS7950_CR_CHAN(ch) | st->settings; - st->tx_buf[0] = cpu_to_be16(cmd); + st->single_tx = cpu_to_be16(cmd); ret = spi_sync(st->spi, &st->scan_single_msg); if (ret) - return ret; + goto out; + + ret = be16_to_cpu(st->single_rx); - return be16_to_cpu(st->rx_buf[0]); +out: + mutex_unlock(&indio_dev->mlock); + + return ret; } static int ti_ads7950_get_range(struct ti_ads7950_state *st) @@ -338,13 +341,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - - ret = iio_device_claim_direct_mode(indio_dev); - if (ret < 0) - return ret; - - ret = ti_ads7950_scan_direct(st, chan->address); - iio_device_release_direct_mode(indio_dev); + ret = ti_ads7950_scan_direct(indio_dev, chan->address); if (ret < 0) return ret; @@ -410,13 +407,13 @@ static int ti_ads7950_probe(struct spi_device *spi) * was read at the end of the first transfer. */ - st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; + st->scan_single_xfer[0].tx_buf = &st->single_tx; st->scan_single_xfer[0].len = 2; st->scan_single_xfer[0].cs_change = 1; - st->scan_single_xfer[1].tx_buf = &st->tx_buf[0]; + st->scan_single_xfer[1].tx_buf = &st->single_tx; st->scan_single_xfer[1].len = 2; st->scan_single_xfer[1].cs_change = 1; - st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; + st->scan_single_xfer[2].rx_buf = &st->single_rx; st->scan_single_xfer[2].len = 2; spi_message_init_with_transfers(&st->scan_single_msg, |