All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <markgross@kernel.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	platform-driver-x86@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes
Date: Fri, 4 Mar 2022 16:19:25 +0300	[thread overview]
Message-ID: <20220304131925.GG28739@kili> (raw)

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


             reply	other threads:[~2022-03-04 13:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 13:19 Dan Carpenter [this message]
2022-03-04 15:33 ` [PATCH] platform/x86/intel-uncore-freq: fix uncore_freq_common_init() error codes srinivas pandruvada
2022-03-08 15:21 ` Hans de Goede

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=20220304131925.GG28739@kili \
    --to=dan.carpenter@oracle.com \
    --cc=hdegoede@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@linux.intel.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 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.