From patchwork Thu Sep 11 13:28:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 4887121 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 357839F32E for ; Thu, 11 Sep 2014 13:28:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B26820220 for ; Thu, 11 Sep 2014 13:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D2F020251 for ; Thu, 11 Sep 2014 13:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbaIKN2y (ORCPT ); Thu, 11 Sep 2014 09:28:54 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35719 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbaIKN2y (ORCPT ); Thu, 11 Sep 2014 09:28:54 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 105F7AB1D; Thu, 11 Sep 2014 13:28:53 +0000 (UTC) From: Oliver Neukum To: linux-pm@vger.kernel.org, rjw@rjwysocki.net, stern@rowland.harvard.edu Cc: Oliver Neukum Subject: [PATCH] add helper for translation of runtime PM errors Date: Thu, 11 Sep 2014 15:28:49 +0200 Message-Id: <1410442129-21130-1-git-send-email-oneukum@suse.de> X-Mailer: git-send-email 1.8.4.5 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 */