platform/x86: fujitsu-laptop: simplify brightness key event generation logic
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. Local integer variables can also be declared in a single line. Signed-off-by: Michał Kępień <kernel@kempniu.pl> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-and-tested-by: Jonathan Woithe <jwoithe@just42.net>
This commit is contained in:
Родитель
5efc800463
Коммит
d2aa3ae86d
|
@ -790,8 +790,7 @@ static int acpi_fujitsu_bl_remove(struct acpi_device *device)
|
||||||
static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
|
static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
|
||||||
{
|
{
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
int keycode;
|
int oldb, newb, keycode;
|
||||||
int oldb, newb;
|
|
||||||
|
|
||||||
input = fujitsu_bl->input;
|
input = fujitsu_bl->input;
|
||||||
|
|
||||||
|
@ -806,7 +805,6 @@ static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
keycode = 0;
|
|
||||||
oldb = fujitsu_bl->brightness_level;
|
oldb = fujitsu_bl->brightness_level;
|
||||||
get_lcd_level();
|
get_lcd_level();
|
||||||
newb = fujitsu_bl->brightness_level;
|
newb = fujitsu_bl->brightness_level;
|
||||||
|
@ -815,30 +813,22 @@ static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
|
||||||
"brightness button event [%i -> %i (%i)]\n",
|
"brightness button event [%i -> %i (%i)]\n",
|
||||||
oldb, newb, fujitsu_bl->brightness_changed);
|
oldb, newb, fujitsu_bl->brightness_changed);
|
||||||
|
|
||||||
if (oldb < newb) {
|
if (oldb == newb)
|
||||||
if (disable_brightness_adjust != 1) {
|
return;
|
||||||
if (use_alt_lcd_levels)
|
|
||||||
set_lcd_level_alt(newb);
|
if (disable_brightness_adjust != 1) {
|
||||||
else
|
if (use_alt_lcd_levels)
|
||||||
set_lcd_level(newb);
|
set_lcd_level_alt(newb);
|
||||||
}
|
else
|
||||||
keycode = KEY_BRIGHTNESSUP;
|
set_lcd_level(newb);
|
||||||
} 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 (keycode != 0) {
|
keycode = oldb < newb ? KEY_BRIGHTNESSUP : KEY_BRIGHTNESSDOWN;
|
||||||
input_report_key(input, keycode, 1);
|
|
||||||
input_sync(input);
|
input_report_key(input, keycode, 1);
|
||||||
input_report_key(input, keycode, 0);
|
input_sync(input);
|
||||||
input_sync(input);
|
input_report_key(input, keycode, 0);
|
||||||
}
|
input_sync(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ACPI device for hotkey handling */
|
/* ACPI device for hotkey handling */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче