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