Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2730427pxf; Sun, 14 Mar 2021 09:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYiQLdyD/gq+piBE0vSORTLHdYDYrzGlyU9qzLy7Rn+12rbR9ipttaCz4dk2z1514RrNVa X-Received: by 2002:aa7:c916:: with SMTP id b22mr26139856edt.299.1615740210397; Sun, 14 Mar 2021 09:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615740210; cv=none; d=google.com; s=arc-20160816; b=ZW/36ne49pubRDweFQlLVWujmQxiRzfLS2vdgi9HU/KWcv4P3eQ3UOek9NtYkcN3nw t28QivsWVz6cdEl9dF04R1v8+58xb9+c7PayE3pmrnk5qd4uEbCX6eHJRGqtWEHBfaKa 79KX5njJPE2/Q+IEvTpm/AWxbBSkQauzKsLfRUdfDL++ZyFRc5Pr5Wi5u674HqsE1+ob ZTDGynPPcrSQHnfbUfiO1tbxyNkWZ35gGyde1wYQkFDxwgFFLcQyXfbxL0dNKHTDQ7Jo HzfdiJX8NhTJvu7hgB8q9k3ioTkVQjIWnE2QqVsKhrA0yHYsWZzpYO8MsHBAil1+ypjN VuMQ== 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=suQTUJT95TToQZtvwJl+RSOWWo46pQcxeekooCpqVRE=; b=JkKU7hePCQ0vyBIft2LCbd1Dk957pQOflbSDdak017h+k+GsCr5wEWJmj5Uv8MhEhS q3/8oKb1HOedUMRHV4rd1fkIq4498/WVGvjB4NkFKzOqK6+Mun7RmQS7KhVWa1VDc8hw +D/mxhvjjB7FyLEO29B8/PHWLCYwkFTfSNC9VmkbDGJo+M5wymzdQymAPK4irV1XgAZ0 NA3LD0pihqOMdxBvdqq2wfJuLGC6ZoZ0ZB6vlxpuBaKFoPdGBQwNCJQhD4nZ/f/N0iHZ Ni1m5Zyd/7haJxzP5HzmeV4gLrrY7kzIieS1qAwqwRRvhm2oIhGE36K/nqS77uKisfJ4 0Y8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mWOhEWII; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si8840058edo.179.2021.03.14.09.43.08; Sun, 14 Mar 2021 09:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=mWOhEWII; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234212AbhCNQfB (ORCPT + 99 others); Sun, 14 Mar 2021 12:35:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233985AbhCNQed (ORCPT ); Sun, 14 Mar 2021 12:34:33 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58A3C061574; Sun, 14 Mar 2021 09:34:32 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id g8so6742911wmd.4; Sun, 14 Mar 2021 09:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=suQTUJT95TToQZtvwJl+RSOWWo46pQcxeekooCpqVRE=; b=mWOhEWIIsc3g51/r4PPuTyVIq+fH9uyJTXCIr7ia4jxvUoOPc/NOBuXvxFpp37+sgM oWFUAvtO3jAmlc+Gh7AgygkSjZ3ZdAt9RnsigCjWBcz9qXNGbojGZYMx2MLYv63ioNUr kBcixmyyH2o612X49U7uUmIdbHOjwNNT+W/jZH7lULyWC6HofFScf3nELSuSnNeEgx+7 c1LQLMTj0bHwnoJwjMCQgRzFXPsrqvDQDaUB3bSIPpPeyhndLfRs9bM6hCnL521qtyN+ slSchI8ROdq4ZXLH6K5M2VnrvEwkx1s1Q0heBXBQFO3w6/7I3w89zIHK/wSRLWOCT3Cn v/gA== 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=suQTUJT95TToQZtvwJl+RSOWWo46pQcxeekooCpqVRE=; b=GxYurg1YWwqgAfPcHrM+Pzj0dCKNFKBkzVFDWAoeg5ASIF0ln2lJqsIgdmvTEsaGI+ Nx3TmhFZv0tAlZ0YD/zNe7ESo8TRNI/Yji+IyqMuO8Oxm5vTGUqUKjAYhy5gyBxplAdQ sbPJQLa0AqiUPZ/t/IBHw/wbv3svZ6Q55Uw8M/txzUo+H5m6YC7w+notBX0UQg703bFh YqjRvypmBbLSfHgeUiV7HdFtVf6+B9j80CxuybcgHNUuLyJ7wuVdnRhK6zeeQiCeHoS9 FM7c1iSEUnjml06UTQlm4306i5KTvEITPf2agohestsdkZcHHBrS1oNsompyMYCCa2dP aYKw== X-Gm-Message-State: AOAM530UpvV6ErfI29Y2uNgpsA6f3hZ+w3zIBI2lzetQQkZFOCKZoXBy R6NCh1OaiEdggrqaeHPnOZU= X-Received: by 2002:a1c:61c5:: with SMTP id v188mr21841943wmb.20.1615739671508; Sun, 14 Mar 2021 09:34:31 -0700 (PDT) Received: from localhost.localdomain (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.gmail.com with ESMTPSA id o7sm15723239wrs.16.2021.03.14.09.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 09:34:31 -0700 (PDT) From: Dmitry Osipenko To: Qiang Yu , Rob Clark , Sean Paul , Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Stanimir Varbanov , Andy Gross , Bjorn Andersson , Mauro Carvalho Chehab , Lukasz Luba , Krzysztof Kozlowski , Adrian Hunter , Ulf Hansson , Viresh Kumar , Nishanth Menon , Stephen Boyd , Mark Brown , Greg Kroah-Hartman , Jiri Slaby , Yangtao Li Cc: Daniel Vetter , dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-media@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v3 01/15] opp: Add devres wrapper for dev_pm_opp_set_clkname Date: Sun, 14 Mar 2021 19:33:54 +0300 Message-Id: <20210314163408.22292-2-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210314163408.22292-1-digetx@gmail.com> References: <20210314163408.22292-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yangtao Li Add devres wrapper for dev_pm_opp_set_clkname() to simplify drivers code. Signed-off-by: Yangtao Li Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 27 +++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 150be4c28c99..02e46508a3a2 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2119,6 +2119,33 @@ void dev_pm_opp_put_clkname(struct opp_table *opp_table) } EXPORT_SYMBOL_GPL(dev_pm_opp_put_clkname); +static void devm_pm_opp_clkname_release(void *data) +{ + dev_pm_opp_put_clkname(data); +} + +/** + * devm_pm_opp_set_clkname() - Set clk name for the device + * @dev: Device for which clk name is being set. + * @name: Clk name. + * + * This is a resource-managed variant of dev_pm_opp_set_clkname(). + * + * Return: 0 on success and errorno otherwise. + */ +int devm_pm_opp_set_clkname(struct device *dev, const char *name) +{ + struct opp_table *opp_table; + + opp_table = dev_pm_opp_set_clkname(dev, name); + if (IS_ERR(opp_table)) + return PTR_ERR(opp_table); + + return devm_add_action_or_reset(dev, devm_pm_opp_clkname_release, + opp_table); +} +EXPORT_SYMBOL_GPL(devm_pm_opp_set_clkname); + /** * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper * @dev: Device for which the helper is getting registered. diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index c0371efa4a0f..0583d775aa5a 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -150,6 +150,7 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * con void dev_pm_opp_put_regulators(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name); void dev_pm_opp_put_clkname(struct opp_table *opp_table); +int devm_pm_opp_set_clkname(struct device *dev, const char *name); struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); struct opp_table *devm_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); @@ -355,6 +356,11 @@ static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {} +static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) +{ + return -EOPNOTSUPP; +} + static inline struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs) { return ERR_PTR(-EOPNOTSUPP); -- 2.30.2