From patchwork Tue Jan 12 05:23:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 59598 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2529147lbb; Mon, 11 Jan 2016 21:23:52 -0800 (PST) X-Received: by 10.66.144.37 with SMTP id sj5mr22364631pab.69.1452576231915; Mon, 11 Jan 2016 21:23:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jj2si8457675pac.179.2016.01.11.21.23.51; Mon, 11 Jan 2016 21:23:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750761AbcALFXv (ORCPT + 11 others); Tue, 12 Jan 2016 00:23:51 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35555 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750713AbcALFXu (ORCPT ); Tue, 12 Jan 2016 00:23:50 -0500 Received: by mail-pf0-f172.google.com with SMTP id 65so56693490pff.2 for ; Mon, 11 Jan 2016 21:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=MqzQ8APgBAye6eXS6yRQ5mLBcLWosZWAeO46u9YYw0Y=; b=hi2/ss47fv8vOdYRHzD4O/VBvOCaMj9L2UNSz2dUtKJw6nkFjSPQBerA4Zg8/GOy8P BDvVBtuW+mz6Px/k8feVbfqQLT++2lgT/aprK0DVZlj7mAMDdzdRNr2xsHz/qTL+lzIK +mz8QsQ/5CfZ66qR5qo9VA2ubEffvynRGvF2U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=MqzQ8APgBAye6eXS6yRQ5mLBcLWosZWAeO46u9YYw0Y=; b=ZY19TZpeHds68vBJT+CeANig0zMnWurqv7HSckYRe6lrhw850cDjjU8sv0bQDlvBV+ MJfE+yyYIYcR3YcS3cWMIf6yRgWOsoadbJK+Z965w/Rx4PJvyFyUtrGQTwKeO6ukpqEV t8VuFSHc5WZ6Ya+q9Wsnq/Xqacq217ZhBuhsl6uon7jnbzCnOpClXI2bC1bvLipKR18Q EjikcTBTMzHgdz8Ni++c5o/MVJycitasdnQf2mHWZyA+3e6QVHxJ3Zor6LyA9iCtcSr8 58mNVUjy3Nf58p/Cr85Ks4HyPx2lrqsb3NcB7OZ/wARAfwWbvj2WcugEHNt649MMevGi ifOg== X-Gm-Message-State: ALoCoQl3s84of0gBWzTMg7wHA5RkfHiHZjgTbgAXXAd4rCkVEhPR2O3npWrp9uuRNyFpampOkq9VCJRr7Ghii3lJ54afrIBs5g== X-Received: by 10.98.13.68 with SMTP id v65mr31441689pfi.54.1452576229764; Mon, 11 Jan 2016 21:23:49 -0800 (PST) Received: from localhost ([122.172.46.246]) by smtp.gmail.com with ESMTPSA id 63sm26922867pfo.67.2016.01.11.21.23.48 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 11 Jan 2016 21:23:49 -0800 (PST) Date: Tue, 12 Jan 2016 10:53:46 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, nm@ti.com Subject: Re: [PATCH 01/17] PM / OPP: get/put regulators from OPP core Message-ID: <20160112052346.GL1084@ubuntu> References: <8731ff871e0eedfb08b9428af8da21b25d1ad283.1450777582.git.viresh.kumar@linaro.org> <20160111232118.GG22188@codeaurora.org> <20160112030543.GG1084@ubuntu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160112030543.GG1084@ubuntu> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 12-01-16, 08:35, Viresh Kumar wrote: > On 11-01-16, 15:21, Stephen Boyd wrote: > > Is there a reason we capitalize regulator? > Something went wrong, I have updated the code correctly. Let me paste it again.. -------------------------8<------------------------- Subject: [PATCH] PM / OPP: get/put regulators from OPP core The allows the OPP core to request/free the regulator resource, attached to a device OPP. The regulator device is fetched using device node and name of the device. For example, a cpu0 device node needs to look like this: cpu0: cpu@900 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0x900>; cpu0-supply = <&varm>; ... }; This will work for both OPP-v1 and v2 bindings. This is a preliminary step in moving the OPP switching logic into the OPP core. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 9 +++++++++ drivers/base/power/opp/opp.h | 4 ++++ 2 files changed, 13 insertions(+) -- viresh -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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..416293b7da23 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h @@ -22,6 +22,8 @@ #include #include +struct regulator; + /* Lock to allow exclusive modification to the device and opp lists */ extern struct mutex dev_opp_list_lock; @@ -132,6 +134,7 @@ 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 +162,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;