From: Joe Perches <joe@perches.com>
To: ycho1399@gmail.com, linux-input@vger.kernel.org
Cc: voyandrea@gmail.com, andrea.ho@advantech.com.tw,
oakley.ding@advantech.com.tw,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Rob Herring <robh@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Luca Weiss <luca@z3ntu.xyz>,
Maximilian Luz <luzmaximilian@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Thomas Gleixner <tglx@linutronix.de>, Pavel Machek <pavel@ucw.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [V1,1/1] Input/misc: add support for Advantech software defined button
Date: Thu, 27 Feb 2020 00:11:02 -0800 [thread overview]
Message-ID: <3ec7521233aed6e1c2d27f387b7b2d2b55694e84.camel@perches.com> (raw)
In-Reply-To: <20200227031721.17703-1-Andrea.Ho@advantech.com.tw>
On Thu, 2020-02-27 at 03:15 +0000, ycho1399@gmail.com wrote:
> From: "Andrea.Ho" <Andrea.Ho@advantech.com.tw>
>
> Advantech sw_button is a ACPI event trigger button.
>
> With this driver, we can report KEY_EVENTs on the
> Advantech Tabletop Network Appliances products and it has been
> tested in FWA1112VC.
>
> Add the software define button support to report KEY_EVENTs by
> different acts of pressing button (like double-click, long pressed
> and tick) that cloud be get on user interface and trigger the
> customized actions.
[]
> diff --git a/drivers/input/misc/adv_swbutton.c b/drivers/input/misc/adv_swbutton.c
> new file mode 100644
mostly trivia:
> +/*
> + * Switch two elements in array.
> + *
> + * @param xp, yp The array elements need to swap.
> + */
> +void array_swap(unsigned int *xp, unsigned int *yp)
> +{
> + int temp = *xp;
> + *xp = *yp;
> + *yp = temp;
> +}
kernel.h has swap
> +/*
> + * Sorting an array in ascending order
> + *
> + * @param arr The array for sorting.
> + * @param n The array size
> + */
> +void sort_asc(unsigned int arr[], int n)
> +{
> + int i, j, min_idx;
> +
> + for (i = 0; i < n - 1; i++) {
> + min_idx = i;
> + for (j = i + 1; j < n; j++)
> + if (arr[j] < arr[min_idx])
> + min_idx = j;
> +
> + array_swap(&arr[min_idx], &arr[i]);
> + }
> +}
sort.h has a generic sort too
> +
> +/*
> + * initial software button timer to check tick or double click
> + *
> + * @param btn Struct of acpi_button that should be required.
> + */
> +static void swbtn_init_timer(struct acpi_button *btn)
> +{
> + pr_info(PREFIX "swbtn timer start\n");
Many of these printks should be removed and ftrace used
when necessary.
> +static int acpi_button_add(struct acpi_device *device)
> +{
> + struct acpi_button *button;
> + struct input_dev *input;
> + const char *hid = acpi_device_hid(device);
> + char *name, *class;
> + int error, i;
> +
> + pr_info(PREFIX "%s\n", __func__);
> + button = kzalloc(sizeof(*button), GFP_KERNEL);
> + if (!button) {
> + pr_err(PREFIX "alloc acpi_button failed\n");
alloc failure messages aren't really necessary
as a dump_stack() is already done on failure.
[]
> + for (i = (!swbtn_cfg.dclick_enabled);
> + i < (swbtn_cfg.lkey_number + 2); i++) {
> + pr_info(PREFIX "%d. Enabled keycode[0x%x]\n",
> + i, swbtn_keycodes[i]);
Is it really useful to print all enabled keycodes?
next prev parent reply other threads:[~2020-02-27 8:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 3:15 ycho1399
2020-02-27 7:22 ` Greg Kroah-Hartman
2020-02-27 8:11 ` Joe Perches [this message]
2020-02-27 8:56 ` Pavel Machek
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=3ec7521233aed6e1c2d27f387b7b2d2b55694e84.camel@perches.com \
--to=joe@perches.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=andrea.ho@advantech.com.tw \
--cc=bgolaszewski@baylibre.com \
--cc=davem@davemloft.net \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca@z3ntu.xyz \
--cc=luzmaximilian@gmail.com \
--cc=mchehab+samsung@kernel.org \
--cc=oakley.ding@advantech.com.tw \
--cc=pavel@ucw.cz \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
--cc=voyandrea@gmail.com \
--cc=ycho1399@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®