From: Stephen Warren <swarren@wwwdotorg.org>
To: Viresh Kumar <viresh.kumar@st.com>
Cc: dmitry.torokhov@gmail.com, devicetree-discuss@lists.ozlabs.org,
spear-devel@list.st.com, viresh.linux@gmail.com,
linux-input@vger.kernel.org, sr@denx.de
Subject: Re: [PATCH V3 1/2] Input: of_keymap: Introduce matrix_keypad_of_build_keymap()
Date: Thu, 29 Mar 2012 09:44:35 -0600 [thread overview]
Message-ID: <4F748363.6040400@wwwdotorg.org> (raw)
In-Reply-To: <69c5aad139fbbf4e99134c414a819e1cf3f6dd84.1333009670.git.viresh.kumar@st.com>
On 03/29/2012 02:33 AM, Viresh Kumar wrote:
> We don't need to allocate memory for keymap in matrix_keyboard_of_fill_keymap(),
> as this would only be used by matrix_keyboard_of_free_keymap(). Instead create
> another routine matrix_keypad_of_build_keymap() which reads directly the
> property from struct device_node and builds keymap.
>
> With this eariler routines matrix_keyboard_of_fill_keymap() and
> matrix_keyboard_of_free_keymap() go away.
>
> This patch also fixes tegra driver according to these changes.
> diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
> -static struct tegra_kbc_platform_data * __devinit
> -tegra_kbc_dt_parse_pdata(struct platform_device *pdev)
> +static struct tegra_kbc_platform_data *
> +__devinit tegra_kbc_dt_parse_pdata(struct device_node *np)
I'd be tempted to keep __devinit on the first line, but not a big deal.
> +int matrix_keypad_of_build_keymap(struct input_dev *idev,
> + unsigned int row_shift, const char *propname)
> + size = proplen / sizeof(u32);
> + if (size > idev->keycodemax) {
> + dev_err(dev, "OF: %s overflow\n", propname);
> + return -EINVAL;
> }
That is checking the number of entries in the property, not the values
of the MATRIX_SCAN_CODE values derived from those entries. I'd say just
remove this check. See below.
> + keycode = idev->keycode;
>
> + for (i = 0; i < size; i++) {
> + unsigned int key = be32_to_cpup(prop + i);
> + unsigned int row = KEY_ROW(key);
> + unsigned int col = KEY_COL(key);
> + unsigned short code = KEY_VAL(key);
>
> + if (col >= col_range) {
> + dev_err(dev, "OF: %s: column %x overflowed its range %d\n",
> + propname, col, col_range);
> + return -EINVAL;
> + }
That check is good.
> + keycode[MATRIX_SCAN_CODE(row, col, row_shift)] = code;
But, you also need to do something like:
scancode = MATRIX_SCAN_CODE(row, col, row_shift);
if (scancode >= idev->keycodemax) {
error out;
}
keycode[scancode] = code;
> + __set_bit(code, idev->keybit);
> }
> + __clear_bit(KEY_RESERVED, idev->keybit);
> +
> + return 0;
> }
next prev parent reply other threads:[~2012-03-29 15:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 8:33 [PATCH V3 0/2] Input: Add matrix_keypad_of_build_keymap() Viresh Kumar
2012-03-29 8:33 ` [PATCH V3 1/2] Input: of_keymap: Introduce matrix_keypad_of_build_keymap() Viresh Kumar
2012-03-29 15:44 ` Stephen Warren [this message]
2012-03-29 16:31 ` viresh kumar
2012-03-30 3:38 ` Viresh Kumar
2012-03-29 8:33 ` [PATCH V3 2/2] Input: spear-keyboard: add device tree bindings Viresh Kumar
2012-05-09 5:28 ` Dmitry Torokhov
2012-05-09 6:53 ` Viresh Kumar
2012-05-15 6:54 ` viresh kumar
2012-05-17 21:31 ` Dmitry Torokhov
2012-03-30 3:33 ` [PATCH v4 1/2] Input: of_keymap: Introduce matrix_keypad_of_build_keymap() Viresh Kumar
2012-03-30 3:55 ` Viresh Kumar
2012-03-30 3:40 ` [PATCH V4 Resend " Viresh Kumar
2012-03-30 18:45 ` Stephen Warren
2012-04-02 3:33 ` Viresh Kumar
2012-04-02 4:01 ` [PATCH] fixup! " Viresh Kumar
2012-04-05 0:45 ` Dmitry Torokhov
2012-04-05 3:52 ` Viresh Kumar
2012-04-17 11:32 ` Viresh Kumar
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=4F748363.6040400@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=spear-devel@list.st.com \
--cc=sr@denx.de \
--cc=viresh.kumar@st.com \
--cc=viresh.linux@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 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.