Skip to content

Commit

Permalink
ACPI / battery: get rid of negations in conditions
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Dmitry Rozhkov authored and Rafael J. Wysocki committed Jul 25, 2018
1 parent dd1fca9 commit 2754435
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ static int acpi_battery_info_proc_show(struct seq_file *seq, void *offset)
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");
Expand Down Expand Up @@ -1111,11 +1111,12 @@ static int acpi_battery_alarm_proc_show(struct seq_file *seq, void *offset)
goto end;
}
seq_printf(seq, "alarm: ");
if (!battery->alarm)
seq_printf(seq, "unsupported\n");
else
if (battery->alarm) {
seq_printf(seq, "%u %sh\n", battery->alarm,
acpi_battery_units(battery));
} else {
seq_printf(seq, "unsupported\n");
}
end:
if (result)
seq_printf(seq, "ERROR: Unable to read battery alarm\n");
Expand Down Expand Up @@ -1148,9 +1149,9 @@ static ssize_t acpi_battery_write_alarm(struct file *file,
}
result = acpi_battery_set_alarm(battery);
end:
if (!result)
return count;
return result;
if (result)
return result;
return count;
}

static int acpi_battery_alarm_proc_open(struct inode *inode, struct file *file)
Expand Down Expand Up @@ -1245,16 +1246,17 @@ 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;

result = sysfs_add_battery(battery);
if (result)
return result;
} else
acpi_battery_refresh(battery);
}

acpi_battery_init_alarm(battery);
acpi_battery_get_state(battery);
Expand Down

0 comments on commit 2754435

Please sign in to comment.