From patchwork Tue May 19 14:11:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6438151 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C12FDC0432 for ; Tue, 19 May 2015 14:12:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C944B20453 for ; Tue, 19 May 2015 14:12:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3C6C20454 for ; Tue, 19 May 2015 14:12:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932699AbbESOMI (ORCPT ); Tue, 19 May 2015 10:12:08 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:33944 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932846AbbESOMG (ORCPT ); Tue, 19 May 2015 10:12:06 -0400 Received: by wghq2 with SMTP id q2so19585892wgh.1; Tue, 19 May 2015 07:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=oe3nukMMb36mrw2gj9PoErOCZPUTazRXbuRlmxZvfos=; b=b5lmY7u7jn/hyw87CiX836TcbrthZ787s0pLIlvXqWL4zcd390ptfoNGW6vF6jr3ez GlpmFU1BO8T9clUIv78tM68UfGZGnLhFCdLA2R+bZeJEPYLOs6k112hpbj2WqROSfrcV xaB9FYVRZ38FFDa30rwpC+W3TPmV6EZx4wSRcFBMJQI0R6hqf8IHRz+xafUOngfANqob LpQfBobXwjv4IvtKHZOvi99glnxmeabg7Tcqc98Y6U4s/oLUeAGiM0aa/Oo4QGX3jRor cuyRNTG7Ybg4nfbB1ZWlR/OBDRpLcccub6kV3kmrhuTT9alOerGHvoQIRLI7J9vdIj3G q5pg== X-Received: by 10.194.85.116 with SMTP id g20mr55407731wjz.154.1432044724886; Tue, 19 May 2015 07:12:04 -0700 (PDT) Received: from cizrna.lan ([109.72.12.94]) by mx.google.com with ESMTPSA id gs7sm17564806wib.10.2015.05.19.07.12.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 07:12:04 -0700 (PDT) From: Tomeu Vizoso To: linux-pm@vger.kernel.org Cc: Laurent Pinchart , Dmitry Torokhov , Alan Stern , Tomeu Vizoso , "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Ulf Hansson , Kevin Hilman , Russell King , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] PM / Runtime: Add pm_runtime_enable_recursive Date: Tue, 19 May 2015 16:11:16 +0200 Message-Id: <1432044679-10256-3-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1432044679-10256-1-git-send-email-tomeu.vizoso@collabora.com> References: <1432044679-10256-1-git-send-email-tomeu.vizoso@collabora.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 This function makes less cumbersome to enable runtime PM in a device and its descendants. Signed-off-by: Tomeu Vizoso --- drivers/base/power/runtime.c | 15 +++++++++++++++ include/linux/pm_runtime.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 5070c4f..2c96f3f 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1189,6 +1189,21 @@ void pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(pm_runtime_enable); +static int __pm_runtime_enable_recursive(struct device *dev, void *data) +{ + pm_runtime_enable(dev); + + device_for_each_child(dev, NULL, __pm_runtime_enable_recursive); + + return 0; +} + +void pm_runtime_enable_recursive(struct device *dev) +{ + __pm_runtime_enable_recursive(dev, NULL); +} +EXPORT_SYMBOL_GPL(pm_runtime_enable_recursive); + /** * pm_runtime_forbid - Block runtime PM of a device. * @dev: Device to handle. diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index 30e84d4..d393ac3 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -43,6 +43,7 @@ extern int pm_schedule_suspend(struct device *dev, unsigned int delay); extern int __pm_runtime_set_status(struct device *dev, unsigned int status); extern int pm_runtime_barrier(struct device *dev); extern void pm_runtime_enable(struct device *dev); +extern void pm_runtime_enable_recursive(struct device *dev); extern void __pm_runtime_disable(struct device *dev, bool check_resume); extern void pm_runtime_allow(struct device *dev); extern void pm_runtime_forbid(struct device *dev);