summaryrefslogtreecommitdiffstats
path: root/drivers/iio/common/st_sensors/st_sensors_core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-26 15:46:08 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-26 15:46:08 -0700
commit23908db413eccd77084b09c9b0a4451dfb0524c0 (patch)
tree646f21a92496bdc04175e95642b0ecb2dc3dd09e /drivers/iio/common/st_sensors/st_sensors_core.c
parent8d7804a2f03dbd34940fcb426450c730adf29dae (diff)
parent53a20e9e378ecd52f0afa4b60f8f8c81b6f97c27 (diff)
downloadlinux-23908db413eccd77084b09c9b0a4451dfb0524c0.tar.bz2
Merge tag 'staging-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver updates from Greg KH: "Here's the big, really big, staging tree patches for 4.2-rc1. Loads of stuff in here, almost all just coding style fixes / churn, and a few new drivers as well, one of which I just disabled from the build a few minutes ago due to way too many build warnings. Other than the one "disable this driver" patch, all of these have been in linux-next for quite a while with no reported issues" * tag 'staging-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1163 commits) staging: wilc1000: disable driver due to build warnings Staging: rts5208: fix CHANGE_LINK_STATE value Staging: sm750fb: ddk750_swi2c.c: Insert spaces before parenthesis Staging: sm750fb: ddk750_swi2c.c: Place braces on correct lines Staging: sm750fb: ddk750_swi2c.c: Insert spaces around operators Staging: sm750fb: ddk750_swi2c.c: Replace spaces with tabs Staging: sm750fb: ddk750_swi2c.h: Shorten lines to under 80 characters Staging: sm750fb: ddk750_swi2c.h: Replace spaces with tabs Staging: sm750fb: modedb.h: Shorten lines to under 80 characters Staging: sm750fb: modedb.h: Replace spaces with tabs staging: comedi: addi_apci_3120: rename 'this_board' variables staging: comedi: addi_apci_1516: rename 'this_board' variables staging: comedi: ni_atmio: cleanup ni_getboardtype() staging: comedi: vmk80xx: sanity check context used to get the boardinfo staging: comedi: vmk80xx: rename 'boardinfo' variables staging: comedi: dt3000: rename 'this_board' variables staging: comedi: adv_pci_dio: rename 'this_board' variables staging: comedi: cb_pcidas64: rename 'thisboard' variables staging: comedi: cb_pcidas: rename 'thisboard' variables staging: comedi: me4000: rename 'thisboard' variables ...
Diffstat (limited to 'drivers/iio/common/st_sensors/st_sensors_core.c')
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 8dd0477e201c..8086cbcff87d 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -245,6 +245,16 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
{
struct st_sensor_data *sdata = iio_priv(indio_dev);
+ /* Sensor does not support interrupts */
+ if (sdata->sensor_settings->drdy_irq.addr == 0) {
+ if (pdata->drdy_int_pin)
+ dev_info(&indio_dev->dev,
+ "DRDY on pin INT%d specified, but sensor "
+ "does not support interrupts\n",
+ pdata->drdy_int_pin);
+ return 0;
+ }
+
switch (pdata->drdy_int_pin) {
case 1:
if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) {
@@ -285,7 +295,7 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
if (!of_property_read_u32(np, "st,drdy-int-pin", &val) && (val <= 2))
pdata->drdy_int_pin = (u8) val;
else
- pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 1;
+ pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 0;
return pdata;
}
@@ -332,11 +342,13 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
return err;
/* set BDU */
- err = st_sensors_write_data_with_mask(indio_dev,
+ if (sdata->sensor_settings->bdu.addr) {
+ err = st_sensors_write_data_with_mask(indio_dev,
sdata->sensor_settings->bdu.addr,
sdata->sensor_settings->bdu.mask, true);
- if (err < 0)
- return err;
+ if (err < 0)
+ return err;
+ }
err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS);
@@ -419,7 +431,9 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
if (err < 0)
goto st_sensors_free_memory;
- if (byte_for_channel == 2)
+ if (byte_for_channel == 1)
+ *data = (s8)*outdata;
+ else if (byte_for_channel == 2)
*data = (s16)get_unaligned_le16(outdata);
else if (byte_for_channel == 3)
*data = (s32)st_sensors_get_unaligned_le24(outdata);
@@ -489,7 +503,8 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
break;
}
if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
- dev_err(&indio_dev->dev, "device name and WhoAmI mismatch.\n");
+ dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
+ indio_dev->name, wai);
goto sensor_name_mismatch;
}