Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1580553 > unrolled thread

[PATCH] Power: Supply: sbs-charger: simplfied bool function

Started byDaniel Perez <danielperezdeandres@gmail.com>
First post2017-02-14 14:50 +0100
Last post2017-02-14 15:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Power: Supply: sbs-charger: simplfied bool function Daniel Perez <danielperezdeandres@gmail.com> - 2017-02-14 14:50 +0100
    Re: [PATCH] Power: Supply: sbs-charger: simplfied bool function Joe Perches <joe@perches.com> - 2017-02-14 15:10 +0100

#1580553 — [PATCH] Power: Supply: sbs-charger: simplfied bool function

FromDaniel Perez <danielperezdeandres@gmail.com>
Date2017-02-14 14:50 +0100
Subject[PATCH] Power: Supply: sbs-charger: simplfied bool function
Message-ID<taLEu-2wc-23@gated-at.bofh.it>
Simplified the syntax of a simple bool return value function.

Signed-off-by: Daniel Perez <danielperezdeandres@gmail.com>
---
 drivers/power/supply/sbs-charger.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/power/supply/sbs-charger.c b/drivers/power/supply/sbs-charger.c
index 353765a..3e40553 100644
--- a/drivers/power/supply/sbs-charger.c
+++ b/drivers/power/supply/sbs-charger.c
@@ -137,10 +137,7 @@ static enum power_supply_property sbs_properties[] = {
 
 static bool sbs_readable_reg(struct device *dev, unsigned int reg)
 {
-	if (reg < SBS_CHARGER_REG_SPEC_INFO)
-		return false;
-	else
-		return true;
+	return reg < SBS_CHARGER_REG_SPEC_INFO ? false : true;
 }
 
 static bool sbs_volatile_reg(struct device *dev, unsigned int reg)
-- 
2.7.4

[toc] | [next] | [standalone]


#1580563

FromJoe Perches <joe@perches.com>
Date2017-02-14 15:10 +0100
Message-ID<taLXP-2S6-5@gated-at.bofh.it>
In reply to#1580553
On Tue, 2017-02-14 at 14:43 +0100, Daniel Perez wrote:
> Simplified the syntax of a simple bool return value function.
> 
> Signed-off-by: Daniel Perez <danielperezdeandres@gmail.com>
> ---
>  drivers/power/supply/sbs-charger.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/sbs-charger.c b/drivers/power/supply/sbs-charger.c
> index 353765a..3e40553 100644
> --- a/drivers/power/supply/sbs-charger.c
> +++ b/drivers/power/supply/sbs-charger.c
> @@ -137,10 +137,7 @@ static enum power_supply_property sbs_properties[] = {
>  
>  static bool sbs_readable_reg(struct device *dev, unsigned int reg)
>  {
> -	if (reg < SBS_CHARGER_REG_SPEC_INFO)
> -		return false;
> -	else
> -		return true;
> +	return reg < SBS_CHARGER_REG_SPEC_INFO ? false : true;

Any ternary with true false could be simplified.
Why not just

	return reg >= SBS_CHARGER_REG_SPEC_INFO;

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web