From patchwork Fri Jun 17 10:27:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9183333 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 202FC60573 for ; Fri, 17 Jun 2016 10:28:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C648283B6 for ; Fri, 17 Jun 2016 10:28:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0017427F54; Fri, 17 Jun 2016 10:28:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 681AA27F54 for ; Fri, 17 Jun 2016 10:28:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755392AbcFQK17 (ORCPT ); Fri, 17 Jun 2016 06:27:59 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:36054 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753029AbcFQK16 (ORCPT ); Fri, 17 Jun 2016 06:27:58 -0400 Received: by mail-lf0-f41.google.com with SMTP id q132so57470924lfe.3 for ; Fri, 17 Jun 2016 03:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=953jhLDpEsVdKStJ4TTlLMqbup5QnIhFgwHyWrHUoMk=; b=hL9ESK4PBMq4LWYwG8ElwzWbHc+KIRxviL93J4SJhIa60FgJIiEbcq9vsUJE3eklsR jv87c2HRIa3X6ombY0JwQexfwDZ0MDLocPY9e37K0PTUUHk49XBxt+ha+hfJ0CMenrN8 UBCcO1gdM4fyIcJGl96nC+Su2cF3JXxHQwMc4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=953jhLDpEsVdKStJ4TTlLMqbup5QnIhFgwHyWrHUoMk=; b=fgIYU6jisIp/G+AZiVLZpi18F+//F/uA+6BZdX9lpbADdmsf63FJh1KMgI37xsDaOW IlEqi7jidyuzFj2zQXeQvUnxcnoyik/QwK7VamG3ajUgO1Ge/4DbH9tQaEp02pTxNgO9 V0PJQDxTO8c10J1Ixtra+PkNiJ02GqQ8WPojU29mjIJwE8Zqut5kz+mWkRW6TK+idZEN zW9jO2SQjo4ezvxFr6Ryvas7jKaMFJ534p+y41193cwArbABlcQB9+uzo5UN66rWVLm9 TVRmgb8mszKz6cfw26CPU3krkAUQj6wgV7mh0OZVBMOPb7qXK9s88R6aj9PfMrws6nTz UO0A== X-Gm-Message-State: ALyK8tJ24+AMLmGgTH6eYlvP3JZVIxPx1erpAyNzEcDEUEyidveOoW+eElAlorHxNq72NRMn X-Received: by 10.25.219.91 with SMTP id s88mr391505lfg.101.1466159276666; Fri, 17 Jun 2016 03:27:56 -0700 (PDT) Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id ld4sm1427004lbc.15.2016.06.17.03.27.54 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Jun 2016 03:27:55 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Geert Uytterhoeven , Lina Iyer , Axel Haslam , Marek Szyprowski , Jon Hunter , Andy Gross , Laurent Pinchart Subject: [PATCH] PM / Domains: Convert pm_genpd_init() to return an error code Date: Fri, 17 Jun 2016 12:27:52 +0200 Message-Id: <1466159272-9726-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The are already cases when pm_genpd_init() can fail. Currently we hide the failures instead of propagating an error code, which is a better method. Moreover, to prepare for future changes like moving away from using a fixed array-size of the struct genpd_power_state, to instead dynamically allocate data for it, the pm_genpd_init() API needs to be able to return an error code, as allocation can fail. Current users of the pm_genpd_init() is thus requested to start dealing with error codes. In the transition phase, users will have to live with only error messages being printed to log. Signed-off-by: Ulf Hansson Acked-by: Kevin Hilman --- drivers/base/power/domain.c | 10 +++++++--- include/linux/pm_domain.h | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 9193aac..a1f2aff 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1258,12 +1258,14 @@ EXPORT_SYMBOL_GPL(pm_genpd_remove_subdomain); * @genpd: PM domain object to initialize. * @gov: PM domain governor to associate with the domain (may be NULL). * @is_off: Initial value of the domain's power_is_off field. + * + * Returns 0 on successful initialization, else a negative error code. */ -void pm_genpd_init(struct generic_pm_domain *genpd, - struct dev_power_governor *gov, bool is_off) +int pm_genpd_init(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, bool is_off) { if (IS_ERR_OR_NULL(genpd)) - return; + return -EINVAL; INIT_LIST_HEAD(&genpd->master_links); INIT_LIST_HEAD(&genpd->slave_links); @@ -1321,6 +1323,8 @@ void pm_genpd_init(struct generic_pm_domain *genpd, mutex_lock(&gpd_list_lock); list_add(&genpd->gpd_list_node, &gpd_list); mutex_unlock(&gpd_list_lock); + + return 0; } EXPORT_SYMBOL_GPL(pm_genpd_init); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index dd5b044..31fec85 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -127,8 +127,8 @@ extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *new_subdomain); extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *target); -extern void pm_genpd_init(struct generic_pm_domain *genpd, - struct dev_power_governor *gov, bool is_off); +extern int pm_genpd_init(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, bool is_off); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -163,9 +163,10 @@ static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, { return -ENOSYS; } -static inline void pm_genpd_init(struct generic_pm_domain *genpd, - struct dev_power_governor *gov, bool is_off) +static inline int pm_genpd_init(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, bool is_off) { + return -ENOSYS; } #endif