Commit 407cf84f authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input

parents b3ce1deb 0aeafa77
...@@ -377,7 +377,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int ...@@ -377,7 +377,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
list_for_each_entry(dev, &input_dev_list, node) { list_for_each_entry(dev, &input_dev_list, node) {
path = dev->dynalloc ? kobject_get_path(&dev->cdev.kobj, GFP_KERNEL) : NULL; path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
...@@ -741,15 +741,21 @@ static void input_register_classdevice(struct input_dev *dev) ...@@ -741,15 +741,21 @@ static void input_register_classdevice(struct input_dev *dev)
sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
} }
void input_register_device(struct input_dev *dev) int input_register_device(struct input_dev *dev)
{ {
struct input_handle *handle; struct input_handle *handle;
struct input_handler *handler; struct input_handler *handler;
struct input_device_id *id; struct input_device_id *id;
set_bit(EV_SYN, dev->evbit); if (!dev->dynalloc) {
printk(KERN_WARNING "input: device %s is statically allocated, will not register\n"
"Please convert to input_allocate_device() or contact dtor_core@ameritech.net\n",
dev->name ? dev->name : "<Unknown>");
return -EINVAL;
}
init_MUTEX(&dev->sem); init_MUTEX(&dev->sem);
set_bit(EV_SYN, dev->evbit);
/* /*
* If delay and period are pre-set by the driver, then autorepeating * If delay and period are pre-set by the driver, then autorepeating
...@@ -767,8 +773,7 @@ void input_register_device(struct input_dev *dev) ...@@ -767,8 +773,7 @@ void input_register_device(struct input_dev *dev)
INIT_LIST_HEAD(&dev->h_list); INIT_LIST_HEAD(&dev->h_list);
list_add_tail(&dev->node, &input_dev_list); list_add_tail(&dev->node, &input_dev_list);
if (dev->dynalloc) input_register_classdevice(dev);
input_register_classdevice(dev);
list_for_each_entry(handler, &input_handler_list, node) list_for_each_entry(handler, &input_handler_list, node)
if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
...@@ -776,8 +781,9 @@ void input_register_device(struct input_dev *dev) ...@@ -776,8 +781,9 @@ void input_register_device(struct input_dev *dev)
if ((handle = handler->connect(handler, dev, id))) if ((handle = handler->connect(handler, dev, id)))
input_link_handle(handle); input_link_handle(handle);
input_wakeup_procfs_readers(); input_wakeup_procfs_readers();
return 0;
} }
void input_unregister_device(struct input_dev *dev) void input_unregister_device(struct input_dev *dev)
...@@ -797,11 +803,10 @@ void input_unregister_device(struct input_dev *dev) ...@@ -797,11 +803,10 @@ void input_unregister_device(struct input_dev *dev)
list_del_init(&dev->node); list_del_init(&dev->node);
if (dev->dynalloc) { sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); sysfs_remove_group(&dev->cdev.kobj, &input_dev_group);
class_device_unregister(&dev->cdev); class_device_unregister(&dev->cdev);
}
input_wakeup_procfs_readers(); input_wakeup_procfs_readers();
} }
......
...@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = { ...@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = {
[0xfb] = KEY_APOSTROPHE, [0xfb] = KEY_APOSTROPHE,
}; };
#define CHECK_LED(LED, BITS) do { \ #define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \
if (test_bit (LED, lk->dev->led)) \ if (test_bit (LED, (LK)->dev->led)) \
leds_on |= BITS; \ VAR_ON |= BITS; \
else \ else \
leds_off |= BITS; \ VAR_OFF |= BITS; \
} while (0) } while (0)
/* /*
...@@ -298,6 +298,42 @@ struct lkkbd { ...@@ -298,6 +298,42 @@ struct lkkbd {
int ctrlclick_volume; int ctrlclick_volume;
}; };
#ifdef LKKBD_DEBUG
/*
* Responses from the keyboard and mapping back to their names.
*/
static struct {
unsigned char value;
unsigned char *name;
} lk_response[] = {
#define RESPONSE(x) { .value = (x), .name = #x, }
RESPONSE (LK_STUCK_KEY),
RESPONSE (LK_SELFTEST_FAILED),
RESPONSE (LK_ALL_KEYS_UP),
RESPONSE (LK_METRONOME),
RESPONSE (LK_OUTPUT_ERROR),
RESPONSE (LK_INPUT_ERROR),
RESPONSE (LK_KBD_LOCKED),
RESPONSE (LK_KBD_TEST_MODE_ACK),
RESPONSE (LK_PREFIX_KEY_DOWN),
RESPONSE (LK_MODE_CHANGE_ACK),
RESPONSE (LK_RESPONSE_RESERVED),
#undef RESPONSE
};
static unsigned char *
response_name (unsigned char value)
{
int i;
for (i = 0; i < ARRAY_SIZE (lk_response); i++)
if (lk_response[i].value == value)
return lk_response[i].name;
return "<unknown>";
}
#endif /* LKKBD_DEBUG */
/* /*
* Calculate volume parameter byte for a given volume. * Calculate volume parameter byte for a given volume.
*/ */
...@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, ...@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
input_report_key (lk->dev, lk->keycode[i], 0); input_report_key (lk->dev, lk->keycode[i], 0);
input_sync (lk->dev); input_sync (lk->dev);
break; break;
case LK_METRONOME:
DBG (KERN_INFO "Got LK_METRONOME and don't " case 0x01:
"know how to handle...\n"); DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
schedule_work (&lk->tq);
break; break;
case LK_METRONOME:
case LK_OUTPUT_ERROR: case LK_OUTPUT_ERROR:
DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
"know how to handle...\n");
break;
case LK_INPUT_ERROR: case LK_INPUT_ERROR:
DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
"know how to handle...\n");
break;
case LK_KBD_LOCKED: case LK_KBD_LOCKED:
DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
"know how to handle...\n");
break;
case LK_KBD_TEST_MODE_ACK: case LK_KBD_TEST_MODE_ACK:
DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
"know how to handle...\n");
break;
case LK_PREFIX_KEY_DOWN: case LK_PREFIX_KEY_DOWN:
DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
"know how to handle...\n");
break;
case LK_MODE_CHANGE_ACK: case LK_MODE_CHANGE_ACK:
DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
"it properly...\n");
break;
case LK_RESPONSE_RESERVED: case LK_RESPONSE_RESERVED:
DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't " DBG (KERN_INFO "Got %s and don't know how to handle...\n",
"know how to handle...\n"); response_name (data));
break;
case 0x01:
DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
schedule_work (&lk->tq);
break; break;
default: default:
...@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code, ...@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
switch (type) { switch (type) {
case EV_LED: case EV_LED:
CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK); CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE); CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK); CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
CHECK_LED (LED_SLEEP, LK_LED_WAIT); CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) { if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON); lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on); lk->serio->write (lk->serio, leds_on);
...@@ -574,10 +591,10 @@ lkkbd_reinit (void *data) ...@@ -574,10 +591,10 @@ lkkbd_reinit (void *data)
lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS); lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);
/* Set LEDs */ /* Set LEDs */
CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK); CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE); CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK); CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
CHECK_LED (LED_SLEEP, LK_LED_WAIT); CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
if (leds_on != 0) { if (leds_on != 0) {
lk->serio->write (lk->serio, LK_CMD_LED_ON); lk->serio->write (lk->serio, LK_CMD_LED_ON);
lk->serio->write (lk->serio, leds_on); lk->serio->write (lk->serio, leds_on);
......
...@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { ...@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
struct locomokbd { struct locomokbd {
unsigned char keycode[LOCOMOKBD_NUMKEYS]; unsigned char keycode[LOCOMOKBD_NUMKEYS];
struct input_dev input; struct input_dev *input;
char phys[32]; char phys[32];
struct locomo_dev *ldev; struct locomo_dev *ldev;
...@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * ...@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *
spin_lock_irqsave(&locomokbd->lock, flags); spin_lock_irqsave(&locomokbd->lock, flags);
if (regs) input_regs(locomokbd->input, regs);
input_regs(&locomokbd->input, regs);
locomokbd_charge_all(membase); locomokbd_charge_all(membase);
...@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * ...@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *
scancode = SCANCODE(col, row); scancode = SCANCODE(col, row);
if (rowd & KB_ROWMASK(row)) { if (rowd & KB_ROWMASK(row)) {
num_pressed += 1; num_pressed += 1;
input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 1); input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1);
} else { } else {
input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 0); input_report_key(locomokbd->input, locomokbd->keycode[scancode], 0);
} }
} }
locomokbd_reset_col(membase, col); locomokbd_reset_col(membase, col);
} }
locomokbd_activate_all(membase); locomokbd_activate_all(membase);
input_sync(&locomokbd->input); input_sync(locomokbd->input);
/* if any keys are pressed, enable the timer */ /* if any keys are pressed, enable the timer */
if (num_pressed) if (num_pressed)
...@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(unsigned long data) ...@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(unsigned long data)
static int locomokbd_probe(struct locomo_dev *dev) static int locomokbd_probe(struct locomo_dev *dev)
{ {
struct locomokbd *locomokbd; struct locomokbd *locomokbd;
struct input_dev *input_dev;
int i, ret; int i, ret;
locomokbd = kmalloc(sizeof(struct locomokbd), GFP_KERNEL); locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL);
if (!locomokbd) input_dev = input_allocate_device();
return -ENOMEM; if (!locomokbd || !input_dev) {
ret = -ENOMEM;
memset(locomokbd, 0, sizeof(struct locomokbd)); goto free;
}
/* try and claim memory region */ /* try and claim memory region */
if (!request_mem_region((unsigned long) dev->mapbase, if (!request_mem_region((unsigned long) dev->mapbase,
...@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev) ...@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev)
locomokbd->timer.function = locomokbd_timer_callback; locomokbd->timer.function = locomokbd_timer_callback;
locomokbd->timer.data = (unsigned long) locomokbd; locomokbd->timer.data = (unsigned long) locomokbd;
locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); locomokbd->input = input_dev;
strcpy(locomokbd->phys, "locomokbd/input0");
input_dev->name = "LoCoMo keyboard";
input_dev->phys = locomokbd->phys;
input_dev->id.bustype = BUS_HOST;
input_dev->id.vendor = 0x0001;
input_dev->id.product = 0x0001;
input_dev->id.version = 0x0100;
input_dev->private = locomokbd;
init_input_dev(&locomokbd->input); input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
locomokbd->input.keycode = locomokbd->keycode; input_dev->keycode = locomokbd->keycode;
locomokbd->input.keycodesize = sizeof(unsigned char); input_dev->keycodesize = sizeof(unsigned char);
locomokbd->input.keycodemax = ARRAY_SIZE(locomokbd_keycode); input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);
locomokbd->input.private = locomokbd;
memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) for (i = 0; i < LOCOMOKBD_NUMKEYS; i++)
set_bit(locomokbd->keycode[i], locomokbd->input.keybit); set_bit(locomokbd->keycode[i], input_dev->keybit);
clear_bit(0, locomokbd->input.keybit); clear_bit(0, input_dev->keybit);
strcpy(locomokbd->phys, "locomokbd/input0");
locomokbd->input.name = "LoCoMo keyboard";
locomokbd->input.phys = locomokbd->phys;
locomokbd->input.id.bustype = BUS_XTKBD;
locomokbd->input.id.vendor = 0x0001;
locomokbd->input.id.product = 0x0001;
locomokbd->input.id.version = 0x0100;
/* attempt to get the interrupt */ /* attempt to get the interrupt */
ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd);
...@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev) ...@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
goto out; goto out;
} }
input_register_device(&locomokbd->input); input_register_device(locomokbd->input);
printk(KERN_INFO "input: LoCoMo keyboard on locomokbd\n");
return 0; return 0;
...@@ -263,6 +261,7 @@ out: ...@@ -263,6 +261,7 @@ out:
release_mem_region((unsigned long) dev->mapbase, dev->length); release_mem_region((unsigned long) dev->mapbase, dev->length);
locomo_set_drvdata(dev, NULL); locomo_set_drvdata(dev, NULL);
free: free:
input_free_device(input_dev);
kfree(locomokbd); kfree(locomokbd);
return ret; return ret;
...@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomo_dev *dev) ...@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomo_dev *dev)
del_timer_sync(&locomokbd->timer); del_timer_sync(&locomokbd->timer);
input_unregister_device(&locomokbd->input); input_unregister_device(locomokbd->input);
locomo_set_drvdata(dev, NULL); locomo_set_drvdata(dev, NULL);
release_mem_region((unsigned long) dev->mapbase, dev->length); release_mem_region((unsigned long) dev->mapbase, dev->length);
......
...@@ -217,6 +217,9 @@ static struct ps2pp_info *get_model_info(unsigned char model) ...@@ -217,6 +217,9 @@ static struct ps2pp_info *get_model_info(unsigned char model)
{ 61, PS2PP_KIND_MX, /* MX700 */ { 61, PS2PP_KIND_MX, /* MX700 */
PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
{ 66, PS2PP_KIND_MX, /* MX3100 reciver */
PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL },
{ 73, 0, PS2PP_SIDE_BTN }, { 73, 0, PS2PP_SIDE_BTN },
{ 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
{ 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
......
...@@ -1007,7 +1007,7 @@ static inline void input_put_device(struct input_dev *dev) ...@@ -1007,7 +1007,7 @@ static inline void input_put_device(struct input_dev *dev)
class_device_put(&dev->cdev); class_device_put(&dev->cdev);
} }
void input_register_device(struct input_dev *); int input_register_device(struct input_dev *);
void input_unregister_device(struct input_dev *); void input_unregister_device(struct input_dev *);
void input_register_handler(struct input_handler *); void input_register_handler(struct input_handler *);
......
...@@ -2805,16 +2805,7 @@ __init setup_beep(void) ...@@ -2805,16 +2805,7 @@ __init setup_beep(void)
return 0 ; return 0 ;
} }
static struct input_dev awacs_beep_dev = { static struct input_dev *awacs_beep_dev;
.evbit = { BIT(EV_SND) },
.sndbit = { BIT(SND_BELL) | BIT(SND_TONE) },
.event = awacs_beep_event,
.name = "dmasound beeper",
.phys = "macio/input0", /* what the heck is this?? */
.id = {
.bustype = BUS_HOST,
},
};
int __init dmasound_awacs_init(void) int __init dmasound_awacs_init(void)
{ {
...@@ -2907,6 +2898,22 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n"); ...@@ -2907,6 +2898,22 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
return -ENODEV; return -ENODEV;
} }
awacs_beep_dev = input_allocate_device();
if (!awacs_beep_dev) {
release_OF_resource(io, 0);
release_OF_resource(io, 1);
release_OF_resource(io, 2);
printk(KERN_ERR "dmasound: can't allocate input device !\n");
return -ENOMEM;
}
awacs_beep_dev->name = "dmasound beeper";
awacs_beep_dev->phys = "macio/input0";
awacs_beep_dev->id.bustype = BUS_HOST;
awacs_beep_dev->event = awacs_beep_event;
awacs_beep_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
awacs_beep_dev->evbit[0] = BIT(EV_SND);
/* all OF versions I've seen use this value */ /* all OF versions I've seen use this value */
if (i2s_node) if (i2s_node)
i2s = ioremap(io->addrs[0].address, 0x1000); i2s = ioremap(io->addrs[0].address, 0x1000);
...@@ -3140,14 +3147,14 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev); ...@@ -3140,14 +3147,14 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
* XXX: we should handle errors here, but that would mean * XXX: we should handle errors here, but that would mean
* rewriting the whole init code. later.. * rewriting the whole init code. later..
*/ */
input_register_device(&awacs_beep_dev); input_register_device(awacs_beep_dev);
return dmasound_init(); return dmasound_init();
} }
static void __exit dmasound_awacs_cleanup(void) static void __exit dmasound_awacs_cleanup(void)
{ {
input_unregister_device(&awacs_beep_dev); input_unregister_device(awacs_beep_dev);
switch (awacs_revision) { switch (awacs_revision) {
case AWACS_TUMBLER: case AWACS_TUMBLER:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment