Re: [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools

2016-01-18 Thread Michael Trimarchi
Hi

On Mon, Jan 18, 2016 at 5:40 PM, Tom Rini  wrote:
> On Mon, Jan 18, 2016 at 09:23:54AM +0100, Michael Trimarchi wrote:
>> Hi
>>
>> On Sun, Jan 17, 2016 at 3:44 AM, Tom Rini  wrote:
>> > With gcc-5.3 we get a warning for using switch() on a bool type.
>> > Rewrite these sections as if/else and update the one section that was
>> > using 1/0 instead of true/false.
>> >
>> > Cc: Simon Glass 
>> > Cc: Przemyslaw Marczak 
>> > Signed-off-by: Tom Rini 
>> > ---
>> >  drivers/power/regulator/max77686.c | 28 
>> >  1 file changed, 8 insertions(+), 20 deletions(-)
>> >
>>
>> I never seen subject that contains the path of a driver.
>
> Uncommon but done sometimes.
>

Can you just fix it up and make more common? I think that patchwork
in general organize better the emails too

Michael


>>
>> Michael
>>
>> > diff --git a/drivers/power/regulator/max77686.c 
>> > b/drivers/power/regulator/max77686.c
>> > index 71678b6..7479af7 100644
>> > --- a/drivers/power/regulator/max77686.c
>> > +++ b/drivers/power/regulator/max77686.c
>> > @@ -515,25 +515,19 @@ static int max77686_ldo_enable(struct udevice *dev, 
>> > int op, bool *enable)
>> >
>> > switch (on_off) {
>> > case OPMODE_OFF:
>> > -   *enable = 0;
>> > +   *enable = false;
>> > break;
>> > case OPMODE_ON:
>> > -   *enable = 1;
>> > +   *enable = true;
>> > break;
>> > default:
>> > return -EINVAL;
>> > }
>> > } else if (op == PMIC_OP_SET) {
>> > -   switch (*enable) {
>> > -   case 0:
>> > -   on_off = OPMODE_OFF;
>> > -   break;
>> > -   case 1:
>> > +   if (*enable)
>> > on_off = OPMODE_ON;
>> > -   break;
>> > -   default:
>> > -   return -EINVAL;
>> > -   }
>> > +   else
>> > +   on_off = OPMODE_OFF;
>> >
>> > ret = max77686_ldo_mode(dev, op, &on_off);
>> > if (ret)
>> > @@ -651,16 +645,10 @@ static int max77686_buck_enable(struct udevice *dev, 
>> > int op, bool *enable)
>> > return -EINVAL;
>> > }
>> > } else if (op == PMIC_OP_SET) {
>> > -   switch (*enable) {
>> > -   case 0:
>> > -   on_off = OPMODE_OFF;
>> > -   break;
>> > -   case 1:
>> > +   if (*enable)
>> > on_off = OPMODE_ON;
>> > -   break;
>> > -   default:
>> > -   return -EINVAL;
>> > -   }
>> > +   else
>> > +   on_off = OPMODE_OFF;
>> >
>> > ret = max77686_buck_mode(dev, op, &on_off);
>> > if (ret)
>> > --
>> > 2.7.0.rc3
>> >
>> > ___
>> > U-Boot mailing list
>> > U-Boot@lists.denx.de
>> > http://lists.denx.de/mailman/listinfo/u-boot
>>
>>
>>
>> --
>> | Michael Nazzareno Trimarchi Amarula Solutions BV |
>> | COO  -  Founder  Cruquiuskade 47 |
>> | +31(0)851119172 Amsterdam 1018 AM NL |
>> |  [`as] http://www.amarulasolutions.com   |
>
> --
> Tom



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools

2016-01-18 Thread Tom Rini
On Mon, Jan 18, 2016 at 09:23:54AM +0100, Michael Trimarchi wrote:
> Hi
> 
> On Sun, Jan 17, 2016 at 3:44 AM, Tom Rini  wrote:
> > With gcc-5.3 we get a warning for using switch() on a bool type.
> > Rewrite these sections as if/else and update the one section that was
> > using 1/0 instead of true/false.
> >
> > Cc: Simon Glass 
> > Cc: Przemyslaw Marczak 
> > Signed-off-by: Tom Rini 
> > ---
> >  drivers/power/regulator/max77686.c | 28 
> >  1 file changed, 8 insertions(+), 20 deletions(-)
> >
> 
> I never seen subject that contains the path of a driver.

Uncommon but done sometimes.

> 
> Michael
> 
> > diff --git a/drivers/power/regulator/max77686.c 
> > b/drivers/power/regulator/max77686.c
> > index 71678b6..7479af7 100644
> > --- a/drivers/power/regulator/max77686.c
> > +++ b/drivers/power/regulator/max77686.c
> > @@ -515,25 +515,19 @@ static int max77686_ldo_enable(struct udevice *dev, 
> > int op, bool *enable)
> >
> > switch (on_off) {
> > case OPMODE_OFF:
> > -   *enable = 0;
> > +   *enable = false;
> > break;
> > case OPMODE_ON:
> > -   *enable = 1;
> > +   *enable = true;
> > break;
> > default:
> > return -EINVAL;
> > }
> > } else if (op == PMIC_OP_SET) {
> > -   switch (*enable) {
> > -   case 0:
> > -   on_off = OPMODE_OFF;
> > -   break;
> > -   case 1:
> > +   if (*enable)
> > on_off = OPMODE_ON;
> > -   break;
> > -   default:
> > -   return -EINVAL;
> > -   }
> > +   else
> > +   on_off = OPMODE_OFF;
> >
> > ret = max77686_ldo_mode(dev, op, &on_off);
> > if (ret)
> > @@ -651,16 +645,10 @@ static int max77686_buck_enable(struct udevice *dev, 
> > int op, bool *enable)
> > return -EINVAL;
> > }
> > } else if (op == PMIC_OP_SET) {
> > -   switch (*enable) {
> > -   case 0:
> > -   on_off = OPMODE_OFF;
> > -   break;
> > -   case 1:
> > +   if (*enable)
> > on_off = OPMODE_ON;
> > -   break;
> > -   default:
> > -   return -EINVAL;
> > -   }
> > +   else
> > +   on_off = OPMODE_OFF;
> >
> > ret = max77686_buck_mode(dev, op, &on_off);
> > if (ret)
> > --
> > 2.7.0.rc3
> >
> > ___
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
> 
> 
> 
> -- 
> | Michael Nazzareno Trimarchi Amarula Solutions BV |
> | COO  -  Founder  Cruquiuskade 47 |
> | +31(0)851119172 Amsterdam 1018 AM NL |
> |  [`as] http://www.amarulasolutions.com   |

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools

2016-01-18 Thread Michael Trimarchi
Hi

On Sun, Jan 17, 2016 at 3:44 AM, Tom Rini  wrote:
> With gcc-5.3 we get a warning for using switch() on a bool type.
> Rewrite these sections as if/else and update the one section that was
> using 1/0 instead of true/false.
>
> Cc: Simon Glass 
> Cc: Przemyslaw Marczak 
> Signed-off-by: Tom Rini 
> ---
>  drivers/power/regulator/max77686.c | 28 
>  1 file changed, 8 insertions(+), 20 deletions(-)
>

I never seen subject that contains the path of a driver.

Michael

> diff --git a/drivers/power/regulator/max77686.c 
> b/drivers/power/regulator/max77686.c
> index 71678b6..7479af7 100644
> --- a/drivers/power/regulator/max77686.c
> +++ b/drivers/power/regulator/max77686.c
> @@ -515,25 +515,19 @@ static int max77686_ldo_enable(struct udevice *dev, int 
> op, bool *enable)
>
> switch (on_off) {
> case OPMODE_OFF:
> -   *enable = 0;
> +   *enable = false;
> break;
> case OPMODE_ON:
> -   *enable = 1;
> +   *enable = true;
> break;
> default:
> return -EINVAL;
> }
> } else if (op == PMIC_OP_SET) {
> -   switch (*enable) {
> -   case 0:
> -   on_off = OPMODE_OFF;
> -   break;
> -   case 1:
> +   if (*enable)
> on_off = OPMODE_ON;
> -   break;
> -   default:
> -   return -EINVAL;
> -   }
> +   else
> +   on_off = OPMODE_OFF;
>
> ret = max77686_ldo_mode(dev, op, &on_off);
> if (ret)
> @@ -651,16 +645,10 @@ static int max77686_buck_enable(struct udevice *dev, 
> int op, bool *enable)
> return -EINVAL;
> }
> } else if (op == PMIC_OP_SET) {
> -   switch (*enable) {
> -   case 0:
> -   on_off = OPMODE_OFF;
> -   break;
> -   case 1:
> +   if (*enable)
> on_off = OPMODE_ON;
> -   break;
> -   default:
> -   return -EINVAL;
> -   }
> +   else
> +   on_off = OPMODE_OFF;
>
> ret = max77686_buck_mode(dev, op, &on_off);
> if (ret)
> --
> 2.7.0.rc3
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools

2016-01-18 Thread Przemyslaw Marczak

Hello Tom,

On 01/17/2016 03:44 AM, Tom Rini wrote:

With gcc-5.3 we get a warning for using switch() on a bool type.
Rewrite these sections as if/else and update the one section that was
using 1/0 instead of true/false.

Cc: Simon Glass 
Cc: Przemyslaw Marczak 
Signed-off-by: Tom Rini 
---
  drivers/power/regulator/max77686.c | 28 
  1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/power/regulator/max77686.c 
b/drivers/power/regulator/max77686.c
index 71678b6..7479af7 100644
--- a/drivers/power/regulator/max77686.c
+++ b/drivers/power/regulator/max77686.c
@@ -515,25 +515,19 @@ static int max77686_ldo_enable(struct udevice *dev, int 
op, bool *enable)

switch (on_off) {
case OPMODE_OFF:
-   *enable = 0;
+   *enable = false;
break;
case OPMODE_ON:
-   *enable = 1;
+   *enable = true;
break;
default:
return -EINVAL;
}
} else if (op == PMIC_OP_SET) {
-   switch (*enable) {
-   case 0:
-   on_off = OPMODE_OFF;
-   break;
-   case 1:
+   if (*enable)
on_off = OPMODE_ON;
-   break;
-   default:
-   return -EINVAL;
-   }
+   else
+   on_off = OPMODE_OFF;

ret = max77686_ldo_mode(dev, op, &on_off);
if (ret)
@@ -651,16 +645,10 @@ static int max77686_buck_enable(struct udevice *dev, int 
op, bool *enable)
return -EINVAL;
}
} else if (op == PMIC_OP_SET) {
-   switch (*enable) {
-   case 0:
-   on_off = OPMODE_OFF;
-   break;
-   case 1:
+   if (*enable)
on_off = OPMODE_ON;
-   break;
-   default:
-   return -EINVAL;
-   }
+   else
+   on_off = OPMODE_OFF;

ret = max77686_buck_mode(dev, op, &on_off);
if (ret)



Thank you for pointing that:)

Acked-by: Przemyslaw Marczak 

Best regards,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marc...@samsung.com
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools

2016-01-17 Thread Bin Meng
On Sun, Jan 17, 2016 at 10:44 AM, Tom Rini  wrote:
> With gcc-5.3 we get a warning for using switch() on a bool type.
> Rewrite these sections as if/else and update the one section that was
> using 1/0 instead of true/false.
>
> Cc: Simon Glass 
> Cc: Przemyslaw Marczak 
> Signed-off-by: Tom Rini 
> ---
>  drivers/power/regulator/max77686.c | 28 
>  1 file changed, 8 insertions(+), 20 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot