Fifth set of IIO fixes for the 4.11 cycle.

As these are rather late in the cycle, they may sneak over into 4.12.
 There is a fix for a regression caused by another fix (hid sensors
 hardware seems to vary a lot in how various corner cases are handled).
 
 * ad7303
   - fix channel description. Numeric values were being passed as characters
   presumably leading to garbage from the userspace interface.
 * as3935
   - the write data macro was wrong so fix it.
 * bmp280
   - incorrect handling of negative values as being unsigned broke humidity
   calculation.
 * hid-sensor
   - Restore the poll and hysteresis values after resume as some hardware
   doesn't do it.
 * stm32-trigger
   - buglet in reading the sampling frequency
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAljw8ScRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojZvBAAh8K9e+3ObpS6/0wj26/XsakiFn4v2ah0
 xKUnafxAVVxU3AU01IJ3CtNdIMyqMwpnB+PvnpgDzZw749QrYKPsBIzheK64eabe
 fzA34X5MWGLwUdOXpfEB0xvsylWjJrqsf1rahgZjiUKkPeZe9EwzPM/fP1sEl5gu
 p+vfSMckboFaKheoQwnWMUTBp0HK+nbFpcSBzljX68u+epiXpDGrjuZC8NJ3JuBn
 Bloz9AhDliIn477H7mIUTXBbt3ixLIDiJ7haQuTNlagosPoUtCBpwY2O9mZ7VRVs
 wM62h7/F170077ReQJRjlfck+7uHoIgDeS46w5UYTzA1HJLxs+veO5xv3VOtHIUg
 BZ+mibQyIUBrFeyYDVbeUpBTffiU6rA+yiM4WFwUFabl7t7rlG0NhLEx7OIQcFMm
 l8u/5JUoJcoykaO8c9Jx5XtrgkXq+rCWVAmhjHqUDAlvsMa6pJWEyqgaVcQeIbdw
 ns9ppJRlOmEst7lMab9TI7BJp3oCIH6uRmctbme42Rw8XgDFdltxqkxmjB8d+cDC
 Q0INhNJN1jRgz6rT6lkxVhAYKtaP5T8qZeliT4MO1E59ggOVSSf8zuhjrEMUK397
 Tu/k7fmATtiKSG+blwYZVRC3+ixh/oKZsvfwZ4O+mFJyhQ616nKMYAywoaZcM8WT
 Z1ABipUDwsE=
 =H5KS
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.11e' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Fifth set of IIO fixes for the 4.11 cycle.

As these are rather late in the cycle, they may sneak over into 4.12.
There is a fix for a regression caused by another fix (hid sensors
hardware seems to vary a lot in how various corner cases are handled).

* ad7303
  - fix channel description. Numeric values were being passed as characters
  presumably leading to garbage from the userspace interface.
* as3935
  - the write data macro was wrong so fix it.
* bmp280
  - incorrect handling of negative values as being unsigned broke humidity
  calculation.
* hid-sensor
  - Restore the poll and hysteresis values after resume as some hardware
  doesn't do it.
* stm32-trigger
  - buglet in reading the sampling frequency
This commit is contained in:
Greg Kroah-Hartman 2017-04-18 19:38:38 +02:00
commit df47c0a638
7 changed files with 56 additions and 18 deletions

View File

@ -232,7 +232,15 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
if (ret < 0 || value < 0)
ret = -EINVAL;
return ret;
ret = sensor_hub_get_feature(st->hsdev,
st->poll.report_id,
st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0)
return -EINVAL;
st->poll_interval = value;
return 0;
}
EXPORT_SYMBOL(hid_sensor_write_samp_freq_value);
@ -277,7 +285,16 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
if (ret < 0 || value < 0)
ret = -EINVAL;
return ret;
ret = sensor_hub_get_feature(st->hsdev,
st->sensitivity.report_id,
st->sensitivity.index, sizeof(value),
&value);
if (ret < 0 || value < 0)
return -EINVAL;
st->raw_hystersis = value;
return 0;
}
EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
@ -380,6 +397,9 @@ int hid_sensor_get_reporting_interval(struct hid_sensor_hub_device *hsdev,
/* Default unit of measure is milliseconds */
if (st->poll.units == 0)
st->poll.units = HID_USAGE_SENSOR_UNITS_MILLISECOND;
st->poll_interval = -1;
return 0;
}
@ -410,6 +430,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS,
&st->sensitivity);
st->raw_hystersis = -1;
sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT, usage_id,
HID_USAGE_SENSOR_TIME_TIMESTAMP,

