[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201107282343.54519.rjw@sisk.pl>
Date: Thu, 28 Jul 2011 23:43:54 +0200
From: "Rafael J. Wysocki" <rjw@...k.pl>
To: Pavel Machek <pavel@....cz>
Cc: Sven Eckelmann <sven@...fation.org>, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, Len Brown <len.brown@...el.com>,
linux-pm@...ts.linux-foundation.org
Subject: Re: [PATCHv4 04/11] PM: Use *_dec_not_zero instead of *_add_unless
On Wednesday, July 27, 2011, Pavel Machek wrote:
> Hi!
>
> > > atomic_dec_not_zero is defined for each architecture through
> > > <linux/atomic.h> to provide the functionality of
> > > atomic_add_unless(x, -1, 0).
> > >
> > > Signed-off-by: Sven Eckelmann <sven@...fation.org>
> > > Cc: Len Brown <len.brown@...el.com>
> > > Cc: Pavel Machek <pavel@....cz>
> > > Cc: Rafael J. Wysocki <rjw@...k.pl>
> > > Cc: linux-pm@...ts.linux-foundation.org
> >
> > Acked-by: Rafael J. Wysocki <rjw@...k.pl>
> >
> > > ---
> > > drivers/base/power/runtime.c | 4 ++--
> > > include/linux/pm_runtime.h | 2 +-
> > > kernel/power/hibernate.c | 4 ++--
> > > kernel/power/user.c | 2 +-
> > > 4 files changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > > index 8dc247c..bda10d9 100644
> > > --- a/drivers/base/power/runtime.c
> > > +++ b/drivers/base/power/runtime.c
> > > @@ -401,7 +401,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
> > >
> > > if (dev->parent) {
> > > parent = dev->parent;
> > > - atomic_add_unless(&parent->power.child_count, -1, 0);
> > > + atomic_dec_not_zero(&parent->power.child_count);
>
> I'd like to understand... Why not atomic_dec in the first place? Count
> should be exact, anyway, or we run into problems, right?
Well, we'll also run into trouble if the count becomes negative. We might
throw a WARN_ON() there if the old value weren't as expected, but that
would be a separate patch.
Thanks,
Rafael
--
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