Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2730289pxf; Sun, 14 Mar 2021 09:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJpBaWXB+q6bDVgehddhoh9Xo4WNXhF10GoHiU8TVZ5ldn8xVqyZO1ywqyfGaF5Yq5Dtfg X-Received: by 2002:a17:906:229b:: with SMTP id p27mr20018756eja.287.1615740188677; Sun, 14 Mar 2021 09:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615740188; cv=none; d=google.com; s=arc-20160816; b=nahOmK3HPMnnvZImPYArpWlFPWActfUqoJuVYmgrnhgTFguGh7eUUMd6dEXs77UHkl uEpAPyMJsGL/tFBqe5KDBJDY8CGWWJVGJvNCdO5ON4s5hAfaDQIIqxYsmlVYju9xwUZK WJnhoBNJt4wkoNLU978WCgI8TSvUBNCilvti88A4Apb/zMtD24sZtMMTCK/oKd5TltVU RM+/xOU2Sn4v4PZzcHEU/MWV0Kz1DsJ6EZMFDy0Ii0N7WnSjTlIIQ9Blsscupj4R+wfw ckwqk3WtePqgJI/HfOVvMfauN8I2P7z0ZSDzUdQnaGh7KLD7t2ynWP8PeJw+epBHt1Fo ybbQ== 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=hPYuaQIiYacDdTRkFz7tGyExYGJ5aL233qtVSVNLxbM=; b=F5uFdUV/9N4ShfhJuZnzdGDFcg/11sLcZeU5bSOPy2f/ZxF7R+9r6VLKSgXiXX62i8 Ra6tIJgjx8fMtjsL8dXlEEPVAj2feCUihsBBu57zYsjgIaf0CY97QVtkYac6L5k33BSy zV+NaJAcB2RXN6LTHb4aW0/EvLBZQh7iMof1/a+Ti5O3+3HM0/VQnizD83QIBPPuwwmb LzZvWbHwPPEnZRc7TpL3e6D/D0cW4Eaw2EiBg+6FS8+hLxqEJ3llIHtqwIoym7eSib+5 TeV3HNlYQU9EWNF6t1T4sqTFu900EWtbLTv/Qn+Q6ZEc8TMftt3ib2XkWCJLmTtBi+3z Pkcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u+Tt9wWI; 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 v21si1642782edq.151.2021.03.14.09.42.46; Sun, 14 Mar 2021 09:43:08 -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=u+Tt9wWI; 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 S233530AbhCNQfM (ORCPT + 99 others); Sun, 14 Mar 2021 12:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbhCNQeh (ORCPT ); Sun, 14 Mar 2021 12:34:37 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27373C061574; Sun, 14 Mar 2021 09:34:37 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v15so7488960wrx.4; Sun, 14 Mar 2021 09:34:37 -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=hPYuaQIiYacDdTRkFz7tGyExYGJ5aL233qtVSVNLxbM=; b=u+Tt9wWI4e3BQ1rYQRpaqKQDgHwRnDqzBh78+io9i+PwANlqkgXpLBdJ0l0ArdAeJR 0wQLZUsIpbwe8BV0z1sh5u9qJ5lw7zXq+EBwqV+CHMuS5/kC2Cl99xWRUsIMKVQgX3lp kZVodOmxbA0vfSykFlRqfrpYBetNmq+8trL0ILDyT8yykYfhnIVmCjxis6SS/GlZDKMA fuOT3dCrNcyj9IAkCm5EfrYbWe8Y6OSAr/Zx+wz+UWY2256KVXw/z77MB8Y7oXg/b6f7 BKnIkcfIZwstErOYkjtwUgnLsyGZvC1+jBV+sPXtYjeUGT7a4M/xHBChZEGLidK3wumh H9fw== 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=hPYuaQIiYacDdTRkFz7tGyExYGJ5aL233qtVSVNLxbM=; b=EwrV4RXVoNY8HuIMweTU/eDlQqNGjI6wrcTEA53zno/NOSi27ak9dbuWCP33+Gwf5B vSdxRjgVdI2lkWHTq8DWofclyusrse3WpHIA6CSdtjO3fzVjAfUiUnSxBRLD0XQQzIlW nsc5AismKasvZsThNNVLBuqygPQzPqib1t+ojA/POPM/nAgzoETv8II2et0usssbothE 3qnU7H4MfLPesBYCZrgW4zxn76o7Ze5DJ22zhCJPyEpONXLI9yCXBLMsRzCPwkbSm/rE ve3DD1xMbFUzhZL1+qGoVw+CDJK2s5pa4PA/8XqNbiLa39tHQ764tWOZDrlDBVU8e/nT NBzg== X-Gm-Message-State: AOAM533lxA+5jF8qzJuGuMG9cpIKVv8FmtWq2YwXwfHWMzzvs9McwnL8 BjxdCYpDVGxBcQtjcmC85lU= X-Received: by 2002:a05:6000:18ac:: with SMTP id b12mr23809490wri.77.1615739675873; Sun, 14 Mar 2021 09:34:35 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 09:34:35 -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 03/15] opp: Add devres wrapper for dev_pm_opp_set_supported_hw Date: Sun, 14 Mar 2021 19:33:56 +0300 Message-Id: <20210314163408.22292-4-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_supported_hw() to simplify drivers code. Signed-off-by: Yangtao Li Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 29 +++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 6217af05141f..34b054bbb28f 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1857,6 +1857,35 @@ 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 a resource-managed variant of dev_pm_opp_set_supported_hw(). + * + * Return: 0 on success and errorno otherwise. + */ +int devm_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, + unsigned int count) +{ + struct opp_table *opp_table; + + opp_table = dev_pm_opp_set_supported_hw(dev, versions, count); + if (IS_ERR(opp_table)) + return PTR_ERR(opp_table); + + return devm_add_action_or_reset(dev, devm_pm_opp_supported_hw_release, + 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 3e667af57211..e455b187e405 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -144,6 +144,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); +int 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); @@ -321,6 +322,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 int devm_pm_opp_set_supported_hw(struct device *dev, + const u32 *versions, + unsigned int count) +{ + return -EOPNOTSUPP; +} + 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)) { -- 2.30.2