Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Torvalds committed Sep 10, 2005
2 parents 2b8dfec + d39969d commit 7f93220
Show file tree
Hide file tree
Showing 26 changed files with 986 additions and 312 deletions.
1 change: 1 addition & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ running once the system is up.
keyboard and can not control its state
(Don't attempt to blink the leds)
i8042.noaux [HW] Don't check for auxiliary (== mouse) port
i8042.nokbd [HW] Don't check/create keyboard port
i8042.nomux [HW] Don't check presence of an active multiplexing
controller
i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
Expand Down
111 changes: 56 additions & 55 deletions drivers/char/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* `Sticky' modifier keys, 951006.
*
* 11-11-96: SAK should now work in the raw mode (Martin Mares)
*
*
* Modified to provide 'generic' keyboard support by Hamish Macdonald
* Merge with the m68k keyboard driver and split-off of the PC low-level
* parts by Geert Uytterhoeven, May 1997
Expand Down Expand Up @@ -52,7 +52,7 @@ extern void ctrl_alt_del(void);
/*
* Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
* This seems a good reason to start with NumLock off. On HIL keyboards
* of PARISC machines however there is no NumLock key and everyone expects the keypad
* of PARISC machines however there is no NumLock key and everyone expects the keypad
* to be used for numbers.
*/

Expand All @@ -76,17 +76,17 @@ void compute_shiftstate(void);
k_meta, k_ascii, k_lock, k_lowercase,\
k_slock, k_dead2, k_ignore, k_ignore

typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value,
typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value,
char up_flag, struct pt_regs *regs);
static k_handler_fn K_HANDLERS;
static k_handler_fn *k_handler[16] = { K_HANDLERS };

#define FN_HANDLERS\
fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\
fn_show_state, fn_send_intr, fn_lastcons, fn_caps_toggle,\
fn_num, fn_hold, fn_scroll_forw, fn_scroll_back,\
fn_boot_it, fn_caps_on, fn_compose, fn_SAK,\
fn_dec_console, fn_inc_console, fn_spawn_con, fn_bare_num
fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\
fn_show_state, fn_send_intr, fn_lastcons, fn_caps_toggle,\
fn_num, fn_hold, fn_scroll_forw, fn_scroll_back,\
fn_boot_it, fn_caps_on, fn_compose, fn_SAK,\
fn_dec_console, fn_inc_console, fn_spawn_con, fn_bare_num

typedef void (fn_handler_fn)(struct vc_data *vc, struct pt_regs *regs);
static fn_handler_fn FN_HANDLERS;
Expand Down Expand Up @@ -159,13 +159,13 @@ static int sysrq_alt;
*/
int getkeycode(unsigned int scancode)
{
struct list_head * node;
struct list_head *node;
struct input_dev *dev = NULL;

list_for_each(node,&kbd_handler.h_list) {
struct input_handle * handle = to_handle_h(node);
if (handle->dev->keycodesize) {
dev = handle->dev;
list_for_each(node, &kbd_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
if (handle->dev->keycodesize) {
dev = handle->dev;
break;
}
}
Expand All @@ -181,15 +181,15 @@ int getkeycode(unsigned int scancode)

int setkeycode(unsigned int scancode, unsigned int keycode)
{
struct list_head * node;
struct list_head *node;
struct input_dev *dev = NULL;
unsigned int i, oldkey;

list_for_each(node,&kbd_handler.h_list) {
list_for_each(node, &kbd_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
if (handle->dev->keycodesize) {
dev = handle->dev;
break;
if (handle->dev->keycodesize) {
dev = handle->dev;
break;
}
}

Expand All @@ -200,7 +200,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
return -EINVAL;
if (keycode < 0 || keycode > KEY_MAX)
return -EINVAL;
if (keycode >> (dev->keycodesize * 8))
if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
return -EINVAL;

oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
Expand All @@ -216,11 +216,11 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
}

/*
* Making beeps and bells.
* Making beeps and bells.
*/
static void kd_nosound(unsigned long ignored)
{
struct list_head * node;
struct list_head *node;

list_for_each(node,&kbd_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
Expand All @@ -237,12 +237,12 @@ static DEFINE_TIMER(kd_mksound_timer, kd_nosound, 0, 0);

void kd_mksound(unsigned int hz, unsigned int ticks)
{
struct list_head * node;
struct list_head *node;

del_timer(&kd_mksound_timer);

if (hz) {
list_for_each_prev(node,&kbd_handler.h_list) {
list_for_each_prev(node, &kbd_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
if (test_bit(EV_SND, handle->dev->evbit)) {
if (test_bit(SND_TONE, handle->dev->sndbit)) {
Expand Down Expand Up @@ -337,19 +337,19 @@ static void to_utf8(struct vc_data *vc, ushort c)
if (c < 0x80)
/* 0******* */
put_queue(vc, c);
else if (c < 0x800) {
else if (c < 0x800) {
/* 110***** 10****** */
put_queue(vc, 0xc0 | (c >> 6));
put_queue(vc, 0xc0 | (c >> 6));
put_queue(vc, 0x80 | (c & 0x3f));
} else {
} else {
/* 1110**** 10****** 10****** */
put_queue(vc, 0xe0 | (c >> 12));
put_queue(vc, 0x80 | ((c >> 6) & 0x3f));
put_queue(vc, 0x80 | (c & 0x3f));
}
}
}

/*
/*
* Called after returning from RAW mode or when changing consoles - recompute
* shift_down[] and shift_state from key_down[] maybe called when keymap is
* undefined, so that shiftkey release is seen
Expand All @@ -360,7 +360,7 @@ void compute_shiftstate(void)

shift_state = 0;
memset(shift_down, 0, sizeof(shift_down));

for (i = 0; i < ARRAY_SIZE(key_down); i++) {

if (!key_down[i])
Expand Down Expand Up @@ -499,9 +499,9 @@ static void fn_dec_console(struct vc_data *vc, struct pt_regs *regs)
if (want_console != -1)
cur = want_console;

for (i = cur-1; i != cur; i--) {
for (i = cur - 1; i != cur; i--) {
if (i == -1)
i = MAX_NR_CONSOLES-1;
i = MAX_NR_CONSOLES - 1;
if (vc_cons_allocated(i))
break;
}
Expand Down Expand Up @@ -567,9 +567,9 @@ static void fn_compose(struct vc_data *vc, struct pt_regs *regs)

static void fn_spawn_con(struct vc_data *vc, struct pt_regs *regs)
{
if (spawnpid)
if(kill_proc(spawnpid, spawnsig, 1))
spawnpid = 0;
if (spawnpid)
if (kill_proc(spawnpid, spawnsig, 1))
spawnpid = 0;
}

static void fn_SAK(struct vc_data *vc, struct pt_regs *regs)
Expand Down Expand Up @@ -603,8 +603,8 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag, struct
return;
if (value >= ARRAY_SIZE(fn_handler))
return;
if ((kbd->kbdmode == VC_RAW ||
kbd->kbdmode == VC_MEDIUMRAW) &&
if ((kbd->kbdmode == VC_RAW ||
kbd->kbdmode == VC_MEDIUMRAW) &&
value != KVAL(K_SAK))
return; /* SAK is allowed even in raw mode */
fn_handler[value](vc, regs);
Expand Down Expand Up @@ -894,11 +894,11 @@ static inline unsigned char getleds(void)

static void kbd_bh(unsigned long dummy)
{
struct list_head * node;
struct list_head *node;
unsigned char leds = getleds();

if (leds != ledstate) {
list_for_each(node,&kbd_handler.h_list) {
list_for_each(node, &kbd_handler.h_list) {
struct input_handle * handle = to_handle_h(node);
input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02));
Expand Down Expand Up @@ -963,11 +963,11 @@ static int sparc_l1_a_state = 0;
extern void sun_do_break(void);
#endif

static int emulate_raw(struct vc_data *vc, unsigned int keycode,
static int emulate_raw(struct vc_data *vc, unsigned int keycode,
unsigned char up_flag)
{
if (keycode > 255 || !x86_keycodes[keycode])
return -1;
return -1;

switch (keycode) {
case KEY_PAUSE:
Expand All @@ -981,7 +981,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
case KEY_HANJA:
if (!up_flag) put_queue(vc, 0xf2);
return 0;
}
}

if (keycode == KEY_SYSRQ && sysrq_alt) {
put_queue(vc, 0x54 | up_flag);
Expand Down Expand Up @@ -1104,11 +1104,12 @@ static void kbd_keycode(unsigned int keycode, int down,
else
clear_bit(keycode, key_down);

if (rep && (!vc_kbd_mode(kbd, VC_REPEAT) || (tty &&
(!L_ECHO(tty) && tty->driver->chars_in_buffer(tty))))) {
if (rep &&
(!vc_kbd_mode(kbd, VC_REPEAT) ||
(tty && !L_ECHO(tty) && tty->driver->chars_in_buffer(tty)))) {
/*
* Don't repeat a key if the input buffers are not empty and the
* characters get aren't echoed locally. This makes key repeat
* characters get aren't echoed locally. This makes key repeat
* usable with slow applications and under heavy loads.
*/
return;
Expand All @@ -1130,7 +1131,8 @@ static void kbd_keycode(unsigned int keycode, int down,
type = KTYP(keysym);

if (type < 0xf0) {
if (down && !raw_mode) to_utf8(vc, keysym);
if (down && !raw_mode)
to_utf8(vc, keysym);
return;
}

Expand All @@ -1154,7 +1156,7 @@ static void kbd_keycode(unsigned int keycode, int down,
kbd->slockstate = 0;
}

static void kbd_event(struct input_handle *handle, unsigned int event_type,
static void kbd_event(struct input_handle *handle, unsigned int event_type,
unsigned int event_code, int value)
{
if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev))
Expand All @@ -1166,34 +1168,33 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type,
schedule_console_callback();
}

static char kbd_name[] = "kbd";

/*
* When a keyboard (or other input device) is found, the kbd_connect
* function is called. The function then looks at the device, and if it
* likes it, it can open it and get events from it. In this (kbd_connect)
* function, we should decide which VT to bind that keyboard to initially.
*/
static struct input_handle *kbd_connect(struct input_handler *handler,
static struct input_handle *kbd_connect(struct input_handler *handler,
struct input_dev *dev,
struct input_device_id *id)
{
struct input_handle *handle;
int i;

for (i = KEY_RESERVED; i < BTN_MISC; i++)
if (test_bit(i, dev->keybit)) break;
if (test_bit(i, dev->keybit))
break;

if ((i == BTN_MISC) && !test_bit(EV_SND, dev->evbit))
if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
return NULL;

if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
return NULL;
memset(handle, 0, sizeof(struct input_handle));

handle->dev = dev;
handle->handler = handler;
handle->name = kbd_name;
handle->name = "kbd";

input_open_device(handle);
kbd_refresh_leds(handle);
Expand All @@ -1212,11 +1213,11 @@ static struct input_device_id kbd_ids[] = {
.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
.evbit = { BIT(EV_KEY) },
},

{
.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
.evbit = { BIT(EV_SND) },
},
},

{ }, /* Terminating entry */
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;
if (get_user(v, ip + 1)) return -EFAULT;
if (v < 0 || v > KEY_MAX) return -EINVAL;
if (v >> (dev->keycodesize * 8)) return -EINVAL;
if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8))) return -EINVAL;
u = SET_INPUT_KEYCODE(dev, t, v);
clear_bit(u, dev->keybit);
set_bit(v, dev->keybit);
Expand Down
32 changes: 7 additions & 25 deletions drivers/input/joystick/iforce/iforce-packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data,

int iforce_get_id_packet(struct iforce *iforce, char *packet)
{
DECLARE_WAITQUEUE(wait, current);
int timeout = HZ; /* 1 second */

switch (iforce->bus) {

case IFORCE_USB:
Expand All @@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
iforce->cr.bRequest = packet[0];
iforce->ctrl->dev = iforce->usbdev;

set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&iforce->wait, &wait);

if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&iforce->wait, &wait);
if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC))
return -1;
}

while (timeout && iforce->ctrl->status == -EINPROGRESS)
timeout = schedule_timeout(timeout);
wait_event_interruptible_timeout(iforce->wait,
iforce->ctrl->status != -EINPROGRESS, HZ);

set_current_state(TASK_RUNNING);
remove_wait_queue(&iforce->wait, &wait);

if (!timeout) {
if (iforce->ctrl->status != -EINPROGRESS) {
usb_unlink_urb(iforce->ctrl);
return -1;
}
Expand All @@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
iforce->expect_packet = FF_CMD_QUERY;
iforce_send_packet(iforce, FF_CMD_QUERY, packet);

set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&iforce->wait, &wait);

while (timeout && iforce->expect_packet)
timeout = schedule_timeout(timeout);

set_current_state(TASK_RUNNING);
remove_wait_queue(&iforce->wait, &wait);
wait_event_interruptible_timeout(iforce->wait,
!iforce->expect_packet, HZ);

if (!timeout) {
if (iforce->expect_packet) {
iforce->expect_packet = 0;
return -1;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/input/joystick/iforce/iforce-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs)
goto exit;
}

wake_up(&iforce->wait);
iforce_process_packet(iforce,
(iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs);

Expand Down
Loading

0 comments on commit 7f93220

Please sign in to comment.