diff mbox

[07/21] cpuidle: rearrange __cpuidle_register_device() to keep minimal exit points

Message ID 2dd257d9843954aaaf0cf30c7fb475daded018a5.1379779777.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar Sept. 22, 2013, 1:20 a.m. UTC
This patch rearranges __cpuidle_register_device() a bit in order to reduce the
number of exit points of this function.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpuidle/cpuidle.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Daniel Lezcano Sept. 25, 2013, 9:49 p.m. UTC | #1
On 09/22/2013 03:20 AM, Viresh Kumar wrote:
> This patch rearranges __cpuidle_register_device() a bit in order to reduce the
> number of exit points of this function.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpuidle/cpuidle.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 211e504..8c91bad 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -383,13 +383,12 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
>  	list_add(&dev->device_list, &cpuidle_detected_devices);
>  
>  	ret = cpuidle_coupled_register_device(dev);
> -	if (ret) {
> +	if (ret)
>  		__cpuidle_unregister_device(dev);
> -		return ret;
> -	}
> +	else
> +		dev->registered = 1;
>  
> -	dev->registered = 1;
> -	return 0;
> +	return ret;
>  }

There is no accounting for taste :)

I agree the patch concentrates more the return statement into a single
place which conforms better to the kernel coding style.
diff mbox

Patch

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 211e504..8c91bad 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -383,13 +383,12 @@  static int __cpuidle_register_device(struct cpuidle_device *dev)
 	list_add(&dev->device_list, &cpuidle_detected_devices);
 
 	ret = cpuidle_coupled_register_device(dev);
-	if (ret) {
+	if (ret)
 		__cpuidle_unregister_device(dev);
-		return ret;
-	}
+	else
+		dev->registered = 1;
 
-	dev->registered = 1;
-	return 0;
+	return ret;
 }
 
 /**