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


Groups > linux.kernel > #1202442

Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro 3 buttons

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro 3 buttons
Date 2015-08-07 10:30 +0200
Message-ID <pULcl-2og-3@gated-at.bofh.it> (permalink)
References <pUKJj-1Az-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, 2015-08-07 at 15:57 +0800, Chen Yu wrote:
> Since Surface Pro 3 does not follow the specs of "Windows ACPI Design
> Guide for SoC Platform", code in drivers/input/misc/soc_array.c can
> not detect these buttons on it.

The comments below are all just style trivia
and can be ignored entirely.

> diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c
[]
> +#define handle_surface_button_notify(type, code)		\
> +({								\
> +	int ret = 0;						\
> +	if (SURFACE_BUTTON_NOTIFY_PRESS_##type == event)	\
> +		pressed = true;					\
> +	if (pressed ||						\
> +		 (SURFACE_BUTTON_NOTIFY_RELEASE_##type == event)) {	\
> +		key_code = code;				\
> +		ret = 1;					\
> +	} else							\
> +		ret = 0;					\
> +	ret;							\
> +})

This seems a bit complicated.

The else ret = 0 isn't necessary as it's initialized to 0.
bool might be better than int.

> +static void surface_button_notify(struct acpi_device *device, u32 event)
> +{
> +	struct surface_button *button = acpi_driver_data(device);
> +	struct input_dev *input;
> +	int key_code = KEY_RESERVED;
> +	bool pressed = false;
> +
> +	if (!handle_surface_button_notify(POWER, KEY_POWER) &&
> +		!handle_surface_button_notify(HOME, KEY_LEFTMETA) &&
> +		!handle_surface_button_notify(VOLUME_UP, KEY_VOLUMEUP) &&
> +		!handle_surface_button_notify(VOLUME_DOWN, KEY_VOLUMEDOWN))
> +		dev_info_ratelimited(&device->dev,
> +			"Unsupported event [0x%x]\n", event);

Some might prefer alignment to the open parenthesis:

	if (!handle_surface_button_notify(POWER, KEY_POWER) &&
	    !handle_surface_button_notify(HOME, KEY_LEFTMETA) &&
	    !handle_surface_button_notify(VOLUME_UP, KEY_VOLUMEUP) &&
	    !handle_surface_button_notify(VOLUME_DOWN, KEY_VOLUMEDOWN))

I think the older switch/case was easier to understand.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] [v2] surface pro 3: Add support driver for Surface Pro 3 buttons Chen Yu <yu.c.chen@intel.com> - 2015-08-07 10:00 +0200
  Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro  3 buttons Joe Perches <joe@perches.com> - 2015-08-07 10:30 +0200
    Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro  3 buttons "Chen, Yu C" <yu.c.chen@intel.com> - 2015-08-07 10:50 +0200
      Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro 3  buttons Darren Hart <dvhart@infradead.org> - 2015-08-11 04:50 +0200
        Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro  3 buttons Yu Chen <yu.c.chen@intel.com> - 2015-08-18 03:40 +0200

csiph-web