summaryrefslogtreecommitdiff
path: root/src/backlight
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-22 23:45:55 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-22 23:45:55 +0900
commitb77c92993442840bed328bd9a68796390e02650e (patch)
tree98a61f3bc45e28beb79edd8f4960d7a5acc8ddc6 /src/backlight
parentd17d66f0abb597584e0a15b5348f2709fe36a3d7 (diff)
downloadsystemd-b77c92993442840bed328bd9a68796390e02650e.tar.gz
backlight: reindent comments
Diffstat (limited to 'src/backlight')
-rw-r--r--src/backlight/backlight.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 836dc37850..86927be62e 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -135,19 +135,14 @@ static int validate_device(sd_device *device) {
assert(device);
- /* Verify whether we should actually care for a specific
- * backlight device. For backlight devices there might be
- * multiple ways to access the same control: "firmware"
- * (i.e. ACPI), "platform" (i.e. via the machine's EC) and
- * "raw" (via the graphics card). In general we should prefer
- * "firmware" (i.e. ACPI) or "platform" access over "raw"
- * access, in order not to confuse the BIOS/EC, and
- * compatibility with possible low-level hotkey handling of
- * screen brightness. The kernel will already make sure to
- * expose only one of "firmware" and "platform" for the same
- * device to userspace. However, we still need to make sure
- * that we use "raw" only if no "firmware" or "platform"
- * device for the same device exists. */
+ /* Verify whether we should actually care for a specific backlight device. For backlight devices
+ * there might be multiple ways to access the same control: "firmware" (i.e. ACPI), "platform"
+ * (i.e. via the machine's EC) and "raw" (via the graphics card). In general we should prefer
+ * "firmware" (i.e. ACPI) or "platform" access over "raw" access, in order not to confuse the
+ * BIOS/EC, and compatibility with possible low-level hotkey handling of screen brightness. The
+ * kernel will already make sure to expose only one of "firmware" and "platform" for the same
+ * device to userspace. However, we still need to make sure that we use "raw" only if no
+ * "firmware" or "platform" device for the same device exists. */
r = sd_device_get_subsystem(device, &subsystem);
if (r < 0)
@@ -192,9 +187,8 @@ static int validate_device(sd_device *device) {
!STR_IN_SET(v, "platform", "firmware"))
continue;
- /* OK, so there's another backlight device, and it's a
- * platform or firmware device, so, let's see if we
- * can verify it belongs to the same device as ours. */
+ /* OK, so there's another backlight device, and it's a platform or firmware device.
+ * Let's see if we can verify it belongs to the same device as ours. */
if (find_pci_or_platform_parent(other, &other_parent) < 0)
continue;
@@ -255,11 +249,6 @@ static int get_max_brightness(sd_device *device, unsigned *ret) {
return 0;
}
-/* Some systems turn the backlight all the way off at the lowest levels.
- * clamp_brightness clamps the saved brightness to at least 1 or 5% of
- * max_brightness in case of 'backlight' subsystem. This avoids preserving
- * an unreadably dim screen, which would otherwise force the user to
- * disable state restoration. */
static int clamp_brightness(sd_device *device, bool saved, unsigned max_brightness, unsigned *brightness) {
unsigned new_brightness, min_brightness;
const char *subsystem;
@@ -268,6 +257,11 @@ static int clamp_brightness(sd_device *device, bool saved, unsigned max_brightne
assert(device);
assert(brightness);
+ /* Some systems turn the backlight all the way off at the lowest levels. This clamps the saved
+ * brightness to at least 1 or 5% of max_brightness in case of 'backlight' subsystem. This
+ * avoids preserving an unreadably dim screen, which would otherwise force the user to disable
+ * state restoration. */
+
r = sd_device_get_subsystem(device, &subsystem);
if (r < 0)
return log_device_warning_errno(device, r, "Failed to get device subsystem: %m");
@@ -410,9 +404,8 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to get backlight or LED device '%s:%s': %m", ss, sysname);
- /* If max_brightness is 0, then there is no actual backlight
- * device. This happens on desktops with Asus mainboards
- * that load the eeepc-wmi module. */
+ /* If max_brightness is 0, then there is no actual backlight device. This happens on desktops
+ * with Asus mainboards that load the eeepc-wmi module. */
if (get_max_brightness(device, &max_brightness) < 0)
return 0;
@@ -433,14 +426,11 @@ static int run(int argc, char *argv[]) {
} else
saved = strjoina("/var/lib/systemd/backlight/", escaped_ss, ":", escaped_sysname);
- /* If there are multiple conflicting backlight devices, then
- * their probing at boot-time might happen in any order. This
- * means the validity checking of the device then is not
- * reliable, since it might not see other devices conflicting
- * with a specific backlight. To deal with this, we will
- * actively delete backlight state files at shutdown (where
- * device probing should be complete), so that the validity
- * check at boot time doesn't have to be reliable. */
+ /* If there are multiple conflicting backlight devices, then their probing at boot-time might
+ * happen in any order. This means the validity checking of the device then is not reliable,
+ * since it might not see other devices conflicting with a specific backlight. To deal with
+ * this, we will actively delete backlight state files at shutdown (where device probing should
+ * be complete), so that the validity check at boot time doesn't have to be reliable. */
if (streq(argv[1], "load")) {
_cleanup_free_ char *value = NULL;