LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw()
@ 2024-04-24 11:40 Dan Carpenter
  2024-04-24 15:53 ` Andre Przywara
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-04-24 11:40 UTC (permalink / raw
  To: Andre Przywara
  Cc: Yangtao Li, Rafael J. Wysocki, Viresh Kumar, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, linux-pm, linux-arm-kernel,
	linux-sunxi, linux-kernel, kernel-janitors

The dt_has_supported_hw() function returns type bool.  That means these
negative error codes are cast to true but the function should return
false instead.

Fixes: fa5aec9561cf ("cpufreq: sun50i: Add support for opp_supported_hw")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/cpufreq/sun50i-cpufreq-nvmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
index cd50cea16a87..0b882765cd66 100644
--- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
@@ -136,11 +136,11 @@ static bool dt_has_supported_hw(void)
 
 	cpu_dev = get_cpu_device(0);
 	if (!cpu_dev)
-		return -ENODEV;
+		return false;
 
 	np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
 	if (!np)
-		return -ENOENT;
+		return false;
 
 	for_each_child_of_node(np, opp) {
 		if (of_find_property(opp, "opp-supported-hw", NULL)) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw()
  2024-04-24 11:40 [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw() Dan Carpenter
@ 2024-04-24 15:53 ` Andre Przywara
  2024-04-24 19:01 ` Jernej Škrabec
  2024-04-25  5:08 ` Viresh Kumar
  2 siblings, 0 replies; 4+ messages in thread
From: Andre Przywara @ 2024-04-24 15:53 UTC (permalink / raw
  To: Dan Carpenter
  Cc: Yangtao Li, Rafael J. Wysocki, Viresh Kumar, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, linux-pm, linux-arm-kernel,
	linux-sunxi, linux-kernel, kernel-janitors

On Wed, 24 Apr 2024 14:40:11 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:

Hi Dan,

thanks for having a look!

> The dt_has_supported_hw() function returns type bool.  That means these
> negative error codes are cast to true but the function should return
> false instead.

Ouch, of course! I refactored the function during development, but missed
that part.

> Fixes: fa5aec9561cf ("cpufreq: sun50i: Add support for opp_supported_hw")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Thanks,
Andre

> ---
>  drivers/cpufreq/sun50i-cpufreq-nvmem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> index cd50cea16a87..0b882765cd66 100644
> --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> @@ -136,11 +136,11 @@ static bool dt_has_supported_hw(void)
>  
>  	cpu_dev = get_cpu_device(0);
>  	if (!cpu_dev)
> -		return -ENODEV;
> +		return false;
>  
>  	np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
>  	if (!np)
> -		return -ENOENT;
> +		return false;
>  
>  	for_each_child_of_node(np, opp) {
>  		if (of_find_property(opp, "opp-supported-hw", NULL)) {


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw()
  2024-04-24 11:40 [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw() Dan Carpenter
  2024-04-24 15:53 ` Andre Przywara
@ 2024-04-24 19:01 ` Jernej Škrabec
  2024-04-25  5:08 ` Viresh Kumar
  2 siblings, 0 replies; 4+ messages in thread
From: Jernej Škrabec @ 2024-04-24 19:01 UTC (permalink / raw
  To: Andre Przywara, Dan Carpenter
  Cc: Yangtao Li, Rafael J. Wysocki, Viresh Kumar, Chen-Yu Tsai,
	Samuel Holland, linux-pm, linux-arm-kernel, linux-sunxi,
	linux-kernel, kernel-janitors

Dne sreda, 24. april 2024 ob 13:40:11 GMT +2 je Dan Carpenter napisal(a):
> The dt_has_supported_hw() function returns type bool.  That means these
> negative error codes are cast to true but the function should return
> false instead.
> 
> Fixes: fa5aec9561cf ("cpufreq: sun50i: Add support for opp_supported_hw")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

> ---
>  drivers/cpufreq/sun50i-cpufreq-nvmem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> index cd50cea16a87..0b882765cd66 100644
> --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> @@ -136,11 +136,11 @@ static bool dt_has_supported_hw(void)
>  
>  	cpu_dev = get_cpu_device(0);
>  	if (!cpu_dev)
> -		return -ENODEV;
> +		return false;
>  
>  	np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
>  	if (!np)
> -		return -ENOENT;
> +		return false;
>  
>  	for_each_child_of_node(np, opp) {
>  		if (of_find_property(opp, "opp-supported-hw", NULL)) {
> 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw()
  2024-04-24 11:40 [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw() Dan Carpenter
  2024-04-24 15:53 ` Andre Przywara
  2024-04-24 19:01 ` Jernej Škrabec
@ 2024-04-25  5:08 ` Viresh Kumar
  2 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2024-04-25  5:08 UTC (permalink / raw
  To: Dan Carpenter
  Cc: Andre Przywara, Yangtao Li, Rafael J. Wysocki, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, linux-pm, linux-arm-kernel,
	linux-sunxi, linux-kernel, kernel-janitors

On 24-04-24, 14:40, Dan Carpenter wrote:
> The dt_has_supported_hw() function returns type bool.  That means these
> negative error codes are cast to true but the function should return
> false instead.
> 
> Fixes: fa5aec9561cf ("cpufreq: sun50i: Add support for opp_supported_hw")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/cpufreq/sun50i-cpufreq-nvmem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-25  5:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 11:40 [PATCH] cpufreq: sun50i: fix error returns in dt_has_supported_hw() Dan Carpenter
2024-04-24 15:53 ` Andre Przywara
2024-04-24 19:01 ` Jernej Škrabec
2024-04-25  5:08 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).