The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Re: [PATCH v3 3/4] PM / devfreq: Fix governor_store() failing when device has no current governor
       [not found] ` <20260430032035.75496-1-tianyaxiong@kylinos.cn>
@ 2026-05-10 12:50   ` Choi Chanwoo
  0 siblings, 0 replies; only message in thread
From: Choi Chanwoo @ 2026-05-10 12:50 UTC (permalink / raw)
  To: Yaxiong Tian
  Cc: cw00.choi, kyungmin.park, linux-kernel, linux-pm, myungjoo.ham,
	nm, zhanjie9



2026-04-30 PM 12:20에 Yaxiong Tian 이(가) 쓴 글:
> Since devfreq_remove_governor() may clear the device's current governor
> in certain situations, while governors actually exist independently
> of the device, directly returning EINVAL in this case is inaccurate.
> 
> To fix this issue, remove this check and add relevant logic for when
> df->governor is NULL.
> 
> Fixes: 483d557ee9a3 ("PM / devfreq: Clean up the devfreq instance name in sysfs attr")
> Co-developed-by: Choi Chanwoo <cwchoi00@gmail.com>
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
> ---
>  drivers/devfreq/devfreq.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 2977b07be939..76e3700577ca 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1390,9 +1390,6 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
>  	char str_governor[DEVFREQ_NAME_LEN + 1];
>  	const struct devfreq_governor *governor, *prev_governor;
>  
> -	if (!df->governor)
> -		return -EINVAL;
> -
>  	ret = sscanf(buf, "%" __stringify(DEVFREQ_NAME_LEN) "s", str_governor);
>  	if (ret != 1)
>  		return -EINVAL;
> @@ -1403,6 +1400,9 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
>  		ret = PTR_ERR(governor);
>  		goto out;
>  	}
> +	if (!df->governor)
> +		goto start_new_governor;
> +
>  	if (df->governor == governor) {
>  		ret = 0;
>  		goto out;
> @@ -1423,6 +1423,7 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
>  		goto out;
>  	}
>  
> +start_new_governor:
>  	/*
>  	 * Start the new governor and create the specific sysfs files
>  	 * which depend on the new governor.
> @@ -1436,6 +1437,9 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
>  
>  		/* Restore previous governor */
>  		df->governor = prev_governor;
> +		if (!df->governor)
> +			goto out;
> +
>  		ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL);
>  		if (ret) {
>  			dev_err(dev,

I'm sorr for late reply. I applied it.

Thanks,
Chanwoo Choi

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-10 12:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260401033119.67821-1-tianyaxiong@kylinos.cn>
     [not found] ` <20260430032035.75496-1-tianyaxiong@kylinos.cn>
2026-05-10 12:50   ` [PATCH v3 3/4] PM / devfreq: Fix governor_store() failing when device has no current governor Choi Chanwoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox