diff options
author | Vernon Mauery <vernux@us.ibm.com> | 2006-01-07 11:35:05 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-01-07 11:35:05 -0500 |
commit | 736ce43295682d060f2b93624b4a339f9af6aab1 (patch) | |
tree | 6f912c51447b389f1456494a3b436534b9b64bed /drivers | |
parent | 6020bafc9e30e04f4db65298d00e8e28ffb40652 (diff) |
Input: ibmasm - convert to dynamic input_dev allocation
Update the ibmasm driver to use the dynamic allocation of input_dev
structs to work with the sysfs subsystem.
Vojtech: Fixed some problems/bugs in the patch.
Dmitry: Fixed some more.
Signed-off-by: Vernon Mauery <vernux@us.ibm.com>
Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/ibmasm/ibmasm.h | 6 | ||||
-rw-r--r-- | drivers/misc/ibmasm/remote.c | 76 |
2 files changed, 48 insertions, 34 deletions
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h index d7e20a34f88d..1cef2387fa65 100644 --- a/drivers/misc/ibmasm/ibmasm.h +++ b/drivers/misc/ibmasm/ibmasm.h | |||
@@ -141,8 +141,8 @@ struct reverse_heartbeat { | |||
141 | }; | 141 | }; |
142 | 142 | ||
143 | struct ibmasm_remote { | 143 | struct ibmasm_remote { |
144 | struct input_dev keybd_dev; | 144 | struct input_dev *keybd_dev; |
145 | struct input_dev mouse_dev; | 145 | struct input_dev *mouse_dev; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | struct service_processor { | 148 | struct service_processor { |
@@ -157,7 +157,7 @@ struct service_processor { | |||
157 | char dirname[IBMASM_NAME_SIZE]; | 157 | char dirname[IBMASM_NAME_SIZE]; |
158 | char devname[IBMASM_NAME_SIZE]; | 158 | char devname[IBMASM_NAME_SIZE]; |
159 | unsigned int number; | 159 | unsigned int number; |
160 | struct ibmasm_remote *remote; | 160 | struct ibmasm_remote remote; |
161 | int serial_line; | 161 | int serial_line; |
162 | struct device *dev; | 162 | struct device *dev; |
163 | }; | 163 | }; |
diff --git a/drivers/misc/ibmasm/remote.c b/drivers/misc/ibmasm/remote.c index d3c48d23ee51..1abd0c58ae27 100644 --- a/drivers/misc/ibmasm/remote.c +++ b/drivers/misc/ibmasm/remote.c | |||
@@ -203,9 +203,9 @@ void ibmasm_handle_mouse_interrupt(struct service_processor *sp, | |||
203 | 203 | ||
204 | print_input(&input); | 204 | print_input(&input); |
205 | if (input.type == INPUT_TYPE_MOUSE) { | 205 | if (input.type == INPUT_TYPE_MOUSE) { |
206 | send_mouse_event(&sp->remote->mouse_dev, regs, &input); | 206 | send_mouse_event(sp->remote.mouse_dev, regs, &input); |
207 | } else if (input.type == INPUT_TYPE_KEYBOARD) { | 207 | } else if (input.type == INPUT_TYPE_KEYBOARD) { |
208 | send_keyboard_event(&sp->remote->keybd_dev, regs, &input); | 208 | send_keyboard_event(sp->remote.keybd_dev, regs, &input); |
209 | } else | 209 | } else |
210 | break; | 210 | break; |
211 | 211 | ||
@@ -217,56 +217,70 @@ void ibmasm_handle_mouse_interrupt(struct service_processor *sp, | |||
217 | int ibmasm_init_remote_input_dev(struct service_processor *sp) | 217 | int ibmasm_init_remote_input_dev(struct service_processor *sp) |
218 | { | 218 | { |
219 | /* set up the mouse input device */ | 219 | /* set up the mouse input device */ |
220 | struct ibmasm_remote *remote; | 220 | struct input_dev *mouse_dev, *keybd_dev; |
221 | struct pci_dev *pdev = to_pci_dev(sp->dev); | 221 | struct pci_dev *pdev = to_pci_dev(sp->dev); |
222 | int error = -ENOMEM; | ||
222 | int i; | 223 | int i; |
223 | 224 | ||
224 | sp->remote = remote = kmalloc(sizeof(*remote), GFP_KERNEL); | 225 | sp->remote.mouse_dev = mouse_dev = input_allocate_device(); |
225 | if (!remote) | 226 | sp->remote.keybd_dev = keybd_dev = input_allocate_device(); |
226 | return -ENOMEM; | ||
227 | 227 | ||
228 | memset(remote, 0, sizeof(*remote)); | 228 | if (!mouse_dev || !keybd_dev) |
229 | goto err_free_devices; | ||
229 | 230 | ||
230 | remote->mouse_dev.private = remote; | 231 | mouse_dev->id.bustype = BUS_PCI; |
231 | init_input_dev(&remote->mouse_dev); | 232 | mouse_dev->id.vendor = pdev->vendor; |
232 | remote->mouse_dev.id.vendor = pdev->vendor; | 233 | mouse_dev->id.product = pdev->device; |
233 | remote->mouse_dev.id.product = pdev->device; | 234 | mouse_dev->id.version = 1; |
234 | remote->mouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 235 | mouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
235 | remote->mouse_dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | | 236 | mouse_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | |
236 | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 237 | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
237 | set_bit(BTN_TOUCH, remote->mouse_dev.keybit); | 238 | set_bit(BTN_TOUCH, mouse_dev->keybit); |
238 | remote->mouse_dev.name = remote_mouse_name; | 239 | mouse_dev->name = remote_mouse_name; |
239 | input_set_abs_params(&remote->mouse_dev, ABS_X, 0, xmax, 0, 0); | 240 | input_set_abs_params(mouse_dev, ABS_X, 0, xmax, 0, 0); |
240 | input_set_abs_params(&remote->mouse_dev, ABS_Y, 0, ymax, 0, 0); | 241 | input_set_abs_params(mouse_dev, ABS_Y, 0, ymax, 0, 0); |
241 | 242 | ||
242 | remote->keybd_dev.private = remote; | 243 | mouse_dev->id.bustype = BUS_PCI; |
243 | init_input_dev(&remote->keybd_dev); | 244 | keybd_dev->id.vendor = pdev->vendor; |
244 | remote->keybd_dev.id.vendor = pdev->vendor; | 245 | keybd_dev->id.product = pdev->device; |
245 | remote->keybd_dev.id.product = pdev->device; | 246 | mouse_dev->id.version = 2; |
246 | remote->keybd_dev.evbit[0] = BIT(EV_KEY); | 247 | keybd_dev->evbit[0] = BIT(EV_KEY); |
247 | remote->keybd_dev.name = remote_keybd_name; | 248 | keybd_dev->name = remote_keybd_name; |
248 | 249 | ||
249 | for (i=0; i<XLATE_SIZE; i++) { | 250 | for (i = 0; i < XLATE_SIZE; i++) { |
250 | if (xlate_high[i]) | 251 | if (xlate_high[i]) |
251 | set_bit(xlate_high[i], remote->keybd_dev.keybit); | 252 | set_bit(xlate_high[i], keybd_dev->keybit); |
252 | if (xlate[i]) | 253 | if (xlate[i]) |
253 | set_bit(xlate[i], remote->keybd_dev.keybit); | 254 | set_bit(xlate[i], keybd_dev->keybit); |
254 | } | 255 | } |
255 | 256 | ||
256 | input_register_device(&remote->mouse_dev); | 257 | error = input_register_device(mouse_dev); |
257 | input_register_device(&remote->keybd_dev); | 258 | if (error) |
259 | goto err_free_devices; | ||
260 | |||
261 | error = input_register_device(keybd_dev); | ||
262 | if (error) | ||
263 | goto err_unregister_mouse_dev; | ||
264 | |||
258 | enable_mouse_interrupts(sp); | 265 | enable_mouse_interrupts(sp); |
259 | 266 | ||
260 | printk(KERN_INFO "ibmasm remote responding to events on RSA card %d\n", sp->number); | 267 | printk(KERN_INFO "ibmasm remote responding to events on RSA card %d\n", sp->number); |
261 | 268 | ||
262 | return 0; | 269 | return 0; |
270 | |||
271 | err_unregister_mouse_dev: | ||
272 | input_unregister_device(mouse_dev); | ||
273 | err_free_devices: | ||
274 | input_free_device(mouse_dev); | ||
275 | input_free_device(keybd_dev); | ||
276 | |||
277 | return error; | ||
263 | } | 278 | } |
264 | 279 | ||
265 | void ibmasm_free_remote_input_dev(struct service_processor *sp) | 280 | void ibmasm_free_remote_input_dev(struct service_processor *sp) |
266 | { | 281 | { |
267 | disable_mouse_interrupts(sp); | 282 | disable_mouse_interrupts(sp); |
268 | input_unregister_device(&sp->remote->keybd_dev); | 283 | input_unregister_device(sp->remote.mouse_dev); |
269 | input_unregister_device(&sp->remote->mouse_dev); | 284 | input_unregister_device(sp->remote.keybd_dev); |
270 | kfree(sp->remote); | ||
271 | } | 285 | } |
272 | 286 | ||