aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-01 02:55:20 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-01 02:55:20 -0500
commit35858adbfca13678af99fb31618ef4428d6dedb0 (patch)
tree3336feaa61324486945816cb52c347733e7c0821 /drivers/input/serio
parent197d4db752e67160d79fed09968c2140376a80a3 (diff)
parent4b70858ba8d4537daf782defebe5f2ff80ccef2b (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/serio')
-rw-r--r--drivers/input/serio/pcips2.c2
-rw-r--r--drivers/input/serio/serio.c131
-rw-r--r--drivers/input/serio/xilinx_ps2.c6
3 files changed, 60 insertions, 79 deletions
diff --git a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
index 1dacbe0d934..797314be7af 100644
--- a/drivers/input/serio/pcips2.c
+++ b/drivers/input/serio/pcips2.c
@@ -186,7 +186,7 @@ static void __devexit pcips2_remove(struct pci_dev *dev)
186 pci_disable_device(dev); 186 pci_disable_device(dev);
187} 187}
188 188
189static struct pci_device_id pcips2_ids[] = { 189static const struct pci_device_id pcips2_ids[] = {
190 { 190 {
191 .vendor = 0x14f2, /* MOBILITY */ 191 .vendor = 0x14f2, /* MOBILITY */
192 .device = 0x0123, /* Keyboard */ 192 .device = 0x0123, /* Keyboard */
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index e0f30186d51..c3b626e9eae 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -26,6 +26,8 @@
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 27 */
28 28
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30
29#include <linux/stddef.h> 31#include <linux/stddef.h>
30#include <linux/module.h> 32#include <linux/module.h>
31#include <linux/serio.h> 33#include <linux/serio.h>
@@ -119,11 +121,10 @@ static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
119 121
120 error = device_bind_driver(&serio->dev); 122 error = device_bind_driver(&serio->dev);
121 if (error) { 123 if (error) {
122 printk(KERN_WARNING 124 dev_warn(&serio->dev,
123 "serio: device_bind_driver() failed " 125 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
124 "for %s (%s) and %s, error: %d\n", 126 serio->phys, serio->name,
125 serio->phys, serio->name, 127 drv->description, error);
126 drv->description, error);
127 serio_disconnect_driver(serio); 128 serio_disconnect_driver(serio);
128 serio->dev.driver = NULL; 129 serio->dev.driver = NULL;
129 return error; 130 return error;
@@ -138,9 +139,9 @@ static void serio_find_driver(struct serio *serio)
138 139
139 error = device_attach(&serio->dev); 140 error = device_attach(&serio->dev);
140 if (error < 0) 141 if (error < 0)
141 printk(KERN_WARNING 142 dev_warn(&serio->dev,
142 "serio: device_attach() failed for %s (%s), error: %d\n", 143 "device_attach() failed for %s (%s), error: %d\n",
143 serio->phys, serio->name, error); 144 serio->phys, serio->name, error);
144} 145}
145 146
146 147
@@ -194,17 +195,14 @@ static int serio_queue_event(void *object, struct module *owner,
194 195
195 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); 196 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC);
196 if (!event) { 197 if (!event) {
197 printk(KERN_ERR 198 pr_err("Not enough memory to queue event %d\n", event_type);
198 "serio: Not enough memory to queue event %d\n",
199 event_type);
200 retval = -ENOMEM; 199 retval = -ENOMEM;
201 goto out; 200 goto out;
202 } 201 }
203 202
204 if (!try_module_get(owner)) { 203 if (!try_module_get(owner)) {
205 printk(KERN_WARNING 204 pr_warning("Can't get module reference, dropping event %d\n",
206 "serio: Can't get module reference, dropping event %d\n", 205 event_type);
207 event_type);
208 kfree(event); 206 kfree(event);
209 retval = -EINVAL; 207 retval = -EINVAL;
210 goto out; 208 goto out;
@@ -230,14 +228,12 @@ static void serio_free_event(struct serio_event *event)
230 228
231static void serio_remove_duplicate_events(struct serio_event *event) 229static void serio_remove_duplicate_events(struct serio_event *event)
232{ 230{
233 struct list_head *node, *next; 231 struct serio_event *e, *next;
234 struct serio_event *e;
235 unsigned long flags; 232 unsigned long flags;
236 233
237 spin_lock_irqsave(&serio_event_lock, flags); 234 spin_lock_irqsave(&serio_event_lock, flags);
238 235
239 list_for_each_safe(node, next, &serio_event_list) { 236 list_for_each_entry_safe(e, next, &serio_event_list, node) {
240 e = list_entry(node, struct serio_event, node);
241 if (event->object == e->object) { 237 if (event->object == e->object) {
242 /* 238 /*
243 * If this event is of different type we should not 239 * If this event is of different type we should not
@@ -247,7 +243,7 @@ static void serio_remove_duplicate_events(struct serio_event *event)
247 if (event->type != e->type) 243 if (event->type != e->type)
248 break; 244 break;
249 245
250 list_del_init(node); 246 list_del_init(&e->node);
251 serio_free_event(e); 247 serio_free_event(e);
252 } 248 }
253 } 249 }
@@ -258,23 +254,18 @@ static void serio_remove_duplicate_events(struct serio_event *event)
258 254
259static struct serio_event *serio_get_event(void) 255static struct serio_event *serio_get_event(void)
260{ 256{
261 struct serio_event *event; 257 struct serio_event *event = NULL;
262 struct list_head *node;
263 unsigned long flags; 258 unsigned long flags;
264 259
265 spin_lock_irqsave(&serio_event_lock, flags); 260 spin_lock_irqsave(&serio_event_lock, flags);
266 261
267 if (list_empty(&serio_event_list)) { 262 if (!list_empty(&serio_event_list)) {
268 spin_unlock_irqrestore(&serio_event_lock, flags); 263 event = list_first_entry(&serio_event_list,
269 return NULL; 264 struct serio_event, node);
265 list_del_init(&event->node);
270 } 266 }
271 267
272 node = serio_event_list.next;
273 event = list_entry(node, struct serio_event, node);
274 list_del_init(node);
275
276 spin_unlock_irqrestore(&serio_event_lock, flags); 268 spin_unlock_irqrestore(&serio_event_lock, flags);
277
278 return event; 269 return event;
279} 270}
280 271
@@ -287,29 +278,27 @@ static void serio_handle_event(void)
287 while ((event = serio_get_event())) { 278 while ((event = serio_get_event())) {
288 279
289 switch (event->type) { 280 switch (event->type) {
290 case SERIO_REGISTER_PORT:
291 serio_add_port(event->object);
292 break;
293 281
294 case SERIO_RECONNECT_PORT: 282 case SERIO_REGISTER_PORT:
295 serio_reconnect_port(event->object); 283 serio_add_port(event->object);
296 break; 284 break;
297 285
298 case SERIO_RESCAN_PORT: 286 case SERIO_RECONNECT_PORT:
299 serio_disconnect_port(event->object); 287 serio_reconnect_port(event->object);
300 serio_find_driver(event->object); 288 break;
301 break;
302 289
303 case SERIO_RECONNECT_CHAIN: 290 case SERIO_RESCAN_PORT:
304 serio_reconnect_chain(event->object); 291 serio_disconnect_port(event->object);
305 break; 292 serio_find_driver(event->object);
293 break;
306 294
307 case SERIO_ATTACH_DRIVER: 295 case SERIO_RECONNECT_CHAIN:
308 serio_attach_driver(event->object); 296 serio_reconnect_chain(event->object);
309 break; 297 break;
310 298
311 default: 299 case SERIO_ATTACH_DRIVER:
312 break; 300 serio_attach_driver(event->object);
301 break;
313 } 302 }
314 303
315 serio_remove_duplicate_events(event); 304 serio_remove_duplicate_events(event);
@@ -325,16 +314,14 @@ static void serio_handle_event(void)
325 */ 314 */
326static void serio_remove_pending_events(void *object) 315static void serio_remove_pending_events(void *object)
327{ 316{
328 struct list_head *node, *next; 317 struct serio_event *event, *next;
329 struct serio_event *event;
330 unsigned long flags; 318 unsigned long flags;
331 319
332 spin_lock_irqsave(&serio_event_lock, flags); 320 spin_lock_irqsave(&serio_event_lock, flags);
333 321
334 list_for_each_safe(node, next, &serio_event_list) { 322 list_for_each_entry_safe(event, next, &serio_event_list, node) {
335 event = list_entry(node, struct serio_event, node);
336 if (event->object == object) { 323 if (event->object == object) {
337 list_del_init(node); 324 list_del_init(&event->node);
338 serio_free_event(event); 325 serio_free_event(event);
339 } 326 }
340 } 327 }
@@ -380,7 +367,6 @@ static int serio_thread(void *nothing)
380 kthread_should_stop() || !list_empty(&serio_event_list)); 367 kthread_should_stop() || !list_empty(&serio_event_list));
381 } while (!kthread_should_stop()); 368 } while (!kthread_should_stop());
382 369
383 printk(KERN_DEBUG "serio: kseriod exiting\n");
384 return 0; 370 return 0;
385} 371}
386 372
@@ -445,6 +431,11 @@ static struct attribute_group serio_id_attr_group = {
445 .attrs = serio_device_id_attrs, 431 .attrs = serio_device_id_attrs,
446}; 432};
447 433
434static const struct attribute_group *serio_device_attr_groups[] = {
435 &serio_id_attr_group,
436 NULL
437};
438
448static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 439static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
449{ 440{
450 struct serio *serio = to_serio_port(dev); 441 struct serio *serio = to_serio_port(dev);
@@ -532,6 +523,7 @@ static void serio_init_port(struct serio *serio)
532 (long)atomic_inc_return(&serio_no) - 1); 523 (long)atomic_inc_return(&serio_no) - 1);
533 serio->dev.bus = &serio_bus; 524 serio->dev.bus = &serio_bus;
534 serio->dev.release = serio_release_port; 525 serio->dev.release = serio_release_port;
526 serio->dev.groups = serio_device_attr_groups;
535 if (serio->parent) { 527 if (serio->parent) {
536 serio->dev.parent = &serio->parent->dev; 528 serio->dev.parent = &serio->parent->dev;
537 serio->depth = serio->parent->depth + 1; 529 serio->depth = serio->parent->depth + 1;
@@ -555,21 +547,15 @@ static void serio_add_port(struct serio *serio)
555 } 547 }
556 548
557 list_add_tail(&serio->node, &serio_list); 549 list_add_tail(&serio->node, &serio_list);
550
558 if (serio->start) 551 if (serio->start)
559 serio->start(serio); 552 serio->start(serio);
553
560 error = device_add(&serio->dev); 554 error = device_add(&serio->dev);
561 if (error) 555 if (error)
562 printk(KERN_ERR 556 dev_err(&serio->dev,
563 "serio: device_add() failed for %s (%s), error: %d\n", 557 "device_add() failed for %s (%s), error: %d\n",
564 serio->phys, serio->name, error); 558 serio->phys, serio->name, error);
565 else {
566 serio->registered = true;
567 error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
568 if (error)
569 printk(KERN_ERR
570 "serio: sysfs_create_group() failed for %s (%s), error: %d\n",
571 serio->phys, serio->name, error);
572 }
573} 559}
574 560
575/* 561/*
@@ -596,11 +582,8 @@ static void serio_destroy_port(struct serio *serio)
596 serio->parent = NULL; 582 serio->parent = NULL;
597 } 583 }
598 584
599 if (serio->registered) { 585 if (device_is_registered(&serio->dev))
600 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
601 device_del(&serio->dev); 586 device_del(&serio->dev);
602 serio->registered = false;
603 }
604 587
605 list_del_init(&serio->node); 588 list_del_init(&serio->node);
606 serio_remove_pending_events(serio); 589 serio_remove_pending_events(serio);
@@ -798,9 +781,8 @@ static void serio_attach_driver(struct serio_driver *drv)
798 781
799 error = driver_attach(&drv->driver); 782 error = driver_attach(&drv->driver);
800 if (error) 783 if (error)
801 printk(KERN_WARNING 784 pr_warning("driver_attach() failed for %s with error %d\n",
802 "serio: driver_attach() failed for %s with error %d\n", 785 drv->driver.name, error);
803 drv->driver.name, error);
804} 786}
805 787
806int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name) 788int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
@@ -820,8 +802,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
820 802
821 error = driver_register(&drv->driver); 803 error = driver_register(&drv->driver);
822 if (error) { 804 if (error) {
823 printk(KERN_ERR 805 pr_err("driver_register() failed for %s, error: %d\n",
824 "serio: driver_register() failed for %s, error: %d\n",
825 drv->driver.name, error); 806 drv->driver.name, error);
826 return error; 807 return error;
827 } 808 }
@@ -987,7 +968,7 @@ irqreturn_t serio_interrupt(struct serio *serio,
987 968
988 if (likely(serio->drv)) { 969 if (likely(serio->drv)) {
989 ret = serio->drv->interrupt(serio, data, dfl); 970 ret = serio->drv->interrupt(serio, data, dfl);
990 } else if (!dfl && serio->registered) { 971 } else if (!dfl && device_is_registered(&serio->dev)) {
991 serio_rescan(serio); 972 serio_rescan(serio);
992 ret = IRQ_HANDLED; 973 ret = IRQ_HANDLED;
993 } 974 }
@@ -1018,7 +999,7 @@ static int __init serio_init(void)
1018 999
1019 error = bus_register(&serio_bus); 1000 error = bus_register(&serio_bus);
1020 if (error) { 1001 if (error) {
1021 printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error); 1002 pr_err("Failed to register serio bus, error: %d\n", error);
1022 return error; 1003 return error;
1023 } 1004 }
1024 1005
@@ -1026,7 +1007,7 @@ static int __init serio_init(void)
1026 if (IS_ERR(serio_task)) { 1007 if (IS_ERR(serio_task)) {
1027 bus_unregister(&serio_bus); 1008 bus_unregister(&serio_bus);
1028 error = PTR_ERR(serio_task); 1009 error = PTR_ERR(serio_task);
1029 printk(KERN_ERR "serio: Failed to start kseriod, error: %d\n", error); 1010 pr_err("Failed to start kseriod, error: %d\n", error);
1030 return error; 1011 return error;
1031 } 1012 }
1032 1013
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index ebb22f88c84..8298e1f6823 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -270,7 +270,7 @@ static int __devinit xps2_of_probe(struct of_device *ofdev,
270 drvdata->irq = r_irq.start; 270 drvdata->irq = r_irq.start;
271 271
272 phys_addr = r_mem.start; 272 phys_addr = r_mem.start;
273 remap_size = r_mem.end - r_mem.start + 1; 273 remap_size = resource_size(&r_mem);
274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) { 274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) {
275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n", 275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n",
276 (unsigned long long)phys_addr); 276 (unsigned long long)phys_addr);
@@ -344,7 +344,7 @@ static int __devexit xps2_of_remove(struct of_device *of_dev)
344 if (of_address_to_resource(of_dev->node, 0, &r_mem)) 344 if (of_address_to_resource(of_dev->node, 0, &r_mem))
345 dev_err(dev, "invalid address\n"); 345 dev_err(dev, "invalid address\n");
346 else 346 else
347 release_mem_region(r_mem.start, r_mem.end - r_mem.start + 1); 347 release_mem_region(r_mem.start, resource_size(&r_mem));
348 348
349 kfree(drvdata); 349 kfree(drvdata);
350 350
@@ -354,7 +354,7 @@ static int __devexit xps2_of_remove(struct of_device *of_dev)
354} 354}
355 355
356/* Match table for of_platform binding */ 356/* Match table for of_platform binding */
357static struct of_device_id xps2_of_match[] __devinitdata = { 357static const struct of_device_id xps2_of_match[] __devinitconst = {
358 { .compatible = "xlnx,xps-ps2-1.00.a", }, 358 { .compatible = "xlnx,xps-ps2-1.00.a", },
359 { /* end of list */ }, 359 { /* end of list */ },
360}; 360};