Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1604512 > unrolled thread

[PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event handling

Started byMichał Kępień <kernel@kempniu.pl>
First post2017-03-20 13:50 +0100
Last post2017-03-24 12:00 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event handling Michał Kępień <kernel@kempniu.pl> - 2017-03-20 13:50 +0100
    [PATCH 4/8] platform/x86: fujitsu-laptop: move hotkey input device setup to a separate function Michał Kępień <kernel@kempniu.pl> - 2017-03-20 13:50 +0100
    Re: [PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event  handling Jonathan Woithe <jwoithe@just42.net> - 2017-03-24 12:00 +0100

#1604512 — [PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event handling

FromMichał Kępień <kernel@kempniu.pl>
Date2017-03-20 13:50 +0100
Subject[PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event handling
Message-ID<tn4V3-4Nu-5@gated-at.bofh.it>
This series simplifies handling of both brightness key and hotkey input
events on Fujitsu laptops by making use of sparse keymaps.  This not
only makes the driver shorter and, hopefully, cleaner, but also enables
us to get rid of the keycodeX fields inside struct fujitsu_bl, which
facilitates further cleanups.  Also, to simplify error handling, input
devices registered by fujitsu-laptop are migrated to the devres API
along the way.

This series was tested on a Lifebook S7020 and a Lifebook E744.

This series depends on the platform cleanup series I posted last week.
While that series has not yet been merged into testing, Jonathan has
reviewed it and Darren also seemed to be okay with it, so I just assumed
it will get merged soon.  I wanted to post this one as soon as possible
as it requires a bit more thorough review and testing compared to the
previous series I posted for fujitsu-laptop.

 drivers/platform/x86/Kconfig          |   1 +
 drivers/platform/x86/fujitsu-laptop.c | 355 +++++++++++++++-------------------
 2 files changed, 154 insertions(+), 202 deletions(-)

-- 
2.12.0

[toc] | [next] | [standalone]


#1604513 — [PATCH 4/8] platform/x86: fujitsu-laptop: move hotkey input device setup to a separate function

FromMichał Kępień <kernel@kempniu.pl>
Date2017-03-20 13:50 +0100
Subject[PATCH 4/8] platform/x86: fujitsu-laptop: move hotkey input device setup to a separate function
Message-ID<tn4V5-4Nu-49@gated-at.bofh.it>
In reply to#1604512
Simplify error handling in acpi_fujitsu_laptop_add() by moving code
responsible for setting up the input device to a separate function.

Signed-off-by: Michał Kępień <kernel@kempniu.pl>
---
 drivers/platform/x86/fujitsu-laptop.c | 74 ++++++++++++++++++++---------------
 1 file changed, 43 insertions(+), 31 deletions(-)

diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 3483ac37bee5..b1a08d83330b 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -756,6 +756,46 @@ static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
 
 /* ACPI device for hotkey handling */
 
+static int acpi_fujitsu_laptop_input_setup(struct acpi_device *device)
+{
+	struct fujitsu_laptop *fujitsu_laptop = acpi_driver_data(device);
+	struct input_dev *input;
+	int error;
+
+	fujitsu_laptop->input = input = input_allocate_device();
+	if (!input)
+		return -ENOMEM;
+
+	snprintf(fujitsu_laptop->phys, sizeof(fujitsu_laptop->phys),
+		 "%s/video/input0", acpi_device_hid(device));
+
+	input->name = acpi_device_name(device);
+	input->phys = fujitsu_laptop->phys;
+	input->id.bustype = BUS_HOST;
+	input->id.product = 0x06;
+	input->dev.parent = &device->dev;
+
+	set_bit(EV_KEY, input->evbit);
+	set_bit(fujitsu_bl->keycode1, input->keybit);
+	set_bit(fujitsu_bl->keycode2, input->keybit);
+	set_bit(fujitsu_bl->keycode3, input->keybit);
+	set_bit(fujitsu_bl->keycode4, input->keybit);
+	set_bit(fujitsu_bl->keycode5, input->keybit);
+	set_bit(KEY_TOUCHPAD_TOGGLE, input->keybit);
+	set_bit(KEY_UNKNOWN, input->keybit);
+
+	error = input_register_device(input);
+	if (error)
+		goto err_free_input_dev;
+
+	return 0;
+
+err_free_input_dev:
+	input_free_device(input);
+
+	return error;
+}
+
 static int fujitsu_laptop_platform_add(void)
 {
 	int ret;
@@ -794,7 +834,6 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
 {
 	int result = 0;
 	int state = 0;
-	struct input_dev *input;
 	int error;
 	int i;
 
@@ -816,33 +855,9 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
 		goto err_stop;
 	}
 
-	fujitsu_laptop->input = input = input_allocate_device();
-	if (!input) {
-		error = -ENOMEM;
-		goto err_free_fifo;
-	}
-
-	snprintf(fujitsu_laptop->phys, sizeof(fujitsu_laptop->phys),
-		 "%s/video/input0", acpi_device_hid(device));
-
-	input->name = acpi_device_name(device);
-	input->phys = fujitsu_laptop->phys;
-	input->id.bustype = BUS_HOST;
-	input->id.product = 0x06;
-	input->dev.parent = &device->dev;
-
-	set_bit(EV_KEY, input->evbit);
-	set_bit(fujitsu_bl->keycode1, input->keybit);
-	set_bit(fujitsu_bl->keycode2, input->keybit);
-	set_bit(fujitsu_bl->keycode3, input->keybit);
-	set_bit(fujitsu_bl->keycode4, input->keybit);
-	set_bit(fujitsu_bl->keycode5, input->keybit);
-	set_bit(KEY_TOUCHPAD_TOGGLE, input->keybit);
-	set_bit(KEY_UNKNOWN, input->keybit);
-
-	error = input_register_device(input);
+	error = acpi_fujitsu_laptop_input_setup(device);
 	if (error)
-		goto err_free_input_dev;
+		goto err_free_fifo;
 
 	error = acpi_bus_update_power(fujitsu_laptop->acpi_handle, &state);
 	if (error) {
@@ -960,10 +975,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
 	return result;
 
 err_unregister_input_dev:
-	input_unregister_device(input);
-	input = NULL;
-err_free_input_dev:
-	input_free_device(input);
+	input_unregister_device(fujitsu_laptop->input);
 err_free_fifo:
 	kfifo_free(&fujitsu_laptop->fifo);
 err_stop:
-- 
2.12.0

[toc] | [prev] | [next] | [standalone]


#1608310 — Re: [PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event handling

FromJonathan Woithe <jwoithe@just42.net>
Date2017-03-24 12:00 +0100
SubjectRe: [PATCH 0/8] fujitsu-laptop: use sparse keymaps for input event handling
Message-ID<tov6O-la-9@gated-at.bofh.it>
In reply to#1604512
On Mon, Mar 20, 2017 at 10:32:16AM +0100, Micha?? K??pie?? wrote:
> This series simplifies handling of both brightness key and hotkey input
> events on Fujitsu laptops by making use of sparse keymaps.  This not
> only makes the driver shorter and, hopefully, cleaner, but also enables
> us to get rid of the keycodeX fields inside struct fujitsu_bl, which
> facilitates further cleanups.  Also, to simplify error handling, input
> devices registered by fujitsu-laptop are migrated to the devres API
> along the way.
> 
> This series was tested on a Lifebook S7020 and a Lifebook E744.
> 
> This series depends on the platform cleanup series I posted last week.
> While that series has not yet been merged into testing, Jonathan has
> reviewed it and Darren also seemed to be okay with it, so I just assumed
> it will get merged soon.  I wanted to post this one as soon as possible
> as it requires a bit more thorough review and testing compared to the
> previous series I posted for fujitsu-laptop.

Thanks for posting this.  I have started going through this and hope to
complete my review by the end of this weekend.

Regards
  jonathan

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web