aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/interact.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/joystick/interact.c')
-rw-r--r--drivers/input/joystick/interact.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index d7b3472bd686..8511ee7bb263 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
54 54
55struct interact { 55struct interact {
56 struct gameport *gameport; 56 struct gameport *gameport;
57 struct input_dev dev; 57 struct input_dev *dev;
58 int bads; 58 int bads;
59 int reads; 59 int reads;
60 unsigned char type; 60 unsigned char type;
@@ -130,7 +130,7 @@ static int interact_read_packet(struct gameport *gameport, int length, u32 *data
130static void interact_poll(struct gameport *gameport) 130static void interact_poll(struct gameport *gameport)
131{ 131{
132 struct interact *interact = gameport_get_drvdata(gameport); 132 struct interact *interact = gameport_get_drvdata(gameport);
133 struct input_dev *dev = &interact->dev; 133 struct input_dev *dev = interact->dev;
134 u32 data[3]; 134 u32 data[3];
135 int i; 135 int i;
136 136
@@ -208,14 +208,20 @@ static void interact_close(struct input_dev *dev)
208static int interact_connect(struct gameport *gameport, struct gameport_driver *drv) 208static int interact_connect(struct gameport *gameport, struct gameport_driver *drv)
209{ 209{
210 struct interact *interact; 210 struct interact *interact;
211 struct input_dev *input_dev;
211 __u32 data[3]; 212 __u32 data[3];
212 int i, t; 213 int i, t;
213 int err; 214 int err;
214 215
215 if (!(interact = kzalloc(sizeof(struct interact), GFP_KERNEL))) 216 interact = kzalloc(sizeof(struct interact), GFP_KERNEL);
216 return -ENOMEM; 217 input_dev = input_allocate_device();
218 if (!interact || !input_dev) {
219 err = -ENOMEM;
220 goto fail1;
221 }
217 222
218 interact->gameport = gameport; 223 interact->gameport = gameport;
224 interact->dev = input_dev;
219 225
220 gameport_set_drvdata(gameport, interact); 226 gameport_set_drvdata(gameport, interact);
221 227
@@ -249,41 +255,40 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
249 interact->type = i; 255 interact->type = i;
250 interact->length = interact_type[i].length; 256 interact->length = interact_type[i].length;
251 257
252 interact->dev.private = interact; 258 input_dev->name = interact_type[i].name;
253 interact->dev.open = interact_open; 259 input_dev->phys = interact->phys;
254 interact->dev.close = interact_close; 260 input_dev->id.bustype = BUS_GAMEPORT;
261 input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
262 input_dev->id.product = interact_type[i].id;
263 input_dev->id.version = 0x0100;
264 input_dev->private = interact;
255 265
256 interact->dev.name = interact_type[i].name; 266 input_dev->open = interact_open;
257 interact->dev.phys = interact->phys; 267 input_dev->close = interact_close;
258 interact->dev.id.bustype = BUS_GAMEPORT;
259 interact->dev.id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
260 interact->dev.id.product = interact_type[i].id;
261 interact->dev.id.version = 0x0100;
262 268
263 interact->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 269 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
264 270
265 for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { 271 for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) {
266 set_bit(t, interact->dev.absbit); 272 set_bit(t, input_dev->absbit);
267 if (i < interact_type[interact->type].b8) { 273 if (i < interact_type[interact->type].b8) {
268 interact->dev.absmin[t] = 0; 274 input_dev->absmin[t] = 0;
269 interact->dev.absmax[t] = 255; 275 input_dev->absmax[t] = 255;
270 } else { 276 } else {
271 interact->dev.absmin[t] = -1; 277 input_dev->absmin[t] = -1;
272 interact->dev.absmax[t] = 1; 278 input_dev->absmax[t] = 1;
273 } 279 }
274 } 280 }
275 281
276 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) 282 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
277 set_bit(t, interact->dev.keybit); 283 set_bit(t, input_dev->keybit);
278 284
279 input_register_device(&interact->dev); 285 input_register_device(interact->dev);
280 printk(KERN_INFO "input: %s on %s\n",
281 interact_type[interact->type].name, gameport->phys);
282 286
283 return 0; 287 return 0;
284 288
285fail2: gameport_close(gameport); 289fail2: gameport_close(gameport);
286fail1: gameport_set_drvdata(gameport, NULL); 290fail1: gameport_set_drvdata(gameport, NULL);
291 input_free_device(input_dev);
287 kfree(interact); 292 kfree(interact);
288 return err; 293 return err;
289} 294}
@@ -292,7 +297,7 @@ static void interact_disconnect(struct gameport *gameport)
292{ 297{
293 struct interact *interact = gameport_get_drvdata(gameport); 298 struct interact *interact = gameport_get_drvdata(gameport);
294 299
295 input_unregister_device(&interact->dev); 300 input_unregister_device(interact->dev);
296 gameport_close(gameport); 301 gameport_close(gameport);
297 gameport_set_drvdata(gameport, NULL); 302 gameport_set_drvdata(gameport, NULL);
298 kfree(interact); 303 kfree(interact);