Skip to content

Commit

Permalink
Merge tag 'iio-fixes-for-3.16a' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First set of IIO fixes for the 3.16 cycle.

A mixed bag of fixes, many of which feel just to late for 3.15.

* hid sensors - some devices need a feature report request in order to
  change power state.  This isn't part of the spec, but has been observed
  on several devices and does no harm to others.
* mpl3115 has had two errors in the buffer description fixed. The presure is
  signed, not unsigned and the temperature has 12 bits rather than 16.
  These could lead to incorrect interpretation of the data in userspace.
* tsl2x7x - the high byte of the proximity thresholds should be written along
  with the low byte (which was). This could lead to interesting results
  with large thresholds.
* twl4030 - a flag to specify processed values were required was not set
  when initializing a reading.  As such values returned were in an unknown
  state. Fixed by simply initializing it appropriately.
* IIO_SIMPLE_DUMMY_BUFFER did not select IIO_BUFFER leading to randconfig
  build errors.
* ak8975 was applying an unwanted le16_to_cpu conversion as the i2c framework
  already performs one.  As such for big endian systems, the bytes would be
  in the wrong order in the magnetic field measurements reported.
* mxs-lradc - the controllable voltage dividers were not enabled / disabled for
  later channels than the first one during conversion.
* at91_adc error handling returned -ENOMEM in a u8. Return value of
  at91_adc_get_trigger_value_by_name changed to int thus allowing -ENOMEM and
  also original values to be returned.
* mcb - mcb_request_mem returns and ERR_PTR but the caller was checking for
  NULL to detect an error.
  • Loading branch information
gregkh committed Jun 18, 2014
2 parents c44b33b + e94f62e commit e28642c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 31 deletions.
16 changes: 8 additions & 8 deletions drivers/iio/adc/at91_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,11 @@ static int at91_adc_channel_init(struct iio_dev *idev)
return idev->num_channels;
}

static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
struct at91_adc_trigger *triggers,
const char *trigger_name)
{
struct at91_adc_state *st = iio_priv(idev);
u8 value = 0;
int i;

for (i = 0; i < st->trigger_number; i++) {
Expand All @@ -528,15 +527,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
return -ENOMEM;

if (strcmp(trigger_name, name) == 0) {
value = triggers[i].value;
kfree(name);
break;
if (triggers[i].value == 0)
return -EINVAL;
return triggers[i].value;
}

kfree(name);
}

return value;
return -EINVAL;
}

static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
Expand All @@ -546,14 +546,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
struct iio_buffer *buffer = idev->buffer;
struct at91_adc_reg_desc *reg = st->registers;
u32 status = at91_adc_readl(st, reg->trigger_register);
u8 value;
int value;
u8 bit;

value = at91_adc_get_trigger_value_by_name(idev,
st->trigger_list,
idev->trig->name);
if (value == 0)
return -EINVAL;
if (value < 0)
return value;

if (state) {
st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL);
Expand Down
4 changes: 2 additions & 2 deletions drivers/iio/adc/men_z188_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ static int men_z188_probe(struct mcb_device *dev,
indio_dev->num_channels = ARRAY_SIZE(z188_adc_iio_channels);

mem = mcb_request_mem(dev, "z188-adc");
if (!mem)
return -ENOMEM;
if (IS_ERR(mem))
return PTR_ERR(mem);

adc->base = ioremap(mem->start, resource_size(mem));
if (adc->base == NULL)
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/adc/twl4030-madc.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ int twl4030_get_madc_conversion(int channel_no)
req.channels = (1 << channel_no);
req.method = TWL4030_MADC_SW2;
req.active = 0;
req.raw = 0;
req.func_cb = NULL;
ret = twl4030_madc_conversion(&req);
if (ret < 0)
Expand Down
3 changes: 3 additions & 0 deletions drivers/iio/common/hid-sensors/hid-sensor-trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
(s32)report_val);
}

sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
st->power_state.index,
&state_val);
return 0;
}
EXPORT_SYMBOL(hid_sensor_power_state);
Expand Down
9 changes: 1 addition & 8 deletions drivers/iio/magnetometer/ak8975.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
{
struct ak8975_data *data = iio_priv(indio_dev);
struct i2c_client *client = data->client;
u16 meas_reg;
s16 raw;
int ret;

mutex_lock(&data->lock);
Expand Down Expand Up @@ -422,16 +420,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
dev_err(&client->dev, "Read axis data fails\n");
goto exit;
}
meas_reg = ret;

mutex_unlock(&data->lock);

/* Endian conversion of the measured values. */
raw = (s16) (le16_to_cpu(meas_reg));

/* Clamp to valid range. */
raw = clamp_t(s16, raw, -4096, 4095);
*val = raw;
*val = clamp_t(s16, ret, -4096, 4095);
return IIO_VAL_INT;

exit:
Expand Down
6 changes: 3 additions & 3 deletions drivers/iio/pressure/mpl3115.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&data->lock);
if (ret < 0)
return ret;
*val = sign_extend32(be32_to_cpu(tmp) >> 12, 23);
*val = be32_to_cpu(tmp) >> 12;
return IIO_VAL_INT;
case IIO_TEMP: /* in 0.0625 celsius / LSB */
mutex_lock(&data->lock);
Expand All @@ -112,7 +112,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&data->lock);
if (ret < 0)
return ret;
*val = sign_extend32(be32_to_cpu(tmp) >> 20, 15);
*val = sign_extend32(be32_to_cpu(tmp) >> 20, 11);
return IIO_VAL_INT;
default:
return -EINVAL;
Expand Down Expand Up @@ -185,7 +185,7 @@ static const struct iio_chan_spec mpl3115_channels[] = {
BIT(IIO_CHAN_INFO_SCALE),
.scan_index = 0,
.scan_type = {
.sign = 's',
.sign = 'u',
.realbits = 20,
.storagebits = 32,
.shift = 12,
Expand Down
9 changes: 5 additions & 4 deletions drivers/staging/iio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ config IIO_SIMPLE_DUMMY_EVENTS
Add some dummy events to the simple dummy driver.

config IIO_SIMPLE_DUMMY_BUFFER
boolean "Buffered capture support"
select IIO_KFIFO_BUF
help
Add buffered data capture to the simple dummy driver.
boolean "Buffered capture support"
select IIO_BUFFER
select IIO_KFIFO_BUF
help
Add buffered data capture to the simple dummy driver.

endif # IIO_SIMPLE_DUMMY

Expand Down
12 changes: 8 additions & 4 deletions drivers/staging/iio/adc/mxs-lradc.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,14 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val)
LRADC_CTRL1);
mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0);

/* Enable / disable the divider per requirement */
if (test_bit(chan, &lradc->is_divided))
mxs_lradc_reg_set(lradc, 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
LRADC_CTRL2);
else
mxs_lradc_reg_clear(lradc,
1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, LRADC_CTRL2);

/* Clean the slot's previous content, then set new one. */
mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0),
LRADC_CTRL4);
Expand Down Expand Up @@ -961,15 +969,11 @@ static int mxs_lradc_write_raw(struct iio_dev *iio_dev,
if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer &&
val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) {
/* divider by two disabled */
writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_CLR);
clear_bit(chan->channel, &lradc->is_divided);
ret = 0;
} else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer &&
val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) {
/* divider by two enabled */
writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_SET);
set_bit(chan->channel, &lradc->is_divided);
ret = 0;
}
Expand Down
8 changes: 6 additions & 2 deletions drivers/staging/iio/light/tsl2x7x_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,13 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
chip->tsl2x7x_settings.prox_pulse_count;
chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
chip->tsl2x7x_settings.prox_thres_low;
(chip->tsl2x7x_settings.prox_thres_low) & 0xFF;
chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] =
(chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF;
chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
chip->tsl2x7x_settings.prox_thres_high;
(chip->tsl2x7x_settings.prox_thres_high) & 0xFF;
chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] =
(chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF;

/* and make sure we're not already on */
if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
Expand Down

0 comments on commit e28642c

Please sign in to comment.