From patchwork Tue Jun 10 10:51:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 31623 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 845DF20675 for ; Tue, 10 Jun 2014 10:52:08 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id uo5sf13075837pbc.4 for ; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=sQpUpBI1QicVLrdZdZSsUwymYpKJvzSx8BEO6LiBoj4=; b=Nm4CE5Q8DxDnHt+s0rDv6XBW7cRb+OV6Y9rdQfYVPkmw+f2X0kDzuoSF9ZHvHHfcmY YQxALheB6+iArVJq4QlDxhR/54or8U8zrLjWzAzuqDXeG9idKhNmNf88uZjZXDDN+8ix mx7g9zZCfiM63D4krKBeQTibWaiQ7Eq7JMnlbLbHFjwuNHwKZVZDebKZwMRzfc3ZBPg8 CRGctxSgB4ho1LCFBc2GBnSr/zNETSeF1g2MBJunRbYas3I8QIqMRPQ5oBOWPz6j2hWA pdXBngbLxjLSuuSPeCPn/z+4jZ7QQIpqv2QLBv176/GwjqCgaN7t1eAfw5CEd0fgjhPj h6XQ== X-Gm-Message-State: ALoCoQlclBA+O4O656Qe99pvnlvrzHSeoqpYuovojzR7vd8Ay+3xG9j3oMrlhLFTo85HdTsRhpC7 X-Received: by 10.68.253.66 with SMTP id zy2mr1211665pbc.1.1402397527797; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.247 with SMTP id b110ls2072127qge.16.gmail; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) X-Received: by 10.58.69.76 with SMTP id c12mr15616302veu.35.1402397527643; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id ee6si12935799vec.94.2014.06.10.03.52.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 03:52:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jz11so3782107veb.17 for ; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) X-Received: by 10.220.53.72 with SMTP id l8mr31657896vcg.16.1402397527568; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp215489vcb; Tue, 10 Jun 2014 03:52:07 -0700 (PDT) X-Received: by 10.152.28.228 with SMTP id e4mr22225937lah.3.1402397526524; Tue, 10 Jun 2014 03:52:06 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) by mx.google.com with ESMTPS id mw4si41876770lbc.17.2014.06.10.03.52.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 03:52:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id hz20so3679734lab.19 for ; Tue, 10 Jun 2014 03:52:05 -0700 (PDT) X-Received: by 10.152.36.38 with SMTP id n6mr22312284laj.0.1402397525899; Tue, 10 Jun 2014 03:52:05 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id y6sm18329925laj.17.2014.06.10.03.52.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 03:52:05 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Kevin Hilman , Alan Stern , Greg Kroah-Hartman , Daniel Lezcano , Tomasz Figa , devicetree@vger.kernel.org, Linus Walleij , Simon Horman , Magnus Damm , Ben Dooks , Kukjin Kim , Stephen Boyd , Philipp Zabel , Mark Brown , Tomasz Figa Subject: [PATCH 02/24] drivercore: Bind/unbind power domain on probe/remove Date: Tue, 10 Jun 2014 12:51:15 +0200 Message-Id: <1402397497-26737-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402397497-26737-1-git-send-email-ulf.hansson@linaro.org> References: <1402397497-26737-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tomasz Figa On a number of platforms, devices are part of controllable power domains, which need to be enabled before such devices can be accessed and may be powered down when the device is idle to save some power. This means that on systems that support power domain control using generic power domains subsystem, it is necessary to add device to its power domain before binding a driver to it and remove it from its power domain after its driver is unbound to make sure that an unused device does not affect power domain state. Since this is not limited to particular busses and specific archs/platforms, it is more convenient to do the above directly in driver core, just as done with pinctrl default configuration. This patch adds necessary code to really_probe() and __device_release_driver() to achieve this and maintain consistent stack-like ordering of operations happening when binding and unbinding a driver. Signed-off-by: Tomasz Figa Reviewed-by: Stephen Boyd Reviewed-by: Philipp Zabel [on i.MX6 GK802] Tested-by: Philipp Zabel Reviewed-by: Mark Brown Reviewed-by: Ulf Hansson --- drivers/base/dd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index e4ffbcf..80ad789 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -287,6 +288,11 @@ static int really_probe(struct device *dev, struct device_driver *drv) dev->driver = drv; + /* If using genpd, bind power domain now before probing */ + ret = genpd_bind_domain(dev); + if (ret) + goto probe_failed; + /* If using pinctrl, bind pins now before probing */ ret = pinctrl_bind_pins(dev); if (ret) @@ -317,6 +323,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) probe_failed: devres_release_all(dev); driver_sysfs_remove(dev); + genpd_unbind_domain(dev); dev->driver = NULL; dev_set_drvdata(dev, NULL); @@ -530,7 +537,7 @@ static void __device_release_driver(struct device *dev) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_UNBOUND_DRIVER, dev); - + genpd_unbind_domain(dev); } }