aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/xtkbd.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-28 18:48:57 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-28 18:48:57 -0400
commit596c96ba06e5d56e72451e02f93f4e15e17458df (patch)
tree78bc640acacb8faeb621c51296e99dbb0533a147 /drivers/input/keyboard/xtkbd.c
parentad18b0ea089928367185e13d11424aea91d4b41f (diff)
parent20731945ae743034353a88c307920d1f16cf8ac8 (diff)
Merge branch 'master'
Diffstat (limited to 'drivers/input/keyboard/xtkbd.c')
-rw-r--r--drivers/input/keyboard/xtkbd.c80
1 files changed, 38 insertions, 42 deletions
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index 19eaec7789d1..4135e3e16c51 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -56,11 +56,9 @@ static unsigned char xtkbd_keycode[256] = {
56 106 56 106
57}; 57};
58 58
59static char *xtkbd_name = "XT Keyboard";
60
61struct xtkbd { 59struct xtkbd {
62 unsigned char keycode[256]; 60 unsigned char keycode[256];
63 struct input_dev dev; 61 struct input_dev *dev;
64 struct serio *serio; 62 struct serio *serio;
65 char phys[32]; 63 char phys[32];
66}; 64};
@@ -77,9 +75,9 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio,
77 default: 75 default:
78 76
79 if (xtkbd->keycode[data & XTKBD_KEY]) { 77 if (xtkbd->keycode[data & XTKBD_KEY]) {
80 input_regs(&xtkbd->dev, regs); 78 input_regs(xtkbd->dev, regs);
81 input_report_key(&xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); 79 input_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE));
82 input_sync(&xtkbd->dev); 80 input_sync(xtkbd->dev);
83 } else { 81 } else {
84 printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n", 82 printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n",
85 data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed"); 83 data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed");
@@ -91,62 +89,60 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio,
91static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) 89static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
92{ 90{
93 struct xtkbd *xtkbd; 91 struct xtkbd *xtkbd;
92 struct input_dev *input_dev;
93 int err = -ENOMEM;
94 int i; 94 int i;
95 int err;
96
97 if (!(xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL)))
98 return -ENOMEM;
99
100 memset(xtkbd, 0, sizeof(struct xtkbd));
101 95
102 xtkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 96 xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL);
97 input_dev = input_allocate_device();
98 if (!xtkbd || !input_dev)
99 goto fail;
103 100
104 xtkbd->serio = serio; 101 xtkbd->serio = serio;
102 xtkbd->dev = input_dev;
103 sprintf(xtkbd->phys, "%s/input0", serio->phys);
104 memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode));
105 105
106 init_input_dev(&xtkbd->dev); 106 input_dev->name = "XT Keyboard";
107 xtkbd->dev.keycode = xtkbd->keycode; 107 input_dev->phys = xtkbd->phys;
108 xtkbd->dev.keycodesize = sizeof(unsigned char); 108 input_dev->id.bustype = BUS_XTKBD;
109 xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode); 109 input_dev->id.vendor = 0x0001;
110 xtkbd->dev.private = xtkbd; 110 input_dev->id.product = 0x0001;
111 111 input_dev->id.version = 0x0100;
112 serio_set_drvdata(serio, xtkbd); 112 input_dev->cdev.dev = &serio->dev;
113 input_dev->private = xtkbd;
113 114
114 err = serio_open(serio, drv); 115 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
115 if (err) { 116 input_dev->keycode = xtkbd->keycode;
116 serio_set_drvdata(serio, NULL); 117 input_dev->keycodesize = sizeof(unsigned char);
117 kfree(xtkbd); 118 input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode);
118 return err;
119 }
120 119
121 memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode));
122 for (i = 0; i < 255; i++) 120 for (i = 0; i < 255; i++)
123 set_bit(xtkbd->keycode[i], xtkbd->dev.keybit); 121 set_bit(xtkbd->keycode[i], input_dev->keybit);
124 clear_bit(0, xtkbd->dev.keybit); 122 clear_bit(0, input_dev->keybit);
125
126 sprintf(xtkbd->phys, "%s/input0", serio->phys);
127
128 xtkbd->dev.name = xtkbd_name;
129 xtkbd->dev.phys = xtkbd->phys;
130 xtkbd->dev.id.bustype = BUS_XTKBD;
131 xtkbd->dev.id.vendor = 0x0001;
132 xtkbd->dev.id.product = 0x0001;
133 xtkbd->dev.id.version = 0x0100;
134 xtkbd->dev.dev = &serio->dev;
135 123
136 input_register_device(&xtkbd->dev); 124 serio_set_drvdata(serio, xtkbd);
137 125
138 printk(KERN_INFO "input: %s on %s\n", xtkbd_name, serio->phys); 126 err = serio_open(serio, drv);
127 if (err)
128 goto fail;
139 129
130 input_register_device(xtkbd->dev);
140 return 0; 131 return 0;
132
133 fail: serio_set_drvdata(serio, NULL);
134 input_free_device(input_dev);
135 kfree(xtkbd);
136 return err;
141} 137}
142 138
143static void xtkbd_disconnect(struct serio *serio) 139static void xtkbd_disconnect(struct serio *serio)
144{ 140{
145 struct xtkbd *xtkbd = serio_get_drvdata(serio); 141 struct xtkbd *xtkbd = serio_get_drvdata(serio);
146 142
147 input_unregister_device(&xtkbd->dev);
148 serio_close(serio); 143 serio_close(serio);
149 serio_set_drvdata(serio, NULL); 144 serio_set_drvdata(serio, NULL);
145 input_unregister_device(xtkbd->dev);
150 kfree(xtkbd); 146 kfree(xtkbd);
151} 147}
152 148