mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 20:24:12 +08:00
Second round of new iio device support, features and cleanups in the 4.8 cycle
Firstly some contact detail updates: * NXP took over freescale. Update the mma8452 header to reflect this. * Martin Kepplinger email address change in mma8452 header. * Adriana Reus has changed email address. Update .mailmap. * Matt Ranostay has changed email address. Update .mailmap. New Device Support * max1363 - add the missing i2c_device_ids for a couple of parts so they can actually be used. * ms5867 - add device ids for ms5805 and ms5837 parts. New Features * ad5755 - DT support. This one was a bit controversial and under review for a long time. Still no one could come up with a better solution. * stx104 - add gpio support * ti-adc081c - Add ACPI device ID matching. Core changes * Refuse to register triggers with duplicate names. There is no way to distinguish between them so this makes no sense. A few drivers do not generate unique names for each instance of the device present. We can't fix this without changing ABI so leave them and wait for someone to actually take the rare step of two identical accelerometers on the same board. * buffer-dma - use ARRAY_SIZE in a few appropriate locations. Tools * Fix the fact that the --trigger-num option in generic_buffer didn't allow 0 which is perfectly valid in the ABI. Cleanups * as3935 - improve error reporting. - remove redundant zeroing of a field in iio_priv. * gp2ap020a00f - use the iio_device_claim_*_mode helpers rather than open coding locking around mode changes. * isl29125 - use the iio_device_claim_*_mode helpers rather than open coding locking. * lidar - use the iio_device_claim_*_mode helpers rather than open coding locking. * mma8452 - more detail in devices supported description in comments (addresses and similar) * sca3000 - add a missing error check. * tcs3414 - use the iio_device_claim_*_mode helpers rather than open coding locking. * tcs3472 - use the iio_device_claim_*_mode helpers rather than open coding locking. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJXdAT2AAoJEFSFNJnE9BaIq68P/3Z0q1lc1cb+K8HV5jgukEKw eoxZa5lFIOuHAGeXo9GAdJiH5oT/yAIhadf3gzuuQLaTJwWYKD51aPVwgpT5M2+x Bnu2XiYcaoIm/Foat70ycjeYaGxO/xO2vbLp5v0BJV2ujvjm/oCKw5pxYeU4Jm63 iKaZo9jn/HoshOMpZBrcPZ7Q1TogRdopBNe2fsc8nXFFsv8ODjOZ9Nebs2lk36e+ PWLUWfSkv2LMBSE2LOFyjSW8E4ItBBngBcyqBTFiiln7mpXU5Vv2QSvUhpP2YjUZ rxKvDiG7ADuxMr901whASxyCO180yCxTRIcBsN8oP73gTGHrJnMT0Sptfz7AUUVN gJneiy+iy3TecJ/R6w/DnNzqmZMiEVqlYGkdXVGu8SXrKWilvzcTp5iTmDVM5zLb 1fDZxjbLdNJuHzoSYNiCBcnfzIixOAyKTGFi3jUaPPQ/Lc1qfmgerWWlOzKeUgCZ 5Bzak8MvWuxcO7jkMG8mbARufy3Nu6eh8a39JXFhViGtTtySydMa8eXdYPjqoAtv vgwJNh9U53yYui8i7vU90dM3gJaGg5a4R6EjEKCYcEJf6kM9Go8xCvjU8YWPtIKk rfykpPkKcQzbax07YKvb4f015x7r0V6WCGJjPn0Fi14ugNGJJ6M88l+2UcXcx1zS RRtVRD49Le7pIDCs1Rqn =6Lja -----END PGP SIGNATURE----- Merge tag 'iio-for-4.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Second round of new iio device support, features and cleanups in the 4.8 cycle Firstly some contact detail updates: * NXP took over freescale. Update the mma8452 header to reflect this. * Martin Kepplinger email address change in mma8452 header. * Adriana Reus has changed email address. Update .mailmap. * Matt Ranostay has changed email address. Update .mailmap. New Device Support * max1363 - add the missing i2c_device_ids for a couple of parts so they can actually be used. * ms5867 - add device ids for ms5805 and ms5837 parts. New Features * ad5755 - DT support. This one was a bit controversial and under review for a long time. Still no one could come up with a better solution. * stx104 - add gpio support * ti-adc081c - Add ACPI device ID matching. Core changes * Refuse to register triggers with duplicate names. There is no way to distinguish between them so this makes no sense. A few drivers do not generate unique names for each instance of the device present. We can't fix this without changing ABI so leave them and wait for someone to actually take the rare step of two identical accelerometers on the same board. * buffer-dma - use ARRAY_SIZE in a few appropriate locations. Tools * Fix the fact that the --trigger-num option in generic_buffer didn't allow 0 which is perfectly valid in the ABI. Cleanups * as3935 - improve error reporting. - remove redundant zeroing of a field in iio_priv. * gp2ap020a00f - use the iio_device_claim_*_mode helpers rather than open coding locking around mode changes. * isl29125 - use the iio_device_claim_*_mode helpers rather than open coding locking. * lidar - use the iio_device_claim_*_mode helpers rather than open coding locking. * mma8452 - more detail in devices supported description in comments (addresses and similar) * sca3000 - add a missing error check. * tcs3414 - use the iio_device_claim_*_mode helpers rather than open coding locking. * tcs3472 - use the iio_device_claim_*_mode helpers rather than open coding locking.
This commit is contained in:
commit
3c9a6793bd
3
.mailmap
3
.mailmap
@ -11,6 +11,7 @@ Aaron Durbin <adurbin@google.com>
|
||||
Adam Oldham <oldhamca@gmail.com>
|
||||
Adam Radford <aradford@gmail.com>
|
||||
Adrian Bunk <bunk@stusta.de>
|
||||
Adriana Reus <adi.reus@gmail.com> <adriana.reus@intel.com>
|
||||
Alan Cox <alan@lxorguk.ukuu.org.uk>
|
||||
Alan Cox <root@hraefn.swansea.linux.org.uk>
|
||||
Aleksey Gorelov <aleksey_gorelov@phoenix.com>
|
||||
@ -90,6 +91,8 @@ Linas Vepstas <linas@austin.ibm.com>
|
||||
Mark Brown <broonie@sirena.org.uk>
|
||||
Matthieu CASTET <castet.matthieu@free.fr>
|
||||
Mauro Carvalho Chehab <mchehab@kernel.org> <maurochehab@gmail.com> <mchehab@infradead.org> <mchehab@redhat.com> <m.chehab@samsung.com> <mchehab@osg.samsung.com> <mchehab@s-opensource.com>
|
||||
Matt Ranostay <mranostay@gmail.com> Matthew Ranostay <mranostay@embeddedalley.com>
|
||||
Matt Ranostay <mranostay@gmail.com> <matt.ranostay@intel.com>
|
||||
Mayuresh Janorkar <mayur@ti.com>
|
||||
Michael Buesch <m@bues.ch>
|
||||
Michel Dänzer <michel@tungstengraphics.com>
|
||||
|
124
Documentation/devicetree/bindings/iio/dac/ad5755.txt
Normal file
124
Documentation/devicetree/bindings/iio/dac/ad5755.txt
Normal file
@ -0,0 +1,124 @@
|
||||
* Analog Device AD5755 IIO Multi-Channel DAC Linux Driver
|
||||
|
||||
Required properties:
|
||||
- compatible: Has to contain one of the following:
|
||||
adi,ad5755
|
||||
adi,ad5755-1
|
||||
adi,ad5757
|
||||
adi,ad5735
|
||||
adi,ad5737
|
||||
|
||||
- reg: spi chip select number for the device
|
||||
- spi-cpha or spi-cpol: is the only modes that is supported
|
||||
|
||||
Recommended properties:
|
||||
- spi-max-frequency: Definition as per
|
||||
Documentation/devicetree/bindings/spi/spi-bus.txt
|
||||
|
||||
Optional properties:
|
||||
See include/dt-bindings/iio/ad5755.h
|
||||
- adi,ext-dc-dc-compenstation-resistor: boolean set if the hardware have an
|
||||
external resistor and thereby bypasses
|
||||
the internal compensation resistor.
|
||||
- adi,dc-dc-phase:
|
||||
Valid values for DC DC Phase control is:
|
||||
0: All dc-to-dc converters clock on the same edge.
|
||||
1: Channel A and Channel B clock on the same edge,
|
||||
Channel C and Channel D clock on opposite edges.
|
||||
2: Channel A and Channel C clock on the same edge,
|
||||
Channel B and Channel D clock on opposite edges.
|
||||
3: Channel A, Channel B, Channel C, and Channel D
|
||||
clock 90 degrees out of phase from each other.
|
||||
- adi,dc-dc-freq-hz:
|
||||
Valid values for DC DC frequency is [Hz]:
|
||||
250000
|
||||
410000
|
||||
650000
|
||||
- adi,dc-dc-max-microvolt:
|
||||
Valid values for the maximum allowed Vboost voltage supplied by
|
||||
the dc-to-dc converter is:
|
||||
23000000
|
||||
24500000
|
||||
27000000
|
||||
29500000
|
||||
|
||||
Optional for every channel:
|
||||
- adi,mode:
|
||||
Valid values for DAC modes is:
|
||||
0: 0 V to 5 V voltage range.
|
||||
1: 0 V to 10 V voltage range.
|
||||
2: Plus minus 5 V voltage range.
|
||||
3: Plus minus 10 V voltage range.
|
||||
4: 4 mA to 20 mA current range.
|
||||
5: 0 mA to 20 mA current range.
|
||||
6: 0 mA to 24 mA current range.
|
||||
- adi,ext-current-sense-resistor: boolean set if the hardware a external
|
||||
current sense resistor.
|
||||
- adi,enable-voltage-overrange: boolean enable voltage overrange
|
||||
- adi,slew: Array of slewrate settings should contain 3 fields:
|
||||
1: Should be either 0 or 1 in order to enable or disable slewrate.
|
||||
2: Slew rate settings:
|
||||
Valid values for the slew rate update frequency:
|
||||
64000
|
||||
32000
|
||||
16000
|
||||
8000
|
||||
4000
|
||||
2000
|
||||
1000
|
||||
500
|
||||
250
|
||||
125
|
||||
64
|
||||
32
|
||||
16
|
||||
8
|
||||
4
|
||||
0
|
||||
3: Slew step size:
|
||||
Valid values for the step size LSBs:
|
||||
1
|
||||
2
|
||||
4
|
||||
16
|
||||
32
|
||||
64
|
||||
128
|
||||
256
|
||||
|
||||
Example:
|
||||
dac@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "adi,ad5755";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <1000000>;
|
||||
spi-cpha;
|
||||
adi,dc-dc-phase = <0>;
|
||||
adi,dc-dc-freq-hz = <410000>;
|
||||
adi,dc-dc-max-microvolt = <23000000>;
|
||||
channel@0 {
|
||||
reg = <0>;
|
||||
adi,mode = <4>;
|
||||
adi,ext-current-sense-resistor;
|
||||
adi,slew = <0 64000 1>;
|
||||
};
|
||||
channel@1 {
|
||||
reg = <1>;
|
||||
adi,mode = <4>;
|
||||
adi,ext-current-sense-resistor;
|
||||
adi,slew = <0 64000 1>;
|
||||
};
|
||||
channel@2 {
|
||||
reg = <2>;
|
||||
adi,mode = <4>;
|
||||
adi,ext-current-sense-resistor;
|
||||
adi,slew = <0 64000 1>;
|
||||
};
|
||||
channel@3 {
|
||||
reg = <3>;
|
||||
adi,mode = <4>;
|
||||
adi,ext-current-sense-resistor;
|
||||
adi,slew = <0 64000 1>;
|
||||
};
|
||||
};
|
@ -157,12 +157,12 @@ config MMA7660
|
||||
will be called mma7660.
|
||||
|
||||
config MMA8452
|
||||
tristate "Freescale MMA8452Q and similar Accelerometers Driver"
|
||||
tristate "Freescale / NXP MMA8452Q and similar Accelerometers Driver"
|
||||
depends on I2C
|
||||
select IIO_BUFFER
|
||||
select IIO_TRIGGERED_BUFFER
|
||||
help
|
||||
Say yes here to build support for the following Freescale 3-axis
|
||||
Say yes here to build support for the following Freescale / NXP 3-axis
|
||||
accelerometers: MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC,
|
||||
FXLS8471Q.
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
/*
|
||||
* mma8452.c - Support for following Freescale 3-axis accelerometers:
|
||||
* mma8452.c - Support for following Freescale / NXP 3-axis accelerometers:
|
||||
*
|
||||
* MMA8451Q (14 bit)
|
||||
* MMA8452Q (12 bit)
|
||||
* MMA8453Q (10 bit)
|
||||
* MMA8652FC (12 bit)
|
||||
* MMA8653FC (10 bit)
|
||||
* FXLS8471Q (14 bit)
|
||||
* device name digital output 7-bit I2C slave address (pin selectable)
|
||||
* ---------------------------------------------------------------------
|
||||
* MMA8451Q 14 bit 0x1c / 0x1d
|
||||
* MMA8452Q 12 bit 0x1c / 0x1d
|
||||
* MMA8453Q 10 bit 0x1c / 0x1d
|
||||
* MMA8652FC 12 bit 0x1d
|
||||
* MMA8653FC 10 bit 0x1d
|
||||
* FXLS8471Q 14 bit 0x1e / 0x1d / 0x1c / 0x1f
|
||||
*
|
||||
* Copyright 2015 Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
|
||||
* Copyright 2015 Martin Kepplinger <martink@posteo.de>
|
||||
* Copyright 2014 Peter Meerwald <pmeerw@pmeerw.net>
|
||||
*
|
||||
* This file is subject to the terms and conditions of version 2 of
|
||||
* the GNU General Public License. See the file COPYING in the main
|
||||
* directory of this archive for more details.
|
||||
*
|
||||
* 7-bit I2C slave address 0x1c/0x1d (pin selectable)
|
||||
*
|
||||
* TODO: orientation events
|
||||
*/
|
||||
|
||||
@ -108,7 +108,7 @@ struct mma8452_data {
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mma_chip_info - chip specific data for Freescale's accelerometers
|
||||
* struct mma_chip_info - chip specific data
|
||||
* @chip_id: WHO_AM_I register's value
|
||||
* @channels: struct iio_chan_spec matching the device's
|
||||
* capabilities
|
||||
@ -1693,5 +1693,5 @@ static struct i2c_driver mma8452_driver = {
|
||||
module_i2c_driver(mma8452_driver);
|
||||
|
||||
MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
|
||||
MODULE_DESCRIPTION("Freescale MMA8452 accelerometer driver");
|
||||
MODULE_DESCRIPTION("Freescale / NXP MMA8452 accelerometer driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/acpi.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
@ -149,12 +150,24 @@ static int adc081c_probe(struct i2c_client *client,
|
||||
{
|
||||
struct iio_dev *iio;
|
||||
struct adc081c *adc;
|
||||
struct adcxx1c_model *model = &adcxx1c_models[id->driver_data];
|
||||
struct adcxx1c_model *model;
|
||||
int err;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (ACPI_COMPANION(&client->dev)) {
|
||||
const struct acpi_device_id *ad_id;
|
||||
|
||||
ad_id = acpi_match_device(client->dev.driver->acpi_match_table,
|
||||
&client->dev);
|
||||
if (!ad_id)
|
||||
return -ENODEV;
|
||||
model = &adcxx1c_models[ad_id->driver_data];
|
||||
} else {
|
||||
model = &adcxx1c_models[id->driver_data];
|
||||
}
|
||||
|
||||
iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
|
||||
if (!iio)
|
||||
return -ENOMEM;
|
||||
@ -231,10 +244,21 @@ static const struct of_device_id adc081c_of_match[] = {
|
||||
MODULE_DEVICE_TABLE(of, adc081c_of_match);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ACPI
|
||||
static const struct acpi_device_id adc081c_acpi_match[] = {
|
||||
{ "ADC081C", ADC081C },
|
||||
{ "ADC101C", ADC101C },
|
||||
{ "ADC121C", ADC121C },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match);
|
||||
#endif
|
||||
|
||||
static struct i2c_driver adc081c_driver = {
|
||||
.driver = {
|
||||
.name = "adc081c",
|
||||
.of_match_table = of_match_ptr(adc081c_of_match),
|
||||
.acpi_match_table = ACPI_PTR(adc081c_acpi_match),
|
||||
},
|
||||
.probe = adc081c_probe,
|
||||
.remove = adc081c_remove,
|
||||
|
@ -305,7 +305,7 @@ int iio_dma_buffer_request_update(struct iio_buffer *buffer)
|
||||
queue->fileio.active_block = NULL;
|
||||
|
||||
spin_lock_irq(&queue->list_lock);
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) {
|
||||
block = queue->fileio.blocks[i];
|
||||
|
||||
/* If we can't re-use it free it */
|
||||
@ -323,7 +323,7 @@ int iio_dma_buffer_request_update(struct iio_buffer *buffer)
|
||||
|
||||
INIT_LIST_HEAD(&queue->incoming);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) {
|
||||
if (queue->fileio.blocks[i]) {
|
||||
block = queue->fileio.blocks[i];
|
||||
if (block->state == IIO_BLOCK_STATE_DEAD) {
|
||||
|
@ -248,11 +248,12 @@ config MCP4922
|
||||
config STX104
|
||||
tristate "Apex Embedded Systems STX104 DAC driver"
|
||||
depends on X86 && ISA_BUS_API
|
||||
select GPIOLIB
|
||||
help
|
||||
Say yes here to build support for the 2-channel DAC on the Apex
|
||||
Embedded Systems STX104 integrated analog PC/104 card. The base port
|
||||
addresses for the devices may be configured via the "base" module
|
||||
parameter array.
|
||||
Say yes here to build support for the 2-channel DAC and GPIO on the
|
||||
Apex Embedded Systems STX104 integrated analog PC/104 card. The base
|
||||
port addresses for the devices may be configured via the base array
|
||||
module parameter.
|
||||
|
||||
config VF610_DAC
|
||||
tristate "Vybrid vf610 DAC driver"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/platform_data/ad5755.h>
|
||||
@ -109,6 +110,51 @@ enum ad5755_type {
|
||||
ID_AD5737,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const int ad5755_dcdc_freq_table[][2] = {
|
||||
{ 250000, AD5755_DC_DC_FREQ_250kHZ },
|
||||
{ 410000, AD5755_DC_DC_FREQ_410kHZ },
|
||||
{ 650000, AD5755_DC_DC_FREQ_650kHZ }
|
||||
};
|
||||
|
||||
static const int ad5755_dcdc_maxv_table[][2] = {
|
||||
{ 23000000, AD5755_DC_DC_MAXV_23V },
|
||||
{ 24500000, AD5755_DC_DC_MAXV_24V5 },
|
||||
{ 27000000, AD5755_DC_DC_MAXV_27V },
|
||||
{ 29500000, AD5755_DC_DC_MAXV_29V5 },
|
||||
};
|
||||
|
||||
static const int ad5755_slew_rate_table[][2] = {
|
||||
{ 64000, AD5755_SLEW_RATE_64k },
|
||||
{ 32000, AD5755_SLEW_RATE_32k },
|
||||
{ 16000, AD5755_SLEW_RATE_16k },
|
||||
{ 8000, AD5755_SLEW_RATE_8k },
|
||||
{ 4000, AD5755_SLEW_RATE_4k },
|
||||
{ 2000, AD5755_SLEW_RATE_2k },
|
||||
{ 1000, AD5755_SLEW_RATE_1k },
|
||||
{ 500, AD5755_SLEW_RATE_500 },
|
||||
{ 250, AD5755_SLEW_RATE_250 },
|
||||
{ 125, AD5755_SLEW_RATE_125 },
|
||||
{ 64, AD5755_SLEW_RATE_64 },
|
||||
{ 32, AD5755_SLEW_RATE_32 },
|
||||
{ 16, AD5755_SLEW_RATE_16 },
|
||||
{ 8, AD5755_SLEW_RATE_8 },
|
||||
{ 4, AD5755_SLEW_RATE_4 },
|
||||
{ 0, AD5755_SLEW_RATE_0_5 },
|
||||
};
|
||||
|
||||
static const int ad5755_slew_step_table[][2] = {
|
||||
{ 256, AD5755_SLEW_STEP_SIZE_256 },
|
||||
{ 128, AD5755_SLEW_STEP_SIZE_128 },
|
||||
{ 64, AD5755_SLEW_STEP_SIZE_64 },
|
||||
{ 32, AD5755_SLEW_STEP_SIZE_32 },
|
||||
{ 16, AD5755_SLEW_STEP_SIZE_16 },
|
||||
{ 4, AD5755_SLEW_STEP_SIZE_4 },
|
||||
{ 2, AD5755_SLEW_STEP_SIZE_2 },
|
||||
{ 1, AD5755_SLEW_STEP_SIZE_1 },
|
||||
};
|
||||
#endif
|
||||
|
||||
static int ad5755_write_unlocked(struct iio_dev *indio_dev,
|
||||
unsigned int reg, unsigned int val)
|
||||
{
|
||||
@ -556,6 +602,129 @@ static const struct ad5755_platform_data ad5755_default_pdata = {
|
||||
},
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev)
|
||||
{
|
||||
struct device_node *np = dev->of_node;
|
||||
struct device_node *pp;
|
||||
struct ad5755_platform_data *pdata;
|
||||
unsigned int tmp;
|
||||
unsigned int tmparray[3];
|
||||
int devnr, i;
|
||||
|
||||
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return NULL;
|
||||
|
||||
pdata->ext_dc_dc_compenstation_resistor =
|
||||
of_property_read_bool(np, "adi,ext-dc-dc-compenstation-resistor");
|
||||
|
||||
if (!of_property_read_u32(np, "adi,dc-dc-phase", &tmp))
|
||||
pdata->dc_dc_phase = tmp;
|
||||
else
|
||||
pdata->dc_dc_phase = AD5755_DC_DC_PHASE_ALL_SAME_EDGE;
|
||||
|
||||
pdata->dc_dc_freq = AD5755_DC_DC_FREQ_410kHZ;
|
||||
if (!of_property_read_u32(np, "adi,dc-dc-freq-hz", &tmp)) {
|
||||
for (i = 0; i < ARRAY_SIZE(ad5755_dcdc_freq_table); i++) {
|
||||
if (tmp == ad5755_dcdc_freq_table[i][0]) {
|
||||
pdata->dc_dc_freq = ad5755_dcdc_freq_table[i][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(ad5755_dcdc_freq_table)) {
|
||||
dev_err(dev,
|
||||
"adi,dc-dc-freq out of range selecting 410kHz");
|
||||
}
|
||||
}
|
||||
|
||||
pdata->dc_dc_maxv = AD5755_DC_DC_MAXV_23V;
|
||||
if (!of_property_read_u32(np, "adi,dc-dc-max-microvolt", &tmp)) {
|
||||
for (i = 0; i < ARRAY_SIZE(ad5755_dcdc_maxv_table); i++) {
|
||||
if (tmp == ad5755_dcdc_maxv_table[i][0]) {
|
||||
pdata->dc_dc_maxv = ad5755_dcdc_maxv_table[i][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == ARRAY_SIZE(ad5755_dcdc_maxv_table)) {
|
||||
dev_err(dev,
|
||||
"adi,dc-dc-maxv out of range selecting 23V");
|
||||
}
|
||||
}
|
||||
|
||||
devnr = 0;
|
||||
for_each_child_of_node(np, pp) {
|
||||
if (devnr > AD5755_NUM_CHANNELS) {
|
||||
dev_err(dev,
|
||||
"There is to many channels defined in DT\n");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if (!of_property_read_u32(pp, "adi,mode", &tmp))
|
||||
pdata->dac[devnr].mode = tmp;
|
||||
else
|
||||
pdata->dac[devnr].mode = AD5755_MODE_CURRENT_4mA_20mA;
|
||||
|
||||
pdata->dac[devnr].ext_current_sense_resistor =
|
||||
of_property_read_bool(pp, "adi,ext-current-sense-resistor");
|
||||
|
||||
pdata->dac[devnr].enable_voltage_overrange =
|
||||
of_property_read_bool(pp, "adi,enable-voltage-overrange");
|
||||
|
||||
if (!of_property_read_u32_array(pp, "adi,slew", tmparray, 3)) {
|
||||
pdata->dac[devnr].slew.enable = tmparray[0];
|
||||
|
||||
pdata->dac[devnr].slew.rate = AD5755_SLEW_RATE_64k;
|
||||
for (i = 0; i < ARRAY_SIZE(ad5755_slew_rate_table); i++) {
|
||||
if (tmparray[1] == ad5755_slew_rate_table[i][0]) {
|
||||
pdata->dac[devnr].slew.rate =
|
||||
ad5755_slew_rate_table[i][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == ARRAY_SIZE(ad5755_slew_rate_table)) {
|
||||
dev_err(dev,
|
||||
"channel %d slew rate out of range selecting 64kHz",
|
||||
devnr);
|
||||
}
|
||||
|
||||
pdata->dac[devnr].slew.step_size = AD5755_SLEW_STEP_SIZE_1;
|
||||
for (i = 0; i < ARRAY_SIZE(ad5755_slew_step_table); i++) {
|
||||
if (tmparray[2] == ad5755_slew_step_table[i][0]) {
|
||||
pdata->dac[devnr].slew.step_size =
|
||||
ad5755_slew_step_table[i][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == ARRAY_SIZE(ad5755_slew_step_table)) {
|
||||
dev_err(dev,
|
||||
"channel %d slew step size out of range selecting 1 LSB",
|
||||
devnr);
|
||||
}
|
||||
} else {
|
||||
pdata->dac[devnr].slew.enable = false;
|
||||
pdata->dac[devnr].slew.rate = AD5755_SLEW_RATE_64k;
|
||||
pdata->dac[devnr].slew.step_size =
|
||||
AD5755_SLEW_STEP_SIZE_1;
|
||||
}
|
||||
devnr++;
|
||||
}
|
||||
|
||||
return pdata;
|
||||
|
||||
error_out:
|
||||
devm_kfree(dev, pdata);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
static
|
||||
struct ad5755_platform_data *ad5755_parse_dt(struct device *dev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ad5755_probe(struct spi_device *spi)
|
||||
{
|
||||
enum ad5755_type type = spi_get_device_id(spi)->driver_data;
|
||||
@ -583,8 +752,15 @@ static int ad5755_probe(struct spi_device *spi)
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->num_channels = AD5755_NUM_CHANNELS;
|
||||
|
||||
if (!pdata)
|
||||
if (spi->dev.of_node)
|
||||
pdata = ad5755_parse_dt(&spi->dev);
|
||||
else
|
||||
pdata = spi->dev.platform_data;
|
||||
|
||||
if (!pdata) {
|
||||
dev_warn(&spi->dev, "no platform data? using default\n");
|
||||
pdata = &ad5755_default_pdata;
|
||||
}
|
||||
|
||||
ret = ad5755_init_channels(indio_dev, pdata);
|
||||
if (ret)
|
||||
@ -607,6 +783,16 @@ static const struct spi_device_id ad5755_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, ad5755_id);
|
||||
|
||||
static const struct of_device_id ad5755_of_match[] = {
|
||||
{ .compatible = "adi,ad5755" },
|
||||
{ .compatible = "adi,ad5755-1" },
|
||||
{ .compatible = "adi,ad5757" },
|
||||
{ .compatible = "adi,ad5735" },
|
||||
{ .compatible = "adi,ad5737" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ad5755_of_match);
|
||||
|
||||
static struct spi_driver ad5755_driver = {
|
||||
.driver = {
|
||||
.name = "ad5755",
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/types.h>
|
||||
#include <linux/io.h>
|
||||
@ -21,6 +22,7 @@
|
||||
#include <linux/isa.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#define STX104_NUM_CHAN 2
|
||||
|
||||
@ -49,6 +51,20 @@ struct stx104_iio {
|
||||
unsigned base;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct stx104_gpio - GPIO device private data structure
|
||||
* @chip: instance of the gpio_chip
|
||||
* @lock: synchronization lock to prevent I/O race conditions
|
||||
* @base: base port address of the GPIO device
|
||||
* @out_state: output bits state
|
||||
*/
|
||||
struct stx104_gpio {
|
||||
struct gpio_chip chip;
|
||||
spinlock_t lock;
|
||||
unsigned int base;
|
||||
unsigned int out_state;
|
||||
};
|
||||
|
||||
static int stx104_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int *val, int *val2, long mask)
|
||||
{
|
||||
@ -88,15 +104,81 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = {
|
||||
STX104_CHAN(1)
|
||||
};
|
||||
|
||||
static int stx104_gpio_get_direction(struct gpio_chip *chip,
|
||||
unsigned int offset)
|
||||
{
|
||||
if (offset < 4)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stx104_gpio_direction_input(struct gpio_chip *chip,
|
||||
unsigned int offset)
|
||||
{
|
||||
if (offset >= 4)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stx104_gpio_direction_output(struct gpio_chip *chip,
|
||||
unsigned int offset, int value)
|
||||
{
|
||||
if (offset < 4)
|
||||
return -EINVAL;
|
||||
|
||||
chip->set(chip, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stx104_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
{
|
||||
struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip);
|
||||
|
||||
if (offset >= 4)
|
||||
return -EINVAL;
|
||||
|
||||
return !!(inb(stx104gpio->base) & BIT(offset));
|
||||
}
|
||||
|
||||
static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip);
|
||||
const unsigned int mask = BIT(offset) >> 4;
|
||||
unsigned long flags;
|
||||
|
||||
if (offset < 4)
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&stx104gpio->lock, flags);
|
||||
|
||||
if (value)
|
||||
stx104gpio->out_state |= mask;
|
||||
else
|
||||
stx104gpio->out_state &= ~mask;
|
||||
|
||||
outb(stx104gpio->out_state, stx104gpio->base);
|
||||
|
||||
spin_unlock_irqrestore(&stx104gpio->lock, flags);
|
||||
}
|
||||
|
||||
static int stx104_probe(struct device *dev, unsigned int id)
|
||||
{
|
||||
struct iio_dev *indio_dev;
|
||||
struct stx104_iio *priv;
|
||||
struct stx104_gpio *stx104gpio;
|
||||
int err;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
|
||||
if (!indio_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
stx104gpio = devm_kzalloc(dev, sizeof(*stx104gpio), GFP_KERNEL);
|
||||
if (!stx104gpio)
|
||||
return -ENOMEM;
|
||||
|
||||
if (!devm_request_region(dev, base[id], STX104_EXTENT,
|
||||
dev_name(dev))) {
|
||||
dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
|
||||
@ -117,14 +199,53 @@ static int stx104_probe(struct device *dev, unsigned int id)
|
||||
outw(0, base[id] + 4);
|
||||
outw(0, base[id] + 6);
|
||||
|
||||
return devm_iio_device_register(dev, indio_dev);
|
||||
err = devm_iio_device_register(dev, indio_dev);
|
||||
if (err) {
|
||||
dev_err(dev, "IIO device registering failed (%d)\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
stx104gpio->chip.label = dev_name(dev);
|
||||
stx104gpio->chip.parent = dev;
|
||||
stx104gpio->chip.owner = THIS_MODULE;
|
||||
stx104gpio->chip.base = -1;
|
||||
stx104gpio->chip.ngpio = 8;
|
||||
stx104gpio->chip.get_direction = stx104_gpio_get_direction;
|
||||
stx104gpio->chip.direction_input = stx104_gpio_direction_input;
|
||||
stx104gpio->chip.direction_output = stx104_gpio_direction_output;
|
||||
stx104gpio->chip.get = stx104_gpio_get;
|
||||
stx104gpio->chip.set = stx104_gpio_set;
|
||||
stx104gpio->base = base[id] + 3;
|
||||
stx104gpio->out_state = 0x0;
|
||||
|
||||
spin_lock_init(&stx104gpio->lock);
|
||||
|
||||
dev_set_drvdata(dev, stx104gpio);
|
||||
|
||||
err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
|
||||
if (err) {
|
||||
dev_err(dev, "GPIO registering failed (%d)\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stx104_remove(struct device *dev, unsigned int id)
|
||||
{
|
||||
struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev);
|
||||
|
||||
gpiochip_remove(&stx104gpio->chip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct isa_driver stx104_driver = {
|
||||
.probe = stx104_probe,
|
||||
.driver = {
|
||||
.name = "stx104"
|
||||
}
|
||||
},
|
||||
.remove = stx104_remove
|
||||
};
|
||||
|
||||
module_isa_driver(stx104_driver, num_stx104);
|
||||
|
@ -64,6 +64,8 @@ static struct attribute *iio_trig_dev_attrs[] = {
|
||||
};
|
||||
ATTRIBUTE_GROUPS(iio_trig_dev);
|
||||
|
||||
static struct iio_trigger *__iio_trigger_find_by_name(const char *name);
|
||||
|
||||
int iio_trigger_register(struct iio_trigger *trig_info)
|
||||
{
|
||||
int ret;
|
||||
@ -86,11 +88,19 @@ int iio_trigger_register(struct iio_trigger *trig_info)
|
||||
|
||||
/* Add to list of available triggers held by the IIO core */
|
||||
mutex_lock(&iio_trigger_list_lock);
|
||||
if (__iio_trigger_find_by_name(trig_info->name)) {
|
||||
pr_err("Duplicate trigger name '%s'\n", trig_info->name);
|
||||
ret = -EEXIST;
|
||||
goto error_device_del;
|
||||
}
|
||||
list_add_tail(&trig_info->list, &iio_trigger_list);
|
||||
mutex_unlock(&iio_trigger_list_lock);
|
||||
|
||||
return 0;
|
||||
|
||||
error_device_del:
|
||||
mutex_unlock(&iio_trigger_list_lock);
|
||||
device_del(&trig_info->dev);
|
||||
error_unregister_id:
|
||||
ida_simple_remove(&iio_trigger_ida, trig_info->id);
|
||||
return ret;
|
||||
@ -109,6 +119,18 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
|
||||
}
|
||||
EXPORT_SYMBOL(iio_trigger_unregister);
|
||||
|
||||
/* Search for trigger by name, assuming iio_trigger_list_lock held */
|
||||
static struct iio_trigger *__iio_trigger_find_by_name(const char *name)
|
||||
{
|
||||
struct iio_trigger *iter;
|
||||
|
||||
list_for_each_entry(iter, &iio_trigger_list, list)
|
||||
if (!strcmp(iter->name, name))
|
||||
return iter;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct iio_trigger *iio_trigger_find_by_name(const char *name,
|
||||
size_t len)
|
||||
{
|
||||
|
@ -1287,22 +1287,14 @@ static int gp2ap020a00f_read_raw(struct iio_dev *indio_dev,
|
||||
struct gp2ap020a00f_data *data = iio_priv(indio_dev);
|
||||
int err = -EINVAL;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (iio_buffer_enabled(indio_dev)) {
|
||||
err = -EBUSY;
|
||||
goto error_unlock;
|
||||
}
|
||||
if (mask == IIO_CHAN_INFO_RAW) {
|
||||
err = iio_device_claim_direct_mode(indio_dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = gp2ap020a00f_read_channel(data, chan, val);
|
||||
break;
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
}
|
||||
|
||||
error_unlock:
|
||||
mutex_unlock(&data->lock);
|
||||
|
||||
return err < 0 ? err : IIO_VAL_INT;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@
|
||||
|
||||
struct isl29125_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex lock;
|
||||
u8 conf1;
|
||||
u16 buffer[8]; /* 3x 16-bit, padding, 8 bytes timestamp */
|
||||
};
|
||||
@ -128,11 +127,11 @@ static int isl29125_read_raw(struct iio_dev *indio_dev,
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (iio_buffer_enabled(indio_dev))
|
||||
return -EBUSY;
|
||||
mutex_lock(&data->lock);
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = isl29125_read_data(data, chan->scan_index);
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = ret;
|
||||
@ -259,7 +258,6 @@ static int isl29125_probe(struct i2c_client *client,
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
mutex_init(&data->lock);
|
||||
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->info = &isl29125_info;
|
||||
|
@ -53,7 +53,6 @@
|
||||
|
||||
struct tcs3414_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex lock;
|
||||
u8 control;
|
||||
u8 gain;
|
||||
u8 timing;
|
||||
@ -134,16 +133,16 @@ static int tcs3414_read_raw(struct iio_dev *indio_dev,
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (iio_buffer_enabled(indio_dev))
|
||||
return -EBUSY;
|
||||
mutex_lock(&data->lock);
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = tcs3414_req_data(data);
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
return ret;
|
||||
}
|
||||
ret = i2c_smbus_read_word_data(data->client, chan->address);
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = ret;
|
||||
@ -288,7 +287,6 @@ static int tcs3414_probe(struct i2c_client *client,
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
mutex_init(&data->lock);
|
||||
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->info = &tcs3414_info;
|
||||
|
@ -52,7 +52,6 @@
|
||||
|
||||
struct tcs3472_data {
|
||||
struct i2c_client *client;
|
||||
struct mutex lock;
|
||||
u8 enable;
|
||||
u8 control;
|
||||
u8 atime;
|
||||
@ -117,17 +116,16 @@ static int tcs3472_read_raw(struct iio_dev *indio_dev,
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (iio_buffer_enabled(indio_dev))
|
||||
return -EBUSY;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = tcs3472_req_data(data);
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
return ret;
|
||||
}
|
||||
ret = i2c_smbus_read_word_data(data->client, chan->address);
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = ret;
|
||||
@ -263,7 +261,6 @@ static int tcs3472_probe(struct i2c_client *client,
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
mutex_init(&data->lock);
|
||||
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->info = &tcs3472_info;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* ms5637.c - Support for Measurement-Specialties ms5637 and ms8607
|
||||
* pressure & temperature sensor
|
||||
* ms5637.c - Support for Measurement-Specialties MS5637, MS5805
|
||||
* MS5837 and MS8607 pressure & temperature sensor
|
||||
*
|
||||
* Copyright (c) 2015 Measurement-Specialties
|
||||
*
|
||||
@ -11,6 +11,10 @@
|
||||
* Datasheet:
|
||||
* http://www.meas-spec.com/downloads/MS5637-02BA03.pdf
|
||||
* Datasheet:
|
||||
* http://www.meas-spec.com/downloads/MS5805-02BA01.pdf
|
||||
* Datasheet:
|
||||
* http://www.meas-spec.com/downloads/MS5837-30BA.pdf
|
||||
* Datasheet:
|
||||
* http://www.meas-spec.com/downloads/MS8607-02BA01.pdf
|
||||
*/
|
||||
|
||||
@ -170,7 +174,9 @@ static int ms5637_probe(struct i2c_client *client,
|
||||
|
||||
static const struct i2c_device_id ms5637_id[] = {
|
||||
{"ms5637", 0},
|
||||
{"ms8607-temppressure", 1},
|
||||
{"ms5805", 0},
|
||||
{"ms5837", 0},
|
||||
{"ms8607-temppressure", 0},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ms5637_id);
|
||||
|
@ -231,10 +231,16 @@ static void as3935_event_work(struct work_struct *work)
|
||||
{
|
||||
struct as3935_state *st;
|
||||
int val;
|
||||
int ret;
|
||||
|
||||
st = container_of(work, struct as3935_state, work.work);
|
||||
|
||||
as3935_read(st, AS3935_INT, &val);
|
||||
ret = as3935_read(st, AS3935_INT, &val);
|
||||
if (ret) {
|
||||
dev_warn(&st->spi->dev, "read error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
val &= AS3935_INT_MASK;
|
||||
|
||||
switch (val) {
|
||||
@ -242,7 +248,7 @@ static void as3935_event_work(struct work_struct *work)
|
||||
iio_trigger_poll(st->trig);
|
||||
break;
|
||||
case AS3935_NOISE_INT:
|
||||
dev_warn(&st->spi->dev, "noise level is too high");
|
||||
dev_warn(&st->spi->dev, "noise level is too high\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -346,7 +352,6 @@ static int as3935_probe(struct spi_device *spi)
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
st->spi = spi;
|
||||
st->tune_cap = 0;
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
mutex_init(&st->lock);
|
||||
|
@ -203,22 +203,19 @@ static int lidar_read_raw(struct iio_dev *indio_dev,
|
||||
struct lidar_data *data = iio_priv(indio_dev);
|
||||
int ret = -EINVAL;
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
|
||||
if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) {
|
||||
ret = -EBUSY;
|
||||
goto error_busy;
|
||||
}
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW: {
|
||||
u16 reg;
|
||||
|
||||
if (iio_device_claim_direct_mode(indio_dev))
|
||||
return -EBUSY;
|
||||
|
||||
ret = lidar_get_measurement(data, ®);
|
||||
if (!ret) {
|
||||
*val = reg;
|
||||
ret = IIO_VAL_INT;
|
||||
}
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
break;
|
||||
}
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
@ -228,9 +225,6 @@ static int lidar_read_raw(struct iio_dev *indio_dev,
|
||||
break;
|
||||
}
|
||||
|
||||
error_busy:
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1046,8 @@ static int sca3000_clean_setup(struct sca3000_state *st)
|
||||
|
||||
/* Disable ring buffer */
|
||||
ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
|
||||
if (ret < 0)
|
||||
goto error_ret;
|
||||
ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL,
|
||||
(ret & SCA3000_OUT_CTRL_PROT_MASK)
|
||||
| SCA3000_OUT_CTRL_BUF_X_EN
|
||||
|
@ -341,7 +341,7 @@ int main(int argc, char **argv)
|
||||
|
||||
char *data = NULL;
|
||||
ssize_t read_size;
|
||||
int dev_num = -1, trig_num;
|
||||
int dev_num = -1, trig_num = -1;
|
||||
char *buffer_access = NULL;
|
||||
int scan_size;
|
||||
int noevents = 0;
|
||||
@ -456,7 +456,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (notrigger) {
|
||||
printf("trigger-less mode selected\n");
|
||||
} if (trig_num > 0) {
|
||||
} if (trig_num >= 0) {
|
||||
char *trig_dev_name;
|
||||
ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num);
|
||||
if (ret < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user