From 94fccb78414a87f3c4bc7049ff8b6e80156944d9 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 18 Jun 2013 14:08:00 +0100 Subject: iio: dac: ad7303: fix error return code in ad7303_probe() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad7303.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index 85aeef60dc5f..d546f50f9258 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi) if (ext_ref) { st->vref_reg = regulator_get(&spi->dev, "REF"); - if (IS_ERR(st->vref_reg)) + if (IS_ERR(st->vref_reg)) { + ret = PTR_ERR(st->vref_reg); goto err_disable_vdd_reg; + } ret = regulator_enable(st->vref_reg); if (ret) -- cgit v1.2.3 From 8bade406649245292d6fcd1947cd7ad2ad8c80c1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 22 Jun 2013 12:00:04 +0100 Subject: iio:trigger: device_unregister->device_del to avoid double free iio_trigger unregistration and freeing has been separated in this code for some time, but it looks like the calls to the device handling were not appropriately updated. Signed-off-by: Jonathan Cameron Reported-by: Otavio Salvador Tested-by: Otavio Salvador Reviewed-by: Lars-Peter Clausen --- drivers/iio/industrialio-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 4d6c7d84e155..ea8a4146620d 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) ida_simple_remove(&iio_trigger_ida, trig_info->id); /* Possible issue in here */ - device_unregister(&trig_info->dev); + device_del(&trig_info->dev); } EXPORT_SYMBOL(iio_trigger_unregister); -- cgit v1.2.3 From 1c297a66654a3295ae87e2b7f3724d214eb2b5ec Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 1 Jul 2013 15:20:00 +0100 Subject: iio: Fix iio_channel_has_info Since the info_mask split, iio_channel_has_info() is not working correctly. info_mask_separate and info_mask_shared_by_type, it is not possible to compare them directly with the iio_chan_info_enum enum. Correct that bit using the BIT() macro. Cc: # 3.10.x Signed-off-by: Alexandre Belloni Signed-off-by: Jonathan Cameron --- include/linux/iio/iio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 8d171f427632..3d35b7023591 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -211,8 +211,8 @@ struct iio_chan_spec { static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, enum iio_chan_info_enum type) { - return (chan->info_mask_separate & type) | - (chan->info_mask_shared_by_type & type); + return (chan->info_mask_separate & BIT(type)) | + (chan->info_mask_shared_by_type & BIT(type)); } #define IIO_ST(si, rb, sb, sh) \ -- cgit v1.2.3 From f91d1b63a4e096d3023aaaafec9d9d3aff25997f Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 1 Jul 2013 17:40:00 +0100 Subject: iio: inkern: fix iio_convert_raw_to_processed_unlocked When reading IIO_CHAN_INFO_OFFSET, the return value of iio_channel_read() for success will be IIO_VAL*, checking for 0 is not correct. Without this fix the offset applied by iio drivers will be ignored when converting a raw value to one in appropriate base units (e.g mV) in a IIO client drivers that use iio_convert_raw_to_processed including iio-hwmon. Cc: # 3.10.x Signed-off-by: Alexandre Belloni Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 98ddc323add0..0cf5f8e06cfc 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, int ret; ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); - if (ret == 0) + if (ret >= 0) raw64 += offset; scale_type = iio_channel_read(chan, &scale_val, &scale_val2, -- cgit v1.2.3 From e1b1fa66a0398f0b52ae79a2bdc7de87c205d074 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 29 Jun 2013 22:20:00 +0100 Subject: iio: mxs-lradc: Fix misuse of iio->trig The struct iio_dev .trig field is to be used only by the IIO core, the driver shall not fill this field. This fixes ugly crash when the driver is compiled as a module and the module is rmmod'd. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Jonathan Cameron Cc: Shawn Guo Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index d92c97a59d61..c5edf1cad07a 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -661,12 +661,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) { int ret; struct iio_trigger *trig; + struct mxs_lradc *lradc = iio_priv(iio); trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); if (trig == NULL) return -ENOMEM; - trig->dev.parent = iio->dev.parent; + trig->dev.parent = lradc->dev; iio_trigger_set_drvdata(trig, iio); trig->ops = &mxs_lradc_trigger_ops; @@ -676,15 +677,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) return ret; } - iio->trig = trig; + lradc->trig = trig; return 0; } static void mxs_lradc_trigger_remove(struct iio_dev *iio) { - iio_trigger_unregister(iio->trig); - iio_trigger_free(iio->trig); + struct mxs_lradc *lradc = iio_priv(iio); + + iio_trigger_unregister(lradc->trig); + iio_trigger_free(lradc->trig); } static int mxs_lradc_buffer_preenable(struct iio_dev *iio) -- cgit v1.2.3 From 2a961d0995cdadbfba565b28beada59c5ae7ebae Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 3 Jul 2013 22:25:00 +0100 Subject: iio: mxs-lradc: Remove useless check in read_raw The removed check in the read_raw implementation was always true, therefore remove it. This also fixes a bug, by closely inspecting the code, one can notice the iio_validate_scan_mask_onehot() will always return 1 and therefore the subsequent condition will always succeed, therefore making the mxs_lradc_read_raw() function always return -EINVAL; . Signed-off-by: Marek Vasut Tested-by: Otavio Salvador Acked-by: Hector Palacios Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index c5edf1cad07a..9f52a2857929 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, { struct mxs_lradc *lradc = iio_priv(iio_dev); int ret; - unsigned long mask; if (m != IIO_CHAN_INFO_RAW) return -EINVAL; @@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, if (chan->channel > LRADC_MAX_TOTAL_CHANS) return -EINVAL; - /* Validate the channel if it doesn't intersect with reserved chans. */ - bitmap_set(&mask, chan->channel, 1); - ret = iio_validate_scan_mask_onehot(iio_dev, &mask); - if (ret) - return -EINVAL; - /* * See if there is no buffered operation in progess. If there is, simply * bail out. This can be improved to support both buffered and raw IO at -- cgit v1.2.3 From bc93aa7640fe97df8d69b50fdce70da1126e12b3 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sat, 6 Jul 2013 05:20:00 +0100 Subject: iio: ti_am335x_adc: add missing .driver_module to struct iio_info Add missing .driver_module of struct iio_info. This prevents the module from being removed from underneath its users. Signed-off-by: Wei Yongjun Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 5f9a7e7d3135..985f58873d03 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -134,6 +134,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, static const struct iio_info tiadc_info = { .read_raw = &tiadc_read_raw, + .driver_module = THIS_MODULE, }; static int tiadc_probe(struct platform_device *pdev) -- cgit v1.2.3 From bb3779610254ea5efbf8ec727138e041d801747c Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 4 Jul 2013 14:46:00 +0100 Subject: staging:iio:ad7291: add missing .driver_module to struct iio_info Add missing .driver_module of struct iio_info. This prevents the module from being removed from underneath its users. Signed-off-by: Wei Yongjun Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7291.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 3fc79e582750..a2e61c2fc8d1 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -517,6 +517,7 @@ static const struct iio_info ad7291_info = { .read_event_value = &ad7291_read_event_value, .write_event_value = &ad7291_write_event_value, .event_attrs = &ad7291_event_attribute_group, + .driver_module = THIS_MODULE, }; static int ad7291_probe(struct i2c_client *client, -- cgit v1.2.3 From 8f6817a0a57cf15935f8f076d0ade34da01cf26d Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 7 Jul 2013 21:24:00 +0100 Subject: iio staging: fix lis3l02dq, read error handling Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/lis3l02dq_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 1bfe5d81792b..8ed75a94f465 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -257,6 +257,8 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, ret = lis3l02dq_read_reg_s16(indio_dev, reg, val); } mutex_unlock(&indio_dev->mlock); + if (ret < 0) + goto error_ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; -- cgit v1.2.3 From 67dbf54a3b03881c7b683801fa49ca1f2c4c3bcf Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Tue, 2 Jul 2013 11:13:00 +0100 Subject: iio: lps331ap: Fix wrong in_pressure_scale output value This patch fixes improper in_pressure_scale output that is returned by the lps331ap barometer sensor driver. According to the documentation the pressure after applying the scale has to be expressed in kilopascal units. With erroneous implementation the scale value larger by two orders of magnitude is returned - 2441410 instead of 24414. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park Acked-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 9c343b40665e..3ffbc56917b4 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -28,7 +28,9 @@ #include #include "st_pressure.h" -#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10) +#define ST_PRESS_LSB_PER_MBAR 4096UL +#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \ + ST_PRESS_LSB_PER_MBAR) #define ST_PRESS_NUMBER_DATA_CHANNELS 1 /* DEFAULT VALUE FOR SENSORS */ @@ -51,8 +53,8 @@ #define ST_PRESS_1_FS_ADDR 0x23 #define ST_PRESS_1_FS_MASK 0x30 #define ST_PRESS_1_FS_AVL_1260_VAL 0x00 -#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141) #define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000 +#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE #define ST_PRESS_1_BDU_ADDR 0x20 #define ST_PRESS_1_BDU_MASK 0x04 #define ST_PRESS_1_DRDY_IRQ_ADDR 0x22 -- cgit v1.2.3