[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <23ced5ac-b0a0-7d87-76d7-bdec0c3e0e15@redhat.com>
Date: Mon, 4 Mar 2019 10:16:56 +0100
From: Hans de Goede <hdegoede@...hat.com>
To: "Chen, Hu" <hu1.chen@...el.com>
Cc: bo.he@...el.com, Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Stephan Gerhold <stephan@...hold.net>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] io: accel: kxcjk1013: restore the range after resume.
Hi,
On 04-03-19 08:05, Chen, Hu wrote:
> From: "he, bo" <bo.he@...el.com>
>
> On some laptops, kxcjk1013 is powered off when system enters S3. We need
> restore the range regiter during resume. Otherwise, the sensor doesn't
> work properly after S3.
>
> Signed-off-by: he, bo <bo.he@...el.com>
> Signed-off-by: Chen, Hu <hu1.chen@...el.com>
Thank you for the patch.
> ---
> Changes in v2:
> - Handle return value independently in resume callback.
>
> drivers/iio/accel/kxcjk-1013.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> index 7096e577b23f..17837e26bcf2 100644
> --- a/drivers/iio/accel/kxcjk-1013.c
> +++ b/drivers/iio/accel/kxcjk-1013.c
> @@ -1437,6 +1437,11 @@ static int kxcjk1013_resume(struct device *dev)
>
> mutex_lock(&data->mutex);
> ret = kxcjk1013_set_mode(data, OPERATION);
> + if (ret < 0) {
> + mutex_unlock(&data->mutex);
> + return ret;
> + }
> + ret = kxcjk1013_set_range(data, data->range);
> mutex_unlock(&data->mutex);
>
> return ret;
I'm not a fan of the extra unlock, IMHO it would be better to instead do:
mutex_lock(&data->mutex);
ret = kxcjk1013_set_mode(data, OPERATION);
if (ret == 0)
ret = kxcjk1013_set_range(data, data->range);
mutex_unlock(&data->mutex);
Regards,
Hans
Powered by blists - more mailing lists