From: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
To: rjw@rjwysocki.net, lenb@kernel.org, linux-acpi@vger.kernel.org
Cc: andriy.shevchenko@linux.intel.com,
Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Subject: [PATCH 4/4] ACPI / battery: get rid of negations in conditions
Date: Fri, 12 Jan 2018 15:58:47 +0200 [thread overview]
Message-ID: <20180112135847.14989-5-dmitry.rozhkov@linux.intel.com> (raw)
In-Reply-To: <20180112135847.14989-1-dmitry.rozhkov@linux.intel.com>
Simple conditions without negations inflict less cognitive load
on readers.
Rework conditional branches not to use negations. Also add braces
around single statement branches where their counterpart else-branches
consist of more than one statement as suggested in the paragraph 3 of
the coding style.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
---
drivers/acpi/battery.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 36c525bc38ba..38b5eed72685 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -848,7 +848,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
acpi_battery_units(battery));
seq_printf(seq, "battery technology: %srechargeable\n",
- (!battery->technology)?"non-":"");
+ battery->technology ? "" : "non-");
if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "design voltage: unknown\n");
@@ -1135,7 +1135,9 @@ static int battery_notify(struct notifier_block *nb,
if (!acpi_battery_present(battery))
return 0;
- if (!battery->bat) {
+ if (battery->bat) {
+ acpi_battery_refresh(battery);
+ } else {
result = acpi_battery_get_info(battery);
if (result)
return result;
@@ -1143,8 +1145,7 @@ static int battery_notify(struct notifier_block *nb,
result = sysfs_add_battery(battery);
if (result)
return result;
- } else
- acpi_battery_refresh(battery);
+ }
acpi_battery_init_alarm(battery);
acpi_battery_get_state(battery);
--
2.13.6
prev parent reply other threads:[~2018-01-12 13:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 13:58 cleanups for acpi/battery.c Dmitry Rozhkov
2018-01-12 13:58 ` [PATCH 1/4] ACPI / battery: drop inclusion of init.h Dmitry Rozhkov
2018-01-12 13:58 ` [PATCH 2/4] ACPI / battery: reorder headers alphabetically Dmitry Rozhkov
2018-01-12 13:58 ` [PATCH 3/4] ACPI / battery: use specialized print macros Dmitry Rozhkov
2018-01-12 18:52 ` Andy Shevchenko
2018-01-12 13:58 ` Dmitry Rozhkov [this message]
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=20180112135847.14989-5-dmitry.rozhkov@linux.intel.com \
--to=dmitry.rozhkov@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.