From mboxrd@z Thu Jan 1 00:00:00 1970 From: Viresh Kumar Subject: Re: [PATCH 01/17] PM / OPP: get/put regulators from OPP core Date: Tue, 12 Jan 2016 08:35:43 +0530 Message-ID: <20160112030543.GG1084@ubuntu> References: <8731ff871e0eedfb08b9428af8da21b25d1ad283.1450777582.git.viresh.kumar@linaro.org> <20160111232118.GG22188@codeaurora.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail-pf0-f172.google.com ([209.85.192.172]:36613 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760144AbcALDFs (ORCPT ); Mon, 11 Jan 2016 22:05:48 -0500 Received: by mail-pf0-f172.google.com with SMTP id n128so54835147pfn.3 for ; Mon, 11 Jan 2016 19:05:47 -0800 (PST) Content-Disposition: inline In-Reply-To: <20160111232118.GG22188@codeaurora.org> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Stephen Boyd Cc: Rafael Wysocki , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, nm@ti.com On 11-01-16, 15:21, Stephen Boyd wrote: > Is there a reason we capitalize regulator? -------------------------8<------------------------- diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index cf351d3dab1c..9e437416e155 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "opp.h" @@ -505,6 +506,7 @@ static struct device_opp *_add_device_opp(struct device *dev) { struct device_opp *dev_opp; struct device_list_opp *list_dev; + const char *name = dev_name(dev); /* Check for existing list for 'dev' first */ dev_opp = _find_device_opp(dev); @@ -527,6 +529,11 @@ static struct device_opp *_add_device_opp(struct device *dev) return NULL; } + dev_opp->regulator = regulator_get_optional(dev, name); + if (IS_ERR(dev_opp->regulator)) + dev_info(dev, "%s: no regulator (%s) found: %ld\n", __func__, + name, PTR_ERR(dev_opp->regulator)); + srcu_init_notifier_head(&dev_opp->srcu_head); INIT_LIST_HEAD(&dev_opp->opp_list); @@ -565,6 +572,8 @@ static void _remove_device_opp(struct device_opp *dev_opp) if (dev_opp->prop_name) return; + regulator_put(dev_opp->regulator); + list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp, node); diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index 690638ef36ee..b9555f28f216 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h @@ -132,6 +132,8 @@ struct device_list_opp { * @supported_hw: Array of version number to support. * @supported_hw_count: Number of elements in supported_hw array. * @prop_name: A name to postfix to many DT properties, while parsing them. + * @regulator: Supply Regulator + * * @dentry: debugfs dentry pointer of the real device directory (not links). * @dentry_name: Name of the real dentry. * @@ -159,6 +161,7 @@ struct device_opp { unsigned int *supported_hw; unsigned int supported_hw_count; const char *prop_name; + struct regulator *regulator; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; -- viresh