From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools
Date: Mon, 18 Jan 2016 09:16:14 +0100 [thread overview]
Message-ID: <569C9F4E.2070209@samsung.com> (raw)
In-Reply-To: <1452998677-30803-1-git-send-email-trini@konsulko.com>
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 <sjg@chromium.org>
> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
> 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 <p.marczak@samsung.com>
Best regards,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
next prev parent reply other threads:[~2016-01-18 8:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-17 2:44 [U-Boot] [PATCH] drivers/power/regulator/max77686.c: Don't use switch() on bools Tom Rini
2016-01-18 5:05 ` Bin Meng
2016-01-18 8:16 ` Przemyslaw Marczak [this message]
2016-01-18 8:23 ` Michael Trimarchi
2016-01-18 16:40 ` Tom Rini
2016-01-18 16:41 ` Michael Trimarchi
2016-01-19 18:08 ` [U-Boot] " Tom Rini
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=569C9F4E.2070209@samsung.com \
--to=p.marczak@samsung.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox