Commit eafe5cfe authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-fixes-for-4.8a' of...

Merge tag 'iio-fixes-for-4.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-linus

Jonathan writes:

First round of IIO fixes for the 4.8 cycle.

This is somewhat of a bumper set due to my unavailabilty earlier in the
month.  The only slightly unusual ones are the dts updates for the
rockchip adc reset.  The fix in the driver only makes sense with these
and the rockchip maintainer is happy with them going through IIO to
reach mainline.

Core stuff

* Fix an issue with a blocking op when !TASK_RUNNING. This been there
  a while and snuck in with seemingly minor additions to some core
  code paths.
* Tools
  - generic_buffer failed to initialize the channel array pointer thus
    in the case of no channels blows up trying to free a random memory
    address.
* sw-trigger:
  - Fix config group initialization when configfs is built as a module.

Drivers

* ad5933
  - Fix an incorrect overwrite of an error value.
* ad799x
  - A missed assignment of the update_scan_mode callback means buffered mode
    doesn't work on the ad7991, ad7995 or ad7999.
* ads1015
  - wrong pointer returned from i2c_get_clientdata (missmatch of assumptions)
* am2315
  - Timestamps are reported, but never actually acquired from anywhere
    (so always 0)
  - missing buffer selects in Kconfig
* am335x adc
  - Protect fifo1 from concurrent access.
  - Increase timeout waiting for ADC to be long enough in all cases.
* as3935
  - Timestamps are reported, but never actually acquired from anywhere
    (so always 0)
* at91
  - Fix reading of channel 3.
* atlas-ph-sensor
  - Typo means that the scale of electrical conductivity readings is way off.
* bma220
  - Timestamps are reported, but never actually acquired from anywhere
    (so always 0)
  - Missing buffer selects in Kconfig
* bmp280
  - pass the write pointer to PTR_ERR (i.e. the one that was just checked
    with IS_ERR).
  - suspend /resume crash due to wrong assumption about what dev_get_drvdata
    would return.
* hdc100x
  - It superficially appeared that smbus_read_byte commands would allow
  reading of the outputs in two goes.  In reality it doesn't work, but
  instead returns the same for the upper and lower bytes (nice catch from
  Alison!)
* kxsd9
  - Fix raw read return value to ensure it actually reports the value rather
  than a blank string.
* max44000
  - Missing buffer selects in Kconfig
* rockchip_saradc
  - Add use of reset controller to enforce a clean state of the ADC.
    Some bootloaders can leave it in an 'intersting' state and effectively
    frozen without this. A couple of associated dts updates.
* stk8ba50
  - Missing buffer selects in Kconfig
* stx104
  - Fix a possible race due to use of devm_iio_device_register when there
    was other stuff in the remove function.
