From: Yaxiong Tian <tianyaxiong@kylinos.cn>
To: Jie Zhan <zhanjie9@hisilicon.com>,
cwchoi00@gmail.com, cw00.choi@samsung.com,
myungjoo.ham@samsung.com, kyungmin.park@samsung.com,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: linuxarm@huawei.com, zhenglifeng1@huawei.com,
zhangpengjie2@huawei.com, lihuisong@huawei.com,
prime.zeng@hisilicon.com
Subject: Re: [PATCH v2 2/6] devfreq: Use mutex guard in devfreq_add/remove_governor()
Date: Thu, 14 May 2026 14:02:50 +0800 [thread overview]
Message-ID: <55fbdfeb-28c0-458b-a3a5-2603fbbf41ea@kylinos.cn> (raw)
In-Reply-To: <20260513093832.1645890-3-zhanjie9@hisilicon.com>
在 2026/5/13 17:38, Jie Zhan 写道:
> Use mutex guard in devfreq_add/remove_governor() so as to simplify the
> locking logic.
>
> No functional impact intended.
>
> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
> ---
> drivers/devfreq/devfreq.c | 22 +++++++---------------
> 1 file changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 7a70dd051644..53c40d795a13 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1261,28 +1261,23 @@ void devfreq_resume(void)
> int devfreq_add_governor(struct devfreq_governor *governor)
> {
> struct devfreq_governor *g;
> - int err = 0;
>
> if (!governor) {
> pr_err("%s: Invalid parameters.\n", __func__);
> return -EINVAL;
> }
>
> - mutex_lock(&devfreq_list_lock);
> + guard(mutex)(&devfreq_list_lock);
> g = find_devfreq_governor(governor->name);
> if (!IS_ERR(g)) {
> pr_err("%s: governor %s already registered\n", __func__,
> g->name);
> - err = -EINVAL;
> - goto err_out;
> + return -EINVAL;
> }
>
> list_add(&governor->node, &devfreq_governor_list);
>
> -err_out:
> - mutex_unlock(&devfreq_list_lock);
> -
> - return err;
> + return 0;
> }
> EXPORT_SYMBOL(devfreq_add_governor);
>
> @@ -1320,21 +1315,20 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
> {
> struct devfreq_governor *g;
> struct devfreq *devfreq;
> - int err = 0;
>
> if (!governor) {
> pr_err("%s: Invalid parameters.\n", __func__);
> return -EINVAL;
> }
>
> - mutex_lock(&devfreq_list_lock);
> + guard(mutex)(&devfreq_list_lock);
> g = find_devfreq_governor(governor->name);
> if (IS_ERR(g)) {
> pr_err("%s: governor %s not registered\n", __func__,
> governor->name);
> - err = PTR_ERR(g);
> - goto err_out;
> + return PTR_ERR(g);
> }
> +
> list_for_each_entry(devfreq, &devfreq_list, node) {
> int ret;
> struct device *dev = devfreq->dev.parent;
> @@ -1356,10 +1350,8 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
> }
>
> list_del(&governor->node);
> -err_out:
> - mutex_unlock(&devfreq_list_lock);
>
> - return err;
> + return 0;
> }
> EXPORT_SYMBOL(devfreq_remove_governor);
>
Reviewed-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
next prev parent reply other threads:[~2026-05-14 6:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 9:38 [PATCH v2 0/6] devfreq: Add refcounts for governor modules Jie Zhan
2026-05-13 9:38 ` [PATCH v2 1/6] devfreq: Use mutex guard in governor_store() Jie Zhan
2026-05-14 6:02 ` Yaxiong Tian
2026-05-13 9:38 ` [PATCH v2 2/6] devfreq: Use mutex guard in devfreq_add/remove_governor() Jie Zhan
2026-05-14 6:02 ` Yaxiong Tian [this message]
2026-05-13 9:38 ` [PATCH v2 3/6] devfreq: Factor out devfreq_set_governor() Jie Zhan
2026-05-14 6:09 ` Yaxiong Tian
2026-05-13 9:38 ` [PATCH v2 4/6] devfreq: Add module owner to devfreq governor Jie Zhan
2026-05-14 6:14 ` Yaxiong Tian
2026-05-13 9:38 ` [PATCH v2 5/6] devfreq: Get and put module refcount when switching governor Jie Zhan
2026-05-14 6:50 ` Yaxiong Tian
2026-05-13 9:38 ` [PATCH v2 6/6] devfreq: Get module refcount in try_then_request_governor() Jie Zhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55fbdfeb-28c0-458b-a3a5-2603fbbf41ea@kylinos.cn \
--to=tianyaxiong@kylinos.cn \
--cc=cw00.choi@samsung.com \
--cc=cwchoi00@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=lihuisong@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=myungjoo.ham@samsung.com \
--cc=prime.zeng@hisilicon.com \
--cc=zhangpengjie2@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox