From: Dmitry Torokhov <dtor@insightbb.com>
To: Adrian McMenamin <lkmladrian@gmail.com>
Cc: Paul Mundt <lethal@linux-sh.org>,
linuxsh-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Add support for keyboard on SEGA Dreamcast
Date: Tue, 4 Sep 2007 23:04:50 -0400 [thread overview]
Message-ID: <200709042304.51510.dtor@insightbb.com> (raw)
In-Reply-To: <8b67d60709041634l198d29f0ja049989acdb30b67@mail.gmail.com>
Hi Adrian,
On Tuesday 04 September 2007 19:34, Adrian McMenamin wrote:
> This patch will add support for the Dreamcast keyboard when used
> alongside the maple bus patch (http://lkml.org/lkml/2007/9/4/165) and
> the pvr2 patch.
>
> Signed off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
>
Thnank you very much for your patch. Couple of comments:
> +
> +static unsigned char dc_kbd_keycode[256] = {
Const?
> +
> +static int dc_kbd_connect(struct maple_device *dev)
> +{
> + int i, retval;
> + unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
> + struct dc_kbd *kbd;
> + if (dev->function != MAPLE_FUNC_KEYBOARD)
> + return -EINVAL;
> +
> + kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
> + if (unlikely(!kbd))
> + return -ENOMEM;
> +
> + dev->private_data = kbd;
> + kbd->dev = input_allocate_device();
> + if (unlikely(!kbd->dev))
> + goto cleanup;
> +
> + kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
> +
> + for (i = 0; i < 255; i++)
> + set_bit(dc_kbd_keycode[i], kbd->dev->keybit);
> +
> + clear_bit(0, kbd->dev->keybit);
> +
> + kbd->dev->private = kbd;
> +
> + kbd->dev->name = dev->product_name;
> + kbd->dev->id.bustype = BUS_MAPLE;
Do we really need a new bus type? Would not BUS_HOST suffice?
> +
> + retval = input_register_device(kbd->dev);
> + if (unlikely(retval))
> + goto cleanup;
> +
> + maple_getcond_callback(dev, dc_kbd_callback, (25 * HZ) / 1000,
> + MAPLE_FUNC_KEYBOARD);
> +
> + printk(KERN_INFO "input: keyboard(0x%lx): %s\n", data,
> + kbd->dev->name);
Input core already prints a line when a new input device is registered,
do we need another one?
> +
> + return 0;
> +
> + cleanup:
> + kfree(kbd);
> + return -EINVAL;
It loks like call to input_free_device() is missing here. You would leak
memory if input_register_device would fail.
I would also get rid of all likelys/unlikelys here - driver registration is
not a hot path...
> +}
> +
> +static void dc_kbd_disconnect(struct maple_device *dev)
> +{
> + struct dc_kbd *kbd = dev->private_data;
> +
> + input_unregister_device(kbd->dev);
> + kfree(kbd);
Are we guaranteed that the dc_kbd_callback is not running in a separate
thread?
Please also consider implementing support for changing keyma. Since
the keymap is pretty full I think the best way is to copy the vanilla
keymap into a per-device memory and set up keymap, keycodesize and
keycodemax in input device structure.
Thank you.
--
Dmitry
next prev parent reply other threads:[~2007-09-05 3:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-04 23:34 [PATCH] Add support for keyboard on SEGA Dreamcast Adrian McMenamin
2007-09-05 3:04 ` Dmitry Torokhov [this message]
2007-09-07 22:01 ` Adrian McMenamin
2007-09-05 4:34 ` Mike Frysinger
2007-09-05 4:50 ` Dmitry Torokhov
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=200709042304.51510.dtor@insightbb.com \
--to=dtor@insightbb.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxsh-dev@lists.sourceforge.net \
--cc=lkmladrian@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.