diff mbox

[1/4] cpu: clean up register_cpu func

Message ID 1471595114-1688-1-git-send-email-alex.shi@linaro.org
State Accepted
Commit 59fffa34069d80662b41438b11130771b4e2a897
Headers show

Commit Message

Alex Shi Aug. 19, 2016, 8:25 a.m. UTC
This patch could reduce one branch in this function. Also
make the code more readble.

Signed-off-by: Alex Shi <alex.shi@linaro.org>

To: linux-kernel@vger.kernel.org
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/base/cpu.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

-- 
2.8.1.101.g72d917a

Comments

Alex Shi Aug. 22, 2016, 3:26 a.m. UTC | #1
Is there any comments for this patch series?

Thanks!

On 08/19/2016 04:25 PM, Alex Shi wrote:
> This patch could reduce one branch in this function. Also

> make the code more readble.

> 

> Signed-off-by: Alex Shi <alex.shi@linaro.org>

> To: linux-kernel@vger.kernel.org

> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---

>  drivers/base/cpu.c | 11 ++++++-----

>  1 file changed, 6 insertions(+), 5 deletions(-)

> 

> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c

> index 691eeea..4c28e1a 100644

> --- a/drivers/base/cpu.c

> +++ b/drivers/base/cpu.c

> @@ -371,12 +371,13 @@ int register_cpu(struct cpu *cpu, int num)

>  	if (cpu->hotpluggable)

>  		cpu->dev.groups = hotplugable_cpu_attr_groups;

>  	error = device_register(&cpu->dev);

> -	if (!error)

> -		per_cpu(cpu_sys_devices, num) = &cpu->dev;

> -	if (!error)

> -		register_cpu_under_node(num, cpu_to_node(num));

> +	if (error)

> +		return error;

>  

> -	return error;

> +	per_cpu(cpu_sys_devices, num) = &cpu->dev;

> +	register_cpu_under_node(num, cpu_to_node(num));

> +

> +	return 0;

>  }

>  

>  struct device *get_cpu_device(unsigned cpu)

>
Daniel Lezcano Aug. 22, 2016, 4:52 p.m. UTC | #2
On 08/19/2016 10:25 AM, Alex Shi wrote:
> This patch could reduce one branch in this function. Also

> make the code more readble.

> 

> Signed-off-by: Alex Shi <alex.shi@linaro.org>

> To: linux-kernel@vger.kernel.org

> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---


Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
diff mbox

Patch

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 691eeea..4c28e1a 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -371,12 +371,13 @@  int register_cpu(struct cpu *cpu, int num)
 	if (cpu->hotpluggable)
 		cpu->dev.groups = hotplugable_cpu_attr_groups;
 	error = device_register(&cpu->dev);
-	if (!error)
-		per_cpu(cpu_sys_devices, num) = &cpu->dev;
-	if (!error)
-		register_cpu_under_node(num, cpu_to_node(num));
+	if (error)
+		return error;
 
-	return error;
+	per_cpu(cpu_sys_devices, num) = &cpu->dev;
+	register_cpu_under_node(num, cpu_to_node(num));
+
+	return 0;
 }
 
 struct device *get_cpu_device(unsigned cpu)