diff mbox series

cpufreq: sun50i: fix error returns in dt_has_supported_hw()

Message ID 9bfe5703-b39b-4d98-9995-f6a7d0ea558d@moroto.mountain (mailing list archive)
State New
Delegated to: viresh kumar
Headers show
Series cpufreq: sun50i: fix error returns in dt_has_supported_hw() | expand

Commit Message

Dan Carpenter April 24, 2024, 11:40 a.m. UTC
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(-)

Comments

Andre Przywara April 24, 2024, 3:53 p.m. UTC | #1
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)) {
Jernej Škrabec April 24, 2024, 7:01 p.m. UTC | #2
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)) {
>
Viresh Kumar April 25, 2024, 5:08 a.m. UTC | #3
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.
diff mbox series

Patch

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)) {