Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1560504 > unrolled thread
| Started by | Michał Kępień <kernel@kempniu.pl> |
|---|---|
| First post | 2017-01-17 12:20 +0100 |
| Last post | 2017-01-17 12:20 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] platform/x86: fujitsu-laptop: simplify brightness key event generation logic Michał Kępień <kernel@kempniu.pl> - 2017-01-17 12:20 +0100
| From | Michał Kępień <kernel@kempniu.pl> |
|---|---|
| Date | 2017-01-17 12:20 +0100 |
| Subject | [PATCH 2/2] platform/x86: fujitsu-laptop: simplify brightness key event generation logic |
| Message-ID | <t0zXX-6py-1@gated-at.bofh.it> |
Returning early when there is no brightness change allows removal of a
duplicate code block, makes the purpose of the following code clearer
and allows the condition surrounding key event generation to be removed.
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
---
drivers/platform/x86/fujitsu-laptop.c | 37 +++++++++++++----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 35c1319b7c8e..37b0fcecff51 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -800,7 +800,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
return;
}
- keycode = 0;
oldb = fujitsu->brightness_level;
get_lcd_level();
newb = fujitsu->brightness_level;
@@ -809,30 +808,22 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
"brightness button event [%i -> %i (%i)]\n",
oldb, newb, fujitsu->brightness_changed);
- if (oldb < newb) {
- if (disable_brightness_adjust != 1) {
- if (use_alt_lcd_levels)
- set_lcd_level_alt(newb);
- else
- set_lcd_level(newb);
- }
- keycode = KEY_BRIGHTNESSUP;
- } else if (oldb > newb) {
- if (disable_brightness_adjust != 1) {
- if (use_alt_lcd_levels)
- set_lcd_level_alt(newb);
- else
- set_lcd_level(newb);
- }
- keycode = KEY_BRIGHTNESSDOWN;
- }
+ if (oldb == newb)
+ return;
- if (keycode != 0) {
- input_report_key(input, keycode, 1);
- input_sync(input);
- input_report_key(input, keycode, 0);
- input_sync(input);
+ if (disable_brightness_adjust != 1) {
+ if (use_alt_lcd_levels)
+ set_lcd_level_alt(newb);
+ else
+ set_lcd_level(newb);
}
+
+ keycode = oldb < newb ? KEY_BRIGHTNESSUP : KEY_BRIGHTNESSDOWN;
+
+ input_report_key(input, keycode, 1);
+ input_sync(input);
+ input_report_key(input, keycode, 0);
+ input_sync(input);
}
/* ACPI device for hotkey handling */
--
2.11.0
Back to top | Article view | linux.kernel
csiph-web