aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/gf2k.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:52 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:53 -0400
commit17dd3f0f7aa729a042af5d3318ff9b3e7781b45b (patch)
tree261580f0229e6365f044cd26925dfb2735e0754d /drivers/input/joystick/gf2k.c
parent0259567ad60df13a55583b84d2cddb5526705907 (diff)
[PATCH] drivers/input/joystick: convert to dynamic input_dev allocation
Input: convert drivers/input/joystick to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/joystick/gf2k.c')
-rw-r--r--drivers/input/joystick/gf2k.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index 8e4f92b115e6..e151f8c5bcb9 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -81,7 +81,7 @@ static short gf2k_seq_digital[] = { 590, 320, 860, 0 };
81 81
82struct gf2k { 82struct gf2k {
83 struct gameport *gameport; 83 struct gameport *gameport;
84 struct input_dev dev; 84 struct input_dev *dev;
85 int reads; 85 int reads;
86 int bads; 86 int bads;
87 unsigned char id; 87 unsigned char id;
@@ -175,7 +175,7 @@ static int gf2k_get_bits(unsigned char *buf, int pos, int num, int shift)
175 175
176static void gf2k_read(struct gf2k *gf2k, unsigned char *data) 176static void gf2k_read(struct gf2k *gf2k, unsigned char *data)
177{ 177{
178 struct input_dev *dev = &gf2k->dev; 178 struct input_dev *dev = gf2k->dev;
179 int i, t; 179 int i, t;
180 180
181 for (i = 0; i < 4 && i < gf2k_axes[gf2k->id]; i++) 181 for (i = 0; i < 4 && i < gf2k_axes[gf2k->id]; i++)
@@ -239,13 +239,19 @@ static void gf2k_close(struct input_dev *dev)
239static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) 239static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
240{ 240{
241 struct gf2k *gf2k; 241 struct gf2k *gf2k;
242 struct input_dev *input_dev;
242 unsigned char data[GF2K_LENGTH]; 243 unsigned char data[GF2K_LENGTH];
243 int i, err; 244 int i, err;
244 245
245 if (!(gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL))) 246 gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL);
246 return -ENOMEM; 247 input_dev = input_allocate_device();
248 if (!gf2k || !input_dev) {
249 err = -ENOMEM;
250 goto fail1;
251 }
247 252
248 gf2k->gameport = gameport; 253 gf2k->gameport = gameport;
254 gf2k->dev = input_dev;
249 255
250 gameport_set_drvdata(gameport, gf2k); 256 gameport_set_drvdata(gameport, gf2k);
251 257
@@ -295,53 +301,52 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
295 301
296 gf2k->length = gf2k_lens[gf2k->id]; 302 gf2k->length = gf2k_lens[gf2k->id];
297 303
298 init_input_dev(&gf2k->dev); 304 input_dev->name = gf2k_names[gf2k->id];
299 305 input_dev->phys = gf2k->phys;
300 gf2k->dev.private = gf2k; 306 input_dev->id.bustype = BUS_GAMEPORT;
301 gf2k->dev.open = gf2k_open; 307 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GENIUS;
302 gf2k->dev.close = gf2k_close; 308 input_dev->id.product = gf2k->id;
303 gf2k->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 309 input_dev->id.version = 0x0100;
310 input_dev->cdev.dev = &gameport->dev;
311 input_dev->private = gf2k;
304 312
305 gf2k->dev.name = gf2k_names[gf2k->id]; 313 input_dev->open = gf2k_open;
306 gf2k->dev.phys = gf2k->phys; 314 input_dev->close = gf2k_close;
307 gf2k->dev.id.bustype = BUS_GAMEPORT; 315 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
308 gf2k->dev.id.vendor = GAMEPORT_ID_VENDOR_GENIUS;
309 gf2k->dev.id.product = gf2k->id;
310 gf2k->dev.id.version = 0x0100;
311 316
312 for (i = 0; i < gf2k_axes[gf2k->id]; i++) 317 for (i = 0; i < gf2k_axes[gf2k->id]; i++)
313 set_bit(gf2k_abs[i], gf2k->dev.absbit); 318 set_bit(gf2k_abs[i], input_dev->absbit);
314 319
315 for (i = 0; i < gf2k_hats[gf2k->id]; i++) { 320 for (i = 0; i < gf2k_hats[gf2k->id]; i++) {
316 set_bit(ABS_HAT0X + i, gf2k->dev.absbit); 321 set_bit(ABS_HAT0X + i, input_dev->absbit);
317 gf2k->dev.absmin[ABS_HAT0X + i] = -1; 322 input_dev->absmin[ABS_HAT0X + i] = -1;
318 gf2k->dev.absmax[ABS_HAT0X + i] = 1; 323 input_dev->absmax[ABS_HAT0X + i] = 1;
319 } 324 }
320 325
321 for (i = 0; i < gf2k_joys[gf2k->id]; i++) 326 for (i = 0; i < gf2k_joys[gf2k->id]; i++)
322 set_bit(gf2k_btn_joy[i], gf2k->dev.keybit); 327 set_bit(gf2k_btn_joy[i], input_dev->keybit);
323 328
324 for (i = 0; i < gf2k_pads[gf2k->id]; i++) 329 for (i = 0; i < gf2k_pads[gf2k->id]; i++)
325 set_bit(gf2k_btn_pad[i], gf2k->dev.keybit); 330 set_bit(gf2k_btn_pad[i], input_dev->keybit);
326 331
327 gf2k_read_packet(gameport, gf2k->length, data); 332 gf2k_read_packet(gameport, gf2k->length, data);
328 gf2k_read(gf2k, data); 333 gf2k_read(gf2k, data);
329 334
330 for (i = 0; i < gf2k_axes[gf2k->id]; i++) { 335 for (i = 0; i < gf2k_axes[gf2k->id]; i++) {
331 gf2k->dev.absmax[gf2k_abs[i]] = (i < 2) ? gf2k->dev.abs[gf2k_abs[i]] * 2 - 32 : 336 input_dev->absmax[gf2k_abs[i]] = (i < 2) ? input_dev->abs[gf2k_abs[i]] * 2 - 32 :
332 gf2k->dev.abs[gf2k_abs[0]] + gf2k->dev.abs[gf2k_abs[1]] - 32; 337 input_dev->abs[gf2k_abs[0]] + input_dev->abs[gf2k_abs[1]] - 32;
333 gf2k->dev.absmin[gf2k_abs[i]] = 32; 338 input_dev->absmin[gf2k_abs[i]] = 32;
334 gf2k->dev.absfuzz[gf2k_abs[i]] = 8; 339 input_dev->absfuzz[gf2k_abs[i]] = 8;
335 gf2k->dev.absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; 340 input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0;
336 } 341 }
337 342
338 input_register_device(&gf2k->dev); 343 input_register_device(gf2k->dev);
339 printk(KERN_INFO "input: %s on %s\n", gf2k_names[gf2k->id], gameport->phys);
340 344
341 return 0; 345 return 0;
342 346
343fail2: gameport_close(gameport); 347 fail2: gameport_close(gameport);
344fail1: gameport_set_drvdata(gameport, NULL); 348 fail1: gameport_set_drvdata(gameport, NULL);
349 input_free_device(input_dev);
345 kfree(gf2k); 350 kfree(gf2k);
346 return err; 351 return err;
347} 352}
@@ -350,7 +355,7 @@ static void gf2k_disconnect(struct gameport *gameport)
350{ 355{
351 struct gf2k *gf2k = gameport_get_drvdata(gameport); 356 struct gf2k *gf2k = gameport_get_drvdata(gameport);
352 357
353 input_unregister_device(&gf2k->dev); 358 input_unregister_device(gf2k->dev);
354 gameport_close(gameport); 359 gameport_close(gameport);
355 gameport_set_drvdata(gameport, NULL); 360 gameport_set_drvdata(gameport, NULL);
356 kfree(gf2k); 361 kfree(gf2k);