All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Kępień" <kernel@kempniu.pl>
To: Jonathan Woithe <jwoithe@just42.net>, Darren Hart <dvhart@infradead.org>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] platform/x86: fujitsu-laptop: decrease indentation in acpi_fujitsu_notify()
Date: Tue, 17 Jan 2017 12:07:34 +0100	[thread overview]
Message-ID: <20170117110735.2543-2-kernel@kempniu.pl> (raw)
In-Reply-To: <20170117110735.2543-1-kernel@kempniu.pl>

acpi_fujitsu_notify() is pretty deeply nested, which hurts readability.
Strip off one level of indentation by returning early when the event
code supplied as argument is not ACPI_FUJITSU_NOTIFY_CODE1.

Signed-off-by: Michał Kępień <kernel@kempniu.pl>
---
Changes introduced by this patch are best viewed when whitespace changes
are ignored.

 drivers/platform/x86/fujitsu-laptop.c | 64 ++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 96f8163d5002..35c1319b7c8e 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -789,40 +789,42 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
 
 	input = fujitsu->input;
 
-	switch (event) {
-	case ACPI_FUJITSU_NOTIFY_CODE1:
-		keycode = 0;
-		oldb = fujitsu->brightness_level;
-		get_lcd_level();
-		newb = fujitsu->brightness_level;
-
-		vdbg_printk(FUJLAPTOP_DBG_TRACE,
-			    "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;
-		}
-		break;
-	default:
+	if (event != ACPI_FUJITSU_NOTIFY_CODE1) {
 		keycode = KEY_UNKNOWN;
 		vdbg_printk(FUJLAPTOP_DBG_WARN,
 			    "unsupported event [0x%x]\n", event);
-		break;
+		input_report_key(input, keycode, 1);
+		input_sync(input);
+		input_report_key(input, keycode, 0);
+		input_sync(input);
+		return;
+	}
+
+	keycode = 0;
+	oldb = fujitsu->brightness_level;
+	get_lcd_level();
+	newb = fujitsu->brightness_level;
+
+	vdbg_printk(FUJLAPTOP_DBG_TRACE,
+		    "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 (keycode != 0) {
-- 
2.11.0

  reply	other threads:[~2017-01-17 11:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 11:07 [PATCH 0/2] fujitsu-laptop: acpi_fujitsu_notify() cleanup Michał Kępień
2017-01-17 11:07 ` Michał Kępień [this message]
2017-01-17 11:07 ` [PATCH 2/2] platform/x86: fujitsu-laptop: simplify brightness key event generation logic Michał Kępień
2017-01-17 11:19 ` [PATCH 0/2] fujitsu-laptop: acpi_fujitsu_notify() cleanup Jonathan Woithe
2017-02-03 14:08   ` Michał Kępień

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=20170117110735.2543-2-kernel@kempniu.pl \
    --to=kernel@kempniu.pl \
    --cc=dvhart@infradead.org \
    --cc=jwoithe@just42.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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.