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: 70310 Delivered-To: patches@linaro.org Received: by 10.140.28.4 with SMTP id 4csp205040qgy; Fri, 17 Jun 2016 03:27:57 -0700 (PDT) X-Received: by 10.25.83.199 with SMTP id h190mr457657lfb.83.1466159277379; Fri, 17 Jun 2016 03:27:57 -0700 (PDT) Return-Path: Received: from mail-lf0-x236.google.com (mail-lf0-x236.google.com. [2a00:1450:4010:c07::236]) by mx.google.com with ESMTPS id n10si3506130lbs.101.2016.06.17.03.27.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 03:27:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) client-ip=2a00:1450:4010:c07::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x236.google.com with SMTP id f6so57539680lfg.0 for ; Fri, 17 Jun 2016 03:27:56 -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=DcfYK15pH8w+mW5S+XgwX8uE0M87WAQh68fnziD/UdNCHZwRnvMz/naLsAjxyznDcw aF9obw2Bxl79zCW81+XKNB6BxmlhXRWu9uC9d8v5Bu96YgfjTsL9djxSLIvd6P7QUhOL zk6L+oFvK5nldHVRl/PgZC1VgZ8iYYcS7RTS4TRwSxPIC6RSafCcRQqdTplCOMYJVeX3 UqIgqy90bVyxyT1+pQlbpAjTA2d0dUzO50qgrlY+vvehmLpW/q0KhDtVAEXvrpj7fKbQ Iimbr02NvJ0xSzitcE/coD8UKzlj00uhylyLsEzDwKVM+SZaXllMJQORxiAMgGNnCtNh ickg== X-Gm-Message-State: ALyK8tLHCDqGiVaTBztO0nyTx0l8r6DZvtbtXX3p11dDuTjdLU6/i7p2idv9/qZc+VbyFC111dw= X-Received: by 10.25.219.91 with SMTP id s88mr391505lfg.101.1466159276666; Fri, 17 Jun 2016 03:27:56 -0700 (PDT) Return-Path: 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 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 --- drivers/base/power/domain.c | 10 +++++++--- include/linux/pm_domain.h | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) -- 1.9.1 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