From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: "Mauro Carvalho Chehab" <mchehab@redhat.com>,
"Linux Input" <linux-input@vger.kernel.org>,
linux-media@vger.kernel.org, "Jarod Wilson" <jarod@redhat.com>,
"Maxim Levitsky" <maximlevitsky@gmail.com>,
"David Härdeman" <david@hardeman.nu>
Subject: Re: Handling of large keycodes
Date: Mon, 2 Aug 2010 01:06:04 -0700 [thread overview]
Message-ID: <20100802080604.GB9872@core.coreip.homeip.net> (raw)
In-Reply-To: <4C5402FE.2080002@s5r6.in-berlin.de>
On Sat, Jul 31, 2010 at 01:03:26PM +0200, Stefan Richter wrote:
> Dmitry Torokhov wrote:
> > --- a/include/linux/input.h
> > +++ b/include/linux/input.h
> > @@ -56,22 +56,35 @@ struct input_absinfo {
> > __s32 resolution;
> > };
> >
> > -struct keycode_table_entry {
> > - __u32 keycode; /* e.g. KEY_A */
> > - __u32 index; /* Index for the given scan/key table, on EVIOCGKEYCODEBIG */
> > - __u32 len; /* Length of the scancode */
> > - __u32 reserved[2]; /* Reserved for future usage */
> > - char *scancode; /* scancode, in machine-endian */
> > +/**
> > + * struct keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
> > + * @scancode: scancode represented in machine-endian form.
> > + * @len: length of the scancode that resides in @scancode buffer.
> > + * @index: index in the keymap, may be used instead of scancode
> > + * @by_index: boolean value indicating that kernel should perform
> > + * lookup in keymap by @index instead of @scancode
> > + * @keycode: key code assigned to this scancode
> > + *
> > + * The structure is used to retrieve and modify keymap data. Users have
> > + * of performing lookup either by @scancode itself or by @index in
> > + * keymap entry. EVIOCGKEYCODE will also return scancode or index
> > + * (depending on which element was used to perform lookup).
> > + */
> > +struct keymap_entry {
> > + __u8 len;
> > + __u8 by_index;
> > + __u16 index;
> > + __u32 keycode;
> > + __u8 scancode[32];
> > };
>
> I agree with Dimitry; don't put a pointer typed member into a userspace
> ABI struct.
>
> Two remarks:
>
> - Presently, <linux/input.h> defines three structs named input_... for
> userspace, two structs named input_... for kernelspace, and a few
> structs named ff_... specially for force-feedback stuff. How about
> calling struct keymap_entry perhaps struct input_keymap_entry
> instead, to keep namespaces tidy?
Good idea, changed.
>
> - I take it from your description that scan codes are fundamentally
> variable-length data. How about defining it as __u8 scancode[0]?
In addition to difficulty in adding members (as you mentioned) it also
makes it more difficult for users to allocate such variables on stack or
make them global (anything but malloc with additional memory buffer)...
--
Dmitry
next prev parent reply other threads:[~2010-08-02 8:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-31 9:19 Handling of large keycodes Dmitry Torokhov
2010-07-31 11:03 ` Stefan Richter
2010-07-31 11:14 ` Stefan Richter
2010-08-02 8:06 ` Dmitry Torokhov [this message]
2010-07-31 13:23 ` Mauro Carvalho Chehab
2010-08-02 8:02 ` Dmitry Torokhov
2010-08-02 11:35 ` Mauro Carvalho Chehab
2010-08-02 15:19 ` Jarod Wilson
2010-08-06 21:00 ` David Härdeman
2010-08-06 20:56 ` David Härdeman
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=20100802080604.GB9872@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=david@hardeman.nu \
--cc=jarod@redhat.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maximlevitsky@gmail.com \
--cc=mchehab@redhat.com \
--cc=stefanr@s5r6.in-berlin.de \
/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;
as well as URLs for NNTP newsgroup(s).