[PATCH 6/44] Fix sunkbd.c to work with serport
From: Vojtech Pavlik
Date: Tue Mar 16 2004 - 09:51:44 EST
You can pull this changeset from:
bk://kernel.bkbits.net/vojtech/input
===================================================================
ChangeSet@xxxxxxxxxxxx, 2004-01-26 13:25:24+01:00, vojtech@xxxxxxx
input: Fix sunkbd.c to work with serport. Must sleep.
sunkbd.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
===================================================================
diff -Nru a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
--- a/drivers/input/keyboard/sunkbd.c Tue Mar 16 13:19:57 2004
+++ b/drivers/input/keyboard/sunkbd.c Tue Mar 16 13:19:57 2004
@@ -77,6 +77,7 @@
struct input_dev dev;
struct serio *serio;
struct work_struct tq;
+ wait_queue_head_t wait;
char name[64];
char phys[32];
char type;
@@ -96,11 +97,13 @@
if (sunkbd->reset <= -1) { /* If cp[i] is 0xff, sunkbd->reset will stay -1. */
sunkbd->reset = data; /* The keyboard sends 0xff 0xff 0xID on powerup */
+ wake_up_interruptible(&sunkbd->wait);
goto out;
}
if (sunkbd->layout == -1) {
sunkbd->layout = data;
+ wake_up_interruptible(&sunkbd->wait);
goto out;
}
@@ -176,22 +179,19 @@
static int sunkbd_initialize(struct sunkbd *sunkbd)
{
- int t;
-
- t = 1000;
sunkbd->reset = -2;
sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET);
- while (sunkbd->reset < 0 && --t) mdelay(1);
- if (!t) return -1;
+ wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
+ if (sunkbd->reset <0)
+ return -1;
sunkbd->type = sunkbd->reset;
if (sunkbd->type == 4) { /* Type 4 keyboard */
- t = 250;
sunkbd->layout = -2;
sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_LAYOUT);
- while (sunkbd->layout < 0 && --t) mdelay(1);
- if (!t) return -1;
+ wait_event_interruptible_timeout(sunkbd->wait, sunkbd->layout >= 0, HZ/4);
+ if (sunkbd->layout < 0) return -1;
if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK) sunkbd->type = 5;
}
@@ -206,9 +206,8 @@
static void sunkbd_reinit(void *data)
{
struct sunkbd *sunkbd = data;
- int t = 1000;
- while (sunkbd->reset < 0 && --t) mdelay(1);
+ wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED);
sunkbd->serio->write(sunkbd->serio,
@@ -239,6 +238,7 @@
memset(sunkbd, 0, sizeof(struct sunkbd));
init_input_dev(&sunkbd->dev);
+ init_waitqueue_head(&sunkbd->wait);
sunkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
sunkbd->dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML);
@@ -275,7 +275,7 @@
set_bit(sunkbd->keycode[i], sunkbd->dev.keybit);
clear_bit(0, sunkbd->dev.keybit);
- sprintf(sunkbd->name, "%s/input", serio->phys);
+ sprintf(sunkbd->phys, "%s/input0", serio->phys);
sunkbd->dev.name = sunkbd->name;
sunkbd->dev.phys = sunkbd->phys;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/