Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge tag 'staging-4.3-rc7' of git://git.kernel.org/pub/scm/linux/ker…
…nel/git/gregkh/staging

Pull staging driver fixes from Greg KH:
 "Here are four iio driver fixes for 4.3-rc7, fixing some reported
  issues.  All of these have been in linux-next for a while"

* tag 'staging-4.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  iio: mxs-lradc: Fix temperature offset
  iio: accel: sca3000: memory corruption in sca3000_read_first_n_hw_rb()
  iio: st_accel: fix interrupt handling on LIS3LV02
  iio: adc: twl4030: Fix ADC[3:6] readings
  • Loading branch information
torvalds committed Oct 23, 2015
2 parents 410694e + 4301de3 commit 4ee8019
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
6 changes: 0 additions & 6 deletions drivers/iio/accel/st_accel_core.c
Expand Up @@ -149,8 +149,6 @@
#define ST_ACCEL_4_BDU_MASK 0x40
#define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21
#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04
#define ST_ACCEL_4_IG1_EN_ADDR 0x21
#define ST_ACCEL_4_IG1_EN_MASK 0x08
#define ST_ACCEL_4_MULTIREAD_BIT true

/* CUSTOM VALUES FOR SENSOR 5 */
Expand Down Expand Up @@ -489,10 +487,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.drdy_irq = {
.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
.ig1 = {
.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
.en_mask = ST_ACCEL_4_IG1_EN_MASK,
},
},
.multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
.bootime = 2, /* guess */
Expand Down
34 changes: 34 additions & 0 deletions drivers/iio/adc/twl4030-madc.c
Expand Up @@ -45,13 +45,18 @@
#include <linux/types.h>
#include <linux/gfp.h>
#include <linux/err.h>
#include <linux/regulator/consumer.h>

#include <linux/iio/iio.h>

#define TWL4030_USB_SEL_MADC_MCPC (1<<3)
#define TWL4030_USB_CARKIT_ANA_CTRL 0xBB

/**
* struct twl4030_madc_data - a container for madc info
* @dev: Pointer to device structure for madc
* @lock: Mutex protecting this data structure
* @regulator: Pointer to bias regulator for madc
* @requests: Array of request struct corresponding to SW1, SW2 and RT
* @use_second_irq: IRQ selection (main or co-processor)
* @imr: Interrupt mask register of MADC
Expand All @@ -60,6 +65,7 @@
struct twl4030_madc_data {
struct device *dev;
struct mutex lock; /* mutex protecting this data structure */
struct regulator *usb3v1;
struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS];
bool use_second_irq;
u8 imr;
Expand Down Expand Up @@ -841,6 +847,32 @@ static int twl4030_madc_probe(struct platform_device *pdev)
}
twl4030_madc = madc;

/* Configure MADC[3:6] */
ret = twl_i2c_read_u8(TWL_MODULE_USB, &regval,
TWL4030_USB_CARKIT_ANA_CTRL);
if (ret) {
dev_err(&pdev->dev, "unable to read reg CARKIT_ANA_CTRL 0x%X\n",
TWL4030_USB_CARKIT_ANA_CTRL);
goto err_i2c;
}
regval |= TWL4030_USB_SEL_MADC_MCPC;
ret = twl_i2c_write_u8(TWL_MODULE_USB, regval,
TWL4030_USB_CARKIT_ANA_CTRL);
if (ret) {
dev_err(&pdev->dev, "unable to write reg CARKIT_ANA_CTRL 0x%X\n",
TWL4030_USB_CARKIT_ANA_CTRL);
goto err_i2c;
}

/* Enable 3v1 bias regulator for MADC[3:6] */
madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1");
if (IS_ERR(madc->usb3v1))
return -ENODEV;

ret = regulator_enable(madc->usb3v1);
if (ret)
dev_err(madc->dev, "could not enable 3v1 bias regulator\n");

ret = iio_device_register(iio_dev);
if (ret) {
dev_err(&pdev->dev, "could not register iio device\n");
Expand All @@ -866,6 +898,8 @@ static int twl4030_madc_remove(struct platform_device *pdev)
twl4030_madc_set_current_generator(madc, 0, 0);
twl4030_madc_set_power(madc, 0);

regulator_disable(madc->usb3v1);

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/accel/sca3000_ring.c
Expand Up @@ -116,7 +116,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r,
if (ret)
goto error_ret;

for (i = 0; i < num_read; i++)
for (i = 0; i < num_read / sizeof(u16); i++)
*(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i);

if (copy_to_user(buf, rx, num_read))
Expand Down
9 changes: 5 additions & 4 deletions drivers/staging/iio/adc/mxs-lradc.c
Expand Up @@ -915,11 +915,12 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
case IIO_CHAN_INFO_OFFSET:
if (chan->type == IIO_TEMP) {
/* The calculated value from the ADC is in Kelvin, we
* want Celsius for hwmon so the offset is
* -272.15 * scale
* want Celsius for hwmon so the offset is -273.15
* The offset is applied before scaling so it is
* actually -213.15 * 4 / 1.012 = -1079.644268
*/
*val = -1075;
*val2 = 691699;
*val = -1079;
*val2 = 644268;

return IIO_VAL_INT_PLUS_MICRO;
}
Expand Down

0 comments on commit 4ee8019

Please sign in to comment.