From patchwork Mon Mar 17 09:34:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 14019091 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B6C221710; Mon, 17 Mar 2025 09:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742204107; cv=none; b=mV2eIQf5xQYuzDW/TTbaqRt5z+PHe65/Lc8G2rWaai8T2YcOHYq4IeAdhS2IWKyeVx9llXkJ9hVM0A4zmXJRsmmtpbJbh9UxdOVLk89lefdPpj7jKdW2A0mJ7nWtruTo9ByDwb+ej5SE7xJSCY/bqsKPt6+KOcrXEuHCVgolOK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742204107; c=relaxed/simple; bh=Fgw2UAIuHZo5WS8dnnGY+5tf1QFW4nKCdX8wBW4sRsg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jwgDMtg8IMp/wJGNTHeZoeFIlHUpRW5jVgZfOiQBLC4L/Rjf4nsBop8KzUAhgN9Un+q+Zp9f/oVVeBjNKAzNmsPgJxJhkLC0CBe7i1Z9TlEcjPRwc+2OsKtrYfUXDvUr9hRtEFKLN6XcnZ9axoGm4vn/hB0wctSol0C98MK8ZGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=sUUWU1vg; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="sUUWU1vg" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id E14BEA02E3; Mon, 17 Mar 2025 10:34:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=+FYeznGF05qGpks00rXy InbtPfAnR/GvyHPNTPLvUWs=; b=sUUWU1vgSO1NmcKKjrDIwKrJy6vUMjnuToZG 5g89H7LbJdzisR4B+lx5Pip93dpgRY6em1zgi6kCMNLw5tN81I16g8BsG/r8xokL uDGtb7lhNBE81WdGY3qDo+cYjQU1HWVjOu965jMLJxuwUtQ+48Zo1TgnFhDuozYP oXDISf+99ycS6XFpGJ/GYKRO3Wv+PMGD7cfb5uErnX3TaVSBVE9c64fWVNMsnpnn u1ZUaDvWxS1urUhuZP9GicFezuZ2mtfgV0EO1dM61r7XMYemj5c2RVwFYLRAZI8G QwRGn/Xxyf5wbHuveCtBu9zarkceD3c1M/g8YojrXFKBdA6k2oo/isKhEQsT2NjV /p+mekwEnuDYXxUo2YYVtJa/rc7jefrPLH0DLMtwRqQudnR0+fXM9KGlTcIw+UJa Dq/B0NJqg96dnpVZGourFCQJzfU1UsPid/jHO0V/Exir1OfL8eefZzMMZd/X6HCB 8uXns+Tvc67RoCuCRT/MrUR9aWm0JrTglDiDDU1t8qxmglA3ZAxkJCsl0d+DB2qZ pJzNXxsAT3rqmfBLA8ocIl+8JBiuzjNJbYLuQjEgpvDdSlYhm7SxqkTSroL6FRvy 9UhJ6kiZeCF79WyMa4DBpCDUe69+PJtKmzSsyj8DFTObkfm4Yv4MnUDu4XblQ/uL QwECytQ= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: , , =?utf-8?b?Q3PDs2vDoXMsIEJlbmNl?= , "Varshini Rajendran" , Tudor Ambarus , Mark Brown , , CC: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Danilo Krummrich , Alexander Dahl , "Nicolas Ferre" , Alexandre Belloni , Claudiu Beznea , Pavel Machek Subject: [PATCH v5 1/2] pm: runtime: Add new devm functions Date: Mon, 17 Mar 2025 10:34:42 +0100 Message-ID: <20250317093445.361821-2-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317093445.361821-1-csokas.bence@prolan.hu> References: <20250317093445.361821-1-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1742204095;VERSION=7986;MC=658418503;ID=162300;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A2980D948526D7462 Add `devm_pm_runtime_set_active()` and `devm_pm_runtime_get_noresume()` for simplifying common use cases in drivers. Signed-off-by: Bence Csókás --- drivers/base/power/runtime.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pm_runtime.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 9589ccb0fda2..821a8b4961d4 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1568,6 +1568,24 @@ void pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(pm_runtime_enable); +static void pm_runtime_set_suspended_action(void *data) +{ + pm_runtime_set_suspended(data); +} + +/** + * devm_pm_runtime_set_active - devres-enabled version of pm_runtime_set_active. + * + * @dev: Device to handle. + */ +int devm_pm_runtime_set_active(struct device *dev) +{ + pm_runtime_set_active(dev); + + return devm_add_action_or_reset(dev, pm_runtime_set_suspended_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_runtime_set_active); + static void pm_runtime_disable_action(void *data) { pm_runtime_dont_use_autosuspend(data); @@ -1590,6 +1608,24 @@ int devm_pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(devm_pm_runtime_enable); +static void pm_runtime_put_noidle_action(void *data) +{ + pm_runtime_put_noidle(data); +} + +/** + * devm_pm_runtime_get_noresume - devres-enabled version of pm_runtime_get_noresume. + * + * @dev: Device to handle. + */ +int devm_pm_runtime_get_noresume(struct device *dev) +{ + pm_runtime_get_noresume(dev); + + return devm_add_action_or_reset(dev, pm_runtime_put_noidle_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_runtime_get_noresume); + /** * 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 7fb5a459847e..364355da349a 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -96,7 +96,9 @@ extern void pm_runtime_new_link(struct device *dev); extern void pm_runtime_drop_link(struct device_link *link); extern void pm_runtime_release_supplier(struct device_link *link); +int devm_pm_runtime_set_active(struct device *dev); extern int devm_pm_runtime_enable(struct device *dev); +int devm_pm_runtime_get_noresume(struct device *dev); /** * pm_suspend_ignore_children - Set runtime PM behavior regarding children. @@ -294,7 +296,9 @@ static inline bool pm_runtime_blocked(struct device *dev) { return true; } static inline void pm_runtime_allow(struct device *dev) {} static inline void pm_runtime_forbid(struct device *dev) {} +static inline int devm_pm_runtime_set_active(struct device *dev) { return 0; } static inline int devm_pm_runtime_enable(struct device *dev) { return 0; } +static inline int devm_pm_runtime_get_noresume(struct device *dev) { return 0; } static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {} static inline void pm_runtime_get_noresume(struct device *dev) {}