From: Oliver Neukum <oneukum@suse.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-pm@vger.kernel.org, rjw@rjwysocki.net
Subject: Re: [PATCH] add helper for translation of runtime PM errors
Date: Thu, 11 Sep 2014 16:18:15 +0200 [thread overview]
Message-ID: <1410445095.21752.4.camel@linux-fkkt.site> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1409111003160.1357-100000@iolanthe.rowland.org>
On Thu, 2014-09-11 at 10:04 -0400, Alan Stern wrote:
> On Thu, 11 Sep 2014, Oliver Neukum wrote:
>
> > pm_runtime_get() returns specialised error codes. They are not
> > fit to be returned to user space. This patch adds a helper
> > for translation.
> >
> > Signed-off-by: Oliver Neukum <oneukum@suse.de>
> > ---
> > include/linux/pm_runtime.h | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
> > index 367f49b..67d078f 100644
> > --- a/include/linux/pm_runtime.h
> > +++ b/include/linux/pm_runtime.h
> > @@ -128,6 +128,27 @@ static inline void pm_runtime_mark_last_busy(struct device *dev)
> > ACCESS_ONCE(dev->power.last_busy) = jiffies;
> > }
> >
> > +static inline int pm_runtime_translate_errors(int error)
> > +{
> > + int rv;
> > +
> > + switch (error) {
> > + case 0:
> > + case -ENOMEM:
> > + case -EBUSY:
> > + rv = error;
> > + break;
> > + case -EINPROGRESS:
> > + rv = -EAGAIN;
> > + break;
> > + default:
> > + rv = error > 0 ? error : -EIO;
> > + break;
> > + }
> > +
> > + return rv;
> > +}
>
> Is this function small enough to be worth inlining?
I did this because many drivers do
if (ret < 0)
return ret;
So the compiler can optimize a part away. But yes, I'll test.
Regards
Oliver
prev parent reply other threads:[~2014-09-11 14:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 13:28 [PATCH] add helper for translation of runtime PM errors Oliver Neukum
2014-09-11 14:04 ` Alan Stern
2014-09-11 14:18 ` Oliver Neukum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410445095.21752.4.camel@linux-fkkt.site \
--to=oneukum@suse.de \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).