From: Chase Douglas <chase.douglas@canonical.com>
To: Seth Forshee <seth.forshee@canonical.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Alessandro Rubini <rubini@cvml.unipv.it>,
Henrik Rydberg <rydberg@euromail.se>,
Andrew Skalski <askalski@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/7] Input: ALPS - Remove assumptions about packet size
Date: Sun, 30 Oct 2011 11:36:19 -0400 [thread overview]
Message-ID: <4EAD6EF3.50109@canonical.com> (raw)
In-Reply-To: <1319663681-11244-5-git-send-email-seth.forshee@canonical.com>
On 10/26/2011 05:14 PM, Seth Forshee wrote:
> In preparation for version 4 protocol support, which has 8-byte
> data packets, remove all hard-coded assumptions about packet size
> and use psmouse->pktsize instead.
>
> Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
> ---
> drivers/input/mouse/alps.c | 27 ++++++++++++++++++---------
> 1 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index 572cb21..14d1f64 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -315,7 +315,7 @@ static void alps_flush_packet(unsigned long data)
>
> serio_pause_rx(psmouse->ps2dev.serio);
>
> - if (psmouse->pktcnt == 6) {
> + if (psmouse->pktcnt == psmouse->pktsize) {
>
> /*
> * We did not any more data in reasonable amount of time.
> @@ -365,15 +365,15 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
> return PSMOUSE_BAD_DATA;
> }
>
> - /* Bytes 2 - 6 should have 0 in the highest bit */
> - if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
> + /* Bytes 2 - pktsize should have 0 in the highest bit */
> + if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
> (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
> dbg("refusing packet[%i] = %x\n",
> psmouse->pktcnt - 1, psmouse->packet[psmouse->pktcnt - 1]);
> return PSMOUSE_BAD_DATA;
> }
>
> - if (psmouse->pktcnt == 6) {
> + if (psmouse->pktcnt == psmouse->pktsize) {
> alps_process_packet(psmouse);
> return PSMOUSE_FULL_PACKET;
> }
> @@ -531,8 +531,13 @@ static int alps_tap_mode(struct psmouse *psmouse, int enable)
> static int alps_poll(struct psmouse *psmouse)
> {
> struct alps_data *priv = psmouse->private;
> - unsigned char buf[6];
> + unsigned char *buf;
> bool poll_failed;
> + int ret = -1;
> +
> + buf = kmalloc(psmouse->pktsize, GFP_KERNEL);
> + if (!buf)
> + return -1;
Can we preallocate a buffer somewhere instead of allocating every time
we enter the function? If we know the maximum packet size we could
allocate on the stack instead.
-- Chase
next prev parent reply other threads:[~2011-10-30 15:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-26 21:14 [PATCH 0/7] Additional ALPS touchpad protocol support Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-26 21:14 ` [PATCH 1/7] Input: ALPS - Move protocol information to Documentation Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:33 ` Chase Douglas
2011-10-31 18:15 ` Seth Forshee
2011-10-26 21:14 ` [PATCH 2/7] Input: psmouse - Add PSMOUSE_CMD_RESET_WRAP Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:33 ` Chase Douglas
2011-10-26 21:14 ` [PATCH 3/7] Input: ALPS - Add protocol version field in alps_model_info Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:34 ` Chase Douglas
2011-10-26 21:14 ` [PATCH 4/7] Input: ALPS - Remove assumptions about packet size Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:36 ` Chase Douglas [this message]
2011-10-31 18:17 ` Seth Forshee
2011-10-31 18:24 ` Dmitry Torokhov
2011-10-31 18:24 ` Dmitry Torokhov
2011-10-31 20:01 ` Seth Forshee
2011-10-26 21:14 ` [PATCH 5/7] Input: ALPS - Add support for protocol versions 3 and 4 Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:37 ` Chase Douglas
2011-10-26 21:14 ` [PATCH 6/7] Input: ALPS - Add semi-MT support for v3 protocol Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:44 ` Chase Douglas
2011-10-26 21:14 ` [PATCH 7/7] Input: ALPS - Add documentation for protocol versions 3 and 4 Seth Forshee
2011-10-26 21:14 ` Seth Forshee
2011-10-30 15:46 ` Chase Douglas
2011-10-26 21:22 ` [PATCH 0/7] Additional ALPS touchpad protocol support Chris Friesen
2011-10-26 21:22 ` Chris Friesen
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=4EAD6EF3.50109@canonical.com \
--to=chase.douglas@canonical.com \
--cc=askalski@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rubini@cvml.unipv.it \
--cc=rydberg@euromail.se \
--cc=seth.forshee@canonical.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 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.