From patchwork Tue Jul 27 21:02:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 486765 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp579315jas; Tue, 27 Jul 2021 14:03:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxpzx6W/fNQhMWmtmDAr+iUjLBT/6AF/CExuKIEz8onsnXd//1Y0piC7o6byLWTiOE+aIW X-Received: by 2002:a17:907:3e22:: with SMTP id hp34mr23911458ejc.334.1627419839228; Tue, 27 Jul 2021 14:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627419839; cv=none; d=google.com; s=arc-20160816; b=Vsm8xlMzavDToBXNA+l/6VGxTR+4o4xjBYHnWPoocM97UTa1Ue67f11Wuug49xRLAq r7WK1e3JSMxaPXiFW/kvvY9MaRj5ZCTFHxzaEIk6mlgMFR+I68KNmPeRgQlZQfkwNc15 v7F+EZlbxvaF6Tyg8weNvgijnOakku+hdWn4aiscgCUGNtspzI3idwCktkVHYs3zUO9h +dgP8QM5Y6rNvTOwZZmEvuBvpNpn9IvXJ6zDPiAISjSRMLUX80s9qX/hUhONuio1lKwK c4/H37jaMbfatIgKJRPzbiE4VcNr4ILJTiVwEHHEd3Q8VdGQk2EHVz8VeLFfaYUB61Ei 1NoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GJaDlSnC/hNhPjnByAZZc7+i+wuzXCs6r81DcH7ZrtQ=; b=EFKTxAPFwk6zuH2DbWvlQjRdQCFBRjJoSeYec4F/i4+hG09UaKSYwrgNH/fn+Dtdw+ 2dpnzlpBjtJOXMbixLsctDCAEEQfdsLJYgcJaFzM84W0lLQkXMNwwT5+fKhiF/3GkN0n q/1NRMMMjGckLYgpU+SUGxmk1bTbi8fHnuY/FrDdVueotqIZB2P2KEa7Fx26aXyPg27M Quqy0IRsL02i2uUvQzsS5ebpBrIgNWQUUgg6aV4/iorEZI4Pj85P1oVZwpBWW8f5/mRP USuObs4qMfJ7B8mw3osin/XpCh+CwK8+or11VzJI3rZDKZfUI6J5zJ7abgGo7vAqoYXU DwNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CthAyw2A; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si3676065ejb.391.2021.07.27.14.03.58; Tue, 27 Jul 2021 14:03:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CthAyw2A; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231555AbhG0VDy (ORCPT + 8 others); Tue, 27 Jul 2021 17:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232614AbhG0VDv (ORCPT ); Tue, 27 Jul 2021 17:03:51 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1294C06139E for ; Tue, 27 Jul 2021 14:02:56 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id f18so24078033lfu.10 for ; Tue, 27 Jul 2021 14:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GJaDlSnC/hNhPjnByAZZc7+i+wuzXCs6r81DcH7ZrtQ=; b=CthAyw2AHCfNIL3b/mZSgU3pTXABYO278cJe2QC9FzEgW8OsHLctazCNx/5FFpXu38 +UCIekq1ZvH30aZ5eX6UqwT1ayGryPp/UTmKU6H7aIQgLt7nwDM548jffyxUWU92JKIe zhSlYAaFX+PHO0gWB/C8P368mKDY8Y7/1eX+laeFgCQFsge4wChEck4vwSbXkRabrdZy tOljxyXcUiRqd8o8ylZ7mqtdWAbqqpAQClcq6qF3M7+7LFQFAFC/fvY26DNvjFq/Fby7 48GaIYTbzHZqA+HEWxl0jD03YtCf9+g5JfR6vXTSSfQiDnUxGqO08zSfuUhKvJO38Lk+ 2zLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GJaDlSnC/hNhPjnByAZZc7+i+wuzXCs6r81DcH7ZrtQ=; b=IxNmgiLyKsks/mCLykmiGt/yhiDb0r86I53g3qYfSPn8fk8VAENsRijFA9Orzt2Bdi k6fIT4/yngmkMS6uNeXWXG7iWcdHusdJ/Z9aCP3ICbdfWRfVIPLou8Vidyl0Iolcljxz Uxe4Otr99fPJBzzjjkyu4qGGw8SIH6WAsknPycjp0FSZ1GNB+t/vA4mdM2kV3nrEH87I FDHfYgSmoujQHbxTjYuOTDmHSm8D3nfe2MwhqTMlgtgVTC/Oy/3lZ5500I2pUglvUOi0 ya4uugBadSsNy1Ina1kwoXk90A89eanje0l6NOlyTX23IOjCLbFQ4VuZKTsTrfHbqd8k 9yHA== X-Gm-Message-State: AOAM533UpgykMI9snDz01LIw09Tg+ZXyQoSa/3gFmm6EAqMMyxChCMxW PmmGJ0IIUURlOWa7Te5yuzZu3A== X-Received: by 2002:a05:6512:1109:: with SMTP id l9mr18251275lfg.384.1627419775114; Tue, 27 Jul 2021 14:02:55 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m5sm355680ljq.22.2021.07.27.14.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 14:02:54 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org Subject: [PATCH 1/2] PM: runtime: add devm_pm_runtime_enable helper Date: Wed, 28 Jul 2021 00:02:01 +0300 Message-Id: <20210727210202.717181-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727210202.717181-1-dmitry.baryshkov@linaro.org> References: <20210727210202.717181-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add helper function handling typical driver action: call pm_runtime_enable at the probe() time and disable it during remove(). Signed-off-by: Dmitry Baryshkov --- drivers/base/power/runtime.c | 17 +++++++++++++++++ include/linux/pm_runtime.h | 4 ++++ 2 files changed, 21 insertions(+) -- 2.30.2 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 8a66eaf731e4..ec94049442b9 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1447,6 +1447,23 @@ void pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(pm_runtime_enable); +static void pm_runtime_disable_action(void *data) +{ + pm_runtime_disable(data); +} + +/** + * devm_pm_runtime_enable - devres-enabled version of pm_runtime_enable. + * @dev: Device to handle. + */ +int devm_pm_runtime_enable(struct device *dev) +{ + pm_runtime_enable(dev); + + return devm_add_action_or_reset(dev, pm_runtime_disable_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_runtime_enable); + /** * 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 aab8b35e9f8a..222da43b7096 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -59,6 +59,8 @@ extern void pm_runtime_put_suppliers(struct device *dev); extern void pm_runtime_new_link(struct device *dev); extern void pm_runtime_drop_link(struct device_link *link); +extern int devm_pm_runtime_enable(struct device *dev); + /** * pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter. * @dev: Target device. @@ -253,6 +255,8 @@ static inline void __pm_runtime_disable(struct device *dev, bool c) {} static inline void pm_runtime_allow(struct device *dev) {} static inline void pm_runtime_forbid(struct device *dev) {} +static inline int devm_pm_runtime_enable(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) {} static inline void pm_runtime_put_noidle(struct device *dev) {} From patchwork Tue Jul 27 21:02:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 486766 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp579355jas; Tue, 27 Jul 2021 14:04:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOts//VQvBRrHAwJhmUnvayyWeESZl7cEKDcpny6rFj+w1tUQ6wl7zSppiNMGLsCe/QRSL X-Received: by 2002:aa7:db11:: with SMTP id t17mr29489973eds.297.1627419842633; Tue, 27 Jul 2021 14:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627419842; cv=none; d=google.com; s=arc-20160816; b=cJ9xNDG9yiJT5aU48+T/+2qfhwW8SvHTtySlGHhzL9EiborLoIdYbmwhLi7T87jils J4dZTY9OxFA4cTGES3dpERAWMyoJobsu8JIO50YA0wXUuZBHzz4TGN+xmv63ZXgl3W3I JDc6RlNcr7BC9muBbRKsNwmUC03h7XzLH29F0FHN1NTJKUdAnGM+XS7d2McAiybEvQiQ zZ60bM0M8W+OdO/LDScxj53BpKYsqjEYRGlwlqPhyaRNxrvuR93Ty+abIpD+irkVf084 9/56wAdwevb33egRFvpGbTdwHCEb5ny3UTrheyNRrEt8m8IzlNIsRDuzF4exSLX+aF7a GqzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R7kGrtZpvotoea9KWR3b5/H2rAVf7kCtopxK8UOkjF0=; b=fUGaYKXLa6G4oVx2h63JuEd/gd5GpNcjUSSSp5xLgRnswTOtBsQmubwtQrzfUQ3Xru BKxN8BzGu+3NVC2pAZAJxDfHFT4i5pQrDWrHtL9jdqGpJh2XEjfIgZJA/hHEyvzfM54V Fkcv29ON9BYHPNbpzRgWF2OaOJK36xSzqpMwf53ZUPMUv/Rmzsb5dYDjPL8YvsrTgFjQ qDUoNdMKsgk2HYDkj1ZXY1/CXFx4ef3yban+Ny9dbJOxKDaG/tmQ9S9mnIoCTIdMN7Bo Ey4A2j4qKlz9fdsvxIbFG1XQQsFJGLXSS+OuKDVj8Vzbc2z5RxVb4uYufbGOKFac3N6S Uvkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=weeQ43he; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si3676065ejb.391.2021.07.27.14.04.01; Tue, 27 Jul 2021 14:04:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=weeQ43he; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231668AbhG0VD6 (ORCPT + 8 others); Tue, 27 Jul 2021 17:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231706AbhG0VDw (ORCPT ); Tue, 27 Jul 2021 17:03:52 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CF4FC06136A for ; Tue, 27 Jul 2021 14:02:57 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id d18so24074870lfb.6 for ; Tue, 27 Jul 2021 14:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7kGrtZpvotoea9KWR3b5/H2rAVf7kCtopxK8UOkjF0=; b=weeQ43hentGrVSMXuKSc3VhYfzg6ona//kj7BtF14rLLBNhoXph1HmWrN6uXx0Q63l FTK+zGN41Dk1MFZnkM7Gu8AVbw46Eow9OBMfpQMr6tOTT+2VqWMVxa10y+Rgxux1cao7 sKMk/Ig+x+idwXjxahcFXiLUv8F0/LBB964sDmvIleU15X/68MnC2ka/ESUcC7xHX2TI 8qp3su8+fzow6Tp3SNxXeln6tK/lKrwwDrKYhH8dB94mbznWmOXBWWdcLBOzUbLmE/TQ I+9vEV0yrgRKLWGlgKwMbjyZ7viUu0/87l6BJLphmqSARM703NURDSzQpfpphgyd3QG0 OpIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7kGrtZpvotoea9KWR3b5/H2rAVf7kCtopxK8UOkjF0=; b=Q0whqf/vQOUICc+OJkH/Jn+rS6alQFoGjLN34rRGl1xHARUiV4/9H5SDur1KZBTxke t2pHU4RDmpoi9IqutMe3/CdGXUN/uPBN//H1lSxodi555jX7WSZirTBlybyrt/BmLm6w MC+6eAc4D3Gh/8ExSqpiZXC8zqbeSDiP8IG45o9O61qGBCAO/cS/f4FXDD7uBlNyHINj FOFH2kAjuLDZs71a949RscKeTBMtaE5T1ptm5GtAllHKdLJigaAtlo7K5c4qLGcFc0sT KVVuptDt4IvJPRtfZ88MZbi94sCi7FWeoFJbgUe61LvkH1gg2cIc5DL+/KbunlGEzUb7 +BKA== X-Gm-Message-State: AOAM531xl5CfMApSrfo+ID5Z268cCNZRnmPqzSe7p+VUSwUuOzWggdde Gr6Kev7hDPm5RYRJT3tquGvvsw== X-Received: by 2002:a05:6512:3767:: with SMTP id z7mr6944536lft.128.1627419775799; Tue, 27 Jul 2021 14:02:55 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id m5sm355680ljq.22.2021.07.27.14.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 14:02:55 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org Subject: [PATCH 2/2] PM: clk: add devm_pm_clk_create helper Date: Wed, 28 Jul 2021 00:02:02 +0300 Message-Id: <20210727210202.717181-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727210202.717181-1-dmitry.baryshkov@linaro.org> References: <20210727210202.717181-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add devm_pm_clk_create helper, devres-enabled version of the pm_clk_create(), which will call pm_clk_destroy at the correct time. Signed-off-by: Dmitry Baryshkov --- drivers/base/power/clock_ops.c | 17 +++++++++++++++++ include/linux/pm_clock.h | 5 +++++ 2 files changed, 22 insertions(+) -- 2.30.2 diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c index 0251f3e6e61d..4110c19c08dc 100644 --- a/drivers/base/power/clock_ops.c +++ b/drivers/base/power/clock_ops.c @@ -519,6 +519,23 @@ void pm_clk_destroy(struct device *dev) } EXPORT_SYMBOL_GPL(pm_clk_destroy); +static void pm_clk_destroy_action(void *data) +{ + pm_clk_destroy(data); +} + +int devm_pm_clk_create(struct device *dev) +{ + int ret; + + ret = pm_clk_create(dev); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, pm_clk_destroy_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_clk_create); + /** * pm_clk_suspend - Disable clocks in a device's PM clock list. * @dev: Device to disable the clocks for. diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h index 8ddc7860e131..ada3a0ab10bf 100644 --- a/include/linux/pm_clock.h +++ b/include/linux/pm_clock.h @@ -47,6 +47,7 @@ extern void pm_clk_remove(struct device *dev, const char *con_id); extern void pm_clk_remove_clk(struct device *dev, struct clk *clk); extern int pm_clk_suspend(struct device *dev); extern int pm_clk_resume(struct device *dev); +extern int devm_pm_clk_create(struct device *dev); #else static inline bool pm_clk_no_clocks(struct device *dev) { @@ -83,6 +84,10 @@ static inline void pm_clk_remove(struct device *dev, const char *con_id) static inline void pm_clk_remove_clk(struct device *dev, struct clk *clk) { } +static inline int devm_pm_clk_create(struct device *dev) +{ + return -EINVAL; +} #endif #ifdef CONFIG_HAVE_CLK