All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes
@ 2022-03-04 13:19 Dan Carpenter
  2022-03-04 15:33 ` srinivas pandruvada
  2022-03-08 15:21 ` Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-03-04 13:19 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Hans de Goede, Mark Gross, Rafael J. Wysocki,
	platform-driver-x86, kernel-janitors

Currently the uncore_freq_common_init() return one on success and
zero on failure.  There is only one caller and it has a "forgot to set
the error code" bug.  Change uncore_freq_common_init() to return
negative error codes which makes the code simpler and avoids this kind
of bug in the future.

Fixes: dbce412a7733 ("platform/x86/intel-uncore-freq: Split common and enumeration part")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 .../x86/intel/uncore-frequency/uncore-frequency-common.c        | 2 +-
 drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index e4d5a7960234..84eabd6156bb 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -231,7 +231,7 @@ int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, u
 		++uncore_instance_count;
 	mutex_unlock(&uncore_lock);
 
-	return (!!uncore_root_kobj);
+	return uncore_root_kobj ? 0 : -ENOMEM;
 }
 EXPORT_SYMBOL_NS_GPL(uncore_freq_common_init, INTEL_UNCORE_FREQUENCY);
 
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
index 791af0e287e4..c61f804dd44e 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
@@ -225,7 +225,7 @@ static int __init intel_uncore_init(void)
 
 	ret = uncore_freq_common_init(uncore_read_control_freq, uncore_write_control_freq,
 				      uncore_read_freq);
-	if (!ret)
+	if (ret)
 		goto err_free;
 
 	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
-- 
2.20.1


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

* Re: [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes
  2022-03-04 13:19 [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes Dan Carpenter
@ 2022-03-04 15:33 ` srinivas pandruvada
  2022-03-08 15:21 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: srinivas pandruvada @ 2022-03-04 15:33 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hans de Goede, Mark Gross, Rafael J. Wysocki,
	platform-driver-x86, kernel-janitors

On Fri, 2022-03-04 at 16:19 +0300, Dan Carpenter wrote:
> Currently the uncore_freq_common_init() return one on success and
> zero on failure.  There is only one caller and it has a "forgot to
> set
> the error code" bug.  Change uncore_freq_common_init() to return
> negative error codes which makes the code simpler and avoids this
> kind
> of bug in the future.
> 
> Fixes: dbce412a7733 ("platform/x86/intel-uncore-freq: Split common
> and enumeration part")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  .../x86/intel/uncore-frequency/uncore-frequency-common.c        | 2
> +-
>  drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c  | 2
> +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-
> frequency-common.c b/drivers/platform/x86/intel/uncore-
> frequency/uncore-frequency-common.c
> index e4d5a7960234..84eabd6156bb 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c
> @@ -231,7 +231,7 @@ int uncore_freq_common_init(int
> (*read_control_freq)(struct uncore_data *data, u
>                 ++uncore_instance_count;
>         mutex_unlock(&uncore_lock);
>  
> -       return (!!uncore_root_kobj);
> +       return uncore_root_kobj ? 0 : -ENOMEM;
>  }
>  EXPORT_SYMBOL_NS_GPL(uncore_freq_common_init,
> INTEL_UNCORE_FREQUENCY);
>  
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-
> frequency.c b/drivers/platform/x86/intel/uncore-frequency/uncore-
> frequency.c
> index 791af0e287e4..c61f804dd44e 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
> @@ -225,7 +225,7 @@ static int __init intel_uncore_init(void)
>  
>         ret = uncore_freq_common_init(uncore_read_control_freq,
> uncore_write_control_freq,
>                                       uncore_read_freq);
> -       if (!ret)
> +       if (ret)
>                 goto err_free;
>  
>         ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,


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

* Re: [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes
  2022-03-04 13:19 [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes Dan Carpenter
  2022-03-04 15:33 ` srinivas pandruvada
@ 2022-03-08 15:21 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2022-03-08 15:21 UTC (permalink / raw)
  To: Dan Carpenter, Srinivas Pandruvada
  Cc: Mark Gross, Rafael J. Wysocki, platform-driver-x86, kernel-janitors

Hi,

On 3/4/22 14:19, Dan Carpenter wrote:
> Currently the uncore_freq_common_init() return one on success and
> zero on failure.  There is only one caller and it has a "forgot to set
> the error code" bug.  Change uncore_freq_common_init() to return
> negative error codes which makes the code simpler and avoids this kind
> of bug in the future.
> 
> Fixes: dbce412a7733 ("platform/x86/intel-uncore-freq: Split common and enumeration part")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
>  .../x86/intel/uncore-frequency/uncore-frequency-common.c        | 2 +-
>  drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> index e4d5a7960234..84eabd6156bb 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> @@ -231,7 +231,7 @@ int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, u
>  		++uncore_instance_count;
>  	mutex_unlock(&uncore_lock);
>  
> -	return (!!uncore_root_kobj);
> +	return uncore_root_kobj ? 0 : -ENOMEM;
>  }
>  EXPORT_SYMBOL_NS_GPL(uncore_freq_common_init, INTEL_UNCORE_FREQUENCY);
>  
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
> index 791af0e287e4..c61f804dd44e 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c
> @@ -225,7 +225,7 @@ static int __init intel_uncore_init(void)
>  
>  	ret = uncore_freq_common_init(uncore_read_control_freq, uncore_write_control_freq,
>  				      uncore_read_freq);
> -	if (!ret)
> +	if (ret)
>  		goto err_free;
>  
>  	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,


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

end of thread, other threads:[~2022-03-08 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 13:19 [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes Dan Carpenter
2022-03-04 15:33 ` srinivas pandruvada
2022-03-08 15:21 ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.