[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201202042344.20253.rjw@sisk.pl>
Date: Sat, 4 Feb 2012 23:44:20 +0100
From: "Rafael J. Wysocki" <rjw@...k.pl>
To: "Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
Cc: Tejun Heo <tj@...nel.org>, pavel@....cz, len.brown@...el.com,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] PM/Hibernate: Refactor and simplify freezer_test_done
On Saturday, February 04, 2012, Srivatsa S. Bhat wrote:
> On 02/02/2012 10:47 PM, Tejun Heo wrote:
>
> > On Thu, Feb 02, 2012 at 07:10:19AM +0530, Srivatsa S. Bhat wrote:
> >> @@ -251,10 +251,10 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
> >> error = hibernation_snapshot(data->platform_support);
> >> if (!error) {
> >> error = put_user(in_suspend, (int __user *)arg);
> >> - if (!error && !freezer_test_done)
> >> - data->ready = 1;
> >> if (freezer_test_done)
> >> freezer_test_done = false;
> >> + else if (!error)
> >> + data->ready = 1;
> >
> > Hmmm... how about..
> >
> > data->ready = !freezer_test_done && !error;
> > freezer_test_done = false;
> >
>
>
> That looks even better, thanks!
>
> Here is the updated patch:
>
> From: Srivatsa S. Bhat <srivatsa.bhat@...ux.vnet.ibm.com>
> Subject: [PATCH] PM/Hibernate: Refactor and simplify freezer_test_done
>
> The code related to 'freezer_test_done' is needlessly convoluted.
> Refactor the code and simplify the implementation.
>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@...ux.vnet.ibm.com>
Applied.
Thanks,
Rafael
> ---
>
> kernel/power/hibernate.c | 10 +++++-----
> kernel/power/user.c | 6 ++----
> 2 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index c6dee73..72baaf0 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -629,12 +629,8 @@ int hibernate(void)
> goto Finish;
>
> error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
> - if (error)
> - goto Thaw;
> - if (freezer_test_done) {
> - freezer_test_done = false;
> + if (error || freezer_test_done)
> goto Thaw;
> - }
>
> if (in_suspend) {
> unsigned int flags = 0;
> @@ -659,6 +655,10 @@ int hibernate(void)
>
> Thaw:
> thaw_processes();
> +
> + /* Don't bother checking whether freezer_test_done is true */
> + freezer_test_done = false;
> +
> Finish:
> free_basic_memory_bitmaps();
> usermodehelper_enable();
> diff --git a/kernel/power/user.c b/kernel/power/user.c
> index 7bee91f..33c4329 100644
> --- a/kernel/power/user.c
> +++ b/kernel/power/user.c
> @@ -251,10 +251,8 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
> error = hibernation_snapshot(data->platform_support);
> if (!error) {
> error = put_user(in_suspend, (int __user *)arg);
> - if (!error && !freezer_test_done)
> - data->ready = 1;
> - if (freezer_test_done)
> - freezer_test_done = false;
> + data->ready = !freezer_test_done && !error;
> + freezer_test_done = false;
> }
> break;
>
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists