* [PATCH] add helper for translation of runtime PM errors
@ 2014-09-11 13:28 Oliver Neukum
2014-09-11 14:04 ` Alan Stern
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Neukum @ 2014-09-11 13:28 UTC (permalink / raw)
To: linux-pm, rjw, stern; +Cc: Oliver Neukum
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;
+}
+
#else /* !CONFIG_PM_RUNTIME */
static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
@@ -178,6 +199,10 @@ static inline unsigned long pm_runtime_autosuspend_expiration(
struct device *dev) { return 0; }
static inline void pm_runtime_set_memalloc_noio(struct device *dev,
bool enable){}
+static inline int pm_runtime_translate_errors(int error)
+{
+ return error;
+}
#endif /* !CONFIG_PM_RUNTIME */
--
1.8.4.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] add helper for translation of runtime PM errors
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
0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2014-09-11 14:04 UTC (permalink / raw)
To: Oliver Neukum; +Cc: linux-pm, rjw
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?
Alan Stern
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] add helper for translation of runtime PM errors
2014-09-11 14:04 ` Alan Stern
@ 2014-09-11 14:18 ` Oliver Neukum
0 siblings, 0 replies; 3+ messages in thread
From: Oliver Neukum @ 2014-09-11 14:18 UTC (permalink / raw)
To: Alan Stern; +Cc: linux-pm, rjw
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-11 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).