aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/guillemot.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/joystick/guillemot.c')
-rw-r--r--drivers/input/joystick/guillemot.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 6a70ec429f06..c528473c09d8 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -67,7 +67,7 @@ struct guillemot_type {
67 67
68struct guillemot { 68struct guillemot {
69 struct gameport *gameport; 69 struct gameport *gameport;
70 struct input_dev dev; 70 struct input_dev *dev;
71 int bads; 71 int bads;
72 int reads; 72 int reads;
73 struct guillemot_type *type; 73 struct guillemot_type *type;
@@ -123,7 +123,7 @@ static int guillemot_read_packet(struct gameport *gameport, u8 *data)
123static void guillemot_poll(struct gameport *gameport) 123static void guillemot_poll(struct gameport *gameport)
124{ 124{
125 struct guillemot *guillemot = gameport_get_drvdata(gameport); 125 struct guillemot *guillemot = gameport_get_drvdata(gameport);
126 struct input_dev *dev = &guillemot->dev; 126 struct input_dev *dev = guillemot->dev;
127 u8 data[GUILLEMOT_MAX_LENGTH]; 127 u8 data[GUILLEMOT_MAX_LENGTH];
128 int i; 128 int i;
129 129
@@ -179,14 +179,20 @@ static void guillemot_close(struct input_dev *dev)
179static int guillemot_connect(struct gameport *gameport, struct gameport_driver *drv) 179static int guillemot_connect(struct gameport *gameport, struct gameport_driver *drv)
180{ 180{
181 struct guillemot *guillemot; 181 struct guillemot *guillemot;
182 struct input_dev *input_dev;
182 u8 data[GUILLEMOT_MAX_LENGTH]; 183 u8 data[GUILLEMOT_MAX_LENGTH];
183 int i, t; 184 int i, t;
184 int err; 185 int err;
185 186
186 if (!(guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL))) 187 guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL);
187 return -ENOMEM; 188 input_dev = input_allocate_device();
189 if (!guillemot || !input_dev) {
190 err = -ENOMEM;
191 goto fail1;
192 }
188 193
189 guillemot->gameport = gameport; 194 guillemot->gameport = gameport;
195 guillemot->dev = input_dev;
190 196
191 gameport_set_drvdata(gameport, guillemot); 197 gameport_set_drvdata(gameport, guillemot);
192 198
@@ -216,41 +222,40 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
216 gameport_set_poll_interval(gameport, 20); 222 gameport_set_poll_interval(gameport, 20);
217 223
218 sprintf(guillemot->phys, "%s/input0", gameport->phys); 224 sprintf(guillemot->phys, "%s/input0", gameport->phys);
219
220 guillemot->type = guillemot_type + i; 225 guillemot->type = guillemot_type + i;
221 226
222 guillemot->dev.private = guillemot; 227 input_dev->name = guillemot_type[i].name;
223 guillemot->dev.open = guillemot_open; 228 input_dev->phys = guillemot->phys;
224 guillemot->dev.close = guillemot_close; 229 input_dev->id.bustype = BUS_GAMEPORT;
230 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT;
231 input_dev->id.product = guillemot_type[i].id;
232 input_dev->id.version = (int)data[14] << 8 | data[15];
233 input_dev->cdev.dev = &gameport->dev;
234 input_dev->private = guillemot;
225 235
226 guillemot->dev.name = guillemot_type[i].name; 236 input_dev->open = guillemot_open;
227 guillemot->dev.phys = guillemot->phys; 237 input_dev->close = guillemot_close;
228 guillemot->dev.id.bustype = BUS_GAMEPORT;
229 guillemot->dev.id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT;
230 guillemot->dev.id.product = guillemot_type[i].id;
231 guillemot->dev.id.version = (int)data[14] << 8 | data[15];
232 238
233 guillemot->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 239 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
234 240
235 for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++) 241 for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++)
236 input_set_abs_params(&guillemot->dev, t, 0, 255, 0, 0); 242 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
237 243
238 if (guillemot->type->hat) { 244 if (guillemot->type->hat) {
239 input_set_abs_params(&guillemot->dev, ABS_HAT0X, -1, 1, 0, 0); 245 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0);
240 input_set_abs_params(&guillemot->dev, ABS_HAT0Y, -1, 1, 0, 0); 246 input_set_abs_params(input_dev, ABS_HAT0Y, -1, 1, 0, 0);
241 } 247 }
242 248
243 for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++) 249 for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++)
244 set_bit(t, guillemot->dev.keybit); 250 set_bit(t, input_dev->keybit);
245 251
246 input_register_device(&guillemot->dev); 252 input_register_device(guillemot->dev);
247 printk(KERN_INFO "input: %s ver %d.%02d on %s\n",
248 guillemot->type->name, data[14], data[15], gameport->phys);
249 253
250 return 0; 254 return 0;
251 255
252fail2: gameport_close(gameport); 256fail2: gameport_close(gameport);
253fail1: gameport_set_drvdata(gameport, NULL); 257fail1: gameport_set_drvdata(gameport, NULL);
258 input_free_device(input_dev);
254 kfree(guillemot); 259 kfree(guillemot);
255 return err; 260 return err;
256} 261}
@@ -260,7 +265,7 @@ static void guillemot_disconnect(struct gameport *gameport)
260 struct guillemot *guillemot = gameport_get_drvdata(gameport); 265 struct guillemot *guillemot = gameport_get_drvdata(gameport);
261 266
262 printk(KERN_INFO "guillemot.c: Failed %d reads out of %d on %s\n", guillemot->reads, guillemot->bads, guillemot->phys); 267 printk(KERN_INFO "guillemot.c: Failed %d reads out of %d on %s\n", guillemot->reads, guillemot->bads, guillemot->phys);
263 input_unregister_device(&guillemot->dev); 268 input_unregister_device(guillemot->dev);
264 gameport_close(gameport); 269 gameport_close(gameport);
265 kfree(guillemot); 270 kfree(guillemot);
266} 271}