All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Juri Lelli <juri.lelli@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux@arm.linux.org.uk, Will Deacon <will.deacon@arm.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	arnd.bergmann@linaro.org, linux-kernel@vger.kernel.org
Subject: [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from topology_parse_cpu_capacity()
Date: Wed, 21 Jun 2017 10:16:43 +0530	[thread overview]
Message-ID: <2213a1f0657ef057dd775085943b362dc3e9757d.1498019799.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1498019799.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1498019799.git.viresh.kumar@linaro.org>

Use the standard way of returning errors instead of returning 0(failure)
OR 1(success) and making it hard to read.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm/kernel/topology.c   | 2 +-
 drivers/base/arch_topology.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index bf949a763dbe..a7ef4c35855e 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -111,7 +111,7 @@ static void __init parse_dt_topology(void)
 			continue;
 		}
 
-		if (topology_parse_cpu_capacity(cn, cpu)) {
+		if (!topology_parse_cpu_capacity(cn, cpu)) {
 			of_node_put(cn);
 			continue;
 		}
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 07784ba666a7..ff8713b83090 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -121,11 +121,11 @@ void topology_normalize_cpu_scale(void)
 
 int __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
 {
-	int ret = 1;
+	int ret;
 	u32 cpu_capacity;
 
 	if (cap_parsing_failed)
-		return !ret;
+		return -EINVAL;
 
 	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
 				   &cpu_capacity);
@@ -137,7 +137,7 @@ int __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
 			if (!raw_capacity) {
 				pr_err("cpu_capacity: failed to allocate memory for raw capacities\n");
 				cap_parsing_failed = true;
-				return 0;
+				return -ENOMEM;
 			}
 		}
 		capacity_scale = max(cpu_capacity, capacity_scale);
@@ -154,7 +154,7 @@ int __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
 		kfree(raw_capacity);
 	}
 
-	return !ret;
+	return ret;
 }
 
 #ifdef CONFIG_CPU_FREQ
-- 
2.13.0.71.gd7076ec9c9cb

WARNING: multiple messages have this Message-ID (diff)
From: viresh.kumar@linaro.org (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from topology_parse_cpu_capacity()
Date: Wed, 21 Jun 2017 10:16:43 +0530	[thread overview]
Message-ID: <2213a1f0657ef057dd775085943b362dc3e9757d.1498019799.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1498019799.git.viresh.kumar@linaro.org>

Use the standard way of returning errors instead of returning 0(failure)
OR 1(success) and making it hard to read.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm/kernel/topology.c   | 2 +-
 drivers/base/arch_topology.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index bf949a763dbe..a7ef4c35855e 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -111,7 +111,7 @@ static void __init parse_dt_topology(void)
 			continue;
 		}
 
-		if (topology_parse_cpu_capacity(cn, cpu)) {
+		if (!topology_parse_cpu_capacity(cn, cpu)) {
 			of_node_put(cn);
 			continue;
 		}
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 07784ba666a7..ff8713b83090 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -121,11 +121,11 @@ void topology_normalize_cpu_scale(void)
 
 int __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
 {
-	int ret = 1;
+	int ret;
 	u32 cpu_capacity;
 
 	if (cap_parsing_failed)
-		return !ret;
+		return -EINVAL;
 
 	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
 				   &cpu_capacity);
@@ -137,7 +137,7 @@ int __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
 			if (!raw_capacity) {
 				pr_err("cpu_capacity: failed to allocate memory for raw capacities\n");
 				cap_parsing_failed = true;
-				return 0;
+				return -ENOMEM;
 			}
 		}
 		capacity_scale = max(cpu_capacity, capacity_scale);
@@ -154,7 +154,7 @@ int __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
 		kfree(raw_capacity);
 	}
 
-	return !ret;
+	return ret;
 }
 
 #ifdef CONFIG_CPU_FREQ
-- 
2.13.0.71.gd7076ec9c9cb

  parent reply	other threads:[~2017-06-21  4:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21  4:46 [PATCH V2 0/5] arch_topology: Minor cleanups Viresh Kumar
2017-06-21  4:46 ` Viresh Kumar
2017-06-21  4:46 ` [PATCH V2 1/5] arch_topology: Get rid of "cap_parsing_done" Viresh Kumar
2017-06-21  4:46   ` Viresh Kumar
2017-06-22  9:44   ` Juri Lelli
2017-06-22  9:44     ` Juri Lelli
2017-06-22 14:29     ` Viresh Kumar
2017-06-22 14:29       ` Viresh Kumar
2017-06-22 16:44       ` Juri Lelli
2017-06-22 16:44         ` Juri Lelli
2017-06-21  4:46 ` [PATCH V2 2/5] arch_topology: Don't break lines unnecessarily Viresh Kumar
2017-06-21  4:46   ` Viresh Kumar
2017-06-21  4:46 ` [PATCH V2 3/5] arch_topology: Covert switch block to if block Viresh Kumar
2017-06-21  4:46   ` Viresh Kumar
2017-06-21  4:46 ` Viresh Kumar [this message]
2017-06-21  4:46   ` [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from topology_parse_cpu_capacity() Viresh Kumar
2017-06-22  9:39   ` Juri Lelli
2017-06-22  9:39     ` Juri Lelli
2017-06-22 14:28     ` Viresh Kumar
2017-06-22 14:28       ` Viresh Kumar
2017-06-22 16:43       ` Juri Lelli
2017-06-22 16:43         ` Juri Lelli
2017-06-21  4:46 ` [PATCH V2 5/5] arch_topology: Localize cap_parsing_failed to topology_parse_cpu_capacity() Viresh Kumar
2017-06-21  4:46   ` Viresh Kumar

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=2213a1f0657ef057dd775085943b362dc3e9757d.1498019799.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=arnd.bergmann@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=juri.lelli@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=vincent.guittot@linaro.org \
    --cc=will.deacon@arm.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.