aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/magellan.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 16:09:47 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 16:09:47 -0400
commit84860bf0644d7c45afe7ddbd30731c3e3c371fae (patch)
treed6c4b98a9c3fd9981e7fcc5d7729c9e01e327767 /drivers/input/joystick/magellan.c
parent8caf89157d64f1eedba37113afb4b303b2b3e301 (diff)
parent6fbfddcb52d8d9fa2cd209f5ac2a1c87497d55b5 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Diffstat (limited to 'drivers/input/joystick/magellan.c')
-rw-r--r--drivers/input/joystick/magellan.c71
1 files changed, 33 insertions, 38 deletions
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 1ba503627242..ca3cc2319d6a 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -49,14 +49,13 @@ MODULE_LICENSE("GPL");
49 49
50static int magellan_buttons[] = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; 50static int magellan_buttons[] = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 };
51static int magellan_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; 51static int magellan_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ };
52static char *magellan_name = "LogiCad3D Magellan / SpaceMouse";
53 52
54/* 53/*
55 * Per-Magellan data. 54 * Per-Magellan data.
56 */ 55 */
57 56
58struct magellan { 57struct magellan {
59 struct input_dev dev; 58 struct input_dev *dev;
60 int idx; 59 int idx;
61 unsigned char data[MAGELLAN_MAX_LENGTH]; 60 unsigned char data[MAGELLAN_MAX_LENGTH];
62 char phys[32]; 61 char phys[32];
@@ -85,7 +84,7 @@ static int magellan_crunch_nibbles(unsigned char *data, int count)
85 84
86static void magellan_process_packet(struct magellan* magellan, struct pt_regs *regs) 85static void magellan_process_packet(struct magellan* magellan, struct pt_regs *regs)
87{ 86{
88 struct input_dev *dev = &magellan->dev; 87 struct input_dev *dev = magellan->dev;
89 unsigned char *data = magellan->data; 88 unsigned char *data = magellan->data;
90 int i, t; 89 int i, t;
91 90
@@ -138,9 +137,9 @@ static void magellan_disconnect(struct serio *serio)
138{ 137{
139 struct magellan* magellan = serio_get_drvdata(serio); 138 struct magellan* magellan = serio_get_drvdata(serio);
140 139
141 input_unregister_device(&magellan->dev);
142 serio_close(serio); 140 serio_close(serio);
143 serio_set_drvdata(serio, NULL); 141 serio_set_drvdata(serio, NULL);
142 input_unregister_device(magellan->dev);
144 kfree(magellan); 143 kfree(magellan);
145} 144}
146 145
@@ -153,52 +152,48 @@ static void magellan_disconnect(struct serio *serio)
153static int magellan_connect(struct serio *serio, struct serio_driver *drv) 152static int magellan_connect(struct serio *serio, struct serio_driver *drv)
154{ 153{
155 struct magellan *magellan; 154 struct magellan *magellan;
156 int i, t; 155 struct input_dev *input_dev;
157 int err; 156 int err = -ENOMEM;
158 157 int i;
159 if (!(magellan = kmalloc(sizeof(struct magellan), GFP_KERNEL)))
160 return -ENOMEM;
161 158
162 memset(magellan, 0, sizeof(struct magellan)); 159 magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL);
160 input_dev = input_allocate_device();
161 if (!magellan || !input_dev)
162 goto fail;
163 163
164 magellan->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 164 magellan->dev = input_dev;
165 sprintf(magellan->phys, "%s/input0", serio->phys);
165 166
166 for (i = 0; i < 9; i++) 167 input_dev->name = "LogiCad3D Magellan / SpaceMouse";
167 set_bit(magellan_buttons[i], magellan->dev.keybit); 168 input_dev->phys = magellan->phys;
169 input_dev->id.bustype = BUS_RS232;
170 input_dev->id.vendor = SERIO_MAGELLAN;
171 input_dev->id.product = 0x0001;
172 input_dev->id.version = 0x0100;
173 input_dev->cdev.dev = &serio->dev;
174 input_dev->private = magellan;
168 175
169 for (i = 0; i < 6; i++) { 176 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
170 t = magellan_axes[i];
171 set_bit(t, magellan->dev.absbit);
172 magellan->dev.absmin[t] = -360;
173 magellan->dev.absmax[t] = 360;
174 }
175 177
176 sprintf(magellan->phys, "%s/input0", serio->phys); 178 for (i = 0; i < 9; i++)
179 set_bit(magellan_buttons[i], input_dev->keybit);
177 180
178 init_input_dev(&magellan->dev); 181 for (i = 0; i < 6; i++)
179 magellan->dev.private = magellan; 182 input_set_abs_params(input_dev, magellan_axes[i], -360, 360, 0, 0);
180 magellan->dev.name = magellan_name;
181 magellan->dev.phys = magellan->phys;
182 magellan->dev.id.bustype = BUS_RS232;
183 magellan->dev.id.vendor = SERIO_MAGELLAN;
184 magellan->dev.id.product = 0x0001;
185 magellan->dev.id.version = 0x0100;
186 magellan->dev.dev = &serio->dev;
187 183
188 serio_set_drvdata(serio, magellan); 184 serio_set_drvdata(serio, magellan);
189 185
190 err = serio_open(serio, drv); 186 err = serio_open(serio, drv);
191 if (err) { 187 if (err)
192 serio_set_drvdata(serio, NULL); 188 goto fail;
193 kfree(magellan);
194 return err;
195 }
196
197 input_register_device(&magellan->dev);
198
199 printk(KERN_INFO "input: %s on %s\n", magellan_name, serio->phys);
200 189
190 input_register_device(magellan->dev);
201 return 0; 191 return 0;
192
193 fail: serio_set_drvdata(serio, NULL);
194 input_free_device(input_dev);
195 kfree(magellan);
196 return err;
202} 197}
203 198
204/* 199/*