mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
To: "Geert Uytterhoeven" <geert@linux-m68k.org>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Michael Schmitz" <schmitz@debian.org>,
	"Roman Zippel" <zippel@linux-m68k.org>
Subject: Re: [patch 04/33] m68k: Atari keyboard and mouse support.
Date: Tue, 1 May 2007 16:46:22 -0400	[thread overview]
Message-ID: <d120d5000705011346h263bb5c4nb534692c11e7081b@mail.gmail.com> (raw)
In-Reply-To: <20070501195129.842338339@mail.of.borg>

Hi,

On 5/1/07, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> +
> +/* These could be settable by some ioctl() in future... */
> +static unsigned int key_repeat_delay = DEFAULT_KEYB_REP_DELAY;
> +static unsigned int key_repeat_rate = DEFAULT_KEYB_REP_RATE;
> +
> +static unsigned char rep_scancode;
> +static struct timer_list atakeyb_rep_timer = {
> +       .function = atakeyb_rep,
> +};

Is there a problem with repeat implementation in input core that
requres custom-made repeater here?

> +
> +                               // handle_scancode(scancode, !break_flag);

The code looks a bit dirty (old code commented out, C++ style comments).

> +
> +
> +int atari_kbdrate(struct kbd_repeat *k)
> +{
> +       if (k->delay > 0) {
> +               /* convert from msec to jiffies */
> +               key_repeat_delay = (k->delay * HZ + 500) / 1000;

If this is really needed - msecs_to_jiffies().

>
> +config KEYBOARD_ATARI
> +       tristate "Atari keyboard"
> +       depends on ATARI
> +       select ATARI_KBD_CORE
> +       help
> +         Say Y here if you are running Linux on any Atari and have a keyboard
> +         attached.
> +
> +         To compile this driver as a module, choose M here: the
> +         module will be called atakbd.

Can we spell it out: atarikbd or atari_kbd?

> +
> +       if (!(atakbd_dev = input_allocate_device()))
> +               return -ENOMEM;
> +
> +       // need to init core driver if not already done so
> +       if (atari_keyb_init())

Memory leak

> +               return -ENODEV;
> +
> +       atakbd_dev->name = "Atari Keyboard";
> +       atakbd_dev->phys = "atakbd/input0";
> +       atakbd_dev->id.bustype = BUS_ATARI;
> +       atakbd_dev->id.vendor = 0x0001;
> +       atakbd_dev->id.product = 0x0001;
> +       atakbd_dev->id.version = 0x0100;
> +
> +       atakbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
> +       atakbd_dev->keycode = atakbd_keycode;
> +       atakbd_dev->keycodesize = sizeof(unsigned char);
> +       atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode);
> +
> +       for (i = 1; i < 0x72; i++) {
> +               atakbd_keycode[i] = i;
> +               set_bit(atakbd_keycode[i], atakbd_dev->keybit);

It looks like this driver is not using standard input event codes. If
Roman does not want to adjust keymaps on Amiga and Atari that should
be handled in legacy keyboard driver (drivers/char/keyboard.c). As it
is programs using /dev/input/eventX have no chance of working.

> +       }
> +
> +       input_register_device(atakbd_dev);

Error handling.

> +
> +static int mouse_threshold[2] = {2,2};
> +
> +#ifdef __MODULE__
> +MODULE_PARM(mouse_threshold, "2i");

MODULE_PARM is so 20th century...

> +#endif
> +#ifdef FIXED_ATARI_JOYSTICK
> +extern int atari_mouse_buttons;
> +#endif
> +static int atamouse_used = 0;

Initialization is not needed. Moreover the counter is not needed.

> +
> +static int atamouse_open(struct input_dev *dev)
> +{
> +       if (atamouse_used++)
> +               return 0;

No need to count, input core takes care of this.

> +
> +static int __init atamouse_init(void)
> +{
> +       if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
> +               return -ENODEV;
> +
> +       if (!(atamouse_dev = input_allocate_device()))
> +               return -ENOMEM;
> +
> +       if (!(atari_keyb_init()))

Memory leak

> +               return -ENODEV;
> +
> +       atamouse_dev->name = "Atari mouse";
> +       atamouse_dev->phys = "atamouse/input0";
> +       atamouse_dev->id.bustype = BUS_ATARI;
> +       atamouse_dev->id.vendor = 0x0001;
> +       atamouse_dev->id.product = 0x0002;
> +       atamouse_dev->id.version = 0x0100;
> +
> +       atamouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
> +       atamouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
> +       atamouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
> +       atamouse_dev->open = atamouse_open;
> +       atamouse_dev->close = atamouse_close;
> +
> +       input_register_device(atamouse_dev);

Error handling.

> +
> +       printk(KERN_INFO "input: %s at keyboard ACIA\n", atamouse_dev->name);

Input core already logs every input device registered, do we need to
repeat it in the driver?

-- 
Dmitry

       reply	other threads:[~2007-05-01 20:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070501195052.390551603@mail.of.borg>
     [not found] ` <20070501195129.842338339@mail.of.borg>
2007-05-01 20:46   ` Dmitry Torokhov [this message]
2007-05-03 17:07     ` Michael Schmitz
2007-05-03 17:33       ` Roman Zippel
2007-05-03 19:17         ` Dmitry Torokhov
2007-05-03 19:41           ` Roman Zippel
2007-05-03 20:32             ` Dmitry Torokhov
2007-05-03 21:01               ` Roman Zippel
2007-05-03 19:06       ` Dmitry Torokhov
2007-05-04 10:25         ` Michael Schmitz
2007-05-01 20:32 [patch 00/33] m68k patches for 2.6.22 Geert Uytterhoeven
2007-05-01 20:32 ` [patch 04/33] m68k: Atari keyboard and mouse support Geert Uytterhoeven
2007-05-01 20:57   ` Christoph Hellwig
2007-05-01 21:09     ` Dmitry Torokhov
2007-05-03 10:34       ` Michael Schmitz
2007-05-03 10:47     ` Michael Schmitz
2007-05-03 10:50       ` Christoph Hellwig
2007-05-03 10:54         ` Michael Schmitz

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=d120d5000705011346h263bb5c4nb534692c11e7081b@mail.gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitz@debian.org \
    --cc=torvalds@linux-foundation.org \
    --cc=zippel@linux-m68k.org \
    /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®