From patchwork Mon Mar 3 16:02:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3755381 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C683BF13A for ; Mon, 3 Mar 2014 16:05:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 876FE203DA for ; Mon, 3 Mar 2014 16:05:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A545B20397 for ; Mon, 3 Mar 2014 16:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755124AbaCCQFU (ORCPT ); Mon, 3 Mar 2014 11:05:20 -0500 Received: from mail-ea0-f182.google.com ([209.85.215.182]:48567 "EHLO mail-ea0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754766AbaCCQCg (ORCPT ); Mon, 3 Mar 2014 11:02:36 -0500 Received: by mail-ea0-f182.google.com with SMTP id b10so3618626eae.41 for ; Mon, 03 Mar 2014 08:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hNt/I77rTj7Z3eH8Ufc8d7kubw54ILxShydPcVWmDdQ=; b=gqbzbS6qdtJZ41z2NGsYGCUcbXNTXMfJcD66rxPX68xdjqslT+1yNZ1QGGbrzVbQHG thXdhLfKcrymxeDgu9TW3TziW13IqE6G0lfnNllVWMX2Nfli1vOMMNXuMfCcgnz1KEqr M31w6aebwJGMUtTqoU9L7Kyj+evfnWnSNXl2DNcdikkKsW2ahzwjeV3z9QSeA3/yjNd/ UYzuOMNEiFqKwYFi0kJjkfjTBzxUPTxx2h7EzqOeF+iHE8961chx/lrrt0sX5EwvXuhC C4HjROPJSYHXVtIzN9GV6LJh9ZnlCluiGxL9QPvE5uaaNzpzphYTxVEjccusSFjpcrHj VAtA== X-Received: by 10.14.179.129 with SMTP id h1mr41093117eem.26.1393862555204; Mon, 03 Mar 2014 08:02:35 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id y51sm51430597eeu.0.2014.03.03.08.02.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Mar 2014 08:02:34 -0800 (PST) From: Tomasz Figa To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Russell King , Kukjin Kim , Kumar Gala , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring , Bartlomiej Zolnierkiewicz , Stephen Warren , Tomasz Figa , Mark Brown , Stephen Boyd , Lorenzo Pieralisi , Ulf Hansson , Marek Szyprowski , Tomasz Figa Subject: [PATCH v2 02/11] drivercore: Bind/unbind power domain on probe/remove Date: Mon, 3 Mar 2014 17:02:07 +0100 Message-Id: <1393862536-9842-3-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393862536-9842-1-git-send-email-tomasz.figa@gmail.com> References: <1393862536-9842-1-git-send-email-tomasz.figa@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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 0605176..78e5b36 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -273,6 +274,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) @@ -303,6 +309,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); @@ -513,7 +520,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); } }