parents c0678b2d 3d4267a5
...@@ -16,6 +16,11 @@ Required properties: ...@@ -16,6 +16,11 @@ Required properties:
- vref-supply: The regulator supply ADC reference voltage. - vref-supply: The regulator supply ADC reference voltage.
- #io-channel-cells: Should be 1, see ../iio-bindings.txt - #io-channel-cells: Should be 1, see ../iio-bindings.txt
Optional properties:
- resets: Must contain an entry for each entry in reset-names if need support
this option. See ../reset/reset.txt for details.
- reset-names: Must include the name "saradc-apb".
Example: Example:
saradc: saradc@2006c000 { saradc: saradc@2006c000 {
compatible = "rockchip,saradc"; compatible = "rockchip,saradc";
...@@ -23,6 +28,8 @@ Example: ...@@ -23,6 +28,8 @@ Example:
interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>; interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
clock-names = "saradc", "apb_pclk"; clock-names = "saradc", "apb_pclk";
resets = <&cru SRST_SARADC>;
reset-names = "saradc-apb";
#io-channel-cells = <1>; #io-channel-cells = <1>;
vref-supply = <&vcc18>; vref-supply = <&vcc18>;
}; };
...@@ -197,6 +197,8 @@ tsadc: tsadc@20060000 { ...@@ -197,6 +197,8 @@ tsadc: tsadc@20060000 {
clock-names = "saradc", "apb_pclk"; clock-names = "saradc", "apb_pclk";
interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
#io-channel-cells = <1>; #io-channel-cells = <1>;
resets = <&cru SRST_SARADC>;
reset-names = "saradc-apb";
status = "disabled"; status = "disabled";
}; };
......
...@@ -279,6 +279,8 @@ saradc: saradc@ff100000 { ...@@ -279,6 +279,8 @@ saradc: saradc@ff100000 {
#io-channel-cells = <1>; #io-channel-cells = <1>;
clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
clock-names = "saradc", "apb_pclk"; clock-names = "saradc", "apb_pclk";
resets = <&cru SRST_SARADC>;
reset-names = "saradc-apb";
status = "disabled"; status = "disabled";
}; };
......
...@@ -399,6 +399,8 @@ saradc: saradc@2006c000 { ...@@ -399,6 +399,8 @@ saradc: saradc@2006c000 {
#io-channel-cells = <1>; #io-channel-cells = <1>;
clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
clock-names = "saradc", "apb_pclk"; clock-names = "saradc", "apb_pclk";
resets = <&cru SRST_SARADC>;
reset-names = "saradc-apb";
status = "disabled"; status = "disabled";
}; };
......
...@@ -270,6 +270,8 @@ saradc: saradc@ff100000 { ...@@ -270,6 +270,8 @@ saradc: saradc@ff100000 {
#io-channel-cells = <1>; #io-channel-cells = <1>;
clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
clock-names = "saradc", "apb_pclk"; clock-names = "saradc", "apb_pclk";
resets = <&cru SRST_SARADC>;
reset-names = "saradc-apb";
status = "disabled"; status = "disabled";
}; };
......
...@@ -20,6 +20,8 @@ config BMA180 ...@@ -20,6 +20,8 @@ config BMA180
config BMA220 config BMA220
tristate "Bosch BMA220 3-Axis Accelerometer Driver" tristate "Bosch BMA220 3-Axis Accelerometer Driver"
depends on SPI depends on SPI
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
Say yes here to add support for the Bosch BMA220 triaxial Say yes here to add support for the Bosch BMA220 triaxial
acceleration sensor. acceleration sensor.
...@@ -234,7 +236,8 @@ config STK8312 ...@@ -234,7 +236,8 @@ config STK8312
config STK8BA50 config STK8BA50
tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver" tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver"
depends on I2C depends on I2C
depends on IIO_TRIGGER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
Say yes here to get support for the Sensortek STK8BA50 3-axis Say yes here to get support for the Sensortek STK8BA50 3-axis
accelerometer. accelerometer.
......
...@@ -253,7 +253,7 @@ static int bma220_probe(struct spi_device *spi) ...@@ -253,7 +253,7 @@ static int bma220_probe(struct spi_device *spi)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
bma220_trigger_handler, NULL); bma220_trigger_handler, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(&spi->dev, "iio triggered buffer setup failed\n"); dev_err(&spi->dev, "iio triggered buffer setup failed\n");
......
...@@ -160,6 +160,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, ...@@ -160,6 +160,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
if (ret < 0) if (ret < 0)
goto error_ret; goto error_ret;
*val = ret; *val = ret;
ret = IIO_VAL_INT;
break; break;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
......
...@@ -389,6 +389,7 @@ config QCOM_SPMI_VADC ...@@ -389,6 +389,7 @@ config QCOM_SPMI_VADC
config ROCKCHIP_SARADC config ROCKCHIP_SARADC
tristate "Rockchip SARADC driver" tristate "Rockchip SARADC driver"
depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
depends on RESET_CONTROLLER
help help
Say yes here to build support for the SARADC found in SoCs from Say yes here to build support for the SARADC found in SoCs from
Rockchip. Rockchip.
......
...@@ -527,6 +527,7 @@ static struct attribute_group ad799x_event_attrs_group = { ...@@ -527,6 +527,7 @@ static struct attribute_group ad799x_event_attrs_group = {
static const struct iio_info ad7991_info = { static const struct iio_info ad7991_info = {
.read_raw = &ad799x_read_raw, .read_raw = &ad799x_read_raw,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.update_scan_mode = ad799x_update_scan_mode,
}; };
static const struct iio_info ad7993_4_7_8_noirq_info = { static const struct iio_info ad7993_4_7_8_noirq_info = {
......
...@@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private) ...@@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
st->ts_bufferedmeasure = false; st->ts_bufferedmeasure = false;
input_report_key(st->ts_input, BTN_TOUCH, 0); input_report_key(st->ts_input, BTN_TOUCH, 0);
input_sync(st->ts_input); input_sync(st->ts_input);
} else if (status & AT91_ADC_EOC(3)) { } else if (status & AT91_ADC_EOC(3) && st->ts_input) {
/* Conversion finished */ /* Conversion finished and we've a touchscreen */
if (st->ts_bufferedmeasure) { if (st->ts_bufferedmeasure) {
/* /*
* Last measurement is always discarded, since it can * Last measurement is always discarded, since it can
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/delay.h>
#include <linux/reset.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
...@@ -53,6 +55,7 @@ struct rockchip_saradc { ...@@ -53,6 +55,7 @@ struct rockchip_saradc {
struct clk *clk; struct clk *clk;
struct completion completion; struct completion completion;
struct regulator *vref; struct regulator *vref;
struct reset_control *reset;
const struct rockchip_saradc_data *data; const struct rockchip_saradc_data *data;
u16 last_val; u16 last_val;
}; };
...@@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = { ...@@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = {
}; };
MODULE_DEVICE_TABLE(of, rockchip_saradc_match); MODULE_DEVICE_TABLE(of, rockchip_saradc_match);
/**
* Reset SARADC Controller.
*/
static void rockchip_saradc_reset_controller(struct reset_control *reset)
{
reset_control_assert(reset);
usleep_range(10, 20);
reset_control_deassert(reset);
}
static int rockchip_saradc_probe(struct platform_device *pdev) static int rockchip_saradc_probe(struct platform_device *pdev)
{ {
struct rockchip_saradc *info = NULL; struct rockchip_saradc *info = NULL;
...@@ -218,6 +231,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev) ...@@ -218,6 +231,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
if (IS_ERR(info->regs)) if (IS_ERR(info->regs))
return PTR_ERR(info->regs); return PTR_ERR(info->regs);
/*
* The reset should be an optional property, as it should work
* with old devicetrees as well
*/
info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb");
if (IS_ERR(info->reset)) {
ret = PTR_ERR(info->reset);
if (ret != -ENOENT)
return ret;
dev_dbg(&pdev->dev, "no reset control found\n");
info->reset = NULL;
}
init_completion(&info->completion); init_completion(&info->completion);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
...@@ -252,6 +279,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev) ...@@ -252,6 +279,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
return PTR_ERR(info->vref); return PTR_ERR(info->vref);
} }
if (info->reset)
rockchip_saradc_reset_controller(info->reset);
/* /*
* Use a default value for the converter clock. * Use a default value for the converter clock.
* This may become user-configurable in the future. * This may become user-configurable in the future.
......
...@@ -489,7 +489,8 @@ static struct iio_info ads1115_info = { ...@@ -489,7 +489,8 @@ static struct iio_info ads1115_info = {
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int ads1015_get_channels_config_of(struct i2c_client *client) static int ads1015_get_channels_config_of(struct i2c_client *client)
{ {
struct ads1015_data *data = i2c_get_clientdata(client); struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ads1015_data *data = iio_priv(indio_dev);
struct device_node *node; struct device_node *node;
if (!client->dev.of_node || if (!client->dev.of_node ||
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
struct tiadc_device { struct tiadc_device {
struct ti_tscadc_dev *mfd_tscadc; struct ti_tscadc_dev *mfd_tscadc;
struct mutex fifo1_lock; /* to protect fifo access */
int channels; int channels;
u8 channel_line[8]; u8 channel_line[8];
u8 channel_step[8]; u8 channel_step[8];
...@@ -359,6 +360,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, ...@@ -359,6 +360,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
struct tiadc_device *adc_dev = iio_priv(indio_dev); struct tiadc_device *adc_dev = iio_priv(indio_dev);
int ret = IIO_VAL_INT;
int i, map_val; int i, map_val;
unsigned int fifo1count, read, stepid; unsigned int fifo1count, read, stepid;
bool found = false; bool found = false;
...@@ -372,13 +374,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, ...@@ -372,13 +374,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
if (!step_en) if (!step_en)
return -EINVAL; return -EINVAL;
mutex_lock(&adc_dev->fifo1_lock);
fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
while (fifo1count--) while (fifo1count--)
tiadc_readl(adc_dev, REG_FIFO1); tiadc_readl(adc_dev, REG_FIFO1);
am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
timeout = jiffies + usecs_to_jiffies timeout = jiffies + msecs_to_jiffies
(IDLE_TIMEOUT * adc_dev->channels); (IDLE_TIMEOUT * adc_dev->channels);
/* Wait for Fifo threshold interrupt */ /* Wait for Fifo threshold interrupt */
while (1) { while (1) {
...@@ -388,7 +391,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, ...@@ -388,7 +391,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
return -EAGAIN; ret = -EAGAIN;
goto err_unlock;
} }
} }
map_val = adc_dev->channel_step[chan->scan_index]; map_val = adc_dev->channel_step[chan->scan_index];
...@@ -414,8 +418,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, ...@@ -414,8 +418,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
if (found == false) if (found == false)
return -EBUSY; ret = -EBUSY;
return IIO_VAL_INT;
err_unlock:
mutex_unlock(&adc_dev->fifo1_lock);
return ret;
} }
static const struct iio_info tiadc_info = { static const struct iio_info tiadc_info = {
...@@ -483,6 +490,7 @@ static int tiadc_probe(struct platform_device *pdev) ...@@ -483,6 +490,7 @@ static int tiadc_probe(struct platform_device *pdev)
tiadc_step_config(indio_dev); tiadc_step_config(indio_dev);
tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD);
mutex_init(&adc_dev->fifo1_lock);
err = tiadc_channel_init(indio_dev, adc_dev->channels); err = tiadc_channel_init(indio_dev, adc_dev->channels);
if (err < 0) if (err < 0)
......
...@@ -434,7 +434,7 @@ static int atlas_read_raw(struct iio_dev *indio_dev, ...@@ -434,7 +434,7 @@ static int atlas_read_raw(struct iio_dev *indio_dev,
break; break;
case IIO_ELECTRICALCONDUCTIVITY: case IIO_ELECTRICALCONDUCTIVITY:
*val = 1; /* 0.00001 */ *val = 1; /* 0.00001 */
*val = 100000; *val2 = 100000;
break; break;
case IIO_CONCENTRATION: case IIO_CONCENTRATION:
*val = 0; /* 0.000000001 */ *val = 0; /* 0.000000001 */
......
...@@ -65,6 +65,16 @@ struct stx104_gpio { ...@@ -65,6 +65,16 @@ struct stx104_gpio {
unsigned int out_state; unsigned int out_state;
}; };
/**
* struct stx104_dev - STX104 device private data structure
* @indio_dev: IIO device
* @chip: instance of the gpio_chip
*/
struct stx104_dev {
struct iio_dev *indio_dev;
struct gpio_chip *chip;
};
static int stx104_read_raw(struct iio_dev *indio_dev, static int stx104_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2, long mask) struct iio_chan_spec const *chan, int *val, int *val2, long mask)
{ {
...@@ -107,6 +117,7 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = { ...@@ -107,6 +117,7 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = {
static int stx104_gpio_get_direction(struct gpio_chip *chip, static int stx104_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset) unsigned int offset)
{ {
/* GPIO 0-3 are input only, while the rest are output only */
if (offset < 4) if (offset < 4)
return 1; return 1;
...@@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev, unsigned int id) ...@@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev, unsigned int id)
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct stx104_iio *priv; struct stx104_iio *priv;
struct stx104_gpio *stx104gpio; struct stx104_gpio *stx104gpio;
struct stx104_dev *stx104dev;
int err; int err;
indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
...@@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev, unsigned int id) ...@@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev, unsigned int id)
if (!stx104gpio) if (!stx104gpio)
return -ENOMEM; return -ENOMEM;
stx104dev = devm_kzalloc(dev, sizeof(*stx104dev), GFP_KERNEL);
if (!stx104dev)
return -ENOMEM;
if (!devm_request_region(dev, base[id], STX104_EXTENT, if (!devm_request_region(dev, base[id], STX104_EXTENT,
dev_name(dev))) { dev_name(dev))) {
dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
...@@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev, unsigned int id) ...@@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev, unsigned int id)
outw(0, base[id] + 4); outw(0, base[id] + 4);
outw(0, base[id] + 6); outw(0, base[id] + 6);
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.label = dev_name(dev);
stx104gpio->chip.parent = dev; stx104gpio->chip.parent = dev;
stx104gpio->chip.owner = THIS_MODULE; stx104gpio->chip.owner = THIS_MODULE;
...@@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev, unsigned int id) ...@@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev, unsigned int id)
spin_lock_init(&stx104gpio->lock); spin_lock_init(&stx104gpio->lock);
dev_set_drvdata(dev, stx104gpio); stx104dev->indio_dev = indio_dev;
stx104dev->chip = &stx104gpio->chip;
dev_set_drvdata(dev, stx104dev);
err = gpiochip_add_data(&stx104gpio->chip, stx104gpio); err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
if (err) { if (err) {
...@@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev, unsigned int id) ...@@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev, unsigned int id)
return err; return err;
} }
err = iio_device_register(indio_dev);
if (err) {
dev_err(dev, "IIO device registering failed (%d)\n", err);
gpiochip_remove(&stx104gpio->chip);
return err;
}
return 0; return 0;
} }
static int stx104_remove(struct device *dev, unsigned int id) static int stx104_remove(struct device *dev, unsigned int id)
{ {
struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev); struct stx104_dev *const stx104dev = dev_get_drvdata(dev);
gpiochip_remove(&stx104gpio->chip); iio_device_unregister(stx104dev->indio_dev);
gpiochip_remove(stx104dev->chip);
return 0; return 0;
} }
......
...@@ -6,6 +6,8 @@ menu "Humidity sensors" ...@@ -6,6 +6,8 @@ menu "Humidity sensors"
config AM2315 config AM2315
tristate "Aosong AM2315 relative humidity and temperature sensor" tristate "Aosong AM2315 relative humidity and temperature sensor"
depends on I2C depends on I2C
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
If you say yes here you get support for the Aosong AM2315 If you say yes here you get support for the Aosong AM2315
relative humidity and ambient temperature sensor. relative humidity and ambient temperature sensor.
......
...@@ -244,7 +244,7 @@ static int am2315_probe(struct i2c_client *client, ...@@ -244,7 +244,7 @@ static int am2315_probe(struct i2c_client *client,
indio_dev->channels = am2315_channels; indio_dev->channels = am2315_channels;
indio_dev->num_channels = ARRAY_SIZE(am2315_channels); indio_dev->num_channels = ARRAY_SIZE(am2315_channels);
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
am2315_trigger_handler, NULL); am2315_trigger_handler, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "iio triggered buffer setup failed\n"); dev_err(&client->dev, "iio triggered buffer setup failed\n");
......
...@@ -142,7 +142,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data, ...@@ -142,7 +142,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
struct i2c_client *client = data->client; struct i2c_client *client = data->client;
int delay = data->adc_int_us[chan->address]; int delay = data->adc_int_us[chan->address];
int ret; int ret;
int val; __be16 val;
/* start measurement */ /* start measurement */
ret = i2c_smbus_write_byte(client, chan->address); ret = i2c_smbus_write_byte(client, chan->address);
...@@ -154,26 +154,13 @@ static int hdc100x_get_measurement(struct hdc100x_data *data, ...@@ -154,26 +154,13 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
/* wait for integration time to pass */ /* wait for integration time to pass */
usleep_range(delay, delay + 1000); usleep_range(delay, delay + 1000);
/* /* read measurement */
* i2c_smbus_read_word_data cannot() be used here due to the command ret = i2c_master_recv(data->client, (char *)&val, sizeof(val));
* value not being understood and causes NAKs preventing any reading
* from being accessed.
*/
ret = i2c_smbus_read_byte(client);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "cannot read high byte measurement"); dev_err(&client->dev, "cannot read sensor data\n");
return ret; return ret;
} }
val = ret << 8; return be16_to_cpu(val);
ret = i2c_smbus_read_byte(client);
if (ret < 0) {
dev_err(&client->dev, "cannot read low byte measurement");
return ret;
}
val |= ret;
return val;
} }
static int hdc100x_get_heater_status(struct hdc100x_data *data) static int hdc100x_get_heater_status(struct hdc100x_data *data)
...@@ -272,8 +259,8 @@ static int hdc100x_probe(struct i2c_client *client, ...@@ -272,8 +259,8 @@ static int hdc100x_probe(struct i2c_client *client,
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct hdc100x_data *data; struct hdc100x_data *data;
if (!i2c_check_functionality(client->adapter, if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE)) I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))
return -EOPNOTSUPP; return -EOPNOTSUPP;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
......
...@@ -107,6 +107,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ...@@ -107,6 +107,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
{ {
struct iio_dev *indio_dev = filp->private_data; struct iio_dev *indio_dev = filp->private_data;
struct iio_buffer *rb = indio_dev->buffer; struct iio_buffer *rb = indio_dev->buffer;
DEFINE_WAIT_FUNC(wait, woken_wake_function);
size_t datum_size; size_t datum_size;
size_t to_wait; size_t to_wait;
int ret; int ret;
...@@ -131,19 +132,29 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ...@@ -131,19 +132,29 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
else else
to_wait = min_t(size_t, n / datum_size, rb->watermark); to_wait = min_t(size_t, n / datum_size, rb->watermark);
add_wait_queue(&rb->pollq, &wait);
do { do {
ret = wait_event_interruptible(rb->pollq, if (!indio_dev->info) {
iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)); ret = -ENODEV;
if (ret) break;
return ret; }
if (!indio_dev->info) if (!iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)) {
return -ENODEV; if (signal_pending(current)) {
ret = -ERESTARTSYS;
break;
}
wait_woken(&wait, TASK_INTERRUPTIBLE,
MAX_SCHEDULE_TIMEOUT);
continue;
}
ret = rb->access->read_first_n(rb, n, buf); ret = rb->access->read_first_n(rb, n, buf);
if (ret == 0 && (filp->f_flags & O_NONBLOCK)) if (ret == 0 && (filp->f_flags & O_NONBLOCK))
ret = -EAGAIN; ret = -EAGAIN;
} while (ret == 0); } while (ret == 0);
remove_wait_queue(&rb->pollq, &wait);
return ret; return ret;
} }
......
...@@ -238,6 +238,8 @@ config MAX44000 ...@@ -238,6 +238,8 @@ config MAX44000
tristate "MAX44000 Ambient and Infrared Proximity Sensor" tristate "MAX44000 Ambient and Infrared Proximity Sensor"
depends on I2C depends on I2C
select REGMAP_I2C select REGMAP_I2C
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
Say Y here if you want to build support for Maxim Integrated's Say Y here if you want to build support for Maxim Integrated's
MAX44000 ambient and infrared proximity sensor device. MAX44000 ambient and infrared proximity sensor device.
......
...@@ -970,7 +970,7 @@ int bmp280_common_probe(struct device *dev, ...@@ -970,7 +970,7 @@ int bmp280_common_probe(struct device *dev,
data->vdda = devm_regulator_get(dev, "vdda"); data->vdda = devm_regulator_get(dev, "vdda");
if (IS_ERR(data->vdda)) { if (IS_ERR(data->vdda)) {
dev_err(dev, "failed to get VDDA regulator\n"); dev_err(dev, "failed to get VDDA regulator\n");
ret = PTR_ERR(data->vddd); ret = PTR_ERR(data->vdda);
goto out_disable_vddd; goto out_disable_vddd;
} }
ret = regulator_enable(data->vdda); ret = regulator_enable(data->vdda);
...@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove); ...@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int bmp280_runtime_suspend(struct device *dev) static int bmp280_runtime_suspend(struct device *dev)
{ {
struct bmp280_data *data = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmp280_data *data = iio_priv(indio_dev);
int ret; int ret;
ret = regulator_disable(data->vdda); ret = regulator_disable(data->vdda);
...@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev) ...@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
static int bmp280_runtime_resume(struct device *dev) static int bmp280_runtime_resume(struct device *dev)
{ {
struct bmp280_data *data = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmp280_data *data = iio_priv(indio_dev);
int ret; int ret;
ret = regulator_enable(data->vddd); ret = regulator_enable(data->vddd);
......
...@@ -397,7 +397,7 @@ static int as3935_probe(struct spi_device *spi) ...@@ -397,7 +397,7 @@ static int as3935_probe(struct spi_device *spi)
return ret; return ret;
} }
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
&as3935_trigger_handler, NULL); &as3935_trigger_handler, NULL);
if (ret) { if (ret) {
......
...@@ -419,6 +419,7 @@ static ssize_t ad5933_store(struct device *dev, ...@@ -419,6 +419,7 @@ static ssize_t ad5933_store(struct device *dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
switch ((u32)this_attr->address) { switch ((u32)this_attr->address) {
case AD5933_OUT_RANGE: case AD5933_OUT_RANGE:
ret = -EINVAL;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
if (val == st->range_avail[i]) { if (val == st->range_avail[i]) {
st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3);
...@@ -426,7 +427,6 @@ static ssize_t ad5933_store(struct device *dev, ...@@ -426,7 +427,6 @@ static ssize_t ad5933_store(struct device *dev,
ret = ad5933_cmd(st, 0); ret = ad5933_cmd(st, 0);
break; break;
} }
ret = -EINVAL;
break; break;
case AD5933_IN_PGA_GAIN: case AD5933_IN_PGA_GAIN:
if (sysfs_streq(buf, "1")) { if (sysfs_streq(buf, "1")) {
......
...@@ -62,7 +62,7 @@ void iio_swt_group_init_type_name(struct iio_sw_trigger *t, ...@@ -62,7 +62,7 @@ void iio_swt_group_init_type_name(struct iio_sw_trigger *t,
const char *name, const char *name,
struct config_item_type *type) struct config_item_type *type)
{ {
#ifdef CONFIG_CONFIGFS_FS #if IS_ENABLED(CONFIG_CONFIGFS_FS)
config_group_init_type_name(&t->group, name, type); config_group_init_type_name(&t->group, name, type);
#endif #endif
} }
......
...@@ -138,16 +138,16 @@ ...@@ -138,16 +138,16 @@
/* /*
* time in us for processing a single channel, calculated as follows: * time in us for processing a single channel, calculated as follows:
* *
* num cycles = open delay + (sample delay + conv time) * averaging * max num cycles = open delay + (sample delay + conv time) * averaging
* *
* num cycles: 152 + (1 + 13) * 16 = 376 * max num cycles: 262143 + (255 + 13) * 16 = 266431
* *
* clock frequency: 26MHz / 8 = 3.25MHz * clock frequency: 26MHz / 8 = 3.25MHz
* clock period: 1 / 3.25MHz = 308ns * clock period: 1 / 3.25MHz = 308ns
* *
* processing time: 376 * 308ns = 116us * max processing time: 266431 * 308ns = 83ms(approx)
*/ */
#define IDLE_TIMEOUT 116 /* microsec */ #define IDLE_TIMEOUT 83 /* milliseconds */
#define TSCADC_CELLS 2 #define TSCADC_CELLS 2
......
...@@ -348,7 +348,7 @@ int main(int argc, char **argv) ...@@ -348,7 +348,7 @@ int main(int argc, char **argv)
int notrigger = 0; int notrigger = 0;
char *dummy; char *dummy;
struct iio_channel_info *channels; struct iio_channel_info *channels = NULL;
register_cleanup(); register_cleanup();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment