Re: [PATCH][for iio-for-4.17b] iio: humidity: hts221: Fix sensor reads after resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lorenzo,

On Mon, 2018-04-30 at 09:48 +0200, Lorenzo Bianconi wrote:
> > CTRL1 register (ODR & BDU settings) gets reset after system comes back
> > from suspend, causing subsequent reads from the sensor to fail.
> > 
> > This patch restores the CTRL1 register after resume.
> > 
> 
> Hi Shrirang,
> 
> is just CTRL1 reset after suspend/resume or also other registers? are
I have checked, contents of other registers survive the suspend/resume 
(both suspend-to-ram & suspend-to-disk)cycle. It's only CTRL1 which resets.
> IIO triggers enabled before the suspend or
No IIO triggers are enabled.
> are you reading data from sysfs?
Yes.
> 
> > Based on:
> > git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git iio-for-4.17b
> > 
> > Fixes: ffebe74b7c95 (iio: humidity: hts221: avoid useless ODR reconfiguration)
> > Signed-off-by: Shrirang Bagul <shrirang.bagul@xxxxxxxxxxxxx>
> > ---
> >  drivers/iio/humidity/hts221_core.c | 13 +++++++------
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> > index 166946d4978d..5d7a652aa6d9 100644
> > --- a/drivers/iio/humidity/hts221_core.c
> > +++ b/drivers/iio/humidity/hts221_core.c
> > @@ -658,12 +658,13 @@ static int __maybe_unused hts221_resume(struct device *dev)
> >         struct hts221_hw *hw = iio_priv(iio_dev);
> >         int err = 0;
> > 
> > -       if (hw->enabled)
> > -               err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR,
> > -                                        HTS221_ENABLE_MASK,
> > -                                        FIELD_PREP(HTS221_ENABLE_MASK,
> > -                                                   true));
> > -       return err;
> > +       err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR,
> > +                                HTS221_BDU_MASK,
> > +                                FIELD_PREP(HTS221_BDU_MASK, 1));
> > +       if (err < 0)
> > +               return err;
> > +
> > +       return hts221_update_odr(hw, hw->odr);
> >  }
> > 
> 
> Here you need to re-enable the sensor if it was running before the
> suspend operation.
> Regards,
> 
> Lorenzo
> 
> >  const struct dev_pm_ops hts221_pm_ops = {
> > --
> > 2.14.1
> > 
> 
> 
> 

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux