From patchwork Sat Jul 31 19:50:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 489847 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp530434jas; Sat, 31 Jul 2021 12:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh47r7ed6uY5yaTy1tNar7sY7JR5m3NW72iaYd8/QhSU/TzKDiU3BBAUaQVpAAtNYfwtJc X-Received: by 2002:a05:6402:95a:: with SMTP id h26mr10354608edz.109.1627761048547; Sat, 31 Jul 2021 12:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627761048; cv=none; d=google.com; s=arc-20160816; b=hSng5asZtuCm5VFZnGf+5pIJinh6yp4np/MPp6jEE6YWVxQ+Fx8qt6Y/6KqPY3GiYV l6bklJO0IBOI0Gmc3mgKZc5FqCrGRoevbX62C9pBKhu1lhmj8Z5bQ86l2bpQ8dinVn88 +Yij3MUwZaSJ/VQwTyKFpQta6jucVQ6cpkP0BSlh/o8Yb2x6lNn1Cvi+cuOe+96JzAJ+ yhJznE9UhvsxdNRYQ6TfI1bHBFuRMpMTI97sTzwNUzzsInV2cqx63Dj59qSGqZ/mu3f2 xZ13A/44Gkawkvzuhw/kg6cpU0VNkHi3ibAr990xUU1cCPg+ZPb8cmdUdWVaJWTB9mCM WwjA== 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=a3HfCoK/N2a3QV65vcttbj2g0Y4NliR7IfkMwtRbhSY=; b=GJLzAi5A0sUgSFgt8jYtCoUTD4JLEn2tQEsKBgH8c82qP8rjLe12ZwkFblIsqchsvi ayWzuJhisRHHEf0MejJtUlxuZCnEN/iDM7jlWWkbR23PjiI3tXzW0gZyVcU8ZlngIQ+6 xE/isKlqM8iAh/peuuKnyLNKKSsfyZ7jT8ee7bZagDOZHySGyvga7IyQNDONGd18+2Pi +8jXc9vFSRNwR6nj63TGpze/9xMYP1GzAxdvdF7W3M48vvdmnIuPcsTCYEaVs4IfMq/X lcOua3IvkGvoH5KovDy9TorScciwL1gTSms1ttsIUdkoSZXj6ahM+ERXK29zTGz+WPmE I+eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h0XIju8e; 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 m10si6805829eji.536.2021.07.31.12.50.48; Sat, 31 Jul 2021 12:50:48 -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=h0XIju8e; 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 S230303AbhGaTuq (ORCPT + 8 others); Sat, 31 Jul 2021 15:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbhGaTup (ORCPT ); Sat, 31 Jul 2021 15:50:45 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 138E1C061798 for ; Sat, 31 Jul 2021 12:50:39 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id f12so18025548ljn.1 for ; Sat, 31 Jul 2021 12:50:38 -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=a3HfCoK/N2a3QV65vcttbj2g0Y4NliR7IfkMwtRbhSY=; b=h0XIju8emNWth5jqECkvdQqW6QJ4e0Q50EMYw1kFfau1vwfi8sIivLnMvYJPkyozCY N3a4vjx4SrW4h6PyJJEwFIJF4PrDiEExFvFeC5t2IKTF9xQuUq6/Rn3InlGB3Gfayxe/ JR2OSb+LkMuDO9gnHJTLWfPMB2rGIx0SmjrxzjY3Zrwyo5dvnYIZO1EqjdWINRjWRFDg 1/NDWHp7LJ6QY91cS81uu3pjMPLj9tYHWVC5G2EPQ87Vcb/jm69/Kefxm1alWrsIqBDR FGtOs27f1UP10Hvf5KMcomYatNRepfmjX/Da0FbfsC0Xbm37bkx/QOnkJ4F5Jq3sMEmM 0i+Q== 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=a3HfCoK/N2a3QV65vcttbj2g0Y4NliR7IfkMwtRbhSY=; b=Hj6JsTMCG2xZia6srKgZKwf4RpEgyqZskRpshqjY3g3n/8tNtgBgnnzWHmjhsPfInS Au+px+vohB1gZR+C/kFlxKcfs4WCTv3H6wP/Sq+Odwu1xu0gduK2mNvvQkSQEfL09iBV rtBYiGY/9S27AS8d33MoZVuAEMKGo/MrV9Uv/WIQpxVdhns2IE31PRcG1dTJUZqdWQ1a +o3AooM5h11t0+zTpDJhN9OupFvj5lBLfdGPf8pBv7AYQQOfN4cbOUablqz1thbfOXeZ wqT6asg9Kd8z52StwMzoEtaIxtQPMmybDrocwwj2TCguuNG5CdGP+N8JNjQGAyLgxrY7 mwtQ== X-Gm-Message-State: AOAM532wwOBpB7jMjq8/tAeJPjxmZ7SN2I9miEpA7MWY/B0maYaV9ro2 fHNQN/hTPFUcn3xpDt7ibOOeaQ== X-Received: by 2002:a2e:9e8e:: with SMTP id f14mr6069954ljk.502.1627761037354; Sat, 31 Jul 2021 12:50:37 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id f3sm469827lfm.76.2021.07.31.12.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 12:50:37 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v3 1/3] PM: runtime: add devm_pm_runtime_enable helper Date: Sat, 31 Jul 2021 22:50:32 +0300 Message-Id: <20210731195034.979084-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210731195034.979084-1-dmitry.baryshkov@linaro.org> References: <20210731195034.979084-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org A typical code pattern for pm_runtime_enable() call is to call it in the _probe function and to call pm_runtime_disable() both from _probe error path and from _remove function. For some drivers the whole remove function would consist of the call to pm_remove_disable(). Add helper function to replace this bolierplate piece of code. Calling devm_pm_runtime_enable() removes the need for calling pm_runtime_disable() both in the probe()'s error path and in the remove() function. 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 Acked-by: Rafael J. Wysocki 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 Sat Jul 31 19:50:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 489848 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp530447jas; Sat, 31 Jul 2021 12:50:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoBW94DclK1znqy8t7SySUEky7qG25TMEftl1yzkCGv3NUszS3mNgKMyQYmg7zS4cPNEdC X-Received: by 2002:a17:906:3048:: with SMTP id d8mr8673462ejd.534.1627761050188; Sat, 31 Jul 2021 12:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627761050; cv=none; d=google.com; s=arc-20160816; b=q7jNf+io1Cv6LZqLFKvkfMCY0so1+nB/SKoqAynPSHrpE1CxZ6+aL3MzXCHc8t352+ rQ0QKofNM9zhXJx+NGz9tvJojLfBYU25wBjHMnshqth0Y38ZVuwIaaVejXbJvlUjYXNJ J4WIKMq4C+HRFMShtBnqOb5GsIe/bfLJQCWezwwNzQrvgfpeUyBl6g6BaZgD+AFR0iVX 5FQV4SekvUBD488rQQb9VTVtdyj95tjzD8BM9p6U8lgNeYG9hirWfFfGYEDYgpL1l5iE l5xm7wLf7BEqY0D57qFXz3HAicctAglym4l3FCRCKYiP5gX39pg9gj1WZ7TgOTpe7uv7 4YYA== 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=kHFwx9ojcB3g03tmggA/XXZ6zfIExa6F6ser3y7PQzw=; b=TKcFsAiaYLFpN70td+hM6qDyJckQJkie2u5JmkRrlyq+kWbleUnGn77nmfwsZWFiEQ SPIKzeVldLHv/bngBqL11twUZLzXz3TPG5+iOZXYseogfr/Vz9ostClg7wtPWKT5siyO bq/UQsyH2dXcaegd/+su9YfpkVvSVFrbR7e09KoCvsaABMRQiboxdXGegE0bk3kFdlBk ZG4Ufb9r4tjxauc0t2nK8g+0bI3P3wJypvNVPwkXZzefSxAO0UxC2aQ7CkipYuZWv6RT 8FB3yoBKGHviAoKfhOJnogpmoQkS9/Z33yQxbRhey81rb9cFuiHf86d3cQZZ4ZHuIuOr O6xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sSNjDrMN; 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 m10si6805829eji.536.2021.07.31.12.50.49; Sat, 31 Jul 2021 12:50:50 -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=sSNjDrMN; 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 S231529AbhGaTus (ORCPT + 8 others); Sat, 31 Jul 2021 15:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbhGaTuq (ORCPT ); Sat, 31 Jul 2021 15:50:46 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C229FC0613CF for ; Sat, 31 Jul 2021 12:50:39 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id f12so18025572ljn.1 for ; Sat, 31 Jul 2021 12:50:39 -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=kHFwx9ojcB3g03tmggA/XXZ6zfIExa6F6ser3y7PQzw=; b=sSNjDrMN1Esd5W5I7LhppFjL0YXjXaKTdbm2Emdl4gdYcc+KBuZTmCrew6R0IpDWbB nHlhU0hurC+f3TDljJwjJiwSaCn9PxkkANp5mVtgRt9Balk0E3U2k7t5EQuK+gXUgOwu nI317bCBRYf8dxLfgtouyX6T7UibbkBWe4wAWNTVK522y/lXGCRYfJPg17eDx5JvFuks +KLDia6BLKVt4dNU5IRq2OLZa+obbbDxn8oOkCMvVdZdQhJiPQE2vlAFmlgp9QC3Onnq ymgg4DqV6G1nAOR1vs0DC+pdA9Xvc4TdSCLGF4rzY5HBhezFAZcecblaRq41pgTITnxx EaMw== 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=kHFwx9ojcB3g03tmggA/XXZ6zfIExa6F6ser3y7PQzw=; b=pZLNTyjAFm9EqCbrozZ1PRJJzuNAiNv4K3MNXp6b5uq3TROX0B2vpljwO3hOIt7E92 xZIGFihw4Pqykh2UCDDz3FchWLcfZaCt8U5sSe9KB8xFUWW/oGrb/tcXNLs6I9gGnwKQ B1a7KspSIdYzC1A1KC+9gFGecYGWUU2UMGNYIWQ86DeHC37jKoCXylfEm5d1WNIlFs5d M3KZlmdxAM3eaHhKeyBtnCtj1Bhlq7m5kAFJccfMIJ7F1qMH8NzxGSJ6h9aXGlRlbxK9 IdUh8cM8M3cWCX2KAM1ksrUp+SrFCyT8QFK2U5a+ehCldjhgFTN+uuoDCcBbLylJFTxb gcIQ== X-Gm-Message-State: AOAM531dIrYrogBt32F4EaOusK9TPjASFvzaTV4nOCH4NfriWbrvKOeG XpSzD2LGffs8MqVYehaD9YOSJg== X-Received: by 2002:a2e:86c5:: with SMTP id n5mr6031314ljj.398.1627761038155; Sat, 31 Jul 2021 12:50:38 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id f3sm469827lfm.76.2021.07.31.12.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 12:50:37 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v3 2/3] PM: runtime: add devm_pm_clk_create helper Date: Sat, 31 Jul 2021 22:50:33 +0300 Message-Id: <20210731195034.979084-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210731195034.979084-1-dmitry.baryshkov@linaro.org> References: <20210731195034.979084-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org A typical code pattern for pm_clk_create() call is to call it in the _probe function and to call pm_clk_destroy() both from _probe error path and from _remove function. For some drivers the whole remove function would consist of the call to pm_remove_disable(). Add helper function to replace this bolierplate piece of code. Calling devm_pm_clk_create() removes the need for calling pm_clk_destroy() both in the probe()'s error path and in the remove() function. 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 From patchwork Sat Jul 31 19:50:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 489849 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp530455jas; Sat, 31 Jul 2021 12:50:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBmo3/UsYheJvc3fp1R4NqVAdO/GU1YaPwj5/JJWA+oZFg6jr3daVbBbPjjN6nXJApSV9j X-Received: by 2002:a17:906:2547:: with SMTP id j7mr8381887ejb.491.1627761050605; Sat, 31 Jul 2021 12:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627761050; cv=none; d=google.com; s=arc-20160816; b=JBrL55f9YfucOI+bJWjp/QkDvbCxXDtIjRameEM0UzBmoe6PLOtggxaIWc7vcGpft9 N5l9hqcOkIFH+ydona+VpdHMEH1ufhYKAZhXse6xxWFAL2r2a5IONb+JoEIqeG/PWQrE auRqOocaOi9amhpl7zW0IaKhbpCKoKI2BLQ1pvmuMbcXx0TQ6hTLs6GN0sZRuixae2U1 +Iy2zjWppDleRnZmpS4AUU4cjO01wTZNJ95Dh7nm7Zvxa4t0aDbwcNH2h2n/0B85wkVw Ek5bYaOcQ3kJZEtr+paZVrdCWatEpNan9G+rToBS95cXWGXFcGhFhe2wp5Ctv2SuccYL Xhow== 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=v2Fy/yGaCX8hbu5Oi1QSk2N9k+27AOHOBEBqCYJNREY=; b=cHJc/LjOyiJTQ5TQccDp1V9i/y3+2OtGg8opE091c/tpSiYqKJOiu42fHfTDkxqElU iTQBLSyrjB/8nCiHLtgLtOvidc4rqZE4Ho5IytotBTKW3VDkzhUVvPJ+QfmaSxBL4ExS /an3DynFzTlPqSwVl4zNX3MRm2Al3xT/FM+yHeHPb+6oVdjmGacJ1zWQJkvLvBrrJo8b 4+mh8FfW35K0/RPwp/QxALrzU3stdVQUYxHiVVmuo7+dIl/KweiTTPjASo4Cz5bg9HfR BPA8KYR8hurzVLD+8YbJPbFr8i2m4vSRdm4WbpwK7unZA98ydiC5c7KjBRTenVwJ12AF zO0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ofjFcHw8; 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 m10si6805829eji.536.2021.07.31.12.50.50; Sat, 31 Jul 2021 12:50:50 -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=ofjFcHw8; 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 S231536AbhGaTus (ORCPT + 8 others); Sat, 31 Jul 2021 15:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbhGaTur (ORCPT ); Sat, 31 Jul 2021 15:50:47 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82BD1C06179A for ; Sat, 31 Jul 2021 12:50:40 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id b6so2619627lff.10 for ; Sat, 31 Jul 2021 12:50:40 -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=v2Fy/yGaCX8hbu5Oi1QSk2N9k+27AOHOBEBqCYJNREY=; b=ofjFcHw8vnpiG28ngDkLY4kJ8axNyITsRDNjaeCQCtwbTubdUqEVqrsdFXT5vEFn+x 7mGVPjQHqgwcVWoLNJppuTlfdpjRceVJTpfA40ByNSu/8Xgv08VWJprZAk0jY4qIrf9J LNbcyXZiF/Q2igmrGohsnccy1Ceoil9zkagLgQVd/xdFyGcyzoCjvVYcOSOxC6sogfcl sSSwXui0AqeoIC63uxbfC9m4s/1QRq3LiLke86i6FDtIJSE4aPpROeEMxNxPSTHcms85 s3svTljZCqnARE0mXyhVHgXKtrOAwfEcDTidJJPhyMhTtFa1nQb23A/T3fMkMOsmjo/q KGhQ== 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=v2Fy/yGaCX8hbu5Oi1QSk2N9k+27AOHOBEBqCYJNREY=; b=RgQrITAG3EN2Y1al/QRNnRzSlwab3aPgNUyFWM5VqWTalCRe0JGls1WVhtm2S8SEn+ fIoGVf4UNtFYkSy+mUzMEdbzqD+mUlfBIW/UQyA5jSUa2malrQwHJMk2PiCLgQYyqRiO cmZGukF68TFov59jnYNuCI6xGzS9eChffW35m/DEgk3vWJEhmbABu63rO7wB1SMm1gL/ HRrpldMOBA5qPkszzRo3fqEhYW/ebsc7ecxZeUh6X7ke6qTVe2vYI5F46VbbCZV21CSr Bb+JrI8I2yBwl5Cq24r+bg+71Sg/8ixH18TtzhetmeiPwmbTDx1WyKf/1HFzSLoNR9oL Kf5w== X-Gm-Message-State: AOAM533svpO9sbyvPTYWe/b5njc+PfZ5wFJgcwmNTY0T31ScQ+TbeslR Ebmlfq23u23l4SQO21UKLjpyUw== X-Received: by 2002:a19:6f07:: with SMTP id k7mr6598801lfc.86.1627761038901; Sat, 31 Jul 2021 12:50:38 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id f3sm469827lfm.76.2021.07.31.12.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 12:50:38 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v3 3/3] clk: qcom: use devm_pm_runtime_enable and devm_pm_clk_create Date: Sat, 31 Jul 2021 22:50:34 +0300 Message-Id: <20210731195034.979084-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210731195034.979084-1-dmitry.baryshkov@linaro.org> References: <20210731195034.979084-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use two new helpers instead of pm_runtime_enable() and pm_clk_create(), removing the need for calling pm_runtime_disable and pm_clk_destroy(). Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/camcc-sc7180.c | 25 +++++++++------------ drivers/clk/qcom/lpass-gfm-sm8250.c | 21 ++++++++---------- drivers/clk/qcom/lpasscorecc-sc7180.c | 18 ++------------- drivers/clk/qcom/mss-sc7180.c | 30 +++++++------------------ drivers/clk/qcom/q6sstop-qcs404.c | 32 ++++++++------------------- drivers/clk/qcom/turingcc-qcs404.c | 30 +++++++------------------ 6 files changed, 46 insertions(+), 110 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/camcc-sc7180.c b/drivers/clk/qcom/camcc-sc7180.c index 9bcf2f8ed4de..ce73ee9037cb 100644 --- a/drivers/clk/qcom/camcc-sc7180.c +++ b/drivers/clk/qcom/camcc-sc7180.c @@ -1652,32 +1652,35 @@ static int cam_cc_sc7180_probe(struct platform_device *pdev) struct regmap *regmap; int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret < 0) + return ret; + + ret = devm_pm_clk_create(&pdev->dev); if (ret < 0) return ret; ret = pm_clk_add(&pdev->dev, "xo"); if (ret < 0) { dev_err(&pdev->dev, "Failed to acquire XO clock\n"); - goto disable_pm_runtime; + return ret; } ret = pm_clk_add(&pdev->dev, "iface"); if (ret < 0) { dev_err(&pdev->dev, "Failed to acquire iface clock\n"); - goto disable_pm_runtime; + return ret; } ret = pm_runtime_get(&pdev->dev); if (ret) - goto destroy_pm_clk; + return ret; regmap = qcom_cc_map(pdev, &cam_cc_sc7180_desc); if (IS_ERR(regmap)) { ret = PTR_ERR(regmap); pm_runtime_put(&pdev->dev); - goto destroy_pm_clk; + return ret; } clk_fabia_pll_configure(&cam_cc_pll0, regmap, &cam_cc_pll0_config); @@ -1689,18 +1692,10 @@ static int cam_cc_sc7180_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); if (ret < 0) { dev_err(&pdev->dev, "Failed to register CAM CC clocks\n"); - goto destroy_pm_clk; + return ret; } return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; } static const struct dev_pm_ops cam_cc_pm_ops = { diff --git a/drivers/clk/qcom/lpass-gfm-sm8250.c b/drivers/clk/qcom/lpass-gfm-sm8250.c index f5e31e692b9b..96f476f24eb2 100644 --- a/drivers/clk/qcom/lpass-gfm-sm8250.c +++ b/drivers/clk/qcom/lpass-gfm-sm8250.c @@ -251,15 +251,18 @@ static int lpass_gfm_clk_driver_probe(struct platform_device *pdev) if (IS_ERR(cc->base)) return PTR_ERR(cc->base); - pm_runtime_enable(dev); - err = pm_clk_create(dev); + err = devm_pm_runtime_enable(dev); if (err) - goto pm_clk_err; + return err; + + err = devm_pm_clk_create(dev); + if (err) + return err; err = of_pm_clk_add_clks(dev); if (err < 0) { dev_dbg(dev, "Failed to get lpass core voting clocks\n"); - goto clk_reg_err; + return err; } for (i = 0; i < data->onecell_data->num; i++) { @@ -273,22 +276,16 @@ static int lpass_gfm_clk_driver_probe(struct platform_device *pdev) err = devm_clk_hw_register(dev, &data->gfm_clks[i]->hw); if (err) - goto clk_reg_err; + return err; } err = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, data->onecell_data); if (err) - goto clk_reg_err; + return err; return 0; - -clk_reg_err: - pm_clk_destroy(dev); -pm_clk_err: - pm_runtime_disable(dev); - return err; } static const struct of_device_id lpass_gfm_clk_match_table[] = { diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 2e0ecc38efdd..ac09b7b840ab 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -356,32 +356,18 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = { .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs), }; -static void lpass_pm_runtime_disable(void *data) -{ - pm_runtime_disable(data); -} - -static void lpass_pm_clk_destroy(void *data) -{ - pm_clk_destroy(data); -} - static int lpass_create_pm_clks(struct platform_device *pdev) { int ret; pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 500); - pm_runtime_enable(&pdev->dev); - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) return ret; - ret = pm_clk_create(&pdev->dev); - if (ret) - return ret; - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_clk_destroy, &pdev->dev); + ret = devm_pm_clk_create(&pdev->dev); if (ret) return ret; diff --git a/drivers/clk/qcom/mss-sc7180.c b/drivers/clk/qcom/mss-sc7180.c index 673fa1a4f734..5a1407440662 100644 --- a/drivers/clk/qcom/mss-sc7180.c +++ b/drivers/clk/qcom/mss-sc7180.c @@ -73,36 +73,23 @@ static int mss_sc7180_probe(struct platform_device *pdev) { int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, "cfg_ahb"); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } ret = qcom_cc_probe(pdev, &mss_sc7180_desc); if (ret < 0) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; -} - -static int mss_sc7180_remove(struct platform_device *pdev) -{ - pm_clk_destroy(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; return 0; } @@ -119,7 +106,6 @@ MODULE_DEVICE_TABLE(of, mss_sc7180_match_table); static struct platform_driver mss_sc7180_driver = { .probe = mss_sc7180_probe, - .remove = mss_sc7180_remove, .driver = { .name = "sc7180-mss", .of_match_table = mss_sc7180_match_table, diff --git a/drivers/clk/qcom/q6sstop-qcs404.c b/drivers/clk/qcom/q6sstop-qcs404.c index 723f932fbf7d..507386bee07d 100644 --- a/drivers/clk/qcom/q6sstop-qcs404.c +++ b/drivers/clk/qcom/q6sstop-qcs404.c @@ -159,15 +159,18 @@ static int q6sstopcc_qcs404_probe(struct platform_device *pdev) const struct qcom_cc_desc *desc; int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, NULL); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } q6sstop_regmap_config.name = "q6sstop_tcsr"; @@ -175,30 +178,14 @@ static int q6sstopcc_qcs404_probe(struct platform_device *pdev) ret = qcom_cc_probe_by_index(pdev, 1, desc); if (ret) - goto destroy_pm_clk; + return ret; q6sstop_regmap_config.name = "q6sstop_cc"; desc = &q6sstop_qcs404_desc; ret = qcom_cc_probe_by_index(pdev, 0, desc); if (ret) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; -} - -static int q6sstopcc_qcs404_remove(struct platform_device *pdev) -{ - pm_clk_destroy(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; return 0; } @@ -209,7 +196,6 @@ static const struct dev_pm_ops q6sstopcc_pm_ops = { static struct platform_driver q6sstopcc_qcs404_driver = { .probe = q6sstopcc_qcs404_probe, - .remove = q6sstopcc_qcs404_remove, .driver = { .name = "qcs404-q6sstopcc", .of_match_table = q6sstopcc_qcs404_match_table, diff --git a/drivers/clk/qcom/turingcc-qcs404.c b/drivers/clk/qcom/turingcc-qcs404.c index 4cfbbf5bf4d9..4543bda793f4 100644 --- a/drivers/clk/qcom/turingcc-qcs404.c +++ b/drivers/clk/qcom/turingcc-qcs404.c @@ -110,36 +110,23 @@ static int turingcc_probe(struct platform_device *pdev) { int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, NULL); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } ret = qcom_cc_probe(pdev, &turingcc_desc); if (ret < 0) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; -} - -static int turingcc_remove(struct platform_device *pdev) -{ - pm_clk_destroy(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; return 0; } @@ -156,7 +143,6 @@ MODULE_DEVICE_TABLE(of, turingcc_match_table); static struct platform_driver turingcc_driver = { .probe = turingcc_probe, - .remove = turingcc_remove, .driver = { .name = "qcs404-turingcc", .of_match_table = turingcc_match_table,