From patchwork Fri Jan 1 16:54:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11994773 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3DB1C433E9 for ; Fri, 1 Jan 2021 16:57:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 944C4221FE for ; Fri, 1 Jan 2021 16:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727390AbhAAQ45 (ORCPT ); Fri, 1 Jan 2021 11:56:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbhAAQ45 (ORCPT ); Fri, 1 Jan 2021 11:56:57 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0495FC0613C1; Fri, 1 Jan 2021 08:56:17 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id i7so14724944pgc.8; Fri, 01 Jan 2021 08:56:16 -0800 (PST) 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; bh=3tAUeVcIKsbnNHgonKad43l224e/4lHHdw2qIBrPq38=; b=FfK3KI96FFLjhzCZlFkiXR4NyaB4Q3hZrnhhwZxakVzjd9BwzCGaRpPqZv6oNDgVez AzpTXNaYLpi1zc7Og4G3mKtUvpsBvnJSnmXLLDblxCrHjGhhkfHk8QqHMs6YCE4OQDvs kkd5jxI1ZPv6vYGHG1nu8JkgsFUHoR8FDLozuAa4ilv6gRd3wyg/ZiiSN07zcOdli84A v1wCExU4grKxuY2R1Y0iHskae3irQznyKqa86crMVzDabGs8V/5ykCd0gLlCe2VGOMdz OYRkcTkAkhElq4zu0DQdfN9V+NrBDVg1vetM6iVLyM55o6oeUAkOXL7M4ruuyLg6nDWq NRZQ== 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; bh=3tAUeVcIKsbnNHgonKad43l224e/4lHHdw2qIBrPq38=; b=lHf0CkiQm2JSIizTqjiHMz/xpSaktD0CKRKabPe/WxcBUeWAIp6G82AN0SSbsR7I9k EFBzcu6HnggzB8wYmms/DioKA2EU+9lRqkWqKCjP6Z78zM+7vhcIRJ3JmBqEkSGKAlsw JtuHLNX8wTLUdJRHx4szHuykJUDoAPoQezMlpDGNySkZyvvBbEWKlFL+9gC2OC3XVnTe WUAMD9d9Iz999Dmy5uWAxmyTKlcqXcYpU/88vz3A8ItmpMem1J7/cy7pP8nMILrozcQa wvTCNH8896bfdIQzrMiO07TJLPGE4+NdIf/8pQKW2jtfEATH4woOuufr7ccZD27Z5tci 2HMA== X-Gm-Message-State: AOAM530eVKy6c/4mAVG7mYdc2gQR3aNidQvvgo0MN1dhk6G0JNbVATSv hgctrEdonE5yDDdHPgBfUJo= X-Google-Smtp-Source: ABdhPJzfaJQaJwc5acHIqB/Y6TtZUJCofjXaLupMrsM/ldtJkO+4jA7SGw1u8nZFUn4jpc80sgpgbA== X-Received: by 2002:aa7:954c:0:b029:1a6:2130:db4f with SMTP id w12-20020aa7954c0000b02901a62130db4fmr56000791pfq.68.1609520176448; Fri, 01 Jan 2021 08:56:16 -0800 (PST) Received: from localhost.localdomain ([43.255.31.23]) by smtp.gmail.com with ESMTPSA id 84sm50002729pfy.9.2021.01.01.08.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 08:56:15 -0800 (PST) From: Yangtao Li To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, krzk@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, digetx@gmail.com, thierry.reding@gmail.com, jonathanh@nvidia.com, yuq825@gmail.com, airlied@linux.ie, daniel@ffwll.ch, robdclark@gmail.com, sean@poorly.run, robh@kernel.org, tomeu.vizoso@collabora.com, steven.price@arm.com, alyssa.rosenzweig@collabora.com, stanimir.varbanov@linaro.org, agross@kernel.org, bjorn.andersson@linaro.org, mchehab@kernel.org, lukasz.luba@arm.com, adrian.hunter@intel.com, ulf.hansson@linaro.org, vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, broonie@kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, rjw@rjwysocki.net, jcrouse@codeaurora.org, hoegsberg@google.com, eric@anholt.net, tzimmermann@suse.de, marijn.suijten@somainline.org, gustavoars@kernel.org, emil.velikov@collabora.com, jonathan@marek.ca, akhilpo@codeaurora.org, smasetty@codeaurora.org, airlied@redhat.com, masneyb@onstation.org, kalyan_t@codeaurora.org, tanmay@codeaurora.org, tiny.windzz@gmail.com, ddavenport@chromium.org, jsanka@codeaurora.org, rnayak@codeaurora.org, tongtiangen@huawei.com, miaoqinglang@huawei.com, khsieh@codeaurora.org, abhinavk@codeaurora.org, chandanu@codeaurora.org, groeck@chromium.org, varar@codeaurora.org, mka@chromium.org, harigovi@codeaurora.org, rikard.falkeborn@gmail.com, natechancellor@gmail.com, georgi.djakov@linaro.org, akashast@codeaurora.org, parashar@codeaurora.org, dianders@chromium.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 03/31] opp: Add devres wrapper for dev_pm_opp_set_supported_hw Date: Fri, 1 Jan 2021 16:54:39 +0000 Message-Id: <20210101165507.19486-4-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210101165507.19486-1-tiny.windzz@gmail.com> References: <20210101165507.19486-1-tiny.windzz@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add devres wrapper for dev_pm_opp_set_supported_hw() to simplify driver code. Signed-off-by: Yangtao Li Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko --- drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 8709689a7152..6b83e373f0d8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1674,6 +1674,44 @@ void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) } EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw); +static void devm_pm_opp_supported_hw_release(void *data) +{ + dev_pm_opp_put_supported_hw(data); +} + +/** + * devm_pm_opp_set_supported_hw() - Set supported platforms + * @dev: Device for which supported-hw has to be set. + * @versions: Array of hierarchy of versions to match. + * @count: Number of elements in the array. + * + * This is required only for the V2 bindings, and it enables a platform to + * specify the hierarchy of versions it supports. OPP layer will then enable + * OPPs, which are available for those versions, based on its 'opp-supported-hw' + * property. + * + * The opp_table structure will be freed after the device is destroyed. + */ +struct opp_table *devm_pm_opp_set_supported_hw(struct device *dev, + const u32 *versions, + unsigned int count) +{ + struct opp_table *opp_table; + int err; + + opp_table = dev_pm_opp_set_supported_hw(dev, versions, count); + if (IS_ERR(opp_table)) + return opp_table; + + err = devm_add_action_or_reset(dev, devm_pm_opp_supported_hw_release, + opp_table); + if (err) + opp_table = ERR_PTR(err); + + return opp_table; +} +EXPORT_SYMBOL_GPL(devm_pm_opp_set_supported_hw); + /** * dev_pm_opp_set_prop_name() - Set prop-extn name * @dev: Device for which the prop-name has to be set. diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 8a329247e08e..e5260fc82ba1 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -139,6 +139,7 @@ int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); void dev_pm_opp_put_supported_hw(struct opp_table *opp_table); +struct opp_table *devm_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name); void dev_pm_opp_put_prop_name(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * const names[], unsigned int count); @@ -301,6 +302,13 @@ static inline struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, static inline void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) {} +static inline struct opp_table *devm_pm_opp_set_supported_hw(struct device *dev, + const u32 *versions, + unsigned int count) +{ + return ERR_PTR(-ENOTSUPP); +} + static inline struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)) {