View File

@ -51,6 +51,8 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
st->report_state.report_id,
st->report_state.index,
HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
poll_value = hid_sensor_read_poll_value(st);
} else {
int val;
@ -87,9 +89,7 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
st->power_state.index,
sizeof(state_val), &state_val);
if (state)
poll_value = hid_sensor_read_poll_value(st);
if (poll_value > 0)
if (state && poll_value)
msleep_interruptible(poll_value * 2);
return 0;
@ -127,6 +127,20 @@ static void hid_sensor_set_power_work(struct work_struct *work)
struct hid_sensor_common *attrb = container_of(work,
struct hid_sensor_common,
work);
if (attrb->poll_interval >= 0)
sensor_hub_set_feature(attrb->hsdev, attrb->poll.report_id,
attrb->poll.index,
sizeof(attrb->poll_interval),
&attrb->poll_interval);
if (attrb->raw_hystersis >= 0)
sensor_hub_set_feature(attrb->hsdev,
attrb->sensitivity.report_id,
attrb->sensitivity.index,
sizeof(attrb->raw_hystersis),
&attrb->raw_hystersis);
_hid_sensor_power_state(attrb, true);
}

View File

@ -184,9 +184,9 @@ static const struct iio_chan_spec_ext_info ad7303_ext_info[] = {
.address = (chan), \
.scan_type = { \
.sign = 'u', \
.realbits = '8', \
.storagebits = '8', \
.shift = '0', \
.realbits = 8, \
.storagebits = 8, \
.shift = 0, \
}, \
.ext_info = ad7303_ext_info, \
}

View File

@ -175,11 +175,12 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data,
}
H6 = sign_extend32(tmp, 7);
var = ((s32)data->t_fine) - 76800;
var = ((((adc_humidity << 14) - (H4 << 20) - (H5 * var)) + 16384) >> 15)
* (((((((var * H6) >> 10) * (((var * H3) >> 11) + 32768)) >> 10)
+ 2097152) * H2 + 8192) >> 14);
var -= ((((var >> 15) * (var >> 15)) >> 7) * H1) >> 4;
var = ((s32)data->t_fine) - (s32)76800;
var = ((((adc_humidity << 14) - (H4 << 20) - (H5 * var))
+ (s32)16384) >> 15) * (((((((var * H6) >> 10)
* (((var * (s32)H3) >> 11) + (s32)32768)) >> 10)
+ (s32)2097152) * H2 + 8192) >> 14);
var -= ((((var >> 15) * (var >> 15)) >> 7) * (s32)H1) >> 4;
return var >> 12;
};

View File

@ -50,7 +50,6 @@
#define AS3935_TUNE_CAP 0x08
#define AS3935_CALIBRATE 0x3D
#define AS3935_WRITE_DATA BIT(15)
#define AS3935_READ_DATA BIT(14)
#define AS3935_ADDRESS(x) ((x) << 8)
@ -105,7 +104,7 @@ static int as3935_write(struct as3935_state *st,
{
u8 *buf = st->buf;
buf[0] = (AS3935_WRITE_DATA | AS3935_ADDRESS(reg)) >> 8;
buf[0] = AS3935_ADDRESS(reg) >> 8;
buf[1] = val;
return spi_write(st->spi, buf, 2);

View File

@ -170,10 +170,10 @@ static ssize_t stm32_tt_read_frequency(struct device *dev,
regmap_read(priv->regmap, TIM_PSC, &psc);
regmap_read(priv->regmap, TIM_ARR, &arr);
if (psc && arr && (cr1 & TIM_CR1_CEN)) {
if (cr1 & TIM_CR1_CEN) {
freq = (unsigned long long)clk_get_rate(priv->clk);
do_div(freq, psc);
do_div(freq, arr);
do_div(freq, psc + 1);
do_div(freq, arr + 1);
}
return sprintf(buf, "%d\n", (unsigned int)freq);

View File

@ -231,6 +231,8 @@ struct hid_sensor_common {
unsigned usage_id;
atomic_t data_ready;
atomic_t user_requested_state;
int poll_interval;
int raw_hystersis;
struct iio_trigger *trigger;
int timestamp_ns_scale;
struct hid_sensor_hub_attribute_info poll;