APPLIED: Re: [SRU OEM-B][PATCH] UBUNTU: SAUCE: iio: humidity: hts221: Fix sensor reads after resume

Timo Aaltonen tjaalton at ubuntu.com
Tue May 29 07:41:53 UTC 2018


On 07.05.2018 16:55, Shrirang Bagul wrote:
> BugLink: http://bugs.launchpad.net/bugs/1769658
> 
> AV_CONF register (RH & TEMP. oversampling ratio's) and CTRL1 register
> (ODR & BDU settings) values are lost after suspend.
> 
> While the change in AV_CONF updates the sensor resolution modes
> (overriding the user configuration before the device went to suspend);
> loss of the contents of the CTRL1 register leads to failure in reading
> sensor output.
> 
> This patch restores the AV_CONF & CTRL1 registers after resume.
> 
> Already submitted upstream for both 4.17.y and 4.14.y (LTS) and under
> review:
> 4.17.y: https://marc.info/?t=152455871600007&r=1&w=2
> 4.14.y: https://marc.info/?t=152506242000001&r=1&w=2
> 
> Fixes: ffebe74b7c95 (iio: humidity: hts221: avoid useless ODR reconfiguration)
> 
> Signed-off-by: Shrirang Bagul <shrirang.bagul at canonical.com>
> ---
>  drivers/iio/humidity/hts221_core.c | 31 +++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index daef177219b6..7d24e3d8fbdf 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -671,13 +671,40 @@ static int __maybe_unused hts221_resume(struct device *dev)
>  {
>  	struct iio_dev *iio_dev = dev_get_drvdata(dev);
>  	struct hts221_hw *hw = iio_priv(iio_dev);
> +	const struct hts221_avg *avg;
> +	u8 data, idx;
>  	int err = 0;
>  
> +	/* Restore contents of AV_CONF (RH & TEMP. oversampling ratio's) */
> +	avg = &hts221_avg_list[HTS221_SENSOR_H];
> +	idx = hw->sensors[HTS221_SENSOR_H].cur_avg_idx;
> +	data = avg->avg_avl[idx];
> +	err = hts221_update_avg(hw, HTS221_SENSOR_H, data);
> +	if (err < 0)
> +		goto fail_err;
> +
> +	avg = &hts221_avg_list[HTS221_SENSOR_T];
> +	idx = hw->sensors[HTS221_SENSOR_T].cur_avg_idx;
> +	data = avg->avg_avl[idx];
> +	err = hts221_update_avg(hw, HTS221_SENSOR_T, data);
> +	if (err < 0)
> +		goto fail_err;
> +
> +	/* Restore contents of CTRL1 (BDU & ODR) */
> +	err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
> +				     HTS221_BDU_MASK, 1);
> +	if (err < 0)
> +		goto fail_err;
> +
> +	err = hts221_update_odr(hw, hw->odr);
> +	if (err < 0)
> +		goto fail_err;
> +
>  	if (hw->enabled)
>  		err = hts221_write_with_mask(hw, HTS221_REG_CNTRL1_ADDR,
>  					     HTS221_ENABLE_MASK, true);
> -
> -	return err;
> +fail_err:
> +	return err < 0 ? err : 0;
>  }
>  
>  const struct dev_pm_ops hts221_pm_ops = {

This got applied to bionic/oem earlier.



-- 
t




More information about the kernel-team mailing list