diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-10-28 21:32:01 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-28 21:32:01 -0400 |
commit | 5615ca7906aefbdc3318604c89db5931d0a25910 (patch) | |
tree | c34bcc7e314f49005ad88ac84c908128729c0329 /drivers | |
parent | 7a9f8f93d2dad38f30fbc79d8a1e6517373aa4b6 (diff) | |
parent | 9dfb7808fb05643b0d06df7411b94d9546696bf1 (diff) |
Merge branch 'upstream'
Diffstat (limited to 'drivers')
358 files changed, 9491 insertions, 6779 deletions
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 6b2eb6f39b4d..2a7d7ae83e1e 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/list.h> | 19 | #include <linux/list.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | 21 | ||
22 | #include "base.h" | ||
23 | |||
22 | /* This is a private structure used to tie the classdev and the | 24 | /* This is a private structure used to tie the classdev and the |
23 | * container .. it should never be visible outside this file */ | 25 | * container .. it should never be visible outside this file */ |
24 | struct internal_container { | 26 | struct internal_container { |
diff --git a/drivers/base/base.h b/drivers/base/base.h index 783752b68a9a..e3b548d46cff 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -1,3 +1,15 @@ | |||
1 | |||
2 | /* initialisation functions */ | ||
3 | |||
4 | extern int devices_init(void); | ||
5 | extern int buses_init(void); | ||
6 | extern int classes_init(void); | ||
7 | extern int firmware_init(void); | ||
8 | extern int platform_bus_init(void); | ||
9 | extern int system_bus_init(void); | ||
10 | extern int cpu_dev_init(void); | ||
11 | extern int attribute_container_init(void); | ||
12 | |||
1 | extern int bus_add_device(struct device * dev); | 13 | extern int bus_add_device(struct device * dev); |
2 | extern void bus_remove_device(struct device * dev); | 14 | extern void bus_remove_device(struct device * dev); |
3 | 15 | ||
diff --git a/drivers/base/class.c b/drivers/base/class.c index ce23dc8c18c5..c3e569730afe 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -99,7 +99,8 @@ struct class * class_get(struct class * cls) | |||
99 | 99 | ||
100 | void class_put(struct class * cls) | 100 | void class_put(struct class * cls) |
101 | { | 101 | { |
102 | subsys_put(&cls->subsys); | 102 | if (cls) |
103 | subsys_put(&cls->subsys); | ||
103 | } | 104 | } |
104 | 105 | ||
105 | 106 | ||
@@ -165,14 +166,25 @@ void class_unregister(struct class * cls) | |||
165 | 166 | ||
166 | static void class_create_release(struct class *cls) | 167 | static void class_create_release(struct class *cls) |
167 | { | 168 | { |
169 | pr_debug("%s called for %s\n", __FUNCTION__, cls->name); | ||
168 | kfree(cls); | 170 | kfree(cls); |
169 | } | 171 | } |
170 | 172 | ||
171 | static void class_device_create_release(struct class_device *class_dev) | 173 | static void class_device_create_release(struct class_device *class_dev) |
172 | { | 174 | { |
175 | pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); | ||
173 | kfree(class_dev); | 176 | kfree(class_dev); |
174 | } | 177 | } |
175 | 178 | ||
179 | /* needed to allow these devices to have parent class devices */ | ||
180 | static int class_device_create_hotplug(struct class_device *class_dev, | ||
181 | char **envp, int num_envp, | ||
182 | char *buffer, int buffer_size) | ||
183 | { | ||
184 | pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); | ||
185 | return 0; | ||
186 | } | ||
187 | |||
176 | /** | 188 | /** |
177 | * class_create - create a struct class structure | 189 | * class_create - create a struct class structure |
178 | * @owner: pointer to the module that is to "own" this struct class | 190 | * @owner: pointer to the module that is to "own" this struct class |
@@ -301,10 +313,12 @@ static void class_dev_release(struct kobject * kobj) | |||
301 | kfree(cd->devt_attr); | 313 | kfree(cd->devt_attr); |
302 | cd->devt_attr = NULL; | 314 | cd->devt_attr = NULL; |
303 | 315 | ||
304 | if (cls->release) | 316 | if (cd->release) |
317 | cd->release(cd); | ||
318 | else if (cls->release) | ||
305 | cls->release(cd); | 319 | cls->release(cd); |
306 | else { | 320 | else { |
307 | printk(KERN_ERR "Device class '%s' does not have a release() function, " | 321 | printk(KERN_ERR "Class Device '%s' does not have a release() function, " |
308 | "it is broken and must be fixed.\n", | 322 | "it is broken and must be fixed.\n", |
309 | cd->class_id); | 323 | cd->class_id); |
310 | WARN_ON(1); | 324 | WARN_ON(1); |
@@ -382,14 +396,18 @@ static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp, | |||
382 | buffer = &buffer[length]; | 396 | buffer = &buffer[length]; |
383 | buffer_size -= length; | 397 | buffer_size -= length; |
384 | 398 | ||
385 | if (class_dev->class->hotplug) { | 399 | if (class_dev->hotplug) { |
386 | /* have the bus specific function add its stuff */ | 400 | /* have the class device specific function add its stuff */ |
387 | retval = class_dev->class->hotplug (class_dev, envp, num_envp, | 401 | retval = class_dev->hotplug(class_dev, envp, num_envp, |
388 | buffer, buffer_size); | 402 | buffer, buffer_size); |
389 | if (retval) { | 403 | if (retval) |
390 | pr_debug ("%s - hotplug() returned %d\n", | 404 | pr_debug("class_dev->hotplug() returned %d\n", retval); |
391 | __FUNCTION__, retval); | 405 | } else if (class_dev->class->hotplug) { |
392 | } | 406 | /* have the class specific function add its stuff */ |
407 | retval = class_dev->class->hotplug(class_dev, envp, num_envp, | ||
408 | buffer, buffer_size); | ||
409 | if (retval) | ||
410 | pr_debug("class->hotplug() returned %d\n", retval); | ||
393 | } | 411 | } |
394 | 412 | ||
395 | return retval; | 413 | return retval; |
@@ -442,6 +460,13 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf) | |||
442 | return print_dev_t(buf, class_dev->devt); | 460 | return print_dev_t(buf, class_dev->devt); |
443 | } | 461 | } |
444 | 462 | ||
463 | static ssize_t store_uevent(struct class_device *class_dev, | ||
464 | const char *buf, size_t count) | ||
465 | { | ||
466 | kobject_hotplug(&class_dev->kobj, KOBJ_ADD); | ||
467 | return count; | ||
468 | } | ||
469 | |||
445 | void class_device_initialize(struct class_device *class_dev) | 470 | void class_device_initialize(struct class_device *class_dev) |
446 | { | 471 | { |
447 | kobj_set_kset_s(class_dev, class_obj_subsys); | 472 | kobj_set_kset_s(class_dev, class_obj_subsys); |
@@ -469,34 +494,45 @@ static char *make_class_name(struct class_device *class_dev) | |||
469 | 494 | ||
470 | int class_device_add(struct class_device *class_dev) | 495 | int class_device_add(struct class_device *class_dev) |
471 | { | 496 | { |
472 | struct class * parent = NULL; | 497 | struct class *parent_class = NULL; |
473 | struct class_interface * class_intf; | 498 | struct class_device *parent_class_dev = NULL; |
499 | struct class_interface *class_intf; | ||
474 | char *class_name = NULL; | 500 | char *class_name = NULL; |
475 | int error; | 501 | int error = -EINVAL; |
476 | 502 | ||
477 | class_dev = class_device_get(class_dev); | 503 | class_dev = class_device_get(class_dev); |
478 | if (!class_dev) | 504 | if (!class_dev) |
479 | return -EINVAL; | 505 | return -EINVAL; |
480 | 506 | ||
481 | if (!strlen(class_dev->class_id)) { | 507 | if (!strlen(class_dev->class_id)) |
482 | error = -EINVAL; | ||
483 | goto register_done; | 508 | goto register_done; |
484 | } | ||
485 | 509 | ||
486 | parent = class_get(class_dev->class); | 510 | parent_class = class_get(class_dev->class); |
511 | if (!parent_class) | ||
512 | goto register_done; | ||
513 | parent_class_dev = class_device_get(class_dev->parent); | ||
487 | 514 | ||
488 | pr_debug("CLASS: registering class device: ID = '%s'\n", | 515 | pr_debug("CLASS: registering class device: ID = '%s'\n", |
489 | class_dev->class_id); | 516 | class_dev->class_id); |
490 | 517 | ||
491 | /* first, register with generic layer. */ | 518 | /* first, register with generic layer. */ |
492 | kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id); | 519 | kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id); |
493 | if (parent) | 520 | if (parent_class_dev) |
494 | class_dev->kobj.parent = &parent->subsys.kset.kobj; | 521 | class_dev->kobj.parent = &parent_class_dev->kobj; |
522 | else | ||
523 | class_dev->kobj.parent = &parent_class->subsys.kset.kobj; | ||
495 | 524 | ||
496 | if ((error = kobject_add(&class_dev->kobj))) | 525 | error = kobject_add(&class_dev->kobj); |
526 | if (error) | ||
497 | goto register_done; | 527 | goto register_done; |
498 | 528 | ||
499 | /* add the needed attributes to this device */ | 529 | /* add the needed attributes to this device */ |
530 | class_dev->uevent_attr.attr.name = "uevent"; | ||
531 | class_dev->uevent_attr.attr.mode = S_IWUSR; | ||
532 | class_dev->uevent_attr.attr.owner = parent_class->owner; | ||
533 | class_dev->uevent_attr.store = store_uevent; | ||
534 | class_device_create_file(class_dev, &class_dev->uevent_attr); | ||
535 | |||
500 | if (MAJOR(class_dev->devt)) { | 536 | if (MAJOR(class_dev->devt)) { |
501 | struct class_device_attribute *attr; | 537 | struct class_device_attribute *attr; |
502 | attr = kzalloc(sizeof(*attr), GFP_KERNEL); | 538 | attr = kzalloc(sizeof(*attr), GFP_KERNEL); |
@@ -505,12 +541,10 @@ int class_device_add(struct class_device *class_dev) | |||
505 | kobject_del(&class_dev->kobj); | 541 | kobject_del(&class_dev->kobj); |
506 | goto register_done; | 542 | goto register_done; |
507 | } | 543 | } |
508 | |||
509 | attr->attr.name = "dev"; | 544 | attr->attr.name = "dev"; |
510 | attr->attr.mode = S_IRUGO; | 545 | attr->attr.mode = S_IRUGO; |
511 | attr->attr.owner = parent->owner; | 546 | attr->attr.owner = parent_class->owner; |
512 | attr->show = show_dev; | 547 | attr->show = show_dev; |
513 | attr->store = NULL; | ||
514 | class_device_create_file(class_dev, attr); | 548 | class_device_create_file(class_dev, attr); |
515 | class_dev->devt_attr = attr; | 549 | class_dev->devt_attr = attr; |
516 | } | 550 | } |
@@ -524,20 +558,23 @@ int class_device_add(struct class_device *class_dev) | |||
524 | class_name); | 558 | class_name); |
525 | } | 559 | } |
526 | 560 | ||
561 | kobject_hotplug(&class_dev->kobj, KOBJ_ADD); | ||
562 | |||
527 | /* notify any interfaces this device is now here */ | 563 | /* notify any interfaces this device is now here */ |
528 | if (parent) { | 564 | if (parent_class) { |
529 | down(&parent->sem); | 565 | down(&parent_class->sem); |
530 | list_add_tail(&class_dev->node, &parent->children); | 566 | list_add_tail(&class_dev->node, &parent_class->children); |
531 | list_for_each_entry(class_intf, &parent->interfaces, node) | 567 | list_for_each_entry(class_intf, &parent_class->interfaces, node) |
532 | if (class_intf->add) | 568 | if (class_intf->add) |
533 | class_intf->add(class_dev); | 569 | class_intf->add(class_dev, class_intf); |
534 | up(&parent->sem); | 570 | up(&parent_class->sem); |
535 | } | 571 | } |
536 | kobject_hotplug(&class_dev->kobj, KOBJ_ADD); | ||
537 | 572 | ||
538 | register_done: | 573 | register_done: |
539 | if (error && parent) | 574 | if (error) { |
540 | class_put(parent); | 575 | class_put(parent_class); |
576 | class_device_put(parent_class_dev); | ||
577 | } | ||
541 | class_device_put(class_dev); | 578 | class_device_put(class_dev); |
542 | kfree(class_name); | 579 | kfree(class_name); |
543 | return error; | 580 | return error; |
@@ -552,21 +589,28 @@ int class_device_register(struct class_device *class_dev) | |||
552 | /** | 589 | /** |
553 | * class_device_create - creates a class device and registers it with sysfs | 590 | * class_device_create - creates a class device and registers it with sysfs |
554 | * @cs: pointer to the struct class that this device should be registered to. | 591 | * @cs: pointer to the struct class that this device should be registered to. |
592 | * @parent: pointer to the parent struct class_device of this new device, if any. | ||
555 | * @dev: the dev_t for the char device to be added. | 593 | * @dev: the dev_t for the char device to be added. |
556 | * @device: a pointer to a struct device that is assiociated with this class device. | 594 | * @device: a pointer to a struct device that is assiociated with this class device. |
557 | * @fmt: string for the class device's name | 595 | * @fmt: string for the class device's name |
558 | * | 596 | * |
559 | * This function can be used by char device classes. A struct | 597 | * This function can be used by char device classes. A struct |
560 | * class_device will be created in sysfs, registered to the specified | 598 | * class_device will be created in sysfs, registered to the specified |
561 | * class. A "dev" file will be created, showing the dev_t for the | 599 | * class. |
562 | * device. The pointer to the struct class_device will be returned from | 600 | * A "dev" file will be created, showing the dev_t for the device, if |
563 | * the call. Any further sysfs files that might be required can be | 601 | * the dev_t is not 0,0. |
564 | * created using this pointer. | 602 | * If a pointer to a parent struct class_device is passed in, the newly |
603 | * created struct class_device will be a child of that device in sysfs. | ||
604 | * The pointer to the struct class_device will be returned from the | ||
605 | * call. Any further sysfs files that might be required can be created | ||
606 | * using this pointer. | ||
565 | * | 607 | * |
566 | * Note: the struct class passed to this function must have previously | 608 | * Note: the struct class passed to this function must have previously |
567 | * been created with a call to class_create(). | 609 | * been created with a call to class_create(). |
568 | */ | 610 | */ |
569 | struct class_device *class_device_create(struct class *cls, dev_t devt, | 611 | struct class_device *class_device_create(struct class *cls, |
612 | struct class_device *parent, | ||
613 | dev_t devt, | ||
570 | struct device *device, char *fmt, ...) | 614 | struct device *device, char *fmt, ...) |
571 | { | 615 | { |
572 | va_list args; | 616 | va_list args; |
@@ -585,6 +629,9 @@ struct class_device *class_device_create(struct class *cls, dev_t devt, | |||
585 | class_dev->devt = devt; | 629 | class_dev->devt = devt; |
586 | class_dev->dev = device; | 630 | class_dev->dev = device; |
587 | class_dev->class = cls; | 631 | class_dev->class = cls; |
632 | class_dev->parent = parent; | ||
633 | class_dev->release = class_device_create_release; | ||
634 | class_dev->hotplug = class_device_create_hotplug; | ||
588 | 635 | ||
589 | va_start(args, fmt); | 636 | va_start(args, fmt); |
590 | vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args); | 637 | vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args); |
@@ -602,17 +649,18 @@ error: | |||
602 | 649 | ||
603 | void class_device_del(struct class_device *class_dev) | 650 | void class_device_del(struct class_device *class_dev) |
604 | { | 651 | { |
605 | struct class * parent = class_dev->class; | 652 | struct class *parent_class = class_dev->class; |
606 | struct class_interface * class_intf; | 653 | struct class_device *parent_device = class_dev->parent; |
654 | struct class_interface *class_intf; | ||
607 | char *class_name = NULL; | 655 | char *class_name = NULL; |
608 | 656 | ||
609 | if (parent) { | 657 | if (parent_class) { |
610 | down(&parent->sem); | 658 | down(&parent_class->sem); |
611 | list_del_init(&class_dev->node); | 659 | list_del_init(&class_dev->node); |
612 | list_for_each_entry(class_intf, &parent->interfaces, node) | 660 | list_for_each_entry(class_intf, &parent_class->interfaces, node) |
613 | if (class_intf->remove) | 661 | if (class_intf->remove) |
614 | class_intf->remove(class_dev); | 662 | class_intf->remove(class_dev, class_intf); |
615 | up(&parent->sem); | 663 | up(&parent_class->sem); |
616 | } | 664 | } |
617 | 665 | ||
618 | if (class_dev->dev) { | 666 | if (class_dev->dev) { |
@@ -620,6 +668,7 @@ void class_device_del(struct class_device *class_dev) | |||
620 | sysfs_remove_link(&class_dev->kobj, "device"); | 668 | sysfs_remove_link(&class_dev->kobj, "device"); |
621 | sysfs_remove_link(&class_dev->dev->kobj, class_name); | 669 | sysfs_remove_link(&class_dev->dev->kobj, class_name); |
622 | } | 670 | } |
671 | class_device_remove_file(class_dev, &class_dev->uevent_attr); | ||
623 | if (class_dev->devt_attr) | 672 | if (class_dev->devt_attr) |
624 | class_device_remove_file(class_dev, class_dev->devt_attr); | 673 | class_device_remove_file(class_dev, class_dev->devt_attr); |
625 | class_device_remove_attrs(class_dev); | 674 | class_device_remove_attrs(class_dev); |
@@ -627,8 +676,8 @@ void class_device_del(struct class_device *class_dev) | |||
627 | kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); | 676 | kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); |
628 | kobject_del(&class_dev->kobj); | 677 | kobject_del(&class_dev->kobj); |
629 | 678 | ||
630 | if (parent) | 679 | class_device_put(parent_device); |
631 | class_put(parent); | 680 | class_put(parent_class); |
632 | kfree(class_name); | 681 | kfree(class_name); |
633 | } | 682 | } |
634 | 683 | ||
@@ -708,7 +757,8 @@ struct class_device * class_device_get(struct class_device *class_dev) | |||
708 | 757 | ||
709 | void class_device_put(struct class_device *class_dev) | 758 | void class_device_put(struct class_device *class_dev) |
710 | { | 759 | { |
711 | kobject_put(&class_dev->kobj); | 760 | if (class_dev) |
761 | kobject_put(&class_dev->kobj); | ||
712 | } | 762 | } |
713 | 763 | ||
714 | 764 | ||
@@ -728,7 +778,7 @@ int class_interface_register(struct class_interface *class_intf) | |||
728 | list_add_tail(&class_intf->node, &parent->interfaces); | 778 | list_add_tail(&class_intf->node, &parent->interfaces); |
729 | if (class_intf->add) { | 779 | if (class_intf->add) { |
730 | list_for_each_entry(class_dev, &parent->children, node) | 780 | list_for_each_entry(class_dev, &parent->children, node) |
731 | class_intf->add(class_dev); | 781 | class_intf->add(class_dev, class_intf); |
732 | } | 782 | } |
733 | up(&parent->sem); | 783 | up(&parent->sem); |
734 | 784 | ||
@@ -747,7 +797,7 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
747 | list_del_init(&class_intf->node); | 797 | list_del_init(&class_intf->node); |
748 | if (class_intf->remove) { | 798 | if (class_intf->remove) { |
749 | list_for_each_entry(class_dev, &parent->children, node) | 799 | list_for_each_entry(class_dev, &parent->children, node) |
750 | class_intf->remove(class_dev); | 800 | class_intf->remove(class_dev, class_intf); |
751 | } | 801 | } |
752 | up(&parent->sem); | 802 | up(&parent->sem); |
753 | 803 | ||
diff --git a/drivers/base/core.c b/drivers/base/core.c index 6ab73f5c799a..8615b42b517a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -154,6 +154,13 @@ static struct kset_hotplug_ops device_hotplug_ops = { | |||
154 | .hotplug = dev_hotplug, | 154 | .hotplug = dev_hotplug, |
155 | }; | 155 | }; |
156 | 156 | ||
157 | static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, | ||
158 | const char *buf, size_t count) | ||
159 | { | ||
160 | kobject_hotplug(&dev->kobj, KOBJ_ADD); | ||
161 | return count; | ||
162 | } | ||
163 | |||
157 | /** | 164 | /** |
158 | * device_subsys - structure to be registered with kobject core. | 165 | * device_subsys - structure to be registered with kobject core. |
159 | */ | 166 | */ |
@@ -225,6 +232,7 @@ void device_initialize(struct device *dev) | |||
225 | klist_children_put); | 232 | klist_children_put); |
226 | INIT_LIST_HEAD(&dev->dma_pools); | 233 | INIT_LIST_HEAD(&dev->dma_pools); |
227 | init_MUTEX(&dev->sem); | 234 | init_MUTEX(&dev->sem); |
235 | device_init_wakeup(dev, 0); | ||
228 | } | 236 | } |
229 | 237 | ||
230 | /** | 238 | /** |
@@ -258,6 +266,14 @@ int device_add(struct device *dev) | |||
258 | 266 | ||
259 | if ((error = kobject_add(&dev->kobj))) | 267 | if ((error = kobject_add(&dev->kobj))) |
260 | goto Error; | 268 | goto Error; |
269 | |||
270 | dev->uevent_attr.attr.name = "uevent"; | ||
271 | dev->uevent_attr.attr.mode = S_IWUSR; | ||
272 | if (dev->driver) | ||
273 | dev->uevent_attr.attr.owner = dev->driver->owner; | ||
274 | dev->uevent_attr.store = store_uevent; | ||
275 | device_create_file(dev, &dev->uevent_attr); | ||
276 | |||
261 | kobject_hotplug(&dev->kobj, KOBJ_ADD); | 277 | kobject_hotplug(&dev->kobj, KOBJ_ADD); |
262 | if ((error = device_pm_add(dev))) | 278 | if ((error = device_pm_add(dev))) |
263 | goto PMError; | 279 | goto PMError; |
@@ -349,6 +365,7 @@ void device_del(struct device * dev) | |||
349 | 365 | ||
350 | if (parent) | 366 | if (parent) |
351 | klist_del(&dev->knode_parent); | 367 | klist_del(&dev->knode_parent); |
368 | device_remove_file(dev, &dev->uevent_attr); | ||
352 | 369 | ||
353 | /* Notify the platform of the removal, in case they | 370 | /* Notify the platform of the removal, in case they |
354 | * need to do anything... | 371 | * need to do anything... |
@@ -390,11 +407,11 @@ static struct device * next_device(struct klist_iter * i) | |||
390 | 407 | ||
391 | /** | 408 | /** |
392 | * device_for_each_child - device child iterator. | 409 | * device_for_each_child - device child iterator. |
393 | * @dev: parent struct device. | 410 | * @parent: parent struct device. |
394 | * @data: data for the callback. | 411 | * @data: data for the callback. |
395 | * @fn: function to be called for each device. | 412 | * @fn: function to be called for each device. |
396 | * | 413 | * |
397 | * Iterate over @dev's child devices, and call @fn for each, | 414 | * Iterate over @parent's child devices, and call @fn for each, |
398 | * passing it @data. | 415 | * passing it @data. |
399 | * | 416 | * |
400 | * We check the return of @fn each time. If it returns anything | 417 | * We check the return of @fn each time. If it returns anything |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index b79badd0f158..081c927b1ed8 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/topology.h> | 9 | #include <linux/topology.h> |
10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
11 | 11 | ||
12 | #include "base.h" | ||
12 | 13 | ||
13 | struct sysdev_class cpu_sysdev_class = { | 14 | struct sysdev_class cpu_sysdev_class = { |
14 | set_kset_name("cpu"), | 15 | set_kset_name("cpu"), |
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index ef3fe513e398..161f3a390d90 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
@@ -28,6 +28,7 @@ static struct device * next_device(struct klist_iter * i) | |||
28 | /** | 28 | /** |
29 | * driver_for_each_device - Iterator for devices bound to a driver. | 29 | * driver_for_each_device - Iterator for devices bound to a driver. |
30 | * @drv: Driver we're iterating. | 30 | * @drv: Driver we're iterating. |
31 | * @start: Device to begin with | ||
31 | * @data: Data to pass to the callback. | 32 | * @data: Data to pass to the callback. |
32 | * @fn: Function to call for each device. | 33 | * @fn: Function to call for each device. |
33 | * | 34 | * |
@@ -57,7 +58,7 @@ EXPORT_SYMBOL_GPL(driver_for_each_device); | |||
57 | 58 | ||
58 | /** | 59 | /** |
59 | * driver_find_device - device iterator for locating a particular device. | 60 | * driver_find_device - device iterator for locating a particular device. |
60 | * @driver: The device's driver | 61 | * @drv: The device's driver |
61 | * @start: Device to begin with | 62 | * @start: Device to begin with |
62 | * @data: Data to pass to match function | 63 | * @data: Data to pass to match function |
63 | * @match: Callback function to check device | 64 | * @match: Callback function to check device |
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c index 88ab044932f2..cb1b98ae0d58 100644 --- a/drivers/base/firmware.c +++ b/drivers/base/firmware.c | |||
@@ -11,6 +11,9 @@ | |||
11 | #include <linux/kobject.h> | 11 | #include <linux/kobject.h> |
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/device.h> | ||
15 | |||
16 | #include "base.h" | ||
14 | 17 | ||
15 | static decl_subsys(firmware, NULL, NULL); | 18 | static decl_subsys(firmware, NULL, NULL); |
16 | 19 | ||
diff --git a/drivers/base/init.c b/drivers/base/init.c index a76ae5a221f3..84e604e25c4f 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c | |||
@@ -10,14 +10,8 @@ | |||
10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | 12 | ||
13 | extern int devices_init(void); | 13 | #include "base.h" |
14 | extern int buses_init(void); | 14 | |
15 | extern int classes_init(void); | ||
16 | extern int firmware_init(void); | ||
17 | extern int platform_bus_init(void); | ||
18 | extern int system_bus_init(void); | ||
19 | extern int cpu_dev_init(void); | ||
20 | extern int attribute_container_init(void); | ||
21 | /** | 15 | /** |
22 | * driver_init - initialize driver model. | 16 | * driver_init - initialize driver model. |
23 | * | 17 | * |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 361e204209eb..75ce8711bca5 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/bootmem.h> | 17 | #include <linux/bootmem.h> |
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | 19 | ||
20 | #include "base.h" | ||
21 | |||
20 | struct device platform_bus = { | 22 | struct device platform_bus = { |
21 | .bus_id = "platform", | 23 | .bus_id = "platform", |
22 | }; | 24 | }; |
@@ -279,13 +281,9 @@ static int platform_suspend(struct device * dev, pm_message_t state) | |||
279 | { | 281 | { |
280 | int ret = 0; | 282 | int ret = 0; |
281 | 283 | ||
282 | if (dev->driver && dev->driver->suspend) { | 284 | if (dev->driver && dev->driver->suspend) |
283 | ret = dev->driver->suspend(dev, state, SUSPEND_DISABLE); | 285 | ret = dev->driver->suspend(dev, state); |
284 | if (ret == 0) | 286 | |
285 | ret = dev->driver->suspend(dev, state, SUSPEND_SAVE_STATE); | ||
286 | if (ret == 0) | ||
287 | ret = dev->driver->suspend(dev, state, SUSPEND_POWER_DOWN); | ||
288 | } | ||
289 | return ret; | 287 | return ret; |
290 | } | 288 | } |
291 | 289 | ||
@@ -293,13 +291,9 @@ static int platform_resume(struct device * dev) | |||
293 | { | 291 | { |
294 | int ret = 0; | 292 | int ret = 0; |
295 | 293 | ||
296 | if (dev->driver && dev->driver->resume) { | 294 | if (dev->driver && dev->driver->resume) |
297 | ret = dev->driver->resume(dev, RESUME_POWER_ON); | 295 | ret = dev->driver->resume(dev); |
298 | if (ret == 0) | 296 | |
299 | ret = dev->driver->resume(dev, RESUME_RESTORE_STATE); | ||
300 | if (ret == 0) | ||
301 | ret = dev->driver->resume(dev, RESUME_ENABLE); | ||
302 | } | ||
303 | return ret; | 297 | return ret; |
304 | } | 298 | } |
305 | 299 | ||
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 8d04fb435c17..89c57875f3e5 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c | |||
@@ -48,8 +48,81 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c | |||
48 | static DEVICE_ATTR(state, 0644, state_show, state_store); | 48 | static DEVICE_ATTR(state, 0644, state_show, state_store); |
49 | 49 | ||
50 | 50 | ||
51 | /* | ||
52 | * wakeup - Report/change current wakeup option for device | ||
53 | * | ||
54 | * Some devices support "wakeup" events, which are hardware signals | ||
55 | * used to activate devices from suspended or low power states. Such | ||
56 | * devices have one of three values for the sysfs power/wakeup file: | ||
57 | * | ||
58 | * + "enabled\n" to issue the events; | ||
59 | * + "disabled\n" not to do so; or | ||
60 | * + "\n" for temporary or permanent inability to issue wakeup. | ||
61 | * | ||
62 | * (For example, unconfigured USB devices can't issue wakeups.) | ||
63 | * | ||
64 | * Familiar examples of devices that can issue wakeup events include | ||
65 | * keyboards and mice (both PS2 and USB styles), power buttons, modems, | ||
66 | * "Wake-On-LAN" Ethernet links, GPIO lines, and more. Some events | ||
67 | * will wake the entire system from a suspend state; others may just | ||
68 | * wake up the device (if the system as a whole is already active). | ||
69 | * Some wakeup events use normal IRQ lines; other use special out | ||
70 | * of band signaling. | ||
71 | * | ||
72 | * It is the responsibility of device drivers to enable (or disable) | ||
73 | * wakeup signaling as part of changing device power states, respecting | ||
74 | * the policy choices provided through the driver model. | ||
75 | * | ||
76 | * Devices may not be able to generate wakeup events from all power | ||
77 | * states. Also, the events may be ignored in some configurations; | ||
78 | * for example, they might need help from other devices that aren't | ||
79 | * active, or which may have wakeup disabled. Some drivers rely on | ||
80 | * wakeup events internally (unless they are disabled), keeping | ||
81 | * their hardware in low power modes whenever they're unused. This | ||
82 | * saves runtime power, without requiring system-wide sleep states. | ||
83 | */ | ||
84 | |||
85 | static const char enabled[] = "enabled"; | ||
86 | static const char disabled[] = "disabled"; | ||
87 | |||
88 | static ssize_t | ||
89 | wake_show(struct device * dev, struct device_attribute *attr, char * buf) | ||
90 | { | ||
91 | return sprintf(buf, "%s\n", device_can_wakeup(dev) | ||
92 | ? (device_may_wakeup(dev) ? enabled : disabled) | ||
93 | : ""); | ||
94 | } | ||
95 | |||
96 | static ssize_t | ||
97 | wake_store(struct device * dev, struct device_attribute *attr, | ||
98 | const char * buf, size_t n) | ||
99 | { | ||
100 | char *cp; | ||
101 | int len = n; | ||
102 | |||
103 | if (!device_can_wakeup(dev)) | ||
104 | return -EINVAL; | ||
105 | |||
106 | cp = memchr(buf, '\n', n); | ||
107 | if (cp) | ||
108 | len = cp - buf; | ||
109 | if (len == sizeof enabled - 1 | ||
110 | && strncmp(buf, enabled, sizeof enabled - 1) == 0) | ||
111 | device_set_wakeup_enable(dev, 1); | ||
112 | else if (len == sizeof disabled - 1 | ||
113 | && strncmp(buf, disabled, sizeof disabled - 1) == 0) | ||
114 | device_set_wakeup_enable(dev, 0); | ||
115 | else | ||
116 | return -EINVAL; | ||
117 | return n; | ||
118 | } | ||
119 | |||
120 | static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); | ||
121 | |||
122 | |||
51 | static struct attribute * power_attrs[] = { | 123 | static struct attribute * power_attrs[] = { |
52 | &dev_attr_state.attr, | 124 | &dev_attr_state.attr, |
125 | &dev_attr_wakeup.attr, | ||
53 | NULL, | 126 | NULL, |
54 | }; | 127 | }; |
55 | static struct attribute_group pm_attr_group = { | 128 | static struct attribute_group pm_attr_group = { |
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index 0e9e586e9ba3..881c48d941b7 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ | 1 | /* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ |
2 | #define VERSION "12" | 2 | #define VERSION "14" |
3 | #define AOE_MAJOR 152 | 3 | #define AOE_MAJOR 152 |
4 | #define DEVICE_NAME "aoe" | 4 | #define DEVICE_NAME "aoe" |
5 | 5 | ||
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index 45a243096187..41ae0ede619a 100644 --- a/drivers/block/aoe/aoechr.c +++ b/drivers/block/aoe/aoechr.c | |||
@@ -224,7 +224,7 @@ aoechr_init(void) | |||
224 | return PTR_ERR(aoe_class); | 224 | return PTR_ERR(aoe_class); |
225 | } | 225 | } |
226 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) | 226 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) |
227 | class_device_create(aoe_class, | 227 | class_device_create(aoe_class, NULL, |
228 | MKDEV(AOE_MAJOR, chardevs[i].minor), | 228 | MKDEV(AOE_MAJOR, chardevs[i].minor), |
229 | NULL, chardevs[i].name); | 229 | NULL, chardevs[i].name); |
230 | 230 | ||
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index b5be4b7d7b5b..5c9c7c1a3d4c 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/blkdev.h> | 8 | #include <linux/blkdev.h> |
9 | #include <linux/skbuff.h> | 9 | #include <linux/skbuff.h> |
10 | #include <linux/netdevice.h> | 10 | #include <linux/netdevice.h> |
11 | #include <asm/unaligned.h> | ||
11 | #include "aoe.h" | 12 | #include "aoe.h" |
12 | 13 | ||
13 | #define TIMERTICK (HZ / 10) | 14 | #define TIMERTICK (HZ / 10) |
@@ -311,16 +312,16 @@ ataid_complete(struct aoedev *d, unsigned char *id) | |||
311 | u16 n; | 312 | u16 n; |
312 | 313 | ||
313 | /* word 83: command set supported */ | 314 | /* word 83: command set supported */ |
314 | n = le16_to_cpup((__le16 *) &id[83<<1]); | 315 | n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1])); |
315 | 316 | ||
316 | /* word 86: command set/feature enabled */ | 317 | /* word 86: command set/feature enabled */ |
317 | n |= le16_to_cpup((__le16 *) &id[86<<1]); | 318 | n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1])); |
318 | 319 | ||
319 | if (n & (1<<10)) { /* bit 10: LBA 48 */ | 320 | if (n & (1<<10)) { /* bit 10: LBA 48 */ |
320 | d->flags |= DEVFL_EXT; | 321 | d->flags |= DEVFL_EXT; |
321 | 322 | ||
322 | /* word 100: number lba48 sectors */ | 323 | /* word 100: number lba48 sectors */ |
323 | ssize = le64_to_cpup((__le64 *) &id[100<<1]); | 324 | ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1])); |
324 | 325 | ||
325 | /* set as in ide-disk.c:init_idedisk_capacity */ | 326 | /* set as in ide-disk.c:init_idedisk_capacity */ |
326 | d->geo.cylinders = ssize; | 327 | d->geo.cylinders = ssize; |
@@ -331,12 +332,12 @@ ataid_complete(struct aoedev *d, unsigned char *id) | |||
331 | d->flags &= ~DEVFL_EXT; | 332 | d->flags &= ~DEVFL_EXT; |
332 | 333 | ||
333 | /* number lba28 sectors */ | 334 | /* number lba28 sectors */ |
334 | ssize = le32_to_cpup((__le32 *) &id[60<<1]); | 335 | ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1])); |
335 | 336 | ||
336 | /* NOTE: obsolete in ATA 6 */ | 337 | /* NOTE: obsolete in ATA 6 */ |
337 | d->geo.cylinders = le16_to_cpup((__le16 *) &id[54<<1]); | 338 | d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1])); |
338 | d->geo.heads = le16_to_cpup((__le16 *) &id[55<<1]); | 339 | d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1])); |
339 | d->geo.sectors = le16_to_cpup((__le16 *) &id[56<<1]); | 340 | d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1])); |
340 | } | 341 | } |
341 | d->ssize = ssize; | 342 | d->ssize = ssize; |
342 | d->geo.start = 0; | 343 | d->geo.start = 0; |
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index d42840cc0d1d..486ce1fdeb8c 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c | |||
@@ -337,10 +337,30 @@ static ssize_t disk_attr_show(struct kobject *kobj, struct attribute *attr, | |||
337 | return ret; | 337 | return ret; |
338 | } | 338 | } |
339 | 339 | ||
340 | static ssize_t disk_attr_store(struct kobject * kobj, struct attribute * attr, | ||
341 | const char *page, size_t count) | ||
342 | { | ||
343 | struct gendisk *disk = to_disk(kobj); | ||
344 | struct disk_attribute *disk_attr = | ||
345 | container_of(attr,struct disk_attribute,attr); | ||
346 | ssize_t ret = 0; | ||
347 | |||
348 | if (disk_attr->store) | ||
349 | ret = disk_attr->store(disk, page, count); | ||
350 | return ret; | ||
351 | } | ||
352 | |||
340 | static struct sysfs_ops disk_sysfs_ops = { | 353 | static struct sysfs_ops disk_sysfs_ops = { |
341 | .show = &disk_attr_show, | 354 | .show = &disk_attr_show, |
355 | .store = &disk_attr_store, | ||
342 | }; | 356 | }; |
343 | 357 | ||
358 | static ssize_t disk_uevent_store(struct gendisk * disk, | ||
359 | const char *buf, size_t count) | ||
360 | { | ||
361 | kobject_hotplug(&disk->kobj, KOBJ_ADD); | ||
362 | return count; | ||
363 | } | ||
344 | static ssize_t disk_dev_read(struct gendisk * disk, char *page) | 364 | static ssize_t disk_dev_read(struct gendisk * disk, char *page) |
345 | { | 365 | { |
346 | dev_t base = MKDEV(disk->major, disk->first_minor); | 366 | dev_t base = MKDEV(disk->major, disk->first_minor); |
@@ -382,6 +402,10 @@ static ssize_t disk_stats_read(struct gendisk * disk, char *page) | |||
382 | jiffies_to_msecs(disk_stat_read(disk, io_ticks)), | 402 | jiffies_to_msecs(disk_stat_read(disk, io_ticks)), |
383 | jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); | 403 | jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); |
384 | } | 404 | } |
405 | static struct disk_attribute disk_attr_uevent = { | ||
406 | .attr = {.name = "uevent", .mode = S_IWUSR }, | ||
407 | .store = disk_uevent_store | ||
408 | }; | ||
385 | static struct disk_attribute disk_attr_dev = { | 409 | static struct disk_attribute disk_attr_dev = { |
386 | .attr = {.name = "dev", .mode = S_IRUGO }, | 410 | .attr = {.name = "dev", .mode = S_IRUGO }, |
387 | .show = disk_dev_read | 411 | .show = disk_dev_read |
@@ -404,6 +428,7 @@ static struct disk_attribute disk_attr_stat = { | |||
404 | }; | 428 | }; |
405 | 429 | ||
406 | static struct attribute * default_attrs[] = { | 430 | static struct attribute * default_attrs[] = { |
431 | &disk_attr_uevent.attr, | ||
407 | &disk_attr_dev.attr, | 432 | &disk_attr_dev.attr, |
408 | &disk_attr_range.attr, | 433 | &disk_attr_range.attr, |
409 | &disk_attr_removable.attr, | 434 | &disk_attr_removable.attr, |
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c index b3982395f22b..82f2d6d2eeef 100644 --- a/drivers/block/paride/pg.c +++ b/drivers/block/paride/pg.c | |||
@@ -674,7 +674,7 @@ static int __init pg_init(void) | |||
674 | for (unit = 0; unit < PG_UNITS; unit++) { | 674 | for (unit = 0; unit < PG_UNITS; unit++) { |
675 | struct pg *dev = &devices[unit]; | 675 | struct pg *dev = &devices[unit]; |
676 | if (dev->present) { | 676 | if (dev->present) { |
677 | class_device_create(pg_class, MKDEV(major, unit), | 677 | class_device_create(pg_class, NULL, MKDEV(major, unit), |
678 | NULL, "pg%u", unit); | 678 | NULL, "pg%u", unit); |
679 | err = devfs_mk_cdev(MKDEV(major, unit), | 679 | err = devfs_mk_cdev(MKDEV(major, unit), |
680 | S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u", | 680 | S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u", |
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index d8d35233cf49..686c95573452 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c | |||
@@ -971,7 +971,7 @@ static int __init pt_init(void) | |||
971 | devfs_mk_dir("pt"); | 971 | devfs_mk_dir("pt"); |
972 | for (unit = 0; unit < PT_UNITS; unit++) | 972 | for (unit = 0; unit < PT_UNITS; unit++) |
973 | if (pt[unit].present) { | 973 | if (pt[unit].present) { |
974 | class_device_create(pt_class, MKDEV(major, unit), | 974 | class_device_create(pt_class, NULL, MKDEV(major, unit), |
975 | NULL, "pt%d", unit); | 975 | NULL, "pt%d", unit); |
976 | err = devfs_mk_cdev(MKDEV(major, unit), | 976 | err = devfs_mk_cdev(MKDEV(major, unit), |
977 | S_IFCHR | S_IRUSR | S_IWUSR, | 977 | S_IFCHR | S_IRUSR | S_IWUSR, |
@@ -980,7 +980,7 @@ static int __init pt_init(void) | |||
980 | class_device_destroy(pt_class, MKDEV(major, unit)); | 980 | class_device_destroy(pt_class, MKDEV(major, unit)); |
981 | goto out_class; | 981 | goto out_class; |
982 | } | 982 | } |
983 | class_device_create(pt_class, MKDEV(major, unit + 128), | 983 | class_device_create(pt_class, NULL, MKDEV(major, unit + 128), |
984 | NULL, "pt%dn", unit); | 984 | NULL, "pt%dn", unit); |
985 | err = devfs_mk_cdev(MKDEV(major, unit + 128), | 985 | err = devfs_mk_cdev(MKDEV(major, unit + 128), |
986 | S_IFCHR | S_IRUSR | S_IWUSR, | 986 | S_IFCHR | S_IRUSR | S_IWUSR, |
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index d57007b92f77..1ded3b433459 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * sx8.c: Driver for Promise SATA SX8 looks-like-I2O hardware | 2 | * sx8.c: Driver for Promise SATA SX8 looks-like-I2O hardware |
3 | * | 3 | * |
4 | * Copyright 2004 Red Hat, Inc. | 4 | * Copyright 2004-2005 Red Hat, Inc. |
5 | * | 5 | * |
6 | * Author/maintainer: Jeff Garzik <jgarzik@pobox.com> | 6 | * Author/maintainer: Jeff Garzik <jgarzik@pobox.com> |
7 | * | 7 | * |
@@ -31,10 +31,6 @@ | |||
31 | #include <asm/semaphore.h> | 31 | #include <asm/semaphore.h> |
32 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
33 | 33 | ||
34 | MODULE_AUTHOR("Jeff Garzik"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | MODULE_DESCRIPTION("Promise SATA SX8 block driver"); | ||
37 | |||
38 | #if 0 | 34 | #if 0 |
39 | #define CARM_DEBUG | 35 | #define CARM_DEBUG |
40 | #define CARM_VERBOSE_DEBUG | 36 | #define CARM_VERBOSE_DEBUG |
@@ -45,9 +41,35 @@ MODULE_DESCRIPTION("Promise SATA SX8 block driver"); | |||
45 | #undef CARM_NDEBUG | 41 | #undef CARM_NDEBUG |
46 | 42 | ||
47 | #define DRV_NAME "sx8" | 43 | #define DRV_NAME "sx8" |
48 | #define DRV_VERSION "0.8" | 44 | #define DRV_VERSION "1.0" |
49 | #define PFX DRV_NAME ": " | 45 | #define PFX DRV_NAME ": " |
50 | 46 | ||
47 | MODULE_AUTHOR("Jeff Garzik"); | ||
48 | MODULE_LICENSE("GPL"); | ||
49 | MODULE_DESCRIPTION("Promise SATA SX8 block driver"); | ||
50 | MODULE_VERSION(DRV_VERSION); | ||
51 | |||
52 | /* | ||
53 | * SX8 hardware has a single message queue for all ATA ports. | ||
54 | * When this driver was written, the hardware (firmware?) would | ||
55 | * corrupt data eventually, if more than one request was outstanding. | ||
56 | * As one can imagine, having 8 ports bottlenecking on a single | ||
57 | * command hurts performance. | ||
58 | * | ||
59 | * Based on user reports, later versions of the hardware (firmware?) | ||
60 | * seem to be able to survive with more than one command queued. | ||
61 | * | ||
62 | * Therefore, we default to the safe option -- 1 command -- but | ||
63 | * allow the user to increase this. | ||
64 | * | ||
65 | * SX8 should be able to support up to ~60 queued commands (CARM_MAX_REQ), | ||
66 | * but problems seem to occur when you exceed ~30, even on newer hardware. | ||
67 | */ | ||
68 | static int max_queue = 1; | ||
69 | module_param(max_queue, int, 0444); | ||
70 | MODULE_PARM_DESC(max_queue, "Maximum number of queued commands. (min==1, max==30, safe==1)"); | ||
71 | |||
72 | |||
51 | #define NEXT_RESP(idx) ((idx + 1) % RMSG_Q_LEN) | 73 | #define NEXT_RESP(idx) ((idx + 1) % RMSG_Q_LEN) |
52 | 74 | ||
53 | /* 0xf is just arbitrary, non-zero noise; this is sorta like poisoning */ | 75 | /* 0xf is just arbitrary, non-zero noise; this is sorta like poisoning */ |
@@ -90,12 +112,10 @@ enum { | |||
90 | 112 | ||
91 | /* command message queue limits */ | 113 | /* command message queue limits */ |
92 | CARM_MAX_REQ = 64, /* max command msgs per host */ | 114 | CARM_MAX_REQ = 64, /* max command msgs per host */ |
93 | CARM_MAX_Q = 1, /* one command at a time */ | ||
94 | CARM_MSG_LOW_WATER = (CARM_MAX_REQ / 4), /* refill mark */ | 115 | CARM_MSG_LOW_WATER = (CARM_MAX_REQ / 4), /* refill mark */ |
95 | 116 | ||
96 | /* S/G limits, host-wide and per-request */ | 117 | /* S/G limits, host-wide and per-request */ |
97 | CARM_MAX_REQ_SG = 32, /* max s/g entries per request */ | 118 | CARM_MAX_REQ_SG = 32, /* max s/g entries per request */ |
98 | CARM_SG_BOUNDARY = 0xffffUL, /* s/g segment boundary */ | ||
99 | CARM_MAX_HOST_SG = 600, /* max s/g entries per host */ | 119 | CARM_MAX_HOST_SG = 600, /* max s/g entries per host */ |
100 | CARM_SG_LOW_WATER = (CARM_MAX_HOST_SG / 4), /* re-fill mark */ | 120 | CARM_SG_LOW_WATER = (CARM_MAX_HOST_SG / 4), /* re-fill mark */ |
101 | 121 | ||
@@ -181,6 +201,10 @@ enum { | |||
181 | FL_DYN_MAJOR = (1 << 17), | 201 | FL_DYN_MAJOR = (1 << 17), |
182 | }; | 202 | }; |
183 | 203 | ||
204 | enum { | ||
205 | CARM_SG_BOUNDARY = 0xffffUL, /* s/g segment boundary */ | ||
206 | }; | ||
207 | |||
184 | enum scatter_gather_types { | 208 | enum scatter_gather_types { |
185 | SGT_32BIT = 0, | 209 | SGT_32BIT = 0, |
186 | SGT_64BIT = 1, | 210 | SGT_64BIT = 1, |
@@ -218,7 +242,6 @@ static const char *state_name[] = { | |||
218 | 242 | ||
219 | struct carm_port { | 243 | struct carm_port { |
220 | unsigned int port_no; | 244 | unsigned int port_no; |
221 | unsigned int n_queued; | ||
222 | struct gendisk *disk; | 245 | struct gendisk *disk; |
223 | struct carm_host *host; | 246 | struct carm_host *host; |
224 | 247 | ||
@@ -448,7 +471,7 @@ static inline int carm_lookup_bucket(u32 msg_size) | |||
448 | for (i = 0; i < ARRAY_SIZE(msg_sizes); i++) | 471 | for (i = 0; i < ARRAY_SIZE(msg_sizes); i++) |
449 | if (msg_size <= msg_sizes[i]) | 472 | if (msg_size <= msg_sizes[i]) |
450 | return i; | 473 | return i; |
451 | 474 | ||
452 | return -ENOENT; | 475 | return -ENOENT; |
453 | } | 476 | } |
454 | 477 | ||
@@ -509,7 +532,7 @@ static struct carm_request *carm_get_request(struct carm_host *host) | |||
509 | if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG)) | 532 | if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG)) |
510 | return NULL; | 533 | return NULL; |
511 | 534 | ||
512 | for (i = 0; i < CARM_MAX_Q; i++) | 535 | for (i = 0; i < max_queue; i++) |
513 | if ((host->msg_alloc & (1ULL << i)) == 0) { | 536 | if ((host->msg_alloc & (1ULL << i)) == 0) { |
514 | struct carm_request *crq = &host->req[i]; | 537 | struct carm_request *crq = &host->req[i]; |
515 | crq->port = NULL; | 538 | crq->port = NULL; |
@@ -521,14 +544,14 @@ static struct carm_request *carm_get_request(struct carm_host *host) | |||
521 | assert(host->n_msgs <= CARM_MAX_REQ); | 544 | assert(host->n_msgs <= CARM_MAX_REQ); |
522 | return crq; | 545 | return crq; |
523 | } | 546 | } |
524 | 547 | ||
525 | DPRINTK("no request available, returning NULL\n"); | 548 | DPRINTK("no request available, returning NULL\n"); |
526 | return NULL; | 549 | return NULL; |
527 | } | 550 | } |
528 | 551 | ||
529 | static int carm_put_request(struct carm_host *host, struct carm_request *crq) | 552 | static int carm_put_request(struct carm_host *host, struct carm_request *crq) |
530 | { | 553 | { |
531 | assert(crq->tag < CARM_MAX_Q); | 554 | assert(crq->tag < max_queue); |
532 | 555 | ||
533 | if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0)) | 556 | if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0)) |
534 | return -EINVAL; /* tried to clear a tag that was not active */ | 557 | return -EINVAL; /* tried to clear a tag that was not active */ |
@@ -791,7 +814,7 @@ static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq, | |||
791 | int is_ok) | 814 | int is_ok) |
792 | { | 815 | { |
793 | carm_end_request_queued(host, crq, is_ok); | 816 | carm_end_request_queued(host, crq, is_ok); |
794 | if (CARM_MAX_Q == 1) | 817 | if (max_queue == 1) |
795 | carm_round_robin(host); | 818 | carm_round_robin(host); |
796 | else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && | 819 | else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && |
797 | (host->hw_sg_used <= CARM_SG_LOW_WATER)) { | 820 | (host->hw_sg_used <= CARM_SG_LOW_WATER)) { |
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 543f93e0f23f..b9fbe6e7f9ae 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig | |||
@@ -55,14 +55,6 @@ config BT_HCIUART_BCSP | |||
55 | 55 | ||
56 | Say Y here to compile support for HCI BCSP protocol. | 56 | Say Y here to compile support for HCI BCSP protocol. |
57 | 57 | ||
58 | config BT_HCIUART_BCSP_TXCRC | ||
59 | bool "Transmit CRC with every BCSP packet" | ||
60 | depends on BT_HCIUART_BCSP | ||
61 | help | ||
62 | If you say Y here, a 16-bit CRC checksum will be transmitted along with | ||
63 | every BCSP (BlueCore Serial Protocol) packet sent to the Bluetooth chip. | ||
64 | This increases reliability, but slightly reduces efficiency. | ||
65 | |||
66 | config BT_HCIBCM203X | 58 | config BT_HCIBCM203X |
67 | tristate "HCI BCM203x USB driver" | 59 | tristate "HCI BCM203x USB driver" |
68 | depends on USB | 60 | depends on USB |
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 4fa85234d8b5..0db0400519c9 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c | |||
@@ -550,6 +550,9 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * | |||
550 | if (ignore) | 550 | if (ignore) |
551 | return -ENODEV; | 551 | return -ENODEV; |
552 | 552 | ||
553 | if (intf->cur_altsetting->desc.bInterfaceNumber > 0) | ||
554 | return -ENODEV; | ||
555 | |||
553 | data = kmalloc(sizeof(*data), GFP_KERNEL); | 556 | data = kmalloc(sizeof(*data), GFP_KERNEL); |
554 | if (!data) { | 557 | if (!data) { |
555 | BT_ERR("Can't allocate data structure"); | 558 | BT_ERR("Can't allocate data structure"); |
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index 0ee324e1265d..0a4761415ac3 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c | |||
@@ -1,35 +1,27 @@ | |||
1 | /* | ||
2 | BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ). | ||
3 | Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com> | ||
4 | |||
5 | Based on | ||
6 | hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com> | ||
7 | ABCSP by Carl Orsborn <cjo@csr.com> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License version 2 as | ||
11 | published by the Free Software Foundation; | ||
12 | |||
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
21 | |||
22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
24 | SOFTWARE IS DISCLAIMED. | ||
25 | */ | ||
26 | |||
27 | /* | 1 | /* |
28 | * $Id: hci_bcsp.c,v 1.2 2002/09/26 05:05:14 maxk Exp $ | 2 | * |
3 | * Bluetooth HCI UART driver | ||
4 | * | ||
5 | * Copyright (C) 2002-2003 Fabrizio Gennari <fabrizio.gennari@philips.com> | ||
6 | * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> | ||
7 | * | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
29 | */ | 23 | */ |
30 | 24 | ||
31 | #define VERSION "0.2" | ||
32 | |||
33 | #include <linux/config.h> | 25 | #include <linux/config.h> |
34 | #include <linux/module.h> | 26 | #include <linux/module.h> |
35 | 27 | ||
@@ -52,16 +44,56 @@ | |||
52 | 44 | ||
53 | #include <net/bluetooth/bluetooth.h> | 45 | #include <net/bluetooth/bluetooth.h> |
54 | #include <net/bluetooth/hci_core.h> | 46 | #include <net/bluetooth/hci_core.h> |
47 | |||
55 | #include "hci_uart.h" | 48 | #include "hci_uart.h" |
56 | #include "hci_bcsp.h" | ||
57 | 49 | ||
58 | #ifndef CONFIG_BT_HCIUART_DEBUG | 50 | #ifndef CONFIG_BT_HCIUART_DEBUG |
59 | #undef BT_DBG | 51 | #undef BT_DBG |
60 | #define BT_DBG( A... ) | 52 | #define BT_DBG( A... ) |
61 | #endif | 53 | #endif |
62 | 54 | ||
55 | #define VERSION "0.3" | ||
56 | |||
57 | static int txcrc = 1; | ||
63 | static int hciextn = 1; | 58 | static int hciextn = 1; |
64 | 59 | ||
60 | #define BCSP_TXWINSIZE 4 | ||
61 | |||
62 | #define BCSP_ACK_PKT 0x05 | ||
63 | #define BCSP_LE_PKT 0x06 | ||
64 | |||
65 | struct bcsp_struct { | ||
66 | struct sk_buff_head unack; /* Unack'ed packets queue */ | ||
67 | struct sk_buff_head rel; /* Reliable packets queue */ | ||
68 | struct sk_buff_head unrel; /* Unreliable packets queue */ | ||
69 | |||
70 | unsigned long rx_count; | ||
71 | struct sk_buff *rx_skb; | ||
72 | u8 rxseq_txack; /* rxseq == txack. */ | ||
73 | u8 rxack; /* Last packet sent by us that the peer ack'ed */ | ||
74 | struct timer_list tbcsp; | ||
75 | |||
76 | enum { | ||
77 | BCSP_W4_PKT_DELIMITER, | ||
78 | BCSP_W4_PKT_START, | ||
79 | BCSP_W4_BCSP_HDR, | ||
80 | BCSP_W4_DATA, | ||
81 | BCSP_W4_CRC | ||
82 | } rx_state; | ||
83 | |||
84 | enum { | ||
85 | BCSP_ESCSTATE_NOESC, | ||
86 | BCSP_ESCSTATE_ESC | ||
87 | } rx_esc_state; | ||
88 | |||
89 | u8 use_crc; | ||
90 | u16 message_crc; | ||
91 | u8 txack_req; /* Do we need to send ack's to the peer? */ | ||
92 | |||
93 | /* Reliable packet sequence number - used to assign seq to each rel pkt. */ | ||
94 | u8 msgq_txseq; | ||
95 | }; | ||
96 | |||
65 | /* ---- BCSP CRC calculation ---- */ | 97 | /* ---- BCSP CRC calculation ---- */ |
66 | 98 | ||
67 | /* Table for calculating CRC for polynomial 0x1021, LSB processed first, | 99 | /* Table for calculating CRC for polynomial 0x1021, LSB processed first, |
@@ -111,6 +143,7 @@ static u16 bcsp_crc_reverse(u16 crc) | |||
111 | rev |= (crc & 1); | 143 | rev |= (crc & 1); |
112 | crc = crc >> 1; | 144 | crc = crc >> 1; |
113 | } | 145 | } |
146 | |||
114 | return (rev); | 147 | return (rev); |
115 | } | 148 | } |
116 | 149 | ||
@@ -119,6 +152,7 @@ static u16 bcsp_crc_reverse(u16 crc) | |||
119 | static void bcsp_slip_msgdelim(struct sk_buff *skb) | 152 | static void bcsp_slip_msgdelim(struct sk_buff *skb) |
120 | { | 153 | { |
121 | const char pkt_delim = 0xc0; | 154 | const char pkt_delim = 0xc0; |
155 | |||
122 | memcpy(skb_put(skb, 1), &pkt_delim, 1); | 156 | memcpy(skb_put(skb, 1), &pkt_delim, 1); |
123 | } | 157 | } |
124 | 158 | ||
@@ -173,11 +207,8 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, | |||
173 | { | 207 | { |
174 | struct sk_buff *nskb; | 208 | struct sk_buff *nskb; |
175 | u8 hdr[4], chan; | 209 | u8 hdr[4], chan; |
176 | int rel, i; | ||
177 | |||
178 | #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC | ||
179 | u16 BCSP_CRC_INIT(bcsp_txmsg_crc); | 210 | u16 BCSP_CRC_INIT(bcsp_txmsg_crc); |
180 | #endif | 211 | int rel, i; |
181 | 212 | ||
182 | switch (pkt_type) { | 213 | switch (pkt_type) { |
183 | case HCI_ACLDATA_PKT: | 214 | case HCI_ACLDATA_PKT: |
@@ -240,9 +271,9 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, | |||
240 | BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); | 271 | BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); |
241 | bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; | 272 | bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; |
242 | } | 273 | } |
243 | #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC | 274 | |
244 | hdr[0] |= 0x40; | 275 | if (bcsp->use_crc) |
245 | #endif | 276 | hdr[0] |= 0x40; |
246 | 277 | ||
247 | hdr[1] = ((len << 4) & 0xff) | chan; | 278 | hdr[1] = ((len << 4) & 0xff) | chan; |
248 | hdr[2] = len >> 4; | 279 | hdr[2] = len >> 4; |
@@ -251,25 +282,25 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data, | |||
251 | /* Put BCSP header */ | 282 | /* Put BCSP header */ |
252 | for (i = 0; i < 4; i++) { | 283 | for (i = 0; i < 4; i++) { |
253 | bcsp_slip_one_byte(nskb, hdr[i]); | 284 | bcsp_slip_one_byte(nskb, hdr[i]); |
254 | #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC | 285 | |
255 | bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]); | 286 | if (bcsp->use_crc) |
256 | #endif | 287 | bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]); |
257 | } | 288 | } |
258 | 289 | ||
259 | /* Put payload */ | 290 | /* Put payload */ |
260 | for (i = 0; i < len; i++) { | 291 | for (i = 0; i < len; i++) { |
261 | bcsp_slip_one_byte(nskb, data[i]); | 292 | bcsp_slip_one_byte(nskb, data[i]); |
262 | #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC | 293 | |
263 | bcsp_crc_update(&bcsp_txmsg_crc, data[i]); | 294 | if (bcsp->use_crc) |
264 | #endif | 295 | bcsp_crc_update(&bcsp_txmsg_crc, data[i]); |
265 | } | 296 | } |
266 | 297 | ||
267 | #ifdef CONFIG_BT_HCIUART_BCSP_TXCRC | ||
268 | /* Put CRC */ | 298 | /* Put CRC */ |
269 | bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc); | 299 | if (bcsp->use_crc) { |
270 | bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff)); | 300 | bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc); |
271 | bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff)); | 301 | bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff)); |
272 | #endif | 302 | bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff)); |
303 | } | ||
273 | 304 | ||
274 | bcsp_slip_msgdelim(nskb); | 305 | bcsp_slip_msgdelim(nskb); |
275 | return nskb; | 306 | return nskb; |
@@ -317,7 +348,6 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu) | |||
317 | 348 | ||
318 | spin_unlock_irqrestore(&bcsp->unack.lock, flags); | 349 | spin_unlock_irqrestore(&bcsp->unack.lock, flags); |
319 | 350 | ||
320 | |||
321 | /* We could not send a reliable packet, either because there are | 351 | /* We could not send a reliable packet, either because there are |
322 | none or because there are too many unack'ed pkts. Did we receive | 352 | none or because there are too many unack'ed pkts. Did we receive |
323 | any packets we have not acknowledged yet ? */ | 353 | any packets we have not acknowledged yet ? */ |
@@ -363,7 +393,7 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp) | |||
363 | BT_ERR("Peer acked invalid packet"); | 393 | BT_ERR("Peer acked invalid packet"); |
364 | 394 | ||
365 | BT_DBG("Removing %u pkts out of %u, up to seqno %u", | 395 | BT_DBG("Removing %u pkts out of %u, up to seqno %u", |
366 | pkts_to_be_removed, bcsp->unack.qlen, (seqno - 1) & 0x07); | 396 | pkts_to_be_removed, bcsp->unack.qlen, (seqno - 1) & 0x07); |
367 | 397 | ||
368 | for (i = 0, skb = ((struct sk_buff *) &bcsp->unack)->next; i < pkts_to_be_removed | 398 | for (i = 0, skb = ((struct sk_buff *) &bcsp->unack)->next; i < pkts_to_be_removed |
369 | && skb != (struct sk_buff *) &bcsp->unack; i++) { | 399 | && skb != (struct sk_buff *) &bcsp->unack; i++) { |
@@ -374,8 +404,10 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp) | |||
374 | kfree_skb(skb); | 404 | kfree_skb(skb); |
375 | skb = nskb; | 405 | skb = nskb; |
376 | } | 406 | } |
407 | |||
377 | if (bcsp->unack.qlen == 0) | 408 | if (bcsp->unack.qlen == 0) |
378 | del_timer(&bcsp->tbcsp); | 409 | del_timer(&bcsp->tbcsp); |
410 | |||
379 | spin_unlock_irqrestore(&bcsp->unack.lock, flags); | 411 | spin_unlock_irqrestore(&bcsp->unack.lock, flags); |
380 | 412 | ||
381 | if (i != pkts_to_be_removed) | 413 | if (i != pkts_to_be_removed) |
@@ -530,6 +562,7 @@ static inline void bcsp_complete_rx_pkt(struct hci_uart *hu) | |||
530 | 562 | ||
531 | hci_recv_frame(bcsp->rx_skb); | 563 | hci_recv_frame(bcsp->rx_skb); |
532 | } | 564 | } |
565 | |||
533 | bcsp->rx_state = BCSP_W4_PKT_DELIMITER; | 566 | bcsp->rx_state = BCSP_W4_PKT_DELIMITER; |
534 | bcsp->rx_skb = NULL; | 567 | bcsp->rx_skb = NULL; |
535 | } | 568 | } |
@@ -598,8 +631,8 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count) | |||
598 | 631 | ||
599 | BT_ERR ("Checksum failed: computed %04x received %04x", | 632 | BT_ERR ("Checksum failed: computed %04x received %04x", |
600 | bcsp_crc_reverse(bcsp->message_crc), | 633 | bcsp_crc_reverse(bcsp->message_crc), |
601 | (bcsp->rx_skb-> data[bcsp->rx_skb->len - 2] << 8) + | 634 | (bcsp->rx_skb-> data[bcsp->rx_skb->len - 2] << 8) + |
602 | bcsp->rx_skb->data[bcsp->rx_skb->len - 1]); | 635 | bcsp->rx_skb->data[bcsp->rx_skb->len - 1]); |
603 | 636 | ||
604 | kfree_skb(bcsp->rx_skb); | 637 | kfree_skb(bcsp->rx_skb); |
605 | bcsp->rx_state = BCSP_W4_PKT_DELIMITER; | 638 | bcsp->rx_state = BCSP_W4_PKT_DELIMITER; |
@@ -633,7 +666,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count) | |||
633 | bcsp->rx_count = 4; | 666 | bcsp->rx_count = 4; |
634 | bcsp->rx_esc_state = BCSP_ESCSTATE_NOESC; | 667 | bcsp->rx_esc_state = BCSP_ESCSTATE_NOESC; |
635 | BCSP_CRC_INIT(bcsp->message_crc); | 668 | BCSP_CRC_INIT(bcsp->message_crc); |
636 | 669 | ||
637 | /* Do not increment ptr or decrement count | 670 | /* Do not increment ptr or decrement count |
638 | * Allocate packet. Max len of a BCSP pkt= | 671 | * Allocate packet. Max len of a BCSP pkt= |
639 | * 0xFFF (payload) +4 (header) +2 (crc) */ | 672 | * 0xFFF (payload) +4 (header) +2 (crc) */ |
@@ -698,6 +731,9 @@ static int bcsp_open(struct hci_uart *hu) | |||
698 | 731 | ||
699 | bcsp->rx_state = BCSP_W4_PKT_DELIMITER; | 732 | bcsp->rx_state = BCSP_W4_PKT_DELIMITER; |
700 | 733 | ||
734 | if (txcrc) | ||
735 | bcsp->use_crc = 1; | ||
736 | |||
701 | return 0; | 737 | return 0; |
702 | } | 738 | } |
703 | 739 | ||
@@ -718,18 +754,19 @@ static int bcsp_close(struct hci_uart *hu) | |||
718 | } | 754 | } |
719 | 755 | ||
720 | static struct hci_uart_proto bcsp = { | 756 | static struct hci_uart_proto bcsp = { |
721 | .id = HCI_UART_BCSP, | 757 | .id = HCI_UART_BCSP, |
722 | .open = bcsp_open, | 758 | .open = bcsp_open, |
723 | .close = bcsp_close, | 759 | .close = bcsp_close, |
724 | .enqueue = bcsp_enqueue, | 760 | .enqueue = bcsp_enqueue, |
725 | .dequeue = bcsp_dequeue, | 761 | .dequeue = bcsp_dequeue, |
726 | .recv = bcsp_recv, | 762 | .recv = bcsp_recv, |
727 | .flush = bcsp_flush | 763 | .flush = bcsp_flush |
728 | }; | 764 | }; |
729 | 765 | ||
730 | int bcsp_init(void) | 766 | int bcsp_init(void) |
731 | { | 767 | { |
732 | int err = hci_uart_register_proto(&bcsp); | 768 | int err = hci_uart_register_proto(&bcsp); |
769 | |||
733 | if (!err) | 770 | if (!err) |
734 | BT_INFO("HCI BCSP protocol initialized"); | 771 | BT_INFO("HCI BCSP protocol initialized"); |
735 | else | 772 | else |
@@ -743,5 +780,8 @@ int bcsp_deinit(void) | |||
743 | return hci_uart_unregister_proto(&bcsp); | 780 | return hci_uart_unregister_proto(&bcsp); |
744 | } | 781 | } |
745 | 782 | ||
783 | module_param(txcrc, bool, 0644); | ||
784 | MODULE_PARM_DESC(txcrc, "Transmit CRC with every BCSP packet"); | ||
785 | |||
746 | module_param(hciextn, bool, 0644); | 786 | module_param(hciextn, bool, 0644); |
747 | MODULE_PARM_DESC(hciextn, "Convert HCI Extensions into BCSP packets"); | 787 | MODULE_PARM_DESC(hciextn, "Convert HCI Extensions into BCSP packets"); |
diff --git a/drivers/bluetooth/hci_bcsp.h b/drivers/bluetooth/hci_bcsp.h deleted file mode 100644 index a2b3bb92274b..000000000000 --- a/drivers/bluetooth/hci_bcsp.h +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | /* | ||
2 | BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ). | ||
3 | Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com> | ||
4 | |||
5 | Based on | ||
6 | hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com> | ||
7 | ABCSP by Carl Orsborn <cjo@csr.com> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License version 2 as | ||
11 | published by the Free Software Foundation; | ||
12 | |||
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
21 | |||
22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
24 | SOFTWARE IS DISCLAIMED. | ||
25 | */ | ||
26 | |||
27 | /* | ||
28 | * $Id: hci_bcsp.h,v 1.2 2002/09/26 05:05:14 maxk Exp $ | ||
29 | */ | ||
30 | |||
31 | #ifndef __HCI_BCSP_H__ | ||
32 | #define __HCI_BCSP_H__ | ||
33 | |||
34 | #define BCSP_TXWINSIZE 4 | ||
35 | |||
36 | #define BCSP_ACK_PKT 0x05 | ||
37 | #define BCSP_LE_PKT 0x06 | ||
38 | |||
39 | struct bcsp_struct { | ||
40 | struct sk_buff_head unack; /* Unack'ed packets queue */ | ||
41 | struct sk_buff_head rel; /* Reliable packets queue */ | ||
42 | struct sk_buff_head unrel; /* Unreliable packets queue */ | ||
43 | |||
44 | unsigned long rx_count; | ||
45 | struct sk_buff *rx_skb; | ||
46 | u8 rxseq_txack; /* rxseq == txack. */ | ||
47 | u8 rxack; /* Last packet sent by us that the peer ack'ed */ | ||
48 | struct timer_list tbcsp; | ||
49 | |||
50 | enum { | ||
51 | BCSP_W4_PKT_DELIMITER, | ||
52 | BCSP_W4_PKT_START, | ||
53 | BCSP_W4_BCSP_HDR, | ||
54 | BCSP_W4_DATA, | ||
55 | BCSP_W4_CRC | ||
56 | } rx_state; | ||
57 | |||
58 | enum { | ||
59 | BCSP_ESCSTATE_NOESC, | ||
60 | BCSP_ESCSTATE_ESC | ||
61 | } rx_esc_state; | ||
62 | |||
63 | u16 message_crc; | ||
64 | u8 txack_req; /* Do we need to send ack's to the peer? */ | ||
65 | |||
66 | /* Reliable packet sequence number - used to assign seq to each rel pkt. */ | ||
67 | u8 msgq_txseq; | ||
68 | }; | ||
69 | |||
70 | #endif /* __HCI_BCSP_H__ */ | ||
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index cf8a22d58d96..12e369a66fc2 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c | |||
@@ -1,33 +1,27 @@ | |||
1 | /* | ||
2 | BlueZ - Bluetooth protocol stack for Linux | ||
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | ||
4 | |||
5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License version 2 as | ||
9 | published by the Free Software Foundation; | ||
10 | |||
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
19 | |||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
22 | SOFTWARE IS DISCLAIMED. | ||
23 | */ | ||
24 | |||
25 | /* | 1 | /* |
26 | * Bluetooth HCI UART(H4) protocol. | ||
27 | * | 2 | * |
28 | * $Id: hci_h4.c,v 1.3 2002/09/09 01:17:32 maxk Exp $ | 3 | * Bluetooth HCI UART driver |
4 | * | ||
5 | * Copyright (C) 2000-2001 Qualcomm Incorporated | ||
6 | * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> | ||
7 | * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> | ||
8 | * | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
29 | */ | 24 | */ |
30 | #define VERSION "1.2" | ||
31 | 25 | ||
32 | #include <linux/config.h> | 26 | #include <linux/config.h> |
33 | #include <linux/module.h> | 27 | #include <linux/module.h> |
@@ -51,24 +45,41 @@ | |||
51 | 45 | ||
52 | #include <net/bluetooth/bluetooth.h> | 46 | #include <net/bluetooth/bluetooth.h> |
53 | #include <net/bluetooth/hci_core.h> | 47 | #include <net/bluetooth/hci_core.h> |
48 | |||
54 | #include "hci_uart.h" | 49 | #include "hci_uart.h" |
55 | #include "hci_h4.h" | ||
56 | 50 | ||
57 | #ifndef CONFIG_BT_HCIUART_DEBUG | 51 | #ifndef CONFIG_BT_HCIUART_DEBUG |
58 | #undef BT_DBG | 52 | #undef BT_DBG |
59 | #define BT_DBG( A... ) | 53 | #define BT_DBG( A... ) |
60 | #endif | 54 | #endif |
61 | 55 | ||
56 | #define VERSION "1.2" | ||
57 | |||
58 | struct h4_struct { | ||
59 | unsigned long rx_state; | ||
60 | unsigned long rx_count; | ||
61 | struct sk_buff *rx_skb; | ||
62 | struct sk_buff_head txq; | ||
63 | }; | ||
64 | |||
65 | /* H4 receiver States */ | ||
66 | #define H4_W4_PACKET_TYPE 0 | ||
67 | #define H4_W4_EVENT_HDR 1 | ||
68 | #define H4_W4_ACL_HDR 2 | ||
69 | #define H4_W4_SCO_HDR 3 | ||
70 | #define H4_W4_DATA 4 | ||
71 | |||
62 | /* Initialize protocol */ | 72 | /* Initialize protocol */ |
63 | static int h4_open(struct hci_uart *hu) | 73 | static int h4_open(struct hci_uart *hu) |
64 | { | 74 | { |
65 | struct h4_struct *h4; | 75 | struct h4_struct *h4; |
66 | 76 | ||
67 | BT_DBG("hu %p", hu); | 77 | BT_DBG("hu %p", hu); |
68 | 78 | ||
69 | h4 = kmalloc(sizeof(*h4), GFP_ATOMIC); | 79 | h4 = kmalloc(sizeof(*h4), GFP_ATOMIC); |
70 | if (!h4) | 80 | if (!h4) |
71 | return -ENOMEM; | 81 | return -ENOMEM; |
82 | |||
72 | memset(h4, 0, sizeof(*h4)); | 83 | memset(h4, 0, sizeof(*h4)); |
73 | 84 | ||
74 | skb_queue_head_init(&h4->txq); | 85 | skb_queue_head_init(&h4->txq); |
@@ -83,7 +94,9 @@ static int h4_flush(struct hci_uart *hu) | |||
83 | struct h4_struct *h4 = hu->priv; | 94 | struct h4_struct *h4 = hu->priv; |
84 | 95 | ||
85 | BT_DBG("hu %p", hu); | 96 | BT_DBG("hu %p", hu); |
97 | |||
86 | skb_queue_purge(&h4->txq); | 98 | skb_queue_purge(&h4->txq); |
99 | |||
87 | return 0; | 100 | return 0; |
88 | } | 101 | } |
89 | 102 | ||
@@ -91,16 +104,19 @@ static int h4_flush(struct hci_uart *hu) | |||
91 | static int h4_close(struct hci_uart *hu) | 104 | static int h4_close(struct hci_uart *hu) |
92 | { | 105 | { |
93 | struct h4_struct *h4 = hu->priv; | 106 | struct h4_struct *h4 = hu->priv; |
107 | |||
94 | hu->priv = NULL; | 108 | hu->priv = NULL; |
95 | 109 | ||
96 | BT_DBG("hu %p", hu); | 110 | BT_DBG("hu %p", hu); |
97 | 111 | ||
98 | skb_queue_purge(&h4->txq); | 112 | skb_queue_purge(&h4->txq); |
113 | |||
99 | if (h4->rx_skb) | 114 | if (h4->rx_skb) |
100 | kfree_skb(h4->rx_skb); | 115 | kfree_skb(h4->rx_skb); |
101 | 116 | ||
102 | hu->priv = NULL; | 117 | hu->priv = NULL; |
103 | kfree(h4); | 118 | kfree(h4); |
119 | |||
104 | return 0; | 120 | return 0; |
105 | } | 121 | } |
106 | 122 | ||
@@ -114,6 +130,7 @@ static int h4_enqueue(struct hci_uart *hu, struct sk_buff *skb) | |||
114 | /* Prepend skb with frame type */ | 130 | /* Prepend skb with frame type */ |
115 | memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); | 131 | memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); |
116 | skb_queue_tail(&h4->txq, skb); | 132 | skb_queue_tail(&h4->txq, skb); |
133 | |||
117 | return 0; | 134 | return 0; |
118 | } | 135 | } |
119 | 136 | ||
@@ -122,6 +139,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len) | |||
122 | register int room = skb_tailroom(h4->rx_skb); | 139 | register int room = skb_tailroom(h4->rx_skb); |
123 | 140 | ||
124 | BT_DBG("len %d room %d", len, room); | 141 | BT_DBG("len %d room %d", len, room); |
142 | |||
125 | if (!len) { | 143 | if (!len) { |
126 | hci_recv_frame(h4->rx_skb); | 144 | hci_recv_frame(h4->rx_skb); |
127 | } else if (len > room) { | 145 | } else if (len > room) { |
@@ -136,6 +154,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len) | |||
136 | h4->rx_state = H4_W4_PACKET_TYPE; | 154 | h4->rx_state = H4_W4_PACKET_TYPE; |
137 | h4->rx_skb = NULL; | 155 | h4->rx_skb = NULL; |
138 | h4->rx_count = 0; | 156 | h4->rx_count = 0; |
157 | |||
139 | return 0; | 158 | return 0; |
140 | } | 159 | } |
141 | 160 | ||
@@ -228,6 +247,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) | |||
228 | ptr++; count--; | 247 | ptr++; count--; |
229 | continue; | 248 | continue; |
230 | }; | 249 | }; |
250 | |||
231 | ptr++; count--; | 251 | ptr++; count--; |
232 | 252 | ||
233 | /* Allocate packet */ | 253 | /* Allocate packet */ |
@@ -238,9 +258,11 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) | |||
238 | h4->rx_count = 0; | 258 | h4->rx_count = 0; |
239 | return 0; | 259 | return 0; |
240 | } | 260 | } |
261 | |||
241 | h4->rx_skb->dev = (void *) hu->hdev; | 262 | h4->rx_skb->dev = (void *) hu->hdev; |
242 | bt_cb(h4->rx_skb)->pkt_type = type; | 263 | bt_cb(h4->rx_skb)->pkt_type = type; |
243 | } | 264 | } |
265 | |||
244 | return count; | 266 | return count; |
245 | } | 267 | } |
246 | 268 | ||
@@ -251,23 +273,24 @@ static struct sk_buff *h4_dequeue(struct hci_uart *hu) | |||
251 | } | 273 | } |
252 | 274 | ||
253 | static struct hci_uart_proto h4p = { | 275 | static struct hci_uart_proto h4p = { |
254 | .id = HCI_UART_H4, | 276 | .id = HCI_UART_H4, |
255 | .open = h4_open, | 277 | .open = h4_open, |
256 | .close = h4_close, | 278 | .close = h4_close, |
257 | .recv = h4_recv, | 279 | .recv = h4_recv, |
258 | .enqueue = h4_enqueue, | 280 | .enqueue = h4_enqueue, |
259 | .dequeue = h4_dequeue, | 281 | .dequeue = h4_dequeue, |
260 | .flush = h4_flush, | 282 | .flush = h4_flush, |
261 | }; | 283 | }; |
262 | 284 | ||
263 | int h4_init(void) | 285 | int h4_init(void) |
264 | { | 286 | { |
265 | int err = hci_uart_register_proto(&h4p); | 287 | int err = hci_uart_register_proto(&h4p); |
288 | |||
266 | if (!err) | 289 | if (!err) |
267 | BT_INFO("HCI H4 protocol initialized"); | 290 | BT_INFO("HCI H4 protocol initialized"); |
268 | else | 291 | else |
269 | BT_ERR("HCI H4 protocol registration failed"); | 292 | BT_ERR("HCI H4 protocol registration failed"); |
270 | 293 | ||
271 | return err; | 294 | return err; |
272 | } | 295 | } |
273 | 296 | ||
diff --git a/drivers/bluetooth/hci_h4.h b/drivers/bluetooth/hci_h4.h deleted file mode 100644 index b95ff54bfd47..000000000000 --- a/drivers/bluetooth/hci_h4.h +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* | ||
2 | BlueZ - Bluetooth protocol stack for Linux | ||
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | ||
4 | |||
5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License version 2 as | ||
9 | published by the Free Software Foundation; | ||
10 | |||
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
19 | |||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
22 | SOFTWARE IS DISCLAIMED. | ||
23 | */ | ||
24 | |||
25 | /* | ||
26 | * $Id: hci_h4.h,v 1.2 2002/09/09 01:17:32 maxk Exp $ | ||
27 | */ | ||
28 | |||
29 | #ifdef __KERNEL__ | ||
30 | struct h4_struct { | ||
31 | unsigned long rx_state; | ||
32 | unsigned long rx_count; | ||
33 | struct sk_buff *rx_skb; | ||
34 | struct sk_buff_head txq; | ||
35 | }; | ||
36 | |||
37 | /* H4 receiver States */ | ||
38 | #define H4_W4_PACKET_TYPE 0 | ||
39 | #define H4_W4_EVENT_HDR 1 | ||
40 | #define H4_W4_ACL_HDR 2 | ||
41 | #define H4_W4_SCO_HDR 3 | ||
42 | #define H4_W4_DATA 4 | ||
43 | |||
44 | #endif /* __KERNEL__ */ | ||
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index aed80cc22890..4a775f6ea390 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -1,33 +1,27 @@ | |||
1 | /* | ||
2 | BlueZ - Bluetooth protocol stack for Linux | ||
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | ||
4 | |||
5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License version 2 as | ||
9 | published by the Free Software Foundation; | ||
10 | |||
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
19 | |||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
22 | SOFTWARE IS DISCLAIMED. | ||
23 | */ | ||
24 | |||
25 | /* | 1 | /* |
26 | * Bluetooth HCI UART driver. | ||
27 | * | 2 | * |
28 | * $Id: hci_ldisc.c,v 1.5 2002/10/02 18:37:20 maxk Exp $ | 3 | * Bluetooth HCI UART driver |
4 | * | ||
5 | * Copyright (C) 2000-2001 Qualcomm Incorporated | ||
6 | * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> | ||
7 | * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> | ||
8 | * | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
29 | */ | 24 | */ |
30 | #define VERSION "2.1" | ||
31 | 25 | ||
32 | #include <linux/config.h> | 26 | #include <linux/config.h> |
33 | #include <linux/module.h> | 27 | #include <linux/module.h> |
@@ -59,6 +53,8 @@ | |||
59 | #define BT_DBG( A... ) | 53 | #define BT_DBG( A... ) |
60 | #endif | 54 | #endif |
61 | 55 | ||
56 | #define VERSION "2.2" | ||
57 | |||
62 | static int reset = 0; | 58 | static int reset = 0; |
63 | 59 | ||
64 | static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO]; | 60 | static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO]; |
@@ -72,6 +68,7 @@ int hci_uart_register_proto(struct hci_uart_proto *p) | |||
72 | return -EEXIST; | 68 | return -EEXIST; |
73 | 69 | ||
74 | hup[p->id] = p; | 70 | hup[p->id] = p; |
71 | |||
75 | return 0; | 72 | return 0; |
76 | } | 73 | } |
77 | 74 | ||
@@ -84,6 +81,7 @@ int hci_uart_unregister_proto(struct hci_uart_proto *p) | |||
84 | return -EINVAL; | 81 | return -EINVAL; |
85 | 82 | ||
86 | hup[p->id] = NULL; | 83 | hup[p->id] = NULL; |
84 | |||
87 | return 0; | 85 | return 0; |
88 | } | 86 | } |
89 | 87 | ||
@@ -91,13 +89,14 @@ static struct hci_uart_proto *hci_uart_get_proto(unsigned int id) | |||
91 | { | 89 | { |
92 | if (id >= HCI_UART_MAX_PROTO) | 90 | if (id >= HCI_UART_MAX_PROTO) |
93 | return NULL; | 91 | return NULL; |
92 | |||
94 | return hup[id]; | 93 | return hup[id]; |
95 | } | 94 | } |
96 | 95 | ||
97 | static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) | 96 | static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) |
98 | { | 97 | { |
99 | struct hci_dev *hdev = hu->hdev; | 98 | struct hci_dev *hdev = hu->hdev; |
100 | 99 | ||
101 | /* Update HCI stat counters */ | 100 | /* Update HCI stat counters */ |
102 | switch (pkt_type) { | 101 | switch (pkt_type) { |
103 | case HCI_COMMAND_PKT: | 102 | case HCI_COMMAND_PKT: |
@@ -117,10 +116,12 @@ static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) | |||
117 | static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) | 116 | static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) |
118 | { | 117 | { |
119 | struct sk_buff *skb = hu->tx_skb; | 118 | struct sk_buff *skb = hu->tx_skb; |
119 | |||
120 | if (!skb) | 120 | if (!skb) |
121 | skb = hu->proto->dequeue(hu); | 121 | skb = hu->proto->dequeue(hu); |
122 | else | 122 | else |
123 | hu->tx_skb = NULL; | 123 | hu->tx_skb = NULL; |
124 | |||
124 | return skb; | 125 | return skb; |
125 | } | 126 | } |
126 | 127 | ||
@@ -129,7 +130,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu) | |||
129 | struct tty_struct *tty = hu->tty; | 130 | struct tty_struct *tty = hu->tty; |
130 | struct hci_dev *hdev = hu->hdev; | 131 | struct hci_dev *hdev = hu->hdev; |
131 | struct sk_buff *skb; | 132 | struct sk_buff *skb; |
132 | 133 | ||
133 | if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { | 134 | if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { |
134 | set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); | 135 | set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); |
135 | return 0; | 136 | return 0; |
@@ -142,7 +143,7 @@ restart: | |||
142 | 143 | ||
143 | while ((skb = hci_uart_dequeue(hu))) { | 144 | while ((skb = hci_uart_dequeue(hu))) { |
144 | int len; | 145 | int len; |
145 | 146 | ||
146 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 147 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
147 | len = tty->driver->write(tty, skb->data, skb->len); | 148 | len = tty->driver->write(tty, skb->data, skb->len); |
148 | hdev->stat.byte_tx += len; | 149 | hdev->stat.byte_tx += len; |
@@ -152,11 +153,11 @@ restart: | |||
152 | hu->tx_skb = skb; | 153 | hu->tx_skb = skb; |
153 | break; | 154 | break; |
154 | } | 155 | } |
155 | 156 | ||
156 | hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); | 157 | hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); |
157 | kfree_skb(skb); | 158 | kfree_skb(skb); |
158 | } | 159 | } |
159 | 160 | ||
160 | if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) | 161 | if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) |
161 | goto restart; | 162 | goto restart; |
162 | 163 | ||
@@ -173,6 +174,7 @@ static int hci_uart_open(struct hci_dev *hdev) | |||
173 | /* Nothing to do for UART driver */ | 174 | /* Nothing to do for UART driver */ |
174 | 175 | ||
175 | set_bit(HCI_RUNNING, &hdev->flags); | 176 | set_bit(HCI_RUNNING, &hdev->flags); |
177 | |||
176 | return 0; | 178 | return 0; |
177 | } | 179 | } |
178 | 180 | ||
@@ -234,6 +236,7 @@ static int hci_uart_send_frame(struct sk_buff *skb) | |||
234 | hu->proto->enqueue(hu, skb); | 236 | hu->proto->enqueue(hu, skb); |
235 | 237 | ||
236 | hci_uart_tx_wakeup(hu); | 238 | hci_uart_tx_wakeup(hu); |
239 | |||
237 | return 0; | 240 | return 0; |
238 | } | 241 | } |
239 | 242 | ||
@@ -241,7 +244,8 @@ static void hci_uart_destruct(struct hci_dev *hdev) | |||
241 | { | 244 | { |
242 | struct hci_uart *hu; | 245 | struct hci_uart *hu; |
243 | 246 | ||
244 | if (!hdev) return; | 247 | if (!hdev) |
248 | return; | ||
245 | 249 | ||
246 | BT_DBG("%s", hdev->name); | 250 | BT_DBG("%s", hdev->name); |
247 | 251 | ||
@@ -272,6 +276,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) | |||
272 | BT_ERR("Can't allocate controll structure"); | 276 | BT_ERR("Can't allocate controll structure"); |
273 | return -ENFILE; | 277 | return -ENFILE; |
274 | } | 278 | } |
279 | |||
275 | memset(hu, 0, sizeof(struct hci_uart)); | 280 | memset(hu, 0, sizeof(struct hci_uart)); |
276 | 281 | ||
277 | tty->disc_data = hu; | 282 | tty->disc_data = hu; |
@@ -280,8 +285,10 @@ static int hci_uart_tty_open(struct tty_struct *tty) | |||
280 | spin_lock_init(&hu->rx_lock); | 285 | spin_lock_init(&hu->rx_lock); |
281 | 286 | ||
282 | /* Flush any pending characters in the driver and line discipline. */ | 287 | /* Flush any pending characters in the driver and line discipline. */ |
288 | |||
283 | /* FIXME: why is this needed. Note don't use ldisc_ref here as the | 289 | /* FIXME: why is this needed. Note don't use ldisc_ref here as the |
284 | open path is before the ldisc is referencable */ | 290 | open path is before the ldisc is referencable */ |
291 | |||
285 | if (tty->ldisc.flush_buffer) | 292 | if (tty->ldisc.flush_buffer) |
286 | tty->ldisc.flush_buffer(tty); | 293 | tty->ldisc.flush_buffer(tty); |
287 | 294 | ||
@@ -372,13 +379,13 @@ static int hci_uart_tty_room (struct tty_struct *tty) | |||
372 | static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count) | 379 | static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count) |
373 | { | 380 | { |
374 | struct hci_uart *hu = (void *)tty->disc_data; | 381 | struct hci_uart *hu = (void *)tty->disc_data; |
375 | 382 | ||
376 | if (!hu || tty != hu->tty) | 383 | if (!hu || tty != hu->tty) |
377 | return; | 384 | return; |
378 | 385 | ||
379 | if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) | 386 | if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) |
380 | return; | 387 | return; |
381 | 388 | ||
382 | spin_lock(&hu->rx_lock); | 389 | spin_lock(&hu->rx_lock); |
383 | hu->proto->recv(hu, (void *) data, count); | 390 | hu->proto->recv(hu, (void *) data, count); |
384 | hu->hdev->stat.byte_rx += count; | 391 | hu->hdev->stat.byte_rx += count; |
@@ -429,8 +436,8 @@ static int hci_uart_register_dev(struct hci_uart *hu) | |||
429 | static int hci_uart_set_proto(struct hci_uart *hu, int id) | 436 | static int hci_uart_set_proto(struct hci_uart *hu, int id) |
430 | { | 437 | { |
431 | struct hci_uart_proto *p; | 438 | struct hci_uart_proto *p; |
432 | int err; | 439 | int err; |
433 | 440 | ||
434 | p = hci_uart_get_proto(id); | 441 | p = hci_uart_get_proto(id); |
435 | if (!p) | 442 | if (!p) |
436 | return -EPROTONOSUPPORT; | 443 | return -EPROTONOSUPPORT; |
@@ -446,6 +453,7 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id) | |||
446 | p->close(hu); | 453 | p->close(hu); |
447 | return err; | 454 | return err; |
448 | } | 455 | } |
456 | |||
449 | return 0; | 457 | return 0; |
450 | } | 458 | } |
451 | 459 | ||
@@ -463,7 +471,7 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id) | |||
463 | * Return Value: Command dependent | 471 | * Return Value: Command dependent |
464 | */ | 472 | */ |
465 | static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, | 473 | static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, |
466 | unsigned int cmd, unsigned long arg) | 474 | unsigned int cmd, unsigned long arg) |
467 | { | 475 | { |
468 | struct hci_uart *hu = (void *)tty->disc_data; | 476 | struct hci_uart *hu = (void *)tty->disc_data; |
469 | int err = 0; | 477 | int err = 0; |
@@ -483,14 +491,14 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, | |||
483 | return err; | 491 | return err; |
484 | } | 492 | } |
485 | tty->low_latency = 1; | 493 | tty->low_latency = 1; |
486 | } else | 494 | } else |
487 | return -EBUSY; | 495 | return -EBUSY; |
488 | 496 | ||
489 | case HCIUARTGETPROTO: | 497 | case HCIUARTGETPROTO: |
490 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | 498 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) |
491 | return hu->proto->id; | 499 | return hu->proto->id; |
492 | return -EUNATCH; | 500 | return -EUNATCH; |
493 | 501 | ||
494 | default: | 502 | default: |
495 | err = n_tty_ioctl(tty, file, cmd, arg); | 503 | err = n_tty_ioctl(tty, file, cmd, arg); |
496 | break; | 504 | break; |
@@ -502,28 +510,24 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, | |||
502 | /* | 510 | /* |
503 | * We don't provide read/write/poll interface for user space. | 511 | * We don't provide read/write/poll interface for user space. |
504 | */ | 512 | */ |
505 | static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, unsigned char __user *buf, size_t nr) | 513 | static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, |
514 | unsigned char __user *buf, size_t nr) | ||
506 | { | 515 | { |
507 | return 0; | 516 | return 0; |
508 | } | 517 | } |
509 | static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, const unsigned char *data, size_t count) | 518 | |
519 | static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, | ||
520 | const unsigned char *data, size_t count) | ||
510 | { | 521 | { |
511 | return 0; | 522 | return 0; |
512 | } | 523 | } |
513 | static unsigned int hci_uart_tty_poll(struct tty_struct *tty, struct file *filp, poll_table *wait) | 524 | |
525 | static unsigned int hci_uart_tty_poll(struct tty_struct *tty, | ||
526 | struct file *filp, poll_table *wait) | ||
514 | { | 527 | { |
515 | return 0; | 528 | return 0; |
516 | } | 529 | } |
517 | 530 | ||
518 | #ifdef CONFIG_BT_HCIUART_H4 | ||
519 | int h4_init(void); | ||
520 | int h4_deinit(void); | ||
521 | #endif | ||
522 | #ifdef CONFIG_BT_HCIUART_BCSP | ||
523 | int bcsp_init(void); | ||
524 | int bcsp_deinit(void); | ||
525 | #endif | ||
526 | |||
527 | static int __init hci_uart_init(void) | 531 | static int __init hci_uart_init(void) |
528 | { | 532 | { |
529 | static struct tty_ldisc hci_uart_ldisc; | 533 | static struct tty_ldisc hci_uart_ldisc; |
@@ -534,18 +538,18 @@ static int __init hci_uart_init(void) | |||
534 | /* Register the tty discipline */ | 538 | /* Register the tty discipline */ |
535 | 539 | ||
536 | memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc)); | 540 | memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc)); |
537 | hci_uart_ldisc.magic = TTY_LDISC_MAGIC; | 541 | hci_uart_ldisc.magic = TTY_LDISC_MAGIC; |
538 | hci_uart_ldisc.name = "n_hci"; | 542 | hci_uart_ldisc.name = "n_hci"; |
539 | hci_uart_ldisc.open = hci_uart_tty_open; | 543 | hci_uart_ldisc.open = hci_uart_tty_open; |
540 | hci_uart_ldisc.close = hci_uart_tty_close; | 544 | hci_uart_ldisc.close = hci_uart_tty_close; |
541 | hci_uart_ldisc.read = hci_uart_tty_read; | 545 | hci_uart_ldisc.read = hci_uart_tty_read; |
542 | hci_uart_ldisc.write = hci_uart_tty_write; | 546 | hci_uart_ldisc.write = hci_uart_tty_write; |
543 | hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; | 547 | hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; |
544 | hci_uart_ldisc.poll = hci_uart_tty_poll; | 548 | hci_uart_ldisc.poll = hci_uart_tty_poll; |
545 | hci_uart_ldisc.receive_room= hci_uart_tty_room; | 549 | hci_uart_ldisc.receive_room = hci_uart_tty_room; |
546 | hci_uart_ldisc.receive_buf = hci_uart_tty_receive; | 550 | hci_uart_ldisc.receive_buf = hci_uart_tty_receive; |
547 | hci_uart_ldisc.write_wakeup= hci_uart_tty_wakeup; | 551 | hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup; |
548 | hci_uart_ldisc.owner = THIS_MODULE; | 552 | hci_uart_ldisc.owner = THIS_MODULE; |
549 | 553 | ||
550 | if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) { | 554 | if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) { |
551 | BT_ERR("HCI line discipline registration failed. (%d)", err); | 555 | BT_ERR("HCI line discipline registration failed. (%d)", err); |
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 0a57d72790ec..b250e6789dee 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h | |||
@@ -1,32 +1,29 @@ | |||
1 | /* | ||
2 | BlueZ - Bluetooth protocol stack for Linux | ||
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | ||
4 | |||
5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License version 2 as | ||
9 | published by the Free Software Foundation; | ||
10 | |||
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
19 | |||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
22 | SOFTWARE IS DISCLAIMED. | ||
23 | */ | ||
24 | |||
25 | /* | 1 | /* |
26 | * $Id: hci_uart.h,v 1.2 2002/09/09 01:17:32 maxk Exp $ | 2 | * |
3 | * Bluetooth HCI UART driver | ||
4 | * | ||
5 | * Copyright (C) 2000-2001 Qualcomm Incorporated | ||
6 | * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> | ||
7 | * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> | ||
8 | * | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | #ifndef N_HCI | 26 | #ifndef N_HCI |
30 | #define N_HCI 15 | 27 | #define N_HCI 15 |
31 | #endif | 28 | #endif |
32 | 29 | ||
@@ -42,7 +39,6 @@ | |||
42 | #define HCI_UART_3WIRE 2 | 39 | #define HCI_UART_3WIRE 2 |
43 | #define HCI_UART_H4DS 3 | 40 | #define HCI_UART_H4DS 3 |
44 | 41 | ||
45 | #ifdef __KERNEL__ | ||
46 | struct hci_uart; | 42 | struct hci_uart; |
47 | 43 | ||
48 | struct hci_uart_proto { | 44 | struct hci_uart_proto { |
@@ -56,27 +52,35 @@ struct hci_uart_proto { | |||
56 | }; | 52 | }; |
57 | 53 | ||
58 | struct hci_uart { | 54 | struct hci_uart { |
59 | struct tty_struct *tty; | 55 | struct tty_struct *tty; |
60 | struct hci_dev *hdev; | 56 | struct hci_dev *hdev; |
61 | unsigned long flags; | 57 | unsigned long flags; |
62 | 58 | ||
63 | struct hci_uart_proto *proto; | 59 | struct hci_uart_proto *proto; |
64 | void *priv; | 60 | void *priv; |
65 | 61 | ||
66 | struct sk_buff *tx_skb; | 62 | struct sk_buff *tx_skb; |
67 | unsigned long tx_state; | 63 | unsigned long tx_state; |
68 | spinlock_t rx_lock; | 64 | spinlock_t rx_lock; |
69 | }; | 65 | }; |
70 | 66 | ||
71 | /* HCI_UART flag bits */ | 67 | /* HCI_UART flag bits */ |
72 | #define HCI_UART_PROTO_SET 0 | 68 | #define HCI_UART_PROTO_SET 0 |
73 | 69 | ||
74 | /* TX states */ | 70 | /* TX states */ |
75 | #define HCI_UART_SENDING 1 | 71 | #define HCI_UART_SENDING 1 |
76 | #define HCI_UART_TX_WAKEUP 2 | 72 | #define HCI_UART_TX_WAKEUP 2 |
77 | 73 | ||
78 | int hci_uart_register_proto(struct hci_uart_proto *p); | 74 | int hci_uart_register_proto(struct hci_uart_proto *p); |
79 | int hci_uart_unregister_proto(struct hci_uart_proto *p); | 75 | int hci_uart_unregister_proto(struct hci_uart_proto *p); |
80 | int hci_uart_tx_wakeup(struct hci_uart *hu); | 76 | int hci_uart_tx_wakeup(struct hci_uart *hu); |
81 | 77 | ||
82 | #endif /* __KERNEL__ */ | 78 | #ifdef CONFIG_BT_HCIUART_H4 |
79 | int h4_init(void); | ||
80 | int h4_deinit(void); | ||
81 | #endif | ||
82 | |||
83 | #ifdef CONFIG_BT_HCIUART_BCSP | ||
84 | int bcsp_init(void); | ||
85 | int bcsp_deinit(void); | ||
86 | #endif | ||
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 26271e3ca823..8693835cb2d5 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c | |||
@@ -515,7 +515,7 @@ static int __init dsp56k_init_driver(void) | |||
515 | err = PTR_ERR(dsp56k_class); | 515 | err = PTR_ERR(dsp56k_class); |
516 | goto out_chrdev; | 516 | goto out_chrdev; |
517 | } | 517 | } |
518 | class_device_create(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); | 518 | class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); |
519 | 519 | ||
520 | err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0), | 520 | err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0), |
521 | S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k"); | 521 | S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k"); |
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c index 5745b74044ec..821357ce7e0e 100644 --- a/drivers/char/ftape/zftape/zftape-init.c +++ b/drivers/char/ftape/zftape/zftape-init.c | |||
@@ -331,27 +331,27 @@ KERN_INFO | |||
331 | 331 | ||
332 | zft_class = class_create(THIS_MODULE, "zft"); | 332 | zft_class = class_create(THIS_MODULE, "zft"); |
333 | for (i = 0; i < 4; i++) { | 333 | for (i = 0; i < 4; i++) { |
334 | class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i); | 334 | class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i); |
335 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i), | 335 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i), |
336 | S_IFCHR | S_IRUSR | S_IWUSR, | 336 | S_IFCHR | S_IRUSR | S_IWUSR, |
337 | "qft%i", i); | 337 | "qft%i", i); |
338 | class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i); | 338 | class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i); |
339 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4), | 339 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4), |
340 | S_IFCHR | S_IRUSR | S_IWUSR, | 340 | S_IFCHR | S_IRUSR | S_IWUSR, |
341 | "nqft%i", i); | 341 | "nqft%i", i); |
342 | class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i); | 342 | class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i); |
343 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16), | 343 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16), |
344 | S_IFCHR | S_IRUSR | S_IWUSR, | 344 | S_IFCHR | S_IRUSR | S_IWUSR, |
345 | "zqft%i", i); | 345 | "zqft%i", i); |
346 | class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i); | 346 | class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i); |
347 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20), | 347 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20), |
348 | S_IFCHR | S_IRUSR | S_IWUSR, | 348 | S_IFCHR | S_IRUSR | S_IWUSR, |
349 | "nzqft%i", i); | 349 | "nzqft%i", i); |
350 | class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i); | 350 | class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i); |
351 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32), | 351 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32), |
352 | S_IFCHR | S_IRUSR | S_IWUSR, | 352 | S_IFCHR | S_IRUSR | S_IWUSR, |
353 | "rawqft%i", i); | 353 | "rawqft%i", i); |
354 | class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i); | 354 | class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i); |
355 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36), | 355 | devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36), |
356 | S_IFCHR | S_IRUSR | S_IWUSR, | 356 | S_IFCHR | S_IRUSR | S_IWUSR, |
357 | "nrawqft%i", i); | 357 | "nrawqft%i", i); |
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index 9e4e26aef94e..d815d197dc3e 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c | |||
@@ -721,8 +721,9 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) | |||
721 | } | 721 | } |
722 | 722 | ||
723 | if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { | 723 | if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { |
724 | class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR, | 724 | class_device_create(ip2_class, NULL, |
725 | 4 * i), NULL, "ipl%d", i); | 725 | MKDEV(IP2_IPL_MAJOR, 4 * i), |
726 | NULL, "ipl%d", i); | ||
726 | err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i), | 727 | err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i), |
727 | S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, | 728 | S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, |
728 | "ip2/ipl%d", i); | 729 | "ip2/ipl%d", i); |
@@ -732,8 +733,9 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) | |||
732 | goto out_class; | 733 | goto out_class; |
733 | } | 734 | } |
734 | 735 | ||
735 | class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR, | 736 | class_device_create(ip2_class, NULL, |
736 | 4 * i + 1), NULL, "stat%d", i); | 737 | MKDEV(IP2_IPL_MAJOR, 4 * i + 1), |
738 | NULL, "stat%d", i); | ||
737 | err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1), | 739 | err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1), |
738 | S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, | 740 | S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, |
739 | "ip2/stat%d", i); | 741 | "ip2/stat%d", i); |
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index a09ff1080687..7c0684deea06 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c | |||
@@ -798,7 +798,7 @@ static void ipmi_new_smi(int if_num) | |||
798 | devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, | 798 | devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, |
799 | "ipmidev/%d", if_num); | 799 | "ipmidev/%d", if_num); |
800 | 800 | ||
801 | class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num); | 801 | class_device_create(ipmi_class, NULL, dev, NULL, "ipmi%d", if_num); |
802 | } | 802 | } |
803 | 803 | ||
804 | static void ipmi_smi_gone(int if_num) | 804 | static void ipmi_smi_gone(int if_num) |
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 9c19e5435a11..e3ddbdb85a2f 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -5246,7 +5246,8 @@ int __init stli_init(void) | |||
5246 | devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), | 5246 | devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), |
5247 | S_IFCHR | S_IRUSR | S_IWUSR, | 5247 | S_IFCHR | S_IRUSR | S_IWUSR, |
5248 | "staliomem/%d", i); | 5248 | "staliomem/%d", i); |
5249 | class_device_create(istallion_class, MKDEV(STL_SIOMEMMAJOR, i), | 5249 | class_device_create(istallion_class, NULL, |
5250 | MKDEV(STL_SIOMEMMAJOR, i), | ||
5250 | NULL, "staliomem%d", i); | 5251 | NULL, "staliomem%d", i); |
5251 | } | 5252 | } |
5252 | 5253 | ||
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 2afb9038dbc5..e57260525293 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
@@ -805,7 +805,7 @@ static int lp_register(int nr, struct parport *port) | |||
805 | if (reset) | 805 | if (reset) |
806 | lp_reset(nr); | 806 | lp_reset(nr); |
807 | 807 | ||
808 | class_device_create(lp_class, MKDEV(LP_MAJOR, nr), NULL, | 808 | class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), NULL, |
809 | "lp%d", nr); | 809 | "lp%d", nr); |
810 | devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO, | 810 | devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO, |
811 | "printers/%d", nr); | 811 | "printers/%d", nr); |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index f182752fe918..38be4b0dbd1c 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -920,7 +920,8 @@ static int __init chr_dev_init(void) | |||
920 | 920 | ||
921 | mem_class = class_create(THIS_MODULE, "mem"); | 921 | mem_class = class_create(THIS_MODULE, "mem"); |
922 | for (i = 0; i < ARRAY_SIZE(devlist); i++) { | 922 | for (i = 0; i < ARRAY_SIZE(devlist); i++) { |
923 | class_device_create(mem_class, MKDEV(MEM_MAJOR, devlist[i].minor), | 923 | class_device_create(mem_class, NULL, |
924 | MKDEV(MEM_MAJOR, devlist[i].minor), | ||
924 | NULL, devlist[i].name); | 925 | NULL, devlist[i].name); |
925 | devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor), | 926 | devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor), |
926 | S_IFCHR | devlist[i].mode, devlist[i].name); | 927 | S_IFCHR | devlist[i].mode, devlist[i].name); |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 0c8375165e29..3e4c0414a01a 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -234,7 +234,7 @@ int misc_register(struct miscdevice * misc) | |||
234 | } | 234 | } |
235 | dev = MKDEV(MISC_MAJOR, misc->minor); | 235 | dev = MKDEV(MISC_MAJOR, misc->minor); |
236 | 236 | ||
237 | misc->class = class_device_create(misc_class, dev, misc->dev, | 237 | misc->class = class_device_create(misc_class, NULL, dev, misc->dev, |
238 | "%s", misc->name); | 238 | "%s", misc->name); |
239 | if (IS_ERR(misc->class)) { | 239 | if (IS_ERR(misc->class)) { |
240 | err = PTR_ERR(misc->class); | 240 | err = PTR_ERR(misc->class); |
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 1af733d07321..9e24bbd4090c 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c | |||
@@ -32,9 +32,11 @@ | |||
32 | * added changelog | 32 | * added changelog |
33 | * 1.2 Erik Gilling: Cobalt Networks support | 33 | * 1.2 Erik Gilling: Cobalt Networks support |
34 | * Tim Hockin: general cleanup, Cobalt support | 34 | * Tim Hockin: general cleanup, Cobalt support |
35 | * 1.3 Jon Ringle: Comdial MP1000 support | ||
36 | * | ||
35 | */ | 37 | */ |
36 | 38 | ||
37 | #define NVRAM_VERSION "1.2" | 39 | #define NVRAM_VERSION "1.3" |
38 | 40 | ||
39 | #include <linux/module.h> | 41 | #include <linux/module.h> |
40 | #include <linux/config.h> | 42 | #include <linux/config.h> |
@@ -45,6 +47,7 @@ | |||
45 | #define PC 1 | 47 | #define PC 1 |
46 | #define ATARI 2 | 48 | #define ATARI 2 |
47 | #define COBALT 3 | 49 | #define COBALT 3 |
50 | #define MP1000 4 | ||
48 | 51 | ||
49 | /* select machine configuration */ | 52 | /* select machine configuration */ |
50 | #if defined(CONFIG_ATARI) | 53 | #if defined(CONFIG_ATARI) |
@@ -54,6 +57,9 @@ | |||
54 | # if defined(CONFIG_COBALT) | 57 | # if defined(CONFIG_COBALT) |
55 | # include <linux/cobalt-nvram.h> | 58 | # include <linux/cobalt-nvram.h> |
56 | # define MACH COBALT | 59 | # define MACH COBALT |
60 | # elif defined(CONFIG_MACH_MP1000) | ||
61 | # undef MACH | ||
62 | # define MACH MP1000 | ||
57 | # else | 63 | # else |
58 | # define MACH PC | 64 | # define MACH PC |
59 | # endif | 65 | # endif |
@@ -112,6 +118,23 @@ | |||
112 | 118 | ||
113 | #endif | 119 | #endif |
114 | 120 | ||
121 | #if MACH == MP1000 | ||
122 | |||
123 | /* RTC in a MP1000 */ | ||
124 | #define CHECK_DRIVER_INIT() 1 | ||
125 | |||
126 | #define MP1000_CKS_RANGE_START 0 | ||
127 | #define MP1000_CKS_RANGE_END 111 | ||
128 | #define MP1000_CKS_LOC 112 | ||
129 | |||
130 | #define NVRAM_BYTES (128-NVRAM_FIRST_BYTE) | ||
131 | |||
132 | #define mach_check_checksum mp1000_check_checksum | ||
133 | #define mach_set_checksum mp1000_set_checksum | ||
134 | #define mach_proc_infos mp1000_proc_infos | ||
135 | |||
136 | #endif | ||
137 | |||
115 | /* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with | 138 | /* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with |
116 | * rtc_lock held. Due to the index-port/data-port design of the RTC, we | 139 | * rtc_lock held. Due to the index-port/data-port design of the RTC, we |
117 | * don't want two different things trying to get to it at once. (e.g. the | 140 | * don't want two different things trying to get to it at once. (e.g. the |
@@ -915,6 +938,91 @@ atari_proc_infos(unsigned char *nvram, char *buffer, int *len, | |||
915 | 938 | ||
916 | #endif /* MACH == ATARI */ | 939 | #endif /* MACH == ATARI */ |
917 | 940 | ||
941 | #if MACH == MP1000 | ||
942 | |||
943 | static int | ||
944 | mp1000_check_checksum(void) | ||
945 | { | ||
946 | int i; | ||
947 | unsigned short sum = 0; | ||
948 | unsigned short expect; | ||
949 | |||
950 | for (i = MP1000_CKS_RANGE_START; i <= MP1000_CKS_RANGE_END; ++i) | ||
951 | sum += __nvram_read_byte(i); | ||
952 | |||
953 | expect = __nvram_read_byte(MP1000_CKS_LOC+1)<<8 | | ||
954 | __nvram_read_byte(MP1000_CKS_LOC); | ||
955 | return ((sum & 0xffff) == expect); | ||
956 | } | ||
957 | |||
958 | static void | ||
959 | mp1000_set_checksum(void) | ||
960 | { | ||
961 | int i; | ||
962 | unsigned short sum = 0; | ||
963 | |||
964 | for (i = MP1000_CKS_RANGE_START; i <= MP1000_CKS_RANGE_END; ++i) | ||
965 | sum += __nvram_read_byte(i); | ||
966 | __nvram_write_byte(sum >> 8, MP1000_CKS_LOC + 1); | ||
967 | __nvram_write_byte(sum & 0xff, MP1000_CKS_LOC); | ||
968 | } | ||
969 | |||
970 | #ifdef CONFIG_PROC_FS | ||
971 | |||
972 | #define SERVER_N_LEN 32 | ||
973 | #define PATH_N_LEN 32 | ||
974 | #define FILE_N_LEN 32 | ||
975 | #define NVRAM_MAGIC_SIG 0xdead | ||
976 | |||
977 | typedef struct NvRamImage | ||
978 | { | ||
979 | unsigned short int magic; | ||
980 | unsigned short int mode; | ||
981 | char fname[FILE_N_LEN]; | ||
982 | char path[PATH_N_LEN]; | ||
983 | char server[SERVER_N_LEN]; | ||
984 | char pad[12]; | ||
985 | } NvRam; | ||
986 | |||
987 | static int | ||
988 | mp1000_proc_infos(unsigned char *nvram, char *buffer, int *len, | ||
989 | off_t *begin, off_t offset, int size) | ||
990 | { | ||
991 | int checksum; | ||
992 | NvRam* nv = (NvRam*)nvram; | ||
993 | |||
994 | spin_lock_irq(&rtc_lock); | ||
995 | checksum = __nvram_check_checksum(); | ||
996 | spin_unlock_irq(&rtc_lock); | ||
997 | |||
998 | PRINT_PROC("Checksum status: %svalid\n", checksum ? "" : "not "); | ||
999 | |||
1000 | switch( nv->mode ) | ||
1001 | { | ||
1002 | case 0 : | ||
1003 | PRINT_PROC( "\tMode 0, tftp prompt\n" ); | ||
1004 | break; | ||
1005 | case 1 : | ||
1006 | PRINT_PROC( "\tMode 1, booting from disk\n" ); | ||
1007 | break; | ||
1008 | case 2 : | ||
1009 | PRINT_PROC( "\tMode 2, Alternate boot from disk /boot/%s\n", nv->fname ); | ||
1010 | break; | ||
1011 | case 3 : | ||
1012 | PRINT_PROC( "\tMode 3, Booting from net:\n" ); | ||
1013 | PRINT_PROC( "\t\t%s:%s%s\n",nv->server, nv->path, nv->fname ); | ||
1014 | break; | ||
1015 | default: | ||
1016 | PRINT_PROC( "\tInconsistant nvram?\n" ); | ||
1017 | break; | ||
1018 | } | ||
1019 | |||
1020 | return 1; | ||
1021 | } | ||
1022 | #endif | ||
1023 | |||
1024 | #endif /* MACH == MP1000 */ | ||
1025 | |||
918 | MODULE_LICENSE("GPL"); | 1026 | MODULE_LICENSE("GPL"); |
919 | 1027 | ||
920 | EXPORT_SYMBOL(__nvram_read_byte); | 1028 | EXPORT_SYMBOL(__nvram_read_byte); |
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 0e22880432bc..306ee0f091a4 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c | |||
@@ -752,7 +752,7 @@ static struct file_operations pp_fops = { | |||
752 | 752 | ||
753 | static void pp_attach(struct parport *port) | 753 | static void pp_attach(struct parport *port) |
754 | { | 754 | { |
755 | class_device_create(ppdev_class, MKDEV(PP_MAJOR, port->number), | 755 | class_device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number), |
756 | NULL, "parport%d", port->number); | 756 | NULL, "parport%d", port->number); |
757 | } | 757 | } |
758 | 758 | ||
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index f13e5de02207..30e4cbe16bb0 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -128,7 +128,7 @@ raw_ioctl(struct inode *inode, struct file *filp, | |||
128 | static void bind_device(struct raw_config_request *rq) | 128 | static void bind_device(struct raw_config_request *rq) |
129 | { | 129 | { |
130 | class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); | 130 | class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); |
131 | class_device_create(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor), | 131 | class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), |
132 | NULL, "raw%d", rq->raw_minor); | 132 | NULL, "raw%d", rq->raw_minor); |
133 | } | 133 | } |
134 | 134 | ||
@@ -307,7 +307,7 @@ static int __init raw_init(void) | |||
307 | unregister_chrdev_region(dev, MAX_RAW_MINORS); | 307 | unregister_chrdev_region(dev, MAX_RAW_MINORS); |
308 | goto error; | 308 | goto error; |
309 | } | 309 | } |
310 | class_device_create(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); | 310 | class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); |
311 | 311 | ||
312 | devfs_mk_cdev(MKDEV(RAW_MAJOR, 0), | 312 | devfs_mk_cdev(MKDEV(RAW_MAJOR, 0), |
313 | S_IFCHR | S_IRUGO | S_IWUGO, | 313 | S_IFCHR | S_IRUGO | S_IWUGO, |
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c index e1a90d9a8756..887b8b2d7882 100644 --- a/drivers/char/s3c2410-rtc.c +++ b/drivers/char/s3c2410-rtc.c | |||
@@ -519,30 +519,28 @@ static struct timespec s3c2410_rtc_delta; | |||
519 | 519 | ||
520 | static int ticnt_save; | 520 | static int ticnt_save; |
521 | 521 | ||
522 | static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state, u32 level) | 522 | static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state) |
523 | { | 523 | { |
524 | struct rtc_time tm; | 524 | struct rtc_time tm; |
525 | struct timespec time; | 525 | struct timespec time; |
526 | 526 | ||
527 | time.tv_nsec = 0; | 527 | time.tv_nsec = 0; |
528 | 528 | ||
529 | if (level == SUSPEND_POWER_DOWN) { | 529 | /* save TICNT for anyone using periodic interrupts */ |
530 | /* save TICNT for anyone using periodic interrupts */ | ||
531 | 530 | ||
532 | ticnt_save = readb(S3C2410_TICNT); | 531 | ticnt_save = readb(S3C2410_TICNT); |
533 | 532 | ||
534 | /* calculate time delta for suspend */ | 533 | /* calculate time delta for suspend */ |
535 | 534 | ||
536 | s3c2410_rtc_gettime(&tm); | 535 | s3c2410_rtc_gettime(&tm); |
537 | rtc_tm_to_time(&tm, &time.tv_sec); | 536 | rtc_tm_to_time(&tm, &time.tv_sec); |
538 | save_time_delta(&s3c2410_rtc_delta, &time); | 537 | save_time_delta(&s3c2410_rtc_delta, &time); |
539 | s3c2410_rtc_enable(dev, 0); | 538 | s3c2410_rtc_enable(dev, 0); |
540 | } | ||
541 | 539 | ||
542 | return 0; | 540 | return 0; |
543 | } | 541 | } |
544 | 542 | ||
545 | static int s3c2410_rtc_resume(struct device *dev, u32 level) | 543 | static int s3c2410_rtc_resume(struct device *dev) |
546 | { | 544 | { |
547 | struct rtc_time tm; | 545 | struct rtc_time tm; |
548 | struct timespec time; | 546 | struct timespec time; |
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 261a41bf6d02..1758a83327e5 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c | |||
@@ -437,7 +437,7 @@ scdrv_init(void) | |||
437 | continue; | 437 | continue; |
438 | } | 438 | } |
439 | 439 | ||
440 | class_device_create(snsc_class, dev, NULL, | 440 | class_device_create(snsc_class, NULL, dev, NULL, |
441 | "%s", devname); | 441 | "%s", devname); |
442 | 442 | ||
443 | ia64_sn_irtr_intr_enable(scd->scd_nasid, | 443 | ia64_sn_irtr_intr_enable(scd->scd_nasid, |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 36ae9ad2598c..f86c15587238 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -424,10 +424,6 @@ static struct sonypi_eventtypes { | |||
424 | 424 | ||
425 | #define SONYPI_BUF_SIZE 128 | 425 | #define SONYPI_BUF_SIZE 128 |
426 | 426 | ||
427 | /* The name of the devices for the input device drivers */ | ||
428 | #define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial" | ||
429 | #define SONYPI_KEY_INPUTNAME "Sony Vaio Keys" | ||
430 | |||
431 | /* Correspondance table between sonypi events and input layer events */ | 427 | /* Correspondance table between sonypi events and input layer events */ |
432 | static struct { | 428 | static struct { |
433 | int sonypiev; | 429 | int sonypiev; |
@@ -490,8 +486,8 @@ static struct sonypi_device { | |||
490 | struct fasync_struct *fifo_async; | 486 | struct fasync_struct *fifo_async; |
491 | int open_count; | 487 | int open_count; |
492 | int model; | 488 | int model; |
493 | struct input_dev input_jog_dev; | 489 | struct input_dev *input_jog_dev; |
494 | struct input_dev input_key_dev; | 490 | struct input_dev *input_key_dev; |
495 | struct work_struct input_work; | 491 | struct work_struct input_work; |
496 | struct kfifo *input_fifo; | 492 | struct kfifo *input_fifo; |
497 | spinlock_t input_fifo_lock; | 493 | spinlock_t input_fifo_lock; |
@@ -779,8 +775,8 @@ static void input_keyrelease(void *data) | |||
779 | 775 | ||
780 | static void sonypi_report_input_event(u8 event) | 776 | static void sonypi_report_input_event(u8 event) |
781 | { | 777 | { |
782 | struct input_dev *jog_dev = &sonypi_device.input_jog_dev; | 778 | struct input_dev *jog_dev = sonypi_device.input_jog_dev; |
783 | struct input_dev *key_dev = &sonypi_device.input_key_dev; | 779 | struct input_dev *key_dev = sonypi_device.input_key_dev; |
784 | struct sonypi_keypress kp = { NULL }; | 780 | struct sonypi_keypress kp = { NULL }; |
785 | int i; | 781 | int i; |
786 | 782 | ||
@@ -1171,19 +1167,17 @@ static int sonypi_disable(void) | |||
1171 | #ifdef CONFIG_PM | 1167 | #ifdef CONFIG_PM |
1172 | static int old_camera_power; | 1168 | static int old_camera_power; |
1173 | 1169 | ||
1174 | static int sonypi_suspend(struct device *dev, pm_message_t state, u32 level) | 1170 | static int sonypi_suspend(struct device *dev, pm_message_t state) |
1175 | { | 1171 | { |
1176 | if (level == SUSPEND_DISABLE) { | 1172 | old_camera_power = sonypi_device.camera_power; |
1177 | old_camera_power = sonypi_device.camera_power; | 1173 | sonypi_disable(); |
1178 | sonypi_disable(); | 1174 | |
1179 | } | ||
1180 | return 0; | 1175 | return 0; |
1181 | } | 1176 | } |
1182 | 1177 | ||
1183 | static int sonypi_resume(struct device *dev, u32 level) | 1178 | static int sonypi_resume(struct device *dev) |
1184 | { | 1179 | { |
1185 | if (level == RESUME_ENABLE) | 1180 | sonypi_enable(old_camera_power); |
1186 | sonypi_enable(old_camera_power); | ||
1187 | return 0; | 1181 | return 0; |
1188 | } | 1182 | } |
1189 | #endif | 1183 | #endif |
@@ -1203,6 +1197,47 @@ static struct device_driver sonypi_driver = { | |||
1203 | .shutdown = sonypi_shutdown, | 1197 | .shutdown = sonypi_shutdown, |
1204 | }; | 1198 | }; |
1205 | 1199 | ||
1200 | static int __devinit sonypi_create_input_devices(void) | ||
1201 | { | ||
1202 | struct input_dev *jog_dev; | ||
1203 | struct input_dev *key_dev; | ||
1204 | int i; | ||
1205 | |||
1206 | sonypi_device.input_jog_dev = jog_dev = input_allocate_device(); | ||
1207 | if (!jog_dev) | ||
1208 | return -ENOMEM; | ||
1209 | |||
1210 | jog_dev->name = "Sony Vaio Jogdial"; | ||
1211 | jog_dev->id.bustype = BUS_ISA; | ||
1212 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; | ||
1213 | |||
1214 | jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
1215 | jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE); | ||
1216 | jog_dev->relbit[0] = BIT(REL_WHEEL); | ||
1217 | |||
1218 | sonypi_device.input_key_dev = key_dev = input_allocate_device(); | ||
1219 | if (!key_dev) { | ||
1220 | input_free_device(jog_dev); | ||
1221 | sonypi_device.input_jog_dev = NULL; | ||
1222 | return -ENOMEM; | ||
1223 | } | ||
1224 | |||
1225 | key_dev->name = "Sony Vaio Keys"; | ||
1226 | key_dev->id.bustype = BUS_ISA; | ||
1227 | key_dev->id.vendor = PCI_VENDOR_ID_SONY; | ||
1228 | |||
1229 | /* Initialize the Input Drivers: special keys */ | ||
1230 | key_dev->evbit[0] = BIT(EV_KEY); | ||
1231 | for (i = 0; sonypi_inputkeys[i].sonypiev; i++) | ||
1232 | if (sonypi_inputkeys[i].inputev) | ||
1233 | set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit); | ||
1234 | |||
1235 | input_register_device(jog_dev); | ||
1236 | input_register_device(key_dev); | ||
1237 | |||
1238 | return 0; | ||
1239 | } | ||
1240 | |||
1206 | static int __devinit sonypi_probe(void) | 1241 | static int __devinit sonypi_probe(void) |
1207 | { | 1242 | { |
1208 | int i, ret; | 1243 | int i, ret; |
@@ -1298,34 +1333,10 @@ static int __devinit sonypi_probe(void) | |||
1298 | } | 1333 | } |
1299 | 1334 | ||
1300 | if (useinput) { | 1335 | if (useinput) { |
1301 | /* Initialize the Input Drivers: jogdial */ | ||
1302 | int i; | ||
1303 | sonypi_device.input_jog_dev.evbit[0] = | ||
1304 | BIT(EV_KEY) | BIT(EV_REL); | ||
1305 | sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] = | ||
1306 | BIT(BTN_MIDDLE); | ||
1307 | sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL); | ||
1308 | sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME; | ||
1309 | sonypi_device.input_jog_dev.id.bustype = BUS_ISA; | ||
1310 | sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY; | ||
1311 | |||
1312 | input_register_device(&sonypi_device.input_jog_dev); | ||
1313 | printk(KERN_INFO "%s input method installed.\n", | ||
1314 | sonypi_device.input_jog_dev.name); | ||
1315 | |||
1316 | /* Initialize the Input Drivers: special keys */ | ||
1317 | sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY); | ||
1318 | for (i = 0; sonypi_inputkeys[i].sonypiev; i++) | ||
1319 | if (sonypi_inputkeys[i].inputev) | ||
1320 | set_bit(sonypi_inputkeys[i].inputev, | ||
1321 | sonypi_device.input_key_dev.keybit); | ||
1322 | sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME; | ||
1323 | sonypi_device.input_key_dev.id.bustype = BUS_ISA; | ||
1324 | sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY; | ||
1325 | 1336 | ||
1326 | input_register_device(&sonypi_device.input_key_dev); | 1337 | ret = sonypi_create_input_devices(); |
1327 | printk(KERN_INFO "%s input method installed.\n", | 1338 | if (ret) |
1328 | sonypi_device.input_key_dev.name); | 1339 | goto out_inputdevices; |
1329 | 1340 | ||
1330 | spin_lock_init(&sonypi_device.input_fifo_lock); | 1341 | spin_lock_init(&sonypi_device.input_fifo_lock); |
1331 | sonypi_device.input_fifo = | 1342 | sonypi_device.input_fifo = |
@@ -1375,8 +1386,9 @@ static int __devinit sonypi_probe(void) | |||
1375 | out_platformdev: | 1386 | out_platformdev: |
1376 | kfifo_free(sonypi_device.input_fifo); | 1387 | kfifo_free(sonypi_device.input_fifo); |
1377 | out_infifo: | 1388 | out_infifo: |
1378 | input_unregister_device(&sonypi_device.input_key_dev); | 1389 | input_unregister_device(sonypi_device.input_key_dev); |
1379 | input_unregister_device(&sonypi_device.input_jog_dev); | 1390 | input_unregister_device(sonypi_device.input_jog_dev); |
1391 | out_inputdevices: | ||
1380 | free_irq(sonypi_device.irq, sonypi_irq); | 1392 | free_irq(sonypi_device.irq, sonypi_irq); |
1381 | out_reqirq: | 1393 | out_reqirq: |
1382 | release_region(sonypi_device.ioport1, sonypi_device.region_size); | 1394 | release_region(sonypi_device.ioport1, sonypi_device.region_size); |
@@ -1402,8 +1414,8 @@ static void __devexit sonypi_remove(void) | |||
1402 | platform_device_unregister(sonypi_device.pdev); | 1414 | platform_device_unregister(sonypi_device.pdev); |
1403 | 1415 | ||
1404 | if (useinput) { | 1416 | if (useinput) { |
1405 | input_unregister_device(&sonypi_device.input_key_dev); | 1417 | input_unregister_device(sonypi_device.input_key_dev); |
1406 | input_unregister_device(&sonypi_device.input_jog_dev); | 1418 | input_unregister_device(sonypi_device.input_jog_dev); |
1407 | kfifo_free(sonypi_device.input_fifo); | 1419 | kfifo_free(sonypi_device.input_fifo); |
1408 | } | 1420 | } |
1409 | 1421 | ||
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 951545a6ef2d..1c686414e0a1 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -3095,7 +3095,9 @@ static int __init stl_init(void) | |||
3095 | devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), | 3095 | devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), |
3096 | S_IFCHR|S_IRUSR|S_IWUSR, | 3096 | S_IFCHR|S_IRUSR|S_IWUSR, |
3097 | "staliomem/%d", i); | 3097 | "staliomem/%d", i); |
3098 | class_device_create(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i); | 3098 | class_device_create(stallion_class, NULL, |
3099 | MKDEV(STL_SIOMEMMAJOR, i), NULL, | ||
3100 | "staliomem%d", i); | ||
3099 | } | 3101 | } |
3100 | 3102 | ||
3101 | stl_serial->owner = THIS_MODULE; | 3103 | stl_serial->owner = THIS_MODULE; |
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c index ec78d2f161f7..41a94bc79f67 100644 --- a/drivers/char/tipar.c +++ b/drivers/char/tipar.c | |||
@@ -436,7 +436,7 @@ tipar_register(int nr, struct parport *port) | |||
436 | goto out; | 436 | goto out; |
437 | } | 437 | } |
438 | 438 | ||
439 | class_device_create(tipar_class, MKDEV(TIPAR_MAJOR, | 439 | class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR, |
440 | TIPAR_MINOR + nr), NULL, "par%d", nr); | 440 | TIPAR_MINOR + nr), NULL, "par%d", nr); |
441 | /* Use devfs, tree: /dev/ticables/par/[0..2] */ | 441 | /* Use devfs, tree: /dev/ticables/par/[0..2] */ |
442 | err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr), | 442 | err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr), |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e5953f3433f3..f5649a337743 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2728,7 +2728,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index, | |||
2728 | pty_line_name(driver, index, name); | 2728 | pty_line_name(driver, index, name); |
2729 | else | 2729 | else |
2730 | tty_line_name(driver, index, name); | 2730 | tty_line_name(driver, index, name); |
2731 | class_device_create(tty_class, dev, device, name); | 2731 | class_device_create(tty_class, NULL, dev, device, "%s", name); |
2732 | } | 2732 | } |
2733 | 2733 | ||
2734 | /** | 2734 | /** |
@@ -2983,14 +2983,14 @@ static int __init tty_init(void) | |||
2983 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) | 2983 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) |
2984 | panic("Couldn't register /dev/tty driver\n"); | 2984 | panic("Couldn't register /dev/tty driver\n"); |
2985 | devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty"); | 2985 | devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty"); |
2986 | class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); | 2986 | class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); |
2987 | 2987 | ||
2988 | cdev_init(&console_cdev, &console_fops); | 2988 | cdev_init(&console_cdev, &console_fops); |
2989 | if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || | 2989 | if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || |
2990 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) | 2990 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) |
2991 | panic("Couldn't register /dev/console driver\n"); | 2991 | panic("Couldn't register /dev/console driver\n"); |
2992 | devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console"); | 2992 | devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console"); |
2993 | class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); | 2993 | class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); |
2994 | 2994 | ||
2995 | #ifdef CONFIG_UNIX98_PTYS | 2995 | #ifdef CONFIG_UNIX98_PTYS |
2996 | cdev_init(&ptmx_cdev, &ptmx_fops); | 2996 | cdev_init(&ptmx_cdev, &ptmx_fops); |
@@ -2998,7 +2998,7 @@ static int __init tty_init(void) | |||
2998 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) | 2998 | register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) |
2999 | panic("Couldn't register /dev/ptmx driver\n"); | 2999 | panic("Couldn't register /dev/ptmx driver\n"); |
3000 | devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx"); | 3000 | devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx"); |
3001 | class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); | 3001 | class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); |
3002 | #endif | 3002 | #endif |
3003 | 3003 | ||
3004 | #ifdef CONFIG_VT | 3004 | #ifdef CONFIG_VT |
@@ -3007,7 +3007,7 @@ static int __init tty_init(void) | |||
3007 | register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) | 3007 | register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) |
3008 | panic("Couldn't register /dev/tty0 driver\n"); | 3008 | panic("Couldn't register /dev/tty0 driver\n"); |
3009 | devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0"); | 3009 | devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0"); |
3010 | class_device_create(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); | 3010 | class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); |
3011 | 3011 | ||
3012 | vty_init(); | 3012 | vty_init(); |
3013 | #endif | 3013 | #endif |
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c index 79c2928a8817..f66c7ad6fd38 100644 --- a/drivers/char/vc_screen.c +++ b/drivers/char/vc_screen.c | |||
@@ -484,8 +484,10 @@ void vcs_make_devfs(struct tty_struct *tty) | |||
484 | devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129), | 484 | devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129), |
485 | S_IFCHR|S_IRUSR|S_IWUSR, | 485 | S_IFCHR|S_IRUSR|S_IWUSR, |
486 | "vcc/a%u", tty->index + 1); | 486 | "vcc/a%u", tty->index + 1); |
487 | class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1); | 487 | class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), |
488 | class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1); | 488 | NULL, "vcs%u", tty->index + 1); |
489 | class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), | ||
490 | NULL, "vcsa%u", tty->index + 1); | ||
489 | } | 491 | } |
490 | void vcs_remove_devfs(struct tty_struct *tty) | 492 | void vcs_remove_devfs(struct tty_struct *tty) |
491 | { | 493 | { |
@@ -503,7 +505,7 @@ int __init vcs_init(void) | |||
503 | 505 | ||
504 | devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0"); | 506 | devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0"); |
505 | devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0"); | 507 | devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0"); |
506 | class_device_create(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); | 508 | class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); |
507 | class_device_create(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); | 509 | class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); |
508 | return 0; | 510 | return 0; |
509 | } | 511 | } |
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index 0aff45fac2e6..a5e104f428f8 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c | |||
@@ -956,9 +956,9 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
956 | state[i].cur_part = 0; | 956 | state[i].cur_part = 0; |
957 | for (j = 0; j < MAX_PARTITIONS; ++j) | 957 | for (j = 0; j < MAX_PARTITIONS; ++j) |
958 | state[i].part_stat_rwi[j] = VIOT_IDLE; | 958 | state[i].part_stat_rwi[j] = VIOT_IDLE; |
959 | class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL, | 959 | class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL, |
960 | "iseries!vt%d", i); | 960 | "iseries!vt%d", i); |
961 | class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80), | 961 | class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), |
962 | NULL, "iseries!nvt%d", i); | 962 | NULL, "iseries!nvt%d", i); |
963 | devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR, | 963 | devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR, |
964 | "iseries/vt%d", i); | 964 | "iseries/vt%d", i); |
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index 3625b2601b42..b732020acadb 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c | |||
@@ -464,32 +464,28 @@ static void s3c2410wdt_shutdown(struct device *dev) | |||
464 | static unsigned long wtcon_save; | 464 | static unsigned long wtcon_save; |
465 | static unsigned long wtdat_save; | 465 | static unsigned long wtdat_save; |
466 | 466 | ||
467 | static int s3c2410wdt_suspend(struct device *dev, pm_message_t state, u32 level) | 467 | static int s3c2410wdt_suspend(struct device *dev, pm_message_t state) |
468 | { | 468 | { |
469 | if (level == SUSPEND_POWER_DOWN) { | 469 | /* Save watchdog state, and turn it off. */ |
470 | /* Save watchdog state, and turn it off. */ | 470 | wtcon_save = readl(wdt_base + S3C2410_WTCON); |
471 | wtcon_save = readl(wdt_base + S3C2410_WTCON); | 471 | wtdat_save = readl(wdt_base + S3C2410_WTDAT); |
472 | wtdat_save = readl(wdt_base + S3C2410_WTDAT); | ||
473 | 472 | ||
474 | /* Note that WTCNT doesn't need to be saved. */ | 473 | /* Note that WTCNT doesn't need to be saved. */ |
475 | s3c2410wdt_stop(); | 474 | s3c2410wdt_stop(); |
476 | } | ||
477 | 475 | ||
478 | return 0; | 476 | return 0; |
479 | } | 477 | } |
480 | 478 | ||
481 | static int s3c2410wdt_resume(struct device *dev, u32 level) | 479 | static int s3c2410wdt_resume(struct device *dev) |
482 | { | 480 | { |
483 | if (level == RESUME_POWER_ON) { | 481 | /* Restore watchdog state. */ |
484 | /* Restore watchdog state. */ | ||
485 | 482 | ||
486 | writel(wtdat_save, wdt_base + S3C2410_WTDAT); | 483 | writel(wtdat_save, wdt_base + S3C2410_WTDAT); |
487 | writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ | 484 | writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ |
488 | writel(wtcon_save, wdt_base + S3C2410_WTCON); | 485 | writel(wtcon_save, wdt_base + S3C2410_WTCON); |
489 | 486 | ||
490 | printk(KERN_INFO PFX "watchdog %sabled\n", | 487 | printk(KERN_INFO PFX "watchdog %sabled\n", |
491 | (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); | 488 | (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); |
492 | } | ||
493 | 489 | ||
494 | return 0; | 490 | return 0; |
495 | } | 491 | } |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index e928cdb041cb..8102876c7c3f 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -121,7 +121,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, | |||
121 | static struct adm1021_data *adm1021_update_device(struct device *dev); | 121 | static struct adm1021_data *adm1021_update_device(struct device *dev); |
122 | 122 | ||
123 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ | 123 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ |
124 | static int read_only = 0; | 124 | static int read_only; |
125 | 125 | ||
126 | 126 | ||
127 | /* This is the driver that will be inserted */ | 127 | /* This is the driver that will be inserted */ |
@@ -204,11 +204,10 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
204 | client structure, even though we cannot fill it completely yet. | 204 | client structure, even though we cannot fill it completely yet. |
205 | But it allows us to access adm1021_{read,write}_value. */ | 205 | But it allows us to access adm1021_{read,write}_value. */ |
206 | 206 | ||
207 | if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { | 207 | if (!(data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { |
208 | err = -ENOMEM; | 208 | err = -ENOMEM; |
209 | goto error0; | 209 | goto error0; |
210 | } | 210 | } |
211 | memset(data, 0, sizeof(struct adm1021_data)); | ||
212 | 211 | ||
213 | new_client = &data->client; | 212 | new_client = &data->client; |
214 | i2c_set_clientdata(new_client, data); | 213 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 526b7ff179eb..3ec12421694f 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -331,11 +331,10 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
331 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 331 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
332 | goto exit; | 332 | goto exit; |
333 | 333 | ||
334 | if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { | 334 | if (!(data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { |
335 | err = -ENOMEM; | 335 | err = -ENOMEM; |
336 | goto exit; | 336 | goto exit; |
337 | } | 337 | } |
338 | memset(data, 0, sizeof(struct adm1025_data)); | ||
339 | 338 | ||
340 | /* The common I2C client data is placed right before the | 339 | /* The common I2C client data is placed right before the |
341 | ADM1025-specific data. */ | 340 | ADM1025-specific data. */ |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 625158110fd4..e0f56549d1d8 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -315,7 +315,7 @@ static struct i2c_driver adm1026_driver = { | |||
315 | .detach_client = adm1026_detach_client, | 315 | .detach_client = adm1026_detach_client, |
316 | }; | 316 | }; |
317 | 317 | ||
318 | int adm1026_attach_adapter(struct i2c_adapter *adapter) | 318 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) |
319 | { | 319 | { |
320 | if (!(adapter->class & I2C_CLASS_HWMON)) { | 320 | if (!(adapter->class & I2C_CLASS_HWMON)) { |
321 | return 0; | 321 | return 0; |
@@ -323,7 +323,7 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter) | |||
323 | return i2c_probe(adapter, &addr_data, adm1026_detect); | 323 | return i2c_probe(adapter, &addr_data, adm1026_detect); |
324 | } | 324 | } |
325 | 325 | ||
326 | int adm1026_detach_client(struct i2c_client *client) | 326 | static int adm1026_detach_client(struct i2c_client *client) |
327 | { | 327 | { |
328 | struct adm1026_data *data = i2c_get_clientdata(client); | 328 | struct adm1026_data *data = i2c_get_clientdata(client); |
329 | hwmon_device_unregister(data->class_dev); | 329 | hwmon_device_unregister(data->class_dev); |
@@ -332,7 +332,7 @@ int adm1026_detach_client(struct i2c_client *client) | |||
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | int adm1026_read_value(struct i2c_client *client, u8 reg) | 335 | static int adm1026_read_value(struct i2c_client *client, u8 reg) |
336 | { | 336 | { |
337 | int res; | 337 | int res; |
338 | 338 | ||
@@ -346,7 +346,7 @@ int adm1026_read_value(struct i2c_client *client, u8 reg) | |||
346 | return res; | 346 | return res; |
347 | } | 347 | } |
348 | 348 | ||
349 | int adm1026_write_value(struct i2c_client *client, u8 reg, int value) | 349 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value) |
350 | { | 350 | { |
351 | int res; | 351 | int res; |
352 | 352 | ||
@@ -360,7 +360,7 @@ int adm1026_write_value(struct i2c_client *client, u8 reg, int value) | |||
360 | return res; | 360 | return res; |
361 | } | 361 | } |
362 | 362 | ||
363 | void adm1026_init_client(struct i2c_client *client) | 363 | static void adm1026_init_client(struct i2c_client *client) |
364 | { | 364 | { |
365 | int value, i; | 365 | int value, i; |
366 | struct adm1026_data *data = i2c_get_clientdata(client); | 366 | struct adm1026_data *data = i2c_get_clientdata(client); |
@@ -460,7 +460,7 @@ void adm1026_init_client(struct i2c_client *client) | |||
460 | } | 460 | } |
461 | } | 461 | } |
462 | 462 | ||
463 | void adm1026_print_gpio(struct i2c_client *client) | 463 | static void adm1026_print_gpio(struct i2c_client *client) |
464 | { | 464 | { |
465 | struct adm1026_data *data = i2c_get_clientdata(client); | 465 | struct adm1026_data *data = i2c_get_clientdata(client); |
466 | int i; | 466 | int i; |
@@ -492,7 +492,7 @@ void adm1026_print_gpio(struct i2c_client *client) | |||
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void adm1026_fixup_gpio(struct i2c_client *client) | 495 | static void adm1026_fixup_gpio(struct i2c_client *client) |
496 | { | 496 | { |
497 | struct adm1026_data *data = i2c_get_clientdata(client); | 497 | struct adm1026_data *data = i2c_get_clientdata(client); |
498 | int i; | 498 | int i; |
@@ -1452,8 +1452,8 @@ static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | |||
1452 | static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1452 | static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
1453 | static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1453 | static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
1454 | 1454 | ||
1455 | int adm1026_detect(struct i2c_adapter *adapter, int address, | 1455 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
1456 | int kind) | 1456 | int kind) |
1457 | { | 1457 | { |
1458 | int company, verstep; | 1458 | int company, verstep; |
1459 | struct i2c_client *new_client; | 1459 | struct i2c_client *new_client; |
@@ -1470,13 +1470,11 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1470 | client structure, even though we cannot fill it completely yet. | 1470 | client structure, even though we cannot fill it completely yet. |
1471 | But it allows us to access adm1026_{read,write}_value. */ | 1471 | But it allows us to access adm1026_{read,write}_value. */ |
1472 | 1472 | ||
1473 | if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { | 1473 | if (!(data = kzalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { |
1474 | err = -ENOMEM; | 1474 | err = -ENOMEM; |
1475 | goto exit; | 1475 | goto exit; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | memset(data, 0, sizeof(struct adm1026_data)); | ||
1479 | |||
1480 | new_client = &data->client; | 1478 | new_client = &data->client; |
1481 | i2c_set_clientdata(new_client, data); | 1479 | i2c_set_clientdata(new_client, data); |
1482 | new_client->addr = address; | 1480 | new_client->addr = address; |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 58338ed7c8a1..7c545d5eee45 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -740,11 +740,10 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
741 | goto exit; | 741 | goto exit; |
742 | 742 | ||
743 | if (!(data = kmalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { | 743 | if (!(data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { |
744 | err = -ENOMEM; | 744 | err = -ENOMEM; |
745 | goto exit; | 745 | goto exit; |
746 | } | 746 | } |
747 | memset(data, 0, sizeof(struct adm1031_data)); | ||
748 | 747 | ||
749 | new_client = &data->client; | 748 | new_client = &data->client; |
750 | i2c_set_clientdata(new_client, data); | 749 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index bc7faef162f7..11dc95f8a17e 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/hwmon-sysfs.h> | ||
48 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
49 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
50 | #include <linux/err.h> | 51 | #include <linux/err.h> |
@@ -69,8 +70,7 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); | |||
69 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | 70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) |
70 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | 71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) |
71 | #define ADM9240_REG_TEMP 0x27 | 72 | #define ADM9240_REG_TEMP 0x27 |
72 | #define ADM9240_REG_TEMP_HIGH 0x39 | 73 | #define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */ |
73 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
74 | #define ADM9240_REG_ANALOG_OUT 0x19 | 74 | #define ADM9240_REG_ANALOG_OUT 0x19 |
75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | 75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 |
76 | #define ADM9240_REG_VID_FAN_DIV 0x47 | 76 | #define ADM9240_REG_VID_FAN_DIV 0x47 |
@@ -162,177 +162,155 @@ struct adm9240_data { | |||
162 | u8 fan_min[2]; /* rw fan1_min */ | 162 | u8 fan_min[2]; /* rw fan1_min */ |
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | 163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ |
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | 164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ |
165 | s8 temp_high; /* rw temp1_max */ | 165 | s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */ |
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | 166 | u16 alarms; /* ro alarms */ |
168 | u8 aout; /* rw aout_output */ | 167 | u8 aout; /* rw aout_output */ |
169 | u8 vid; /* ro vid */ | 168 | u8 vid; /* ro vid */ |
170 | u8 vrm; /* -- vrm set on startup, no accessor */ | 169 | u8 vrm; /* -- vrm set on startup, no accessor */ |
171 | }; | 170 | }; |
172 | 171 | ||
173 | /* i2c byte read/write interface */ | 172 | /*** sysfs accessors ***/ |
174 | static int adm9240_read_value(struct i2c_client *client, u8 reg) | 173 | |
174 | /* temperature */ | ||
175 | static ssize_t show_temp(struct device *dev, struct device_attribute *dummy, | ||
176 | char *buf) | ||
175 | { | 177 | { |
176 | return i2c_smbus_read_byte_data(client, reg); | 178 | struct adm9240_data *data = adm9240_update_device(dev); |
179 | return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */ | ||
177 | } | 180 | } |
178 | 181 | ||
179 | static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) | 182 | static ssize_t show_max(struct device *dev, struct device_attribute *devattr, |
183 | char *buf) | ||
180 | { | 184 | { |
181 | return i2c_smbus_write_byte_data(client, reg, value); | 185 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
186 | struct adm9240_data *data = adm9240_update_device(dev); | ||
187 | return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000); | ||
182 | } | 188 | } |
183 | 189 | ||
184 | /*** sysfs accessors ***/ | 190 | static ssize_t set_max(struct device *dev, struct device_attribute *devattr, |
191 | const char *buf, size_t count) | ||
192 | { | ||
193 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
194 | struct i2c_client *client = to_i2c_client(dev); | ||
195 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
196 | long val = simple_strtol(buf, NULL, 10); | ||
197 | |||
198 | down(&data->update_lock); | ||
199 | data->temp_max[attr->index] = TEMP_TO_REG(val); | ||
200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), | ||
201 | data->temp_max[attr->index]); | ||
202 | up(&data->update_lock); | ||
203 | return count; | ||
204 | } | ||
185 | 205 | ||
186 | /* temperature */ | ||
187 | #define show_temp(value, scale) \ | ||
188 | static ssize_t show_##value(struct device *dev, \ | ||
189 | struct device_attribute *attr, \ | ||
190 | char *buf) \ | ||
191 | { \ | ||
192 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
193 | return sprintf(buf, "%d\n", data->value * scale); \ | ||
194 | } | ||
195 | show_temp(temp_high, 1000); | ||
196 | show_temp(temp_hyst, 1000); | ||
197 | show_temp(temp, 500); /* 0.5'C per bit */ | ||
198 | |||
199 | #define set_temp(value, reg) \ | ||
200 | static ssize_t set_##value(struct device *dev, \ | ||
201 | struct device_attribute *attr, \ | ||
202 | const char *buf, size_t count) \ | ||
203 | { \ | ||
204 | struct i2c_client *client = to_i2c_client(dev); \ | ||
205 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
206 | long temp = simple_strtoul(buf, NULL, 10); \ | ||
207 | \ | ||
208 | down(&data->update_lock); \ | ||
209 | data->value = TEMP_TO_REG(temp); \ | ||
210 | adm9240_write_value(client, reg, data->value); \ | ||
211 | up(&data->update_lock); \ | ||
212 | return count; \ | ||
213 | } | ||
214 | |||
215 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | ||
216 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | ||
217 | |||
218 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
219 | show_temp_high, set_temp_high); | ||
220 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
221 | show_temp_hyst, set_temp_hyst); | ||
222 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | 206 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); |
207 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
208 | show_max, set_max, 0); | ||
209 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
210 | show_max, set_max, 1); | ||
223 | 211 | ||
224 | /* voltage */ | 212 | /* voltage */ |
225 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 213 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
214 | char *buf) | ||
226 | { | 215 | { |
216 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
227 | struct adm9240_data *data = adm9240_update_device(dev); | 217 | struct adm9240_data *data = adm9240_update_device(dev); |
228 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | 218 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index], |
219 | attr->index)); | ||
229 | } | 220 | } |
230 | 221 | ||
231 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 222 | static ssize_t show_in_min(struct device *dev, |
223 | struct device_attribute *devattr, char *buf) | ||
232 | { | 224 | { |
225 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
233 | struct adm9240_data *data = adm9240_update_device(dev); | 226 | struct adm9240_data *data = adm9240_update_device(dev); |
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | 227 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index], |
228 | attr->index)); | ||
235 | } | 229 | } |
236 | 230 | ||
237 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 231 | static ssize_t show_in_max(struct device *dev, |
232 | struct device_attribute *devattr, char *buf) | ||
238 | { | 233 | { |
234 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
239 | struct adm9240_data *data = adm9240_update_device(dev); | 235 | struct adm9240_data *data = adm9240_update_device(dev); |
240 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | 236 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index], |
237 | attr->index)); | ||
241 | } | 238 | } |
242 | 239 | ||
243 | static ssize_t set_in_min(struct device *dev, const char *buf, | 240 | static ssize_t set_in_min(struct device *dev, |
244 | size_t count, int nr) | 241 | struct device_attribute *devattr, |
242 | const char *buf, size_t count) | ||
245 | { | 243 | { |
244 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
246 | struct i2c_client *client = to_i2c_client(dev); | 245 | struct i2c_client *client = to_i2c_client(dev); |
247 | struct adm9240_data *data = i2c_get_clientdata(client); | 246 | struct adm9240_data *data = i2c_get_clientdata(client); |
248 | unsigned long val = simple_strtoul(buf, NULL, 10); | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); |
249 | 248 | ||
250 | down(&data->update_lock); | 249 | down(&data->update_lock); |
251 | data->in_min[nr] = IN_TO_REG(val, nr); | 250 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
252 | adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); | 251 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
252 | data->in_min[attr->index]); | ||
253 | up(&data->update_lock); | 253 | up(&data->update_lock); |
254 | return count; | 254 | return count; |
255 | } | 255 | } |
256 | 256 | ||
257 | static ssize_t set_in_max(struct device *dev, const char *buf, | 257 | static ssize_t set_in_max(struct device *dev, |
258 | size_t count, int nr) | 258 | struct device_attribute *devattr, |
259 | const char *buf, size_t count) | ||
259 | { | 260 | { |
261 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
260 | struct i2c_client *client = to_i2c_client(dev); | 262 | struct i2c_client *client = to_i2c_client(dev); |
261 | struct adm9240_data *data = i2c_get_clientdata(client); | 263 | struct adm9240_data *data = i2c_get_clientdata(client); |
262 | unsigned long val = simple_strtoul(buf, NULL, 10); | 264 | unsigned long val = simple_strtoul(buf, NULL, 10); |
263 | 265 | ||
264 | down(&data->update_lock); | 266 | down(&data->update_lock); |
265 | data->in_max[nr] = IN_TO_REG(val, nr); | 267 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
266 | adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); | 268 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
269 | data->in_max[attr->index]); | ||
267 | up(&data->update_lock); | 270 | up(&data->update_lock); |
268 | return count; | 271 | return count; |
269 | } | 272 | } |
270 | 273 | ||
271 | #define show_in_offset(offset) \ | 274 | #define vin(nr) \ |
272 | static ssize_t show_in##offset(struct device *dev, \ | 275 | static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ |
273 | struct device_attribute *attr, \ | 276 | show_in, NULL, nr); \ |
274 | char *buf) \ | 277 | static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ |
275 | { \ | 278 | show_in_min, set_in_min, nr); \ |
276 | return show_in(dev, buf, offset); \ | 279 | static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \ |
277 | } \ | 280 | show_in_max, set_in_max, nr); |
278 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | 281 | |
279 | static ssize_t show_in##offset##_min(struct device *dev, \ | 282 | vin(0); |
280 | struct device_attribute *attr, \ | 283 | vin(1); |
281 | char *buf) \ | 284 | vin(2); |
282 | { \ | 285 | vin(3); |
283 | return show_in_min(dev, buf, offset); \ | 286 | vin(4); |
284 | } \ | 287 | vin(5); |
285 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
286 | struct device_attribute *attr, \ | ||
287 | char *buf) \ | ||
288 | { \ | ||
289 | return show_in_max(dev, buf, offset); \ | ||
290 | } \ | ||
291 | static ssize_t \ | ||
292 | set_in##offset##_min(struct device *dev, \ | ||
293 | struct device_attribute *attr, const char *buf, \ | ||
294 | size_t count) \ | ||
295 | { \ | ||
296 | return set_in_min(dev, buf, count, offset); \ | ||
297 | } \ | ||
298 | static ssize_t \ | ||
299 | set_in##offset##_max(struct device *dev, \ | ||
300 | struct device_attribute *attr, const char *buf, \ | ||
301 | size_t count) \ | ||
302 | { \ | ||
303 | return set_in_max(dev, buf, count, offset); \ | ||
304 | } \ | ||
305 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
306 | show_in##offset##_min, set_in##offset##_min); \ | ||
307 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
308 | show_in##offset##_max, set_in##offset##_max); | ||
309 | |||
310 | show_in_offset(0); | ||
311 | show_in_offset(1); | ||
312 | show_in_offset(2); | ||
313 | show_in_offset(3); | ||
314 | show_in_offset(4); | ||
315 | show_in_offset(5); | ||
316 | 288 | ||
317 | /* fans */ | 289 | /* fans */ |
318 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 290 | static ssize_t show_fan(struct device *dev, |
291 | struct device_attribute *devattr, char *buf) | ||
319 | { | 292 | { |
293 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
320 | struct adm9240_data *data = adm9240_update_device(dev); | 294 | struct adm9240_data *data = adm9240_update_device(dev); |
321 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | 295 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], |
322 | 1 << data->fan_div[nr])); | 296 | 1 << data->fan_div[attr->index])); |
323 | } | 297 | } |
324 | 298 | ||
325 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 299 | static ssize_t show_fan_min(struct device *dev, |
300 | struct device_attribute *devattr, char *buf) | ||
326 | { | 301 | { |
302 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
327 | struct adm9240_data *data = adm9240_update_device(dev); | 303 | struct adm9240_data *data = adm9240_update_device(dev); |
328 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | 304 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index], |
329 | 1 << data->fan_div[nr])); | 305 | 1 << data->fan_div[attr->index])); |
330 | } | 306 | } |
331 | 307 | ||
332 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 308 | static ssize_t show_fan_div(struct device *dev, |
309 | struct device_attribute *devattr, char *buf) | ||
333 | { | 310 | { |
311 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
334 | struct adm9240_data *data = adm9240_update_device(dev); | 312 | struct adm9240_data *data = adm9240_update_device(dev); |
335 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | 313 | return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]); |
336 | } | 314 | } |
337 | 315 | ||
338 | /* write new fan div, callers must hold data->update_lock */ | 316 | /* write new fan div, callers must hold data->update_lock */ |
@@ -341,16 +319,16 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
341 | { | 319 | { |
342 | u8 reg, old, shift = (nr + 2) * 2; | 320 | u8 reg, old, shift = (nr + 2) * 2; |
343 | 321 | ||
344 | reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | 322 | reg = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |
345 | old = (reg >> shift) & 3; | 323 | old = (reg >> shift) & 3; |
346 | reg &= ~(3 << shift); | 324 | reg &= ~(3 << shift); |
347 | reg |= (fan_div << shift); | 325 | reg |= (fan_div << shift); |
348 | adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); | 326 | i2c_smbus_write_byte_data(client, ADM9240_REG_VID_FAN_DIV, reg); |
349 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " | 327 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " |
350 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); | 328 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); |
351 | } | 329 | } |
352 | 330 | ||
353 | /* | 331 | /* |
354 | * set fan speed low limit: | 332 | * set fan speed low limit: |
355 | * | 333 | * |
356 | * - value is zero: disable fan speed low limit alarm | 334 | * - value is zero: disable fan speed low limit alarm |
@@ -361,12 +339,15 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
361 | * - otherwise: select fan clock divider to suit fan speed low limit, | 339 | * - otherwise: select fan clock divider to suit fan speed low limit, |
362 | * measurement code may adjust registers to ensure fan speed reading | 340 | * measurement code may adjust registers to ensure fan speed reading |
363 | */ | 341 | */ |
364 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 342 | static ssize_t set_fan_min(struct device *dev, |
365 | size_t count, int nr) | 343 | struct device_attribute *devattr, |
344 | const char *buf, size_t count) | ||
366 | { | 345 | { |
346 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
367 | struct i2c_client *client = to_i2c_client(dev); | 347 | struct i2c_client *client = to_i2c_client(dev); |
368 | struct adm9240_data *data = i2c_get_clientdata(client); | 348 | struct adm9240_data *data = i2c_get_clientdata(client); |
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | 349 | unsigned long val = simple_strtoul(buf, NULL, 10); |
350 | int nr = attr->index; | ||
370 | u8 new_div; | 351 | u8 new_div; |
371 | 352 | ||
372 | down(&data->update_lock); | 353 | down(&data->update_lock); |
@@ -406,50 +387,27 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
406 | data->fan_div[nr] = new_div; | 387 | data->fan_div[nr] = new_div; |
407 | adm9240_write_fan_div(client, nr, new_div); | 388 | adm9240_write_fan_div(client, nr, new_div); |
408 | } | 389 | } |
409 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), | 390 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), |
410 | data->fan_min[nr]); | 391 | data->fan_min[nr]); |
411 | 392 | ||
412 | up(&data->update_lock); | 393 | up(&data->update_lock); |
413 | return count; | 394 | return count; |
414 | } | 395 | } |
415 | 396 | ||
416 | #define show_fan_offset(offset) \ | 397 | #define fan(nr) \ |
417 | static ssize_t show_fan_##offset (struct device *dev, \ | 398 | static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \ |
418 | struct device_attribute *attr, \ | 399 | show_fan, NULL, nr - 1); \ |
419 | char *buf) \ | 400 | static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \ |
420 | { \ | 401 | show_fan_div, NULL, nr - 1); \ |
421 | return show_fan(dev, buf, offset - 1); \ | 402 | static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \ |
422 | } \ | 403 | show_fan_min, set_fan_min, nr - 1); |
423 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | 404 | |
424 | struct device_attribute *attr, \ | 405 | fan(1); |
425 | char *buf) \ | 406 | fan(2); |
426 | { \ | ||
427 | return show_fan_div(dev, buf, offset - 1); \ | ||
428 | } \ | ||
429 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
430 | struct device_attribute *attr, \ | ||
431 | char *buf) \ | ||
432 | { \ | ||
433 | return show_fan_min(dev, buf, offset - 1); \ | ||
434 | } \ | ||
435 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
436 | struct device_attribute *attr, \ | ||
437 | const char *buf, size_t count) \ | ||
438 | { \ | ||
439 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
440 | } \ | ||
441 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
442 | show_fan_##offset, NULL); \ | ||
443 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
444 | show_fan_##offset##_div, NULL); \ | ||
445 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
446 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
447 | |||
448 | show_fan_offset(1); | ||
449 | show_fan_offset(2); | ||
450 | 407 | ||
451 | /* alarms */ | 408 | /* alarms */ |
452 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 409 | static ssize_t show_alarms(struct device *dev, |
410 | struct device_attribute *attr, char *buf) | ||
453 | { | 411 | { |
454 | struct adm9240_data *data = adm9240_update_device(dev); | 412 | struct adm9240_data *data = adm9240_update_device(dev); |
455 | return sprintf(buf, "%u\n", data->alarms); | 413 | return sprintf(buf, "%u\n", data->alarms); |
@@ -457,7 +415,8 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
457 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 415 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
458 | 416 | ||
459 | /* vid */ | 417 | /* vid */ |
460 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 418 | static ssize_t show_vid(struct device *dev, |
419 | struct device_attribute *attr, char *buf) | ||
461 | { | 420 | { |
462 | struct adm9240_data *data = adm9240_update_device(dev); | 421 | struct adm9240_data *data = adm9240_update_device(dev); |
463 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | 422 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); |
@@ -465,13 +424,16 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char | |||
465 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 424 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
466 | 425 | ||
467 | /* analog output */ | 426 | /* analog output */ |
468 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) | 427 | static ssize_t show_aout(struct device *dev, |
428 | struct device_attribute *attr, char *buf) | ||
469 | { | 429 | { |
470 | struct adm9240_data *data = adm9240_update_device(dev); | 430 | struct adm9240_data *data = adm9240_update_device(dev); |
471 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | 431 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); |
472 | } | 432 | } |
473 | 433 | ||
474 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 434 | static ssize_t set_aout(struct device *dev, |
435 | struct device_attribute *attr, | ||
436 | const char *buf, size_t count) | ||
475 | { | 437 | { |
476 | struct i2c_client *client = to_i2c_client(dev); | 438 | struct i2c_client *client = to_i2c_client(dev); |
477 | struct adm9240_data *data = i2c_get_clientdata(client); | 439 | struct adm9240_data *data = i2c_get_clientdata(client); |
@@ -479,20 +441,23 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const | |||
479 | 441 | ||
480 | down(&data->update_lock); | 442 | down(&data->update_lock); |
481 | data->aout = AOUT_TO_REG(val); | 443 | data->aout = AOUT_TO_REG(val); |
482 | adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); | 444 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); |
483 | up(&data->update_lock); | 445 | up(&data->update_lock); |
484 | return count; | 446 | return count; |
485 | } | 447 | } |
486 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 448 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
487 | 449 | ||
488 | /* chassis_clear */ | 450 | /* chassis_clear */ |
489 | static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 451 | static ssize_t chassis_clear(struct device *dev, |
452 | struct device_attribute *attr, | ||
453 | const char *buf, size_t count) | ||
490 | { | 454 | { |
491 | struct i2c_client *client = to_i2c_client(dev); | 455 | struct i2c_client *client = to_i2c_client(dev); |
492 | unsigned long val = simple_strtol(buf, NULL, 10); | 456 | unsigned long val = simple_strtol(buf, NULL, 10); |
493 | 457 | ||
494 | if (val == 1) { | 458 | if (val == 1) { |
495 | adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); | 459 | i2c_smbus_write_byte_data(client, |
460 | ADM9240_REG_CHASSIS_CLEAR, 0x80); | ||
496 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); | 461 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); |
497 | } | 462 | } |
498 | return count; | 463 | return count; |
@@ -513,11 +478,10 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
513 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 478 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
514 | goto exit; | 479 | goto exit; |
515 | 480 | ||
516 | if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { | 481 | if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { |
517 | err = -ENOMEM; | 482 | err = -ENOMEM; |
518 | goto exit; | 483 | goto exit; |
519 | } | 484 | } |
520 | memset(data, 0, sizeof(struct adm9240_data)); | ||
521 | 485 | ||
522 | new_client = &data->client; | 486 | new_client = &data->client; |
523 | i2c_set_clientdata(new_client, data); | 487 | i2c_set_clientdata(new_client, data); |
@@ -533,7 +497,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
533 | if (kind < 0) { | 497 | if (kind < 0) { |
534 | 498 | ||
535 | /* verify chip: reg address should match i2c address */ | 499 | /* verify chip: reg address should match i2c address */ |
536 | if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) | 500 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) |
537 | != address) { | 501 | != address) { |
538 | dev_err(&adapter->dev, "detect fail: address match, " | 502 | dev_err(&adapter->dev, "detect fail: address match, " |
539 | "0x%02x\n", address); | 503 | "0x%02x\n", address); |
@@ -541,8 +505,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
541 | } | 505 | } |
542 | 506 | ||
543 | /* check known chip manufacturer */ | 507 | /* check known chip manufacturer */ |
544 | man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); | 508 | man_id = i2c_smbus_read_byte_data(new_client, |
545 | 509 | ADM9240_REG_MAN_ID); | |
546 | if (man_id == 0x23) { | 510 | if (man_id == 0x23) { |
547 | kind = adm9240; | 511 | kind = adm9240; |
548 | } else if (man_id == 0xda) { | 512 | } else if (man_id == 0xda) { |
@@ -556,7 +520,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
556 | } | 520 | } |
557 | 521 | ||
558 | /* successful detect, print chip info */ | 522 | /* successful detect, print chip info */ |
559 | die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); | 523 | die_rev = i2c_smbus_read_byte_data(new_client, |
524 | ADM9240_REG_DIE_REV); | ||
560 | dev_info(&adapter->dev, "found %s revision %u\n", | 525 | dev_info(&adapter->dev, "found %s revision %u\n", |
561 | man_id == 0x23 ? "ADM9240" : | 526 | man_id == 0x23 ? "ADM9240" : |
562 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | 527 | man_id == 0xda ? "DS1780" : "LM81", die_rev); |
@@ -588,33 +553,59 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
588 | goto exit_detach; | 553 | goto exit_detach; |
589 | } | 554 | } |
590 | 555 | ||
591 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 556 | device_create_file(&new_client->dev, |
592 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 557 | &sensor_dev_attr_in0_input.dev_attr); |
593 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 558 | device_create_file(&new_client->dev, |
594 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 559 | &sensor_dev_attr_in0_min.dev_attr); |
595 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 560 | device_create_file(&new_client->dev, |
596 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 561 | &sensor_dev_attr_in0_max.dev_attr); |
597 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 562 | device_create_file(&new_client->dev, |
598 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 563 | &sensor_dev_attr_in1_input.dev_attr); |
599 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 564 | device_create_file(&new_client->dev, |
600 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 565 | &sensor_dev_attr_in1_min.dev_attr); |
601 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 566 | device_create_file(&new_client->dev, |
602 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 567 | &sensor_dev_attr_in1_max.dev_attr); |
603 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 568 | device_create_file(&new_client->dev, |
604 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 569 | &sensor_dev_attr_in2_input.dev_attr); |
605 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 570 | device_create_file(&new_client->dev, |
606 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 571 | &sensor_dev_attr_in2_min.dev_attr); |
607 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 572 | device_create_file(&new_client->dev, |
608 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 573 | &sensor_dev_attr_in2_max.dev_attr); |
609 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 574 | device_create_file(&new_client->dev, |
610 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | 575 | &sensor_dev_attr_in3_input.dev_attr); |
576 | device_create_file(&new_client->dev, | ||
577 | &sensor_dev_attr_in3_min.dev_attr); | ||
578 | device_create_file(&new_client->dev, | ||
579 | &sensor_dev_attr_in3_max.dev_attr); | ||
580 | device_create_file(&new_client->dev, | ||
581 | &sensor_dev_attr_in4_input.dev_attr); | ||
582 | device_create_file(&new_client->dev, | ||
583 | &sensor_dev_attr_in4_min.dev_attr); | ||
584 | device_create_file(&new_client->dev, | ||
585 | &sensor_dev_attr_in4_max.dev_attr); | ||
586 | device_create_file(&new_client->dev, | ||
587 | &sensor_dev_attr_in5_input.dev_attr); | ||
588 | device_create_file(&new_client->dev, | ||
589 | &sensor_dev_attr_in5_min.dev_attr); | ||
590 | device_create_file(&new_client->dev, | ||
591 | &sensor_dev_attr_in5_max.dev_attr); | ||
611 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 592 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
612 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 593 | device_create_file(&new_client->dev, |
613 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 594 | &sensor_dev_attr_temp1_max.dev_attr); |
614 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 595 | device_create_file(&new_client->dev, |
615 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 596 | &sensor_dev_attr_temp1_max_hyst.dev_attr); |
616 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 597 | device_create_file(&new_client->dev, |
617 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 598 | &sensor_dev_attr_fan1_input.dev_attr); |
599 | device_create_file(&new_client->dev, | ||
600 | &sensor_dev_attr_fan1_div.dev_attr); | ||
601 | device_create_file(&new_client->dev, | ||
602 | &sensor_dev_attr_fan1_min.dev_attr); | ||
603 | device_create_file(&new_client->dev, | ||
604 | &sensor_dev_attr_fan2_input.dev_attr); | ||
605 | device_create_file(&new_client->dev, | ||
606 | &sensor_dev_attr_fan2_div.dev_attr); | ||
607 | device_create_file(&new_client->dev, | ||
608 | &sensor_dev_attr_fan2_min.dev_attr); | ||
618 | device_create_file(&new_client->dev, &dev_attr_alarms); | 609 | device_create_file(&new_client->dev, &dev_attr_alarms); |
619 | device_create_file(&new_client->dev, &dev_attr_aout_output); | 610 | device_create_file(&new_client->dev, &dev_attr_aout_output); |
620 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | 611 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); |
@@ -654,8 +645,8 @@ static int adm9240_detach_client(struct i2c_client *client) | |||
654 | static void adm9240_init_client(struct i2c_client *client) | 645 | static void adm9240_init_client(struct i2c_client *client) |
655 | { | 646 | { |
656 | struct adm9240_data *data = i2c_get_clientdata(client); | 647 | struct adm9240_data *data = i2c_get_clientdata(client); |
657 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | 648 | u8 conf = i2c_smbus_read_byte_data(client, ADM9240_REG_CONFIG); |
658 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | 649 | u8 mode = i2c_smbus_read_byte_data(client, ADM9240_REG_TEMP_CONF) & 3; |
659 | 650 | ||
660 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ | 651 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ |
661 | 652 | ||
@@ -672,18 +663,22 @@ static void adm9240_init_client(struct i2c_client *client) | |||
672 | 663 | ||
673 | for (i = 0; i < 6; i++) | 664 | for (i = 0; i < 6; i++) |
674 | { | 665 | { |
675 | adm9240_write_value(client, | 666 | i2c_smbus_write_byte_data(client, |
676 | ADM9240_REG_IN_MIN(i), 0); | 667 | ADM9240_REG_IN_MIN(i), 0); |
677 | adm9240_write_value(client, | 668 | i2c_smbus_write_byte_data(client, |
678 | ADM9240_REG_IN_MAX(i), 255); | 669 | ADM9240_REG_IN_MAX(i), 255); |
679 | } | 670 | } |
680 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); | 671 | i2c_smbus_write_byte_data(client, |
681 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); | 672 | ADM9240_REG_FAN_MIN(0), 255); |
682 | adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); | 673 | i2c_smbus_write_byte_data(client, |
683 | adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); | 674 | ADM9240_REG_FAN_MIN(1), 255); |
675 | i2c_smbus_write_byte_data(client, | ||
676 | ADM9240_REG_TEMP_MAX(0), 127); | ||
677 | i2c_smbus_write_byte_data(client, | ||
678 | ADM9240_REG_TEMP_MAX(1), 127); | ||
684 | 679 | ||
685 | /* start measurement cycle */ | 680 | /* start measurement cycle */ |
686 | adm9240_write_value(client, ADM9240_REG_CONFIG, 1); | 681 | i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1); |
687 | 682 | ||
688 | dev_info(&client->dev, "cold start: config was 0x%02x " | 683 | dev_info(&client->dev, "cold start: config was 0x%02x " |
689 | "mode %u\n", conf, mode); | 684 | "mode %u\n", conf, mode); |
@@ -704,25 +699,25 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
704 | 699 | ||
705 | for (i = 0; i < 6; i++) /* read voltages */ | 700 | for (i = 0; i < 6; i++) /* read voltages */ |
706 | { | 701 | { |
707 | data->in[i] = adm9240_read_value(client, | 702 | data->in[i] = i2c_smbus_read_byte_data(client, |
708 | ADM9240_REG_IN(i)); | 703 | ADM9240_REG_IN(i)); |
709 | } | 704 | } |
710 | data->alarms = adm9240_read_value(client, | 705 | data->alarms = i2c_smbus_read_byte_data(client, |
711 | ADM9240_REG_INT(0)) | | 706 | ADM9240_REG_INT(0)) | |
712 | adm9240_read_value(client, | 707 | i2c_smbus_read_byte_data(client, |
713 | ADM9240_REG_INT(1)) << 8; | 708 | ADM9240_REG_INT(1)) << 8; |
714 | 709 | ||
715 | /* read temperature: assume temperature changes less than | 710 | /* read temperature: assume temperature changes less than |
716 | * 0.5'C per two measurement cycles thus ignore possible | 711 | * 0.5'C per two measurement cycles thus ignore possible |
717 | * but unlikely aliasing error on lsb reading. --Grant */ | 712 | * but unlikely aliasing error on lsb reading. --Grant */ |
718 | data->temp = ((adm9240_read_value(client, | 713 | data->temp = ((i2c_smbus_read_byte_data(client, |
719 | ADM9240_REG_TEMP) << 8) | | 714 | ADM9240_REG_TEMP) << 8) | |
720 | adm9240_read_value(client, | 715 | i2c_smbus_read_byte_data(client, |
721 | ADM9240_REG_TEMP_CONF)) / 128; | 716 | ADM9240_REG_TEMP_CONF)) / 128; |
722 | 717 | ||
723 | for (i = 0; i < 2; i++) /* read fans */ | 718 | for (i = 0; i < 2; i++) /* read fans */ |
724 | { | 719 | { |
725 | data->fan[i] = adm9240_read_value(client, | 720 | data->fan[i] = i2c_smbus_read_byte_data(client, |
726 | ADM9240_REG_FAN(i)); | 721 | ADM9240_REG_FAN(i)); |
727 | 722 | ||
728 | /* adjust fan clock divider on overflow */ | 723 | /* adjust fan clock divider on overflow */ |
@@ -747,30 +742,30 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
747 | 742 | ||
748 | for (i = 0; i < 6; i++) | 743 | for (i = 0; i < 6; i++) |
749 | { | 744 | { |
750 | data->in_min[i] = adm9240_read_value(client, | 745 | data->in_min[i] = i2c_smbus_read_byte_data(client, |
751 | ADM9240_REG_IN_MIN(i)); | 746 | ADM9240_REG_IN_MIN(i)); |
752 | data->in_max[i] = adm9240_read_value(client, | 747 | data->in_max[i] = i2c_smbus_read_byte_data(client, |
753 | ADM9240_REG_IN_MAX(i)); | 748 | ADM9240_REG_IN_MAX(i)); |
754 | } | 749 | } |
755 | for (i = 0; i < 2; i++) | 750 | for (i = 0; i < 2; i++) |
756 | { | 751 | { |
757 | data->fan_min[i] = adm9240_read_value(client, | 752 | data->fan_min[i] = i2c_smbus_read_byte_data(client, |
758 | ADM9240_REG_FAN_MIN(i)); | 753 | ADM9240_REG_FAN_MIN(i)); |
759 | } | 754 | } |
760 | data->temp_high = adm9240_read_value(client, | 755 | data->temp_max[0] = i2c_smbus_read_byte_data(client, |
761 | ADM9240_REG_TEMP_HIGH); | 756 | ADM9240_REG_TEMP_MAX(0)); |
762 | data->temp_hyst = adm9240_read_value(client, | 757 | data->temp_max[1] = i2c_smbus_read_byte_data(client, |
763 | ADM9240_REG_TEMP_HYST); | 758 | ADM9240_REG_TEMP_MAX(1)); |
764 | 759 | ||
765 | /* read fan divs and 5-bit VID */ | 760 | /* read fan divs and 5-bit VID */ |
766 | i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | 761 | i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |
767 | data->fan_div[0] = (i >> 4) & 3; | 762 | data->fan_div[0] = (i >> 4) & 3; |
768 | data->fan_div[1] = (i >> 6) & 3; | 763 | data->fan_div[1] = (i >> 6) & 3; |
769 | data->vid = i & 0x0f; | 764 | data->vid = i & 0x0f; |
770 | data->vid |= (adm9240_read_value(client, | 765 | data->vid |= (i2c_smbus_read_byte_data(client, |
771 | ADM9240_REG_VID4) & 1) << 4; | 766 | ADM9240_REG_VID4) & 1) << 4; |
772 | /* read analog out */ | 767 | /* read analog out */ |
773 | data->aout = adm9240_read_value(client, | 768 | data->aout = i2c_smbus_read_byte_data(client, |
774 | ADM9240_REG_ANALOG_OUT); | 769 | ADM9240_REG_ANALOG_OUT); |
775 | 770 | ||
776 | data->last_updated_config = jiffies; | 771 | data->last_updated_config = jiffies; |
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 8e34855a6274..52c469722a65 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -629,19 +629,17 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | |||
629 | int i, id, err; | 629 | int i, id, err; |
630 | struct asb100_data *data = i2c_get_clientdata(new_client); | 630 | struct asb100_data *data = i2c_get_clientdata(new_client); |
631 | 631 | ||
632 | data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 632 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
633 | if (!(data->lm75[0])) { | 633 | if (!(data->lm75[0])) { |
634 | err = -ENOMEM; | 634 | err = -ENOMEM; |
635 | goto ERROR_SC_0; | 635 | goto ERROR_SC_0; |
636 | } | 636 | } |
637 | memset(data->lm75[0], 0x00, sizeof(struct i2c_client)); | ||
638 | 637 | ||
639 | data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 638 | data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
640 | if (!(data->lm75[1])) { | 639 | if (!(data->lm75[1])) { |
641 | err = -ENOMEM; | 640 | err = -ENOMEM; |
642 | goto ERROR_SC_1; | 641 | goto ERROR_SC_1; |
643 | } | 642 | } |
644 | memset(data->lm75[1], 0x00, sizeof(struct i2c_client)); | ||
645 | 643 | ||
646 | id = i2c_adapter_id(adapter); | 644 | id = i2c_adapter_id(adapter); |
647 | 645 | ||
@@ -724,12 +722,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
724 | client structure, even though we cannot fill it completely yet. | 722 | client structure, even though we cannot fill it completely yet. |
725 | But it allows us to access asb100_{read,write}_value. */ | 723 | But it allows us to access asb100_{read,write}_value. */ |
726 | 724 | ||
727 | if (!(data = kmalloc(sizeof(struct asb100_data), GFP_KERNEL))) { | 725 | if (!(data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL))) { |
728 | pr_debug("asb100.o: detect failed, kmalloc failed!\n"); | 726 | pr_debug("asb100.o: detect failed, kzalloc failed!\n"); |
729 | err = -ENOMEM; | 727 | err = -ENOMEM; |
730 | goto ERROR0; | 728 | goto ERROR0; |
731 | } | 729 | } |
732 | memset(data, 0, sizeof(struct asb100_data)); | ||
733 | 730 | ||
734 | new_client = &data->client; | 731 | new_client = &data->client; |
735 | init_MUTEX(&data->lock); | 732 | init_MUTEX(&data->lock); |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index deb4d34c9539..53324f56404e 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -253,6 +253,8 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | |||
253 | 253 | ||
254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | 254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) |
255 | { | 255 | { |
256 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
257 | return 0; | ||
256 | return i2c_probe(adapter, &addr_data, &atxp1_detect); | 258 | return i2c_probe(adapter, &addr_data, &atxp1_detect); |
257 | }; | 259 | }; |
258 | 260 | ||
@@ -266,12 +268,11 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
266 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 268 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
267 | goto exit; | 269 | goto exit; |
268 | 270 | ||
269 | if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { | 271 | if (!(data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { |
270 | err = -ENOMEM; | 272 | err = -ENOMEM; |
271 | goto exit; | 273 | goto exit; |
272 | } | 274 | } |
273 | 275 | ||
274 | memset(data, 0, sizeof(struct atxp1_data)); | ||
275 | new_client = &data->client; | 276 | new_client = &data->client; |
276 | i2c_set_clientdata(new_client, data); | 277 | i2c_set_clientdata(new_client, data); |
277 | 278 | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index b0199e063d0e..34f71b7c7f37 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -180,12 +180,14 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); | |||
180 | 180 | ||
181 | static int ds1621_attach_adapter(struct i2c_adapter *adapter) | 181 | static int ds1621_attach_adapter(struct i2c_adapter *adapter) |
182 | { | 182 | { |
183 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
184 | return 0; | ||
183 | return i2c_probe(adapter, &addr_data, ds1621_detect); | 185 | return i2c_probe(adapter, &addr_data, ds1621_detect); |
184 | } | 186 | } |
185 | 187 | ||
186 | /* This function is called by i2c_probe */ | 188 | /* This function is called by i2c_probe */ |
187 | int ds1621_detect(struct i2c_adapter *adapter, int address, | 189 | static int ds1621_detect(struct i2c_adapter *adapter, int address, |
188 | int kind) | 190 | int kind) |
189 | { | 191 | { |
190 | int conf, temp; | 192 | int conf, temp; |
191 | struct i2c_client *new_client; | 193 | struct i2c_client *new_client; |
@@ -200,11 +202,10 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
200 | /* OK. For now, we presume we have a valid client. We now create the | 202 | /* OK. For now, we presume we have a valid client. We now create the |
201 | client structure, even though we cannot fill it completely yet. | 203 | client structure, even though we cannot fill it completely yet. |
202 | But it allows us to access ds1621_{read,write}_value. */ | 204 | But it allows us to access ds1621_{read,write}_value. */ |
203 | if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { | 205 | if (!(data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { |
204 | err = -ENOMEM; | 206 | err = -ENOMEM; |
205 | goto exit; | 207 | goto exit; |
206 | } | 208 | } |
207 | memset(data, 0, sizeof(struct ds1621_data)); | ||
208 | 209 | ||
209 | new_client = &data->client; | 210 | new_client = &data->client; |
210 | i2c_set_clientdata(new_client, data); | 211 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index eef6061d786b..a02e1c34c757 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -303,11 +303,10 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
303 | /* OK. For now, we presume we have a valid client. We now create the | 303 | /* OK. For now, we presume we have a valid client. We now create the |
304 | * client structure, even though we cannot fill it completely yet. | 304 | * client structure, even though we cannot fill it completely yet. |
305 | * But it allows us to access i2c_smbus_read_byte_data. */ | 305 | * But it allows us to access i2c_smbus_read_byte_data. */ |
306 | if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { | 306 | if (!(data = kzalloc(sizeof(struct fscher_data), GFP_KERNEL))) { |
307 | err = -ENOMEM; | 307 | err = -ENOMEM; |
308 | goto exit; | 308 | goto exit; |
309 | } | 309 | } |
310 | memset(data, 0, sizeof(struct fscher_data)); | ||
311 | 310 | ||
312 | /* The common I2C client data is placed right before the | 311 | /* The common I2C client data is placed right before the |
313 | * Hermes-specific data. */ | 312 | * Hermes-specific data. */ |
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 5fc77a5fed07..64e4edc64f8d 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -438,7 +438,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) | |||
438 | return i2c_probe(adapter, &addr_data, fscpos_detect); | 438 | return i2c_probe(adapter, &addr_data, fscpos_detect); |
439 | } | 439 | } |
440 | 440 | ||
441 | int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | 441 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) |
442 | { | 442 | { |
443 | struct i2c_client *new_client; | 443 | struct i2c_client *new_client; |
444 | struct fscpos_data *data; | 444 | struct fscpos_data *data; |
@@ -453,11 +453,10 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
453 | * But it allows us to access fscpos_{read,write}_value. | 453 | * But it allows us to access fscpos_{read,write}_value. |
454 | */ | 454 | */ |
455 | 455 | ||
456 | if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { | 456 | if (!(data = kzalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { |
457 | err = -ENOMEM; | 457 | err = -ENOMEM; |
458 | goto exit; | 458 | goto exit; |
459 | } | 459 | } |
460 | memset(data, 0, sizeof(struct fscpos_data)); | ||
461 | 460 | ||
462 | new_client = &data->client; | 461 | new_client = &data->client; |
463 | i2c_set_clientdata(new_client, data); | 462 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 256b9323c84b..2f178dbe3d87 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -365,11 +365,10 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
365 | client structure, even though we cannot fill it completely yet. | 365 | client structure, even though we cannot fill it completely yet. |
366 | But it allows us to access gl518_{read,write}_value. */ | 366 | But it allows us to access gl518_{read,write}_value. */ |
367 | 367 | ||
368 | if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { | 368 | if (!(data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL))) { |
369 | err = -ENOMEM; | 369 | err = -ENOMEM; |
370 | goto exit; | 370 | goto exit; |
371 | } | 371 | } |
372 | memset(data, 0, sizeof(struct gl518_data)); | ||
373 | 372 | ||
374 | new_client = &data->client; | 373 | new_client = &data->client; |
375 | i2c_set_clientdata(new_client, data); | 374 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 12fd757066fc..c39ba1239426 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -536,11 +536,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
536 | client structure, even though we cannot fill it completely yet. | 536 | client structure, even though we cannot fill it completely yet. |
537 | But it allows us to access gl520_{read,write}_value. */ | 537 | But it allows us to access gl520_{read,write}_value. */ |
538 | 538 | ||
539 | if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { | 539 | if (!(data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL))) { |
540 | err = -ENOMEM; | 540 | err = -ENOMEM; |
541 | goto exit; | 541 | goto exit; |
542 | } | 542 | } |
543 | memset(data, 0, sizeof(struct gl520_data)); | ||
544 | 543 | ||
545 | new_client = &data->client; | 544 | new_client = &data->client; |
546 | i2c_set_clientdata(new_client, data); | 545 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 7f0107613827..0015da5668a1 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -296,11 +296,9 @@ static int hdaps_probe(struct device *dev) | |||
296 | return 0; | 296 | return 0; |
297 | } | 297 | } |
298 | 298 | ||
299 | static int hdaps_resume(struct device *dev, u32 level) | 299 | static int hdaps_resume(struct device *dev) |
300 | { | 300 | { |
301 | if (level == RESUME_ENABLE) | 301 | return hdaps_device_init(); |
302 | return hdaps_device_init(); | ||
303 | return 0; | ||
304 | } | 302 | } |
305 | 303 | ||
306 | static struct device_driver hdaps_driver = { | 304 | static struct device_driver hdaps_driver = { |
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 9b41c9bd805f..6f48579799b5 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -45,7 +45,7 @@ struct class_device *hwmon_device_register(struct device *dev) | |||
45 | return ERR_PTR(-ENOMEM); | 45 | return ERR_PTR(-ENOMEM); |
46 | 46 | ||
47 | id = id & MAX_ID_MASK; | 47 | id = id & MAX_ID_MASK; |
48 | cdev = class_device_create(hwmon_class, MKDEV(0,0), dev, | 48 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, |
49 | HWMON_ID_FORMAT, id); | 49 | HWMON_ID_FORMAT, id); |
50 | 50 | ||
51 | if (IS_ERR(cdev)) | 51 | if (IS_ERR(cdev)) |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 53cc2b6d6385..6c41e25e670b 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -2,7 +2,7 @@ | |||
2 | it87.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | it87.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring. | 3 | monitoring. |
4 | 4 | ||
5 | Supports: IT8705F Super I/O chip w/LPC interface & SMBus | 5 | Supports: IT8705F Super I/O chip w/LPC interface |
6 | IT8712F Super I/O chip w/LPC interface & SMBus | 6 | IT8712F Super I/O chip w/LPC interface & SMBus |
7 | Sis950 A clone of the IT8705F | 7 | Sis950 A clone of the IT8705F |
8 | 8 | ||
@@ -47,7 +47,7 @@ | |||
47 | /* Addresses to scan */ | 47 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, | 48 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
49 | 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | 0x2e, 0x2f, I2C_CLIENT_END }; |
50 | static unsigned short isa_address = 0x290; | 50 | static unsigned short isa_address; |
51 | 51 | ||
52 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
53 | I2C_CLIENT_INSMOD_2(it87, it8712); | 53 | I2C_CLIENT_INSMOD_2(it87, it8712); |
@@ -706,7 +706,7 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter) | |||
706 | } | 706 | } |
707 | 707 | ||
708 | /* SuperIO detection - will change isa_address if a chip is found */ | 708 | /* SuperIO detection - will change isa_address if a chip is found */ |
709 | static int __init it87_find(int *address) | 709 | static int __init it87_find(unsigned short *address) |
710 | { | 710 | { |
711 | int err = -ENODEV; | 711 | int err = -ENODEV; |
712 | 712 | ||
@@ -738,7 +738,7 @@ exit: | |||
738 | } | 738 | } |
739 | 739 | ||
740 | /* This function is called by i2c_probe */ | 740 | /* This function is called by i2c_probe */ |
741 | int it87_detect(struct i2c_adapter *adapter, int address, int kind) | 741 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind) |
742 | { | 742 | { |
743 | int i; | 743 | int i; |
744 | struct i2c_client *new_client; | 744 | struct i2c_client *new_client; |
@@ -757,42 +757,14 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
757 | if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) | 757 | if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) |
758 | goto ERROR0; | 758 | goto ERROR0; |
759 | 759 | ||
760 | /* Probe whether there is anything available on this address. Already | 760 | /* For now, we presume we have a valid client. We create the |
761 | done for SMBus and Super-I/O clients */ | ||
762 | if (kind < 0) { | ||
763 | if (is_isa && !chip_type) { | ||
764 | #define REALLY_SLOW_IO | ||
765 | /* We need the timeouts for at least some IT87-like chips. But only | ||
766 | if we read 'undefined' registers. */ | ||
767 | i = inb_p(address + 1); | ||
768 | if (inb_p(address + 2) != i | ||
769 | || inb_p(address + 3) != i | ||
770 | || inb_p(address + 7) != i) { | ||
771 | err = -ENODEV; | ||
772 | goto ERROR1; | ||
773 | } | ||
774 | #undef REALLY_SLOW_IO | ||
775 | |||
776 | /* Let's just hope nothing breaks here */ | ||
777 | i = inb_p(address + 5) & 0x7f; | ||
778 | outb_p(~i & 0x7f, address + 5); | ||
779 | if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { | ||
780 | outb_p(i, address + 5); | ||
781 | err = -ENODEV; | ||
782 | goto ERROR1; | ||
783 | } | ||
784 | } | ||
785 | } | ||
786 | |||
787 | /* OK. For now, we presume we have a valid client. We now create the | ||
788 | client structure, even though we cannot fill it completely yet. | 761 | client structure, even though we cannot fill it completely yet. |
789 | But it allows us to access it87_{read,write}_value. */ | 762 | But it allows us to access it87_{read,write}_value. */ |
790 | 763 | ||
791 | if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { | 764 | if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { |
792 | err = -ENOMEM; | 765 | err = -ENOMEM; |
793 | goto ERROR1; | 766 | goto ERROR1; |
794 | } | 767 | } |
795 | memset(data, 0, sizeof(struct it87_data)); | ||
796 | 768 | ||
797 | new_client = &data->client; | 769 | new_client = &data->client; |
798 | if (is_isa) | 770 | if (is_isa) |
@@ -1182,20 +1154,18 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1182 | 1154 | ||
1183 | static int __init sm_it87_init(void) | 1155 | static int __init sm_it87_init(void) |
1184 | { | 1156 | { |
1185 | int addr, res; | 1157 | int res; |
1186 | |||
1187 | if (!it87_find(&addr)) { | ||
1188 | isa_address = addr; | ||
1189 | } | ||
1190 | 1158 | ||
1191 | res = i2c_add_driver(&it87_driver); | 1159 | res = i2c_add_driver(&it87_driver); |
1192 | if (res) | 1160 | if (res) |
1193 | return res; | 1161 | return res; |
1194 | 1162 | ||
1195 | res = i2c_isa_add_driver(&it87_isa_driver); | 1163 | if (!it87_find(&isa_address)) { |
1196 | if (res) { | 1164 | res = i2c_isa_add_driver(&it87_isa_driver); |
1197 | i2c_del_driver(&it87_driver); | 1165 | if (res) { |
1198 | return res; | 1166 | i2c_del_driver(&it87_driver); |
1167 | return res; | ||
1168 | } | ||
1199 | } | 1169 | } |
1200 | 1170 | ||
1201 | return 0; | 1171 | return 0; |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index be5c7095ecbb..954ec2497249 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -375,11 +375,10 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
375 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 375 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
376 | goto exit; | 376 | goto exit; |
377 | 377 | ||
378 | if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) { | 378 | if (!(data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL))) { |
379 | err = -ENOMEM; | 379 | err = -ENOMEM; |
380 | goto exit; | 380 | goto exit; |
381 | } | 381 | } |
382 | memset(data, 0, sizeof(struct lm63_data)); | ||
383 | 382 | ||
384 | /* The common I2C client data is placed right before the | 383 | /* The common I2C client data is placed right before the |
385 | LM63-specific data. */ | 384 | LM63-specific data. */ |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 9a3ebdf583f4..d70f4c8fc1e6 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -127,11 +127,10 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
127 | /* OK. For now, we presume we have a valid client. We now create the | 127 | /* OK. For now, we presume we have a valid client. We now create the |
128 | client structure, even though we cannot fill it completely yet. | 128 | client structure, even though we cannot fill it completely yet. |
129 | But it allows us to access lm75_{read,write}_value. */ | 129 | But it allows us to access lm75_{read,write}_value. */ |
130 | if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { | 130 | if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { |
131 | err = -ENOMEM; | 131 | err = -ENOMEM; |
132 | goto exit; | 132 | goto exit; |
133 | } | 133 | } |
134 | memset(data, 0, sizeof(struct lm75_data)); | ||
135 | 134 | ||
136 | new_client = &data->client; | 135 | new_client = &data->client; |
137 | i2c_set_clientdata(new_client, data); | 136 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 866eab96a6f6..9380fda7dcd1 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -226,11 +226,10 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
226 | /* OK. For now, we presume we have a valid client. We now create the | 226 | /* OK. For now, we presume we have a valid client. We now create the |
227 | client structure, even though we cannot fill it completely yet. | 227 | client structure, even though we cannot fill it completely yet. |
228 | But it allows us to access lm77_{read,write}_value. */ | 228 | But it allows us to access lm77_{read,write}_value. */ |
229 | if (!(data = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) { | 229 | if (!(data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL))) { |
230 | err = -ENOMEM; | 230 | err = -ENOMEM; |
231 | goto exit; | 231 | goto exit; |
232 | } | 232 | } |
233 | memset(data, 0, sizeof(struct lm77_data)); | ||
234 | 233 | ||
235 | new_client = &data->client; | 234 | new_client = &data->client; |
236 | i2c_set_clientdata(new_client, data); | 235 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f6730dc3573b..bde0cda9477e 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -480,7 +480,7 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) | |||
480 | } | 480 | } |
481 | 481 | ||
482 | /* This function is called by i2c_probe */ | 482 | /* This function is called by i2c_probe */ |
483 | int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | 483 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) |
484 | { | 484 | { |
485 | int i, err; | 485 | int i, err; |
486 | struct i2c_client *new_client; | 486 | struct i2c_client *new_client; |
@@ -540,11 +540,10 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
540 | client structure, even though we cannot fill it completely yet. | 540 | client structure, even though we cannot fill it completely yet. |
541 | But it allows us to access lm78_{read,write}_value. */ | 541 | But it allows us to access lm78_{read,write}_value. */ |
542 | 542 | ||
543 | if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { | 543 | if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) { |
544 | err = -ENOMEM; | 544 | err = -ENOMEM; |
545 | goto ERROR1; | 545 | goto ERROR1; |
546 | } | 546 | } |
547 | memset(data, 0, sizeof(struct lm78_data)); | ||
548 | 547 | ||
549 | new_client = &data->client; | 548 | new_client = &data->client; |
550 | if (is_isa) | 549 | if (is_isa) |
@@ -726,7 +725,6 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
726 | return i2c_smbus_write_byte_data(client, reg, value); | 725 | return i2c_smbus_write_byte_data(client, reg, value); |
727 | } | 726 | } |
728 | 727 | ||
729 | /* Called when we have found a new LM78. It should set limits, etc. */ | ||
730 | static void lm78_init_client(struct i2c_client *client) | 728 | static void lm78_init_client(struct i2c_client *client) |
731 | { | 729 | { |
732 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); | 730 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 83af8b3a0cac..c359fdea211e 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -393,7 +393,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter) | |||
393 | return i2c_probe(adapter, &addr_data, lm80_detect); | 393 | return i2c_probe(adapter, &addr_data, lm80_detect); |
394 | } | 394 | } |
395 | 395 | ||
396 | int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | 396 | static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) |
397 | { | 397 | { |
398 | int i, cur; | 398 | int i, cur; |
399 | struct i2c_client *new_client; | 399 | struct i2c_client *new_client; |
@@ -407,11 +407,10 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | |||
407 | /* OK. For now, we presume we have a valid client. We now create the | 407 | /* OK. For now, we presume we have a valid client. We now create the |
408 | client structure, even though we cannot fill it completely yet. | 408 | client structure, even though we cannot fill it completely yet. |
409 | But it allows us to access lm80_{read,write}_value. */ | 409 | But it allows us to access lm80_{read,write}_value. */ |
410 | if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { | 410 | if (!(data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL))) { |
411 | err = -ENOMEM; | 411 | err = -ENOMEM; |
412 | goto exit; | 412 | goto exit; |
413 | } | 413 | } |
414 | memset(data, 0, sizeof(struct lm80_data)); | ||
415 | 414 | ||
416 | new_client = &data->client; | 415 | new_client = &data->client; |
417 | i2c_set_clientdata(new_client, data); | 416 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index d74b2c20c719..9a70611a9f69 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -230,11 +230,10 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
230 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 230 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
231 | goto exit; | 231 | goto exit; |
232 | 232 | ||
233 | if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) { | 233 | if (!(data = kzalloc(sizeof(struct lm83_data), GFP_KERNEL))) { |
234 | err = -ENOMEM; | 234 | err = -ENOMEM; |
235 | goto exit; | 235 | goto exit; |
236 | } | 236 | } |
237 | memset(data, 0, sizeof(struct lm83_data)); | ||
238 | 237 | ||
239 | /* The common I2C client data is placed right after the | 238 | /* The common I2C client data is placed right after the |
240 | * LM83-specific data. */ | 239 | * LM83-specific data. */ |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index ab214df9624b..d1070ed2bee6 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -1007,14 +1007,14 @@ temp_auto(1); | |||
1007 | temp_auto(2); | 1007 | temp_auto(2); |
1008 | temp_auto(3); | 1008 | temp_auto(3); |
1009 | 1009 | ||
1010 | int lm85_attach_adapter(struct i2c_adapter *adapter) | 1010 | static int lm85_attach_adapter(struct i2c_adapter *adapter) |
1011 | { | 1011 | { |
1012 | if (!(adapter->class & I2C_CLASS_HWMON)) | 1012 | if (!(adapter->class & I2C_CLASS_HWMON)) |
1013 | return 0; | 1013 | return 0; |
1014 | return i2c_probe(adapter, &addr_data, lm85_detect); | 1014 | return i2c_probe(adapter, &addr_data, lm85_detect); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | int lm85_detect(struct i2c_adapter *adapter, int address, | 1017 | static int lm85_detect(struct i2c_adapter *adapter, int address, |
1018 | int kind) | 1018 | int kind) |
1019 | { | 1019 | { |
1020 | int company, verstep ; | 1020 | int company, verstep ; |
@@ -1033,11 +1033,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1033 | client structure, even though we cannot fill it completely yet. | 1033 | client structure, even though we cannot fill it completely yet. |
1034 | But it allows us to access lm85_{read,write}_value. */ | 1034 | But it allows us to access lm85_{read,write}_value. */ |
1035 | 1035 | ||
1036 | if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { | 1036 | if (!(data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL))) { |
1037 | err = -ENOMEM; | 1037 | err = -ENOMEM; |
1038 | goto ERROR0; | 1038 | goto ERROR0; |
1039 | } | 1039 | } |
1040 | memset(data, 0, sizeof(struct lm85_data)); | ||
1041 | 1040 | ||
1042 | new_client = &data->client; | 1041 | new_client = &data->client; |
1043 | i2c_set_clientdata(new_client, data); | 1042 | i2c_set_clientdata(new_client, data); |
@@ -1236,7 +1235,7 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1236 | return err; | 1235 | return err; |
1237 | } | 1236 | } |
1238 | 1237 | ||
1239 | int lm85_detach_client(struct i2c_client *client) | 1238 | static int lm85_detach_client(struct i2c_client *client) |
1240 | { | 1239 | { |
1241 | struct lm85_data *data = i2c_get_clientdata(client); | 1240 | struct lm85_data *data = i2c_get_clientdata(client); |
1242 | hwmon_device_unregister(data->class_dev); | 1241 | hwmon_device_unregister(data->class_dev); |
@@ -1246,7 +1245,7 @@ int lm85_detach_client(struct i2c_client *client) | |||
1246 | } | 1245 | } |
1247 | 1246 | ||
1248 | 1247 | ||
1249 | int lm85_read_value(struct i2c_client *client, u8 reg) | 1248 | static int lm85_read_value(struct i2c_client *client, u8 reg) |
1250 | { | 1249 | { |
1251 | int res; | 1250 | int res; |
1252 | 1251 | ||
@@ -1276,7 +1275,7 @@ int lm85_read_value(struct i2c_client *client, u8 reg) | |||
1276 | return res ; | 1275 | return res ; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | int lm85_write_value(struct i2c_client *client, u8 reg, int value) | 1278 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value) |
1280 | { | 1279 | { |
1281 | int res ; | 1280 | int res ; |
1282 | 1281 | ||
@@ -1305,7 +1304,7 @@ int lm85_write_value(struct i2c_client *client, u8 reg, int value) | |||
1305 | return res ; | 1304 | return res ; |
1306 | } | 1305 | } |
1307 | 1306 | ||
1308 | void lm85_init_client(struct i2c_client *client) | 1307 | static void lm85_init_client(struct i2c_client *client) |
1309 | { | 1308 | { |
1310 | int value; | 1309 | int value; |
1311 | struct lm85_data *data = i2c_get_clientdata(client); | 1310 | struct lm85_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index dca996de4c33..eeec18177861 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -554,11 +554,10 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
554 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 554 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
555 | goto exit; | 555 | goto exit; |
556 | 556 | ||
557 | if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { | 557 | if (!(data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL))) { |
558 | err = -ENOMEM; | 558 | err = -ENOMEM; |
559 | goto exit; | 559 | goto exit; |
560 | } | 560 | } |
561 | memset(data, 0, sizeof(struct lm87_data)); | ||
562 | 561 | ||
563 | /* The common I2C client data is placed right before the | 562 | /* The common I2C client data is placed right before the |
564 | LM87-specific data. */ | 563 | LM87-specific data. */ |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 14de05fcd431..83cf2e1b09f5 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -31,7 +31,7 @@ | |||
31 | * Devices. That chip is similar to the LM90, with a few differences | 31 | * Devices. That chip is similar to the LM90, with a few differences |
32 | * that are not handled by this driver. Complete datasheet can be | 32 | * that are not handled by this driver. Complete datasheet can be |
33 | * obtained from Analog's website at: | 33 | * obtained from Analog's website at: |
34 | * http://products.analog.com/products/info.asp?product=ADM1032 | 34 | * http://www.analog.com/en/prod/0,2877,ADM1032,00.html |
35 | * Among others, it has a higher accuracy than the LM90, much like the | 35 | * Among others, it has a higher accuracy than the LM90, much like the |
36 | * LM86 does. | 36 | * LM86 does. |
37 | * | 37 | * |
@@ -49,7 +49,7 @@ | |||
49 | * register values are decoded differently) it is ignored by this | 49 | * register values are decoded differently) it is ignored by this |
50 | * driver. Complete datasheet can be obtained from Analog's website | 50 | * driver. Complete datasheet can be obtained from Analog's website |
51 | * at: | 51 | * at: |
52 | * http://products.analog.com/products/info.asp?product=ADT7461 | 52 | * http://www.analog.com/en/prod/0,2877,ADT7461,00.html |
53 | * | 53 | * |
54 | * Since the LM90 was the first chipset supported by this driver, most | 54 | * Since the LM90 was the first chipset supported by this driver, most |
55 | * comments will refer to this chipset, but are actually general and | 55 | * comments will refer to this chipset, but are actually general and |
@@ -83,10 +83,10 @@ | |||
83 | * Addresses to scan | 83 | * Addresses to scan |
84 | * Address is fully defined internally and cannot be changed except for | 84 | * Address is fully defined internally and cannot be changed except for |
85 | * MAX6659. | 85 | * MAX6659. |
86 | * LM86, LM89, LM90, LM99, ADM1032, MAX6657 and MAX6658 have address 0x4c. | 86 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 |
87 | * LM89-1, and LM99-1 have address 0x4d. | 87 | * have address 0x4c. |
88 | * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. | ||
88 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). | 89 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). |
89 | * ADT7461 always has address 0x4c. | ||
90 | */ | 90 | */ |
91 | 91 | ||
92 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; | 92 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; |
@@ -345,10 +345,74 @@ static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, | |||
345 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); | 345 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); |
346 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 346 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
347 | 347 | ||
348 | /* pec used for ADM1032 only */ | ||
349 | static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, | ||
350 | char *buf) | ||
351 | { | ||
352 | struct i2c_client *client = to_i2c_client(dev); | ||
353 | return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC)); | ||
354 | } | ||
355 | |||
356 | static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, | ||
357 | const char *buf, size_t count) | ||
358 | { | ||
359 | struct i2c_client *client = to_i2c_client(dev); | ||
360 | long val = simple_strtol(buf, NULL, 10); | ||
361 | |||
362 | switch (val) { | ||
363 | case 0: | ||
364 | client->flags &= ~I2C_CLIENT_PEC; | ||
365 | break; | ||
366 | case 1: | ||
367 | client->flags |= I2C_CLIENT_PEC; | ||
368 | break; | ||
369 | default: | ||
370 | return -EINVAL; | ||
371 | } | ||
372 | |||
373 | return count; | ||
374 | } | ||
375 | |||
376 | static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); | ||
377 | |||
348 | /* | 378 | /* |
349 | * Real code | 379 | * Real code |
350 | */ | 380 | */ |
351 | 381 | ||
382 | /* The ADM1032 supports PEC but not on write byte transactions, so we need | ||
383 | to explicitely ask for a transaction without PEC. */ | ||
384 | static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) | ||
385 | { | ||
386 | return i2c_smbus_xfer(client->adapter, client->addr, | ||
387 | client->flags & ~I2C_CLIENT_PEC, | ||
388 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); | ||
389 | } | ||
390 | |||
391 | /* It is assumed that client->update_lock is held (unless we are in | ||
392 | detection or initialization steps). This matters when PEC is enabled, | ||
393 | because we don't want the address pointer to change between the write | ||
394 | byte and the read byte transactions. */ | ||
395 | static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value) | ||
396 | { | ||
397 | int err; | ||
398 | |||
399 | if (client->flags & I2C_CLIENT_PEC) { | ||
400 | err = adm1032_write_byte(client, reg); | ||
401 | if (err >= 0) | ||
402 | err = i2c_smbus_read_byte(client); | ||
403 | } else | ||
404 | err = i2c_smbus_read_byte_data(client, reg); | ||
405 | |||
406 | if (err < 0) { | ||
407 | dev_warn(&client->dev, "Register %#02x read failed (%d)\n", | ||
408 | reg, err); | ||
409 | return err; | ||
410 | } | ||
411 | *value = err; | ||
412 | |||
413 | return 0; | ||
414 | } | ||
415 | |||
352 | static int lm90_attach_adapter(struct i2c_adapter *adapter) | 416 | static int lm90_attach_adapter(struct i2c_adapter *adapter) |
353 | { | 417 | { |
354 | if (!(adapter->class & I2C_CLASS_HWMON)) | 418 | if (!(adapter->class & I2C_CLASS_HWMON)) |
@@ -370,11 +434,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
370 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 434 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
371 | goto exit; | 435 | goto exit; |
372 | 436 | ||
373 | if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { | 437 | if (!(data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL))) { |
374 | err = -ENOMEM; | 438 | err = -ENOMEM; |
375 | goto exit; | 439 | goto exit; |
376 | } | 440 | } |
377 | memset(data, 0, sizeof(struct lm90_data)); | ||
378 | 441 | ||
379 | /* The common I2C client data is placed right before the | 442 | /* The common I2C client data is placed right before the |
380 | LM90-specific data. */ | 443 | LM90-specific data. */ |
@@ -403,20 +466,22 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
403 | if (kind < 0) { /* detection and identification */ | 466 | if (kind < 0) { /* detection and identification */ |
404 | u8 man_id, chip_id, reg_config1, reg_convrate; | 467 | u8 man_id, chip_id, reg_config1, reg_convrate; |
405 | 468 | ||
406 | man_id = i2c_smbus_read_byte_data(new_client, | 469 | if (lm90_read_reg(new_client, LM90_REG_R_MAN_ID, |
407 | LM90_REG_R_MAN_ID); | 470 | &man_id) < 0 |
408 | chip_id = i2c_smbus_read_byte_data(new_client, | 471 | || lm90_read_reg(new_client, LM90_REG_R_CHIP_ID, |
409 | LM90_REG_R_CHIP_ID); | 472 | &chip_id) < 0 |
410 | reg_config1 = i2c_smbus_read_byte_data(new_client, | 473 | || lm90_read_reg(new_client, LM90_REG_R_CONFIG1, |
411 | LM90_REG_R_CONFIG1); | 474 | ®_config1) < 0 |
412 | reg_convrate = i2c_smbus_read_byte_data(new_client, | 475 | || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, |
413 | LM90_REG_R_CONVRATE); | 476 | ®_convrate) < 0) |
477 | goto exit_free; | ||
414 | 478 | ||
415 | if (man_id == 0x01) { /* National Semiconductor */ | 479 | if (man_id == 0x01) { /* National Semiconductor */ |
416 | u8 reg_config2; | 480 | u8 reg_config2; |
417 | 481 | ||
418 | reg_config2 = i2c_smbus_read_byte_data(new_client, | 482 | if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, |
419 | LM90_REG_R_CONFIG2); | 483 | ®_config2) < 0) |
484 | goto exit_free; | ||
420 | 485 | ||
421 | if ((reg_config1 & 0x2A) == 0x00 | 486 | if ((reg_config1 & 0x2A) == 0x00 |
422 | && (reg_config2 & 0xF8) == 0x00 | 487 | && (reg_config2 & 0xF8) == 0x00 |
@@ -435,14 +500,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
435 | } | 500 | } |
436 | } else | 501 | } else |
437 | if (man_id == 0x41) { /* Analog Devices */ | 502 | if (man_id == 0x41) { /* Analog Devices */ |
438 | if (address == 0x4C | 503 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ |
439 | && (chip_id & 0xF0) == 0x40 /* ADM1032 */ | ||
440 | && (reg_config1 & 0x3F) == 0x00 | 504 | && (reg_config1 & 0x3F) == 0x00 |
441 | && reg_convrate <= 0x0A) { | 505 | && reg_convrate <= 0x0A) { |
442 | kind = adm1032; | 506 | kind = adm1032; |
443 | } else | 507 | } else |
444 | if (address == 0x4c | 508 | if (chip_id == 0x51 /* ADT7461 */ |
445 | && chip_id == 0x51 /* ADT7461 */ | ||
446 | && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ | 509 | && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ |
447 | && reg_convrate <= 0x0A) { | 510 | && reg_convrate <= 0x0A) { |
448 | kind = adt7461; | 511 | kind = adt7461; |
@@ -477,6 +540,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
477 | name = "lm90"; | 540 | name = "lm90"; |
478 | } else if (kind == adm1032) { | 541 | } else if (kind == adm1032) { |
479 | name = "adm1032"; | 542 | name = "adm1032"; |
543 | /* The ADM1032 supports PEC, but only if combined | ||
544 | transactions are not used. */ | ||
545 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | ||
546 | new_client->flags |= I2C_CLIENT_PEC; | ||
480 | } else if (kind == lm99) { | 547 | } else if (kind == lm99) { |
481 | name = "lm99"; | 548 | name = "lm99"; |
482 | } else if (kind == lm86) { | 549 | } else if (kind == lm86) { |
@@ -529,6 +596,9 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
529 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | 596 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); |
530 | device_create_file(&new_client->dev, &dev_attr_alarms); | 597 | device_create_file(&new_client->dev, &dev_attr_alarms); |
531 | 598 | ||
599 | if (new_client->flags & I2C_CLIENT_PEC) | ||
600 | device_create_file(&new_client->dev, &dev_attr_pec); | ||
601 | |||
532 | return 0; | 602 | return 0; |
533 | 603 | ||
534 | exit_detach: | 604 | exit_detach: |
@@ -548,7 +618,10 @@ static void lm90_init_client(struct i2c_client *client) | |||
548 | */ | 618 | */ |
549 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, | 619 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, |
550 | 5); /* 2 Hz */ | 620 | 5); /* 2 Hz */ |
551 | config = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1); | 621 | if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { |
622 | dev_warn(&client->dev, "Initialization failed!\n"); | ||
623 | return; | ||
624 | } | ||
552 | if (config & 0x40) | 625 | if (config & 0x40) |
553 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, | 626 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, |
554 | config & 0xBF); /* run */ | 627 | config & 0xBF); /* run */ |
@@ -576,21 +649,15 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
576 | down(&data->update_lock); | 649 | down(&data->update_lock); |
577 | 650 | ||
578 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
579 | u8 oldh, newh; | 652 | u8 oldh, newh, l; |
580 | 653 | ||
581 | dev_dbg(&client->dev, "Updating lm90 data.\n"); | 654 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
582 | data->temp8[0] = i2c_smbus_read_byte_data(client, | 655 | lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP, &data->temp8[0]); |
583 | LM90_REG_R_LOCAL_TEMP); | 656 | lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[1]); |
584 | data->temp8[1] = i2c_smbus_read_byte_data(client, | 657 | lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[2]); |
585 | LM90_REG_R_LOCAL_LOW); | 658 | lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[3]); |
586 | data->temp8[2] = i2c_smbus_read_byte_data(client, | 659 | lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[4]); |
587 | LM90_REG_R_LOCAL_HIGH); | 660 | lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst); |
588 | data->temp8[3] = i2c_smbus_read_byte_data(client, | ||
589 | LM90_REG_R_LOCAL_CRIT); | ||
590 | data->temp8[4] = i2c_smbus_read_byte_data(client, | ||
591 | LM90_REG_R_REMOTE_CRIT); | ||
592 | data->temp_hyst = i2c_smbus_read_byte_data(client, | ||
593 | LM90_REG_R_TCRIT_HYST); | ||
594 | 661 | ||
595 | /* | 662 | /* |
596 | * There is a trick here. We have to read two registers to | 663 | * There is a trick here. We have to read two registers to |
@@ -606,36 +673,20 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
606 | * then we have a valid reading. Else we have to read the low | 673 | * then we have a valid reading. Else we have to read the low |
607 | * byte again, and now we believe we have a correct reading. | 674 | * byte again, and now we believe we have a correct reading. |
608 | */ | 675 | */ |
609 | oldh = i2c_smbus_read_byte_data(client, | 676 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &oldh) == 0 |
610 | LM90_REG_R_REMOTE_TEMPH); | 677 | && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0 |
611 | data->temp11[0] = i2c_smbus_read_byte_data(client, | 678 | && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &newh) == 0 |
612 | LM90_REG_R_REMOTE_TEMPL); | 679 | && (newh == oldh |
613 | newh = i2c_smbus_read_byte_data(client, | 680 | || lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0)) |
614 | LM90_REG_R_REMOTE_TEMPH); | 681 | data->temp11[0] = (newh << 8) | l; |
615 | if (newh != oldh) { | 682 | |
616 | data->temp11[0] = i2c_smbus_read_byte_data(client, | 683 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &newh) == 0 |
617 | LM90_REG_R_REMOTE_TEMPL); | 684 | && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, &l) == 0) |
618 | #ifdef DEBUG | 685 | data->temp11[1] = (newh << 8) | l; |
619 | oldh = i2c_smbus_read_byte_data(client, | 686 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0 |
620 | LM90_REG_R_REMOTE_TEMPH); | 687 | && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0) |
621 | /* oldh is actually newer */ | 688 | data->temp11[2] = (newh << 8) | l; |
622 | if (newh != oldh) | 689 | lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); |
623 | dev_warn(&client->dev, "Remote temperature may be " | ||
624 | "wrong.\n"); | ||
625 | #endif | ||
626 | } | ||
627 | data->temp11[0] |= (newh << 8); | ||
628 | |||
629 | data->temp11[1] = (i2c_smbus_read_byte_data(client, | ||
630 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
631 | i2c_smbus_read_byte_data(client, | ||
632 | LM90_REG_R_REMOTE_LOWL); | ||
633 | data->temp11[2] = (i2c_smbus_read_byte_data(client, | ||
634 | LM90_REG_R_REMOTE_HIGHH) << 8) + | ||
635 | i2c_smbus_read_byte_data(client, | ||
636 | LM90_REG_R_REMOTE_HIGHL); | ||
637 | data->alarms = i2c_smbus_read_byte_data(client, | ||
638 | LM90_REG_R_STATUS); | ||
639 | 690 | ||
640 | data->last_updated = jiffies; | 691 | data->last_updated = jiffies; |
641 | data->valid = 1; | 692 | data->valid = 1; |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 647b7c7cd575..7a4b3701ed1a 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -300,11 +300,10 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | |||
300 | | I2C_FUNC_SMBUS_WORD_DATA)) | 300 | | I2C_FUNC_SMBUS_WORD_DATA)) |
301 | goto exit; | 301 | goto exit; |
302 | 302 | ||
303 | if (!(data = kmalloc(sizeof(struct lm92_data), GFP_KERNEL))) { | 303 | if (!(data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL))) { |
304 | err = -ENOMEM; | 304 | err = -ENOMEM; |
305 | goto exit; | 305 | goto exit; |
306 | } | 306 | } |
307 | memset(data, 0, sizeof(struct lm92_data)); | ||
308 | 307 | ||
309 | /* Fill in enough client fields so that we can read from the chip, | 308 | /* Fill in enough client fields so that we can read from the chip, |
310 | which is required for identication */ | 309 | which is required for identication */ |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 16bf71f3a04d..6a82ffae1bfd 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -197,11 +197,10 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) | |||
197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
198 | goto exit; | 198 | goto exit; |
199 | 199 | ||
200 | if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) { | 200 | if (!(data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL))) { |
201 | err = -ENOMEM; | 201 | err = -ENOMEM; |
202 | goto exit; | 202 | goto exit; |
203 | } | 203 | } |
204 | memset(data, 0, sizeof(struct max1619_data)); | ||
205 | 204 | ||
206 | /* The common I2C client data is placed right before the | 205 | /* The common I2C client data is placed right before the |
207 | MAX1619-specific data. */ | 206 | MAX1619-specific data. */ |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index cf2a35799c7c..17f745a23d04 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -754,9 +754,8 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
754 | const char *name = "pc87360"; | 754 | const char *name = "pc87360"; |
755 | int use_thermistors = 0; | 755 | int use_thermistors = 0; |
756 | 756 | ||
757 | if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | 757 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) |
758 | return -ENOMEM; | 758 | return -ENOMEM; |
759 | memset(data, 0x00, sizeof(struct pc87360_data)); | ||
760 | 759 | ||
761 | new_client = &data->client; | 760 | new_client = &data->client; |
762 | i2c_set_clientdata(new_client, data); | 761 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 21aa9a41f62c..9c6cadec1087 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -518,11 +518,10 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
518 | goto exit_release; | 518 | goto exit_release; |
519 | } | 519 | } |
520 | 520 | ||
521 | if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { | 521 | if (!(data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { |
522 | err = -ENOMEM; | 522 | err = -ENOMEM; |
523 | goto exit_release; | 523 | goto exit_release; |
524 | } | 524 | } |
525 | memset(data, 0, sizeof(struct sis5595_data)); | ||
526 | 525 | ||
527 | new_client = &data->client; | 526 | new_client = &data->client; |
528 | new_client->addr = address; | 527 | new_client->addr = address; |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 7fe71576dea4..2a3e21b5b6b4 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -244,11 +244,10 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) | |||
244 | return -EBUSY; | 244 | return -EBUSY; |
245 | } | 245 | } |
246 | 246 | ||
247 | if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { | 247 | if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { |
248 | err = -ENOMEM; | 248 | err = -ENOMEM; |
249 | goto error_release; | 249 | goto error_release; |
250 | } | 250 | } |
251 | memset(data, 0x00, sizeof(struct smsc47b397_data)); | ||
252 | 251 | ||
253 | new_client = &data->client; | 252 | new_client = &data->client; |
254 | i2c_set_clientdata(new_client, data); | 253 | i2c_set_clientdata(new_client, data); |
@@ -299,7 +298,7 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
299 | superio_enter(); | 298 | superio_enter(); |
300 | id = superio_inb(SUPERIO_REG_DEVID); | 299 | id = superio_inb(SUPERIO_REG_DEVID); |
301 | 300 | ||
302 | if (id != 0x6f) { | 301 | if ((id != 0x6f) && (id != 0x81)) { |
303 | superio_exit(); | 302 | superio_exit(); |
304 | return -ENODEV; | 303 | return -ENODEV; |
305 | } | 304 | } |
@@ -310,8 +309,9 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
310 | *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) | 309 | *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) |
311 | | superio_inb(SUPERIO_REG_BASE_LSB); | 310 | | superio_inb(SUPERIO_REG_BASE_LSB); |
312 | 311 | ||
313 | printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " | 312 | printk(KERN_INFO "smsc47b397: found SMSC %s " |
314 | "(base address 0x%04x, revision %u)\n", *addr, rev); | 313 | "(base address 0x%04x, revision %u)\n", |
314 | id == 0x81 ? "SCH5307-NS" : "LPC47B397-NC", *addr, rev); | ||
315 | 315 | ||
316 | superio_exit(); | 316 | superio_exit(); |
317 | return 0; | 317 | return 0; |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index c9cc683eba4a..5905c1af88f2 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -3,7 +3,7 @@ | |||
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, | 5 | Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, |
6 | LPC47M15x and LPC47M192 Super-I/O chips. | 6 | LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips. |
7 | 7 | ||
8 | Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> | 8 | Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
9 | Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 9 | Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> |
@@ -356,6 +356,8 @@ static int __init smsc47m1_find(unsigned short *addr) | |||
356 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. | 356 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. |
357 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" | 357 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" |
358 | * can do much more besides (device id 0x60). | 358 | * can do much more besides (device id 0x60). |
359 | * The LPC47M997 is undocumented, but seems to be compatible with | ||
360 | * the LPC47M192, and has the same device id. | ||
359 | */ | 361 | */ |
360 | if (val == 0x51) | 362 | if (val == 0x51) |
361 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); | 363 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); |
@@ -364,7 +366,8 @@ static int __init smsc47m1_find(unsigned short *addr) | |||
364 | else if (val == 0x5F) | 366 | else if (val == 0x5F) |
365 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); | 367 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); |
366 | else if (val == 0x60) | 368 | else if (val == 0x60) |
367 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); | 369 | printk(KERN_INFO "smsc47m1: Found SMSC " |
370 | "LPC47M15x/LPC47M192/LPC47M997\n"); | ||
368 | else { | 371 | else { |
369 | superio_exit(); | 372 | superio_exit(); |
370 | return -ENODEV; | 373 | return -ENODEV; |
@@ -396,11 +399,10 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) | |||
396 | return -EBUSY; | 399 | return -EBUSY; |
397 | } | 400 | } |
398 | 401 | ||
399 | if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { | 402 | if (!(data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { |
400 | err = -ENOMEM; | 403 | err = -ENOMEM; |
401 | goto error_release; | 404 | goto error_release; |
402 | } | 405 | } |
403 | memset(data, 0x00, sizeof(struct smsc47m1_data)); | ||
404 | 406 | ||
405 | new_client = &data->client; | 407 | new_client = &data->client; |
406 | i2c_set_clientdata(new_client, data); | 408 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 05ddc88e7dd2..6f696f897176 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | /* If force_addr is set to anything different from 0, we forcibly enable | 45 | /* If force_addr is set to anything different from 0, we forcibly enable |
46 | the device at the given address. */ | 46 | the device at the given address. */ |
47 | static unsigned short force_addr = 0; | 47 | static unsigned short force_addr; |
48 | module_param(force_addr, ushort, 0); | 48 | module_param(force_addr, ushort, 0); |
49 | MODULE_PARM_DESC(force_addr, | 49 | MODULE_PARM_DESC(force_addr, |
50 | "Initialize the base address of the sensors"); | 50 | "Initialize the base address of the sensors"); |
@@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
198 | but the function is very linear in the useful range (0-80 deg C), so | 198 | but the function is very linear in the useful range (0-80 deg C), so |
199 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT | 199 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT |
200 | is the temp at via register values 0-255: */ | 200 | is the temp at via register values 0-255: */ |
201 | static const long tempLUT[] = | 201 | static const s16 tempLUT[] = |
202 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, | 202 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, |
203 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, | 203 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, |
204 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, | 204 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, |
@@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val) | |||
270 | } | 270 | } |
271 | 271 | ||
272 | /* for 8-bit temperature hyst and over registers */ | 272 | /* for 8-bit temperature hyst and over registers */ |
273 | #define TEMP_FROM_REG(val) (tempLUT[(val)] * 100) | 273 | #define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100) |
274 | 274 | ||
275 | /* for 10-bit temperature readings */ | 275 | /* for 10-bit temperature readings */ |
276 | static inline long TEMP_FROM_REG10(u16 val) | 276 | static inline long TEMP_FROM_REG10(u16 val) |
@@ -589,10 +589,8 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
589 | u16 val; | 589 | u16 val; |
590 | 590 | ||
591 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ | 591 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ |
592 | if (force_addr) | ||
593 | address = force_addr & 0xFF00; | ||
594 | |||
595 | if (force_addr) { | 592 | if (force_addr) { |
593 | address = force_addr & 0xFF00; | ||
596 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", | 594 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", |
597 | address); | 595 | address); |
598 | if (PCIBIOS_SUCCESSFUL != | 596 | if (PCIBIOS_SUCCESSFUL != |
@@ -603,11 +601,17 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
603 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) | 601 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) |
604 | return -ENODEV; | 602 | return -ENODEV; |
605 | if (!(val & 0x0001)) { | 603 | if (!(val & 0x0001)) { |
606 | dev_warn(&adapter->dev, "enabling sensors\n"); | 604 | if (force_addr) { |
607 | if (PCIBIOS_SUCCESSFUL != | 605 | dev_info(&adapter->dev, "enabling sensors\n"); |
608 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, | 606 | if (PCIBIOS_SUCCESSFUL != |
609 | val | 0x0001)) | 607 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, |
608 | val | 0x0001)) | ||
609 | return -ENODEV; | ||
610 | } else { | ||
611 | dev_warn(&adapter->dev, "sensors disabled - enable " | ||
612 | "with force_addr=0x%x\n", address); | ||
610 | return -ENODEV; | 613 | return -ENODEV; |
614 | } | ||
611 | } | 615 | } |
612 | 616 | ||
613 | /* Reserve the ISA region */ | 617 | /* Reserve the ISA region */ |
@@ -617,11 +621,10 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
617 | return -ENODEV; | 621 | return -ENODEV; |
618 | } | 622 | } |
619 | 623 | ||
620 | if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { | 624 | if (!(data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL))) { |
621 | err = -ENOMEM; | 625 | err = -ENOMEM; |
622 | goto exit_release; | 626 | goto exit_release; |
623 | } | 627 | } |
624 | memset(data, 0, sizeof(struct via686a_data)); | ||
625 | 628 | ||
626 | new_client = &data->client; | 629 | new_client = &data->client; |
627 | i2c_set_clientdata(new_client, data); | 630 | i2c_set_clientdata(new_client, data); |
@@ -708,7 +711,6 @@ static int via686a_detach_client(struct i2c_client *client) | |||
708 | return 0; | 711 | return 0; |
709 | } | 712 | } |
710 | 713 | ||
711 | /* Called when we have found a new VIA686A. Set limits, etc. */ | ||
712 | static void via686a_init_client(struct i2c_client *client) | 714 | static void via686a_init_client(struct i2c_client *client) |
713 | { | 715 | { |
714 | u8 reg; | 716 | u8 reg; |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index b60efe8f8b26..eee22a57e929 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -105,7 +105,9 @@ superio_exit(void) | |||
105 | * ISA constants | 105 | * ISA constants |
106 | */ | 106 | */ |
107 | 107 | ||
108 | #define REGION_LENGTH 8 | 108 | #define REGION_ALIGNMENT ~7 |
109 | #define REGION_OFFSET 5 | ||
110 | #define REGION_LENGTH 2 | ||
109 | #define ADDR_REG_OFFSET 5 | 111 | #define ADDR_REG_OFFSET 5 |
110 | #define DATA_REG_OFFSET 6 | 112 | #define DATA_REG_OFFSET 6 |
111 | 113 | ||
@@ -673,16 +675,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | struct w83627ehf_data *data; | 675 | struct w83627ehf_data *data; |
674 | int i, err = 0; | 676 | int i, err = 0; |
675 | 677 | ||
676 | if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { | 678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
679 | w83627ehf_driver.name)) { | ||
677 | err = -EBUSY; | 680 | err = -EBUSY; |
678 | goto exit; | 681 | goto exit; |
679 | } | 682 | } |
680 | 683 | ||
681 | if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { | 684 | if (!(data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { |
682 | err = -ENOMEM; | 685 | err = -ENOMEM; |
683 | goto exit_release; | 686 | goto exit_release; |
684 | } | 687 | } |
685 | memset(data, 0, sizeof(struct w83627ehf_data)); | ||
686 | 688 | ||
687 | client = &data->client; | 689 | client = &data->client; |
688 | i2c_set_clientdata(client, data); | 690 | i2c_set_clientdata(client, data); |
@@ -762,7 +764,7 @@ exit_detach: | |||
762 | exit_free: | 764 | exit_free: |
763 | kfree(data); | 765 | kfree(data); |
764 | exit_release: | 766 | exit_release: |
765 | release_region(address, REGION_LENGTH); | 767 | release_region(address + REGION_OFFSET, REGION_LENGTH); |
766 | exit: | 768 | exit: |
767 | return err; | 769 | return err; |
768 | } | 770 | } |
@@ -776,7 +778,7 @@ static int w83627ehf_detach_client(struct i2c_client *client) | |||
776 | 778 | ||
777 | if ((err = i2c_detach_client(client))) | 779 | if ((err = i2c_detach_client(client))) |
778 | return err; | 780 | return err; |
779 | release_region(client->addr, REGION_LENGTH); | 781 | release_region(client->addr + REGION_OFFSET, REGION_LENGTH); |
780 | kfree(data); | 782 | kfree(data); |
781 | 783 | ||
782 | return 0; | 784 | return 0; |
@@ -807,7 +809,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr) | |||
807 | superio_select(W83627EHF_LD_HWM); | 809 | superio_select(W83627EHF_LD_HWM); |
808 | val = (superio_inb(SIO_REG_ADDR) << 8) | 810 | val = (superio_inb(SIO_REG_ADDR) << 8) |
809 | | superio_inb(SIO_REG_ADDR + 1); | 811 | | superio_inb(SIO_REG_ADDR + 1); |
810 | *addr = val & ~(REGION_LENGTH - 1); | 812 | *addr = val & REGION_ALIGNMENT; |
811 | if (*addr == 0) { | 813 | if (*addr == 0) { |
812 | superio_exit(); | 814 | superio_exit(); |
813 | return -ENODEV; | 815 | return -ENODEV; |
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 3479dc5208e2..70ef926c3bd8 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -142,10 +142,14 @@ superio_exit(void) | |||
142 | #define WINB_BASE_REG 0x60 | 142 | #define WINB_BASE_REG 0x60 |
143 | /* Constants specified below */ | 143 | /* Constants specified below */ |
144 | 144 | ||
145 | /* Length of ISA address segment */ | 145 | /* Alignment of the base address */ |
146 | #define WINB_EXTENT 8 | 146 | #define WINB_ALIGNMENT ~7 |
147 | 147 | ||
148 | /* Where are the ISA address/data registers relative to the base address */ | 148 | /* Offset & size of I/O region we are interested in */ |
149 | #define WINB_REGION_OFFSET 5 | ||
150 | #define WINB_REGION_SIZE 2 | ||
151 | |||
152 | /* Where are the sensors address/data registers relative to the base address */ | ||
149 | #define W83781D_ADDR_REG_OFFSET 5 | 153 | #define W83781D_ADDR_REG_OFFSET 5 |
150 | #define W83781D_DATA_REG_OFFSET 6 | 154 | #define W83781D_DATA_REG_OFFSET 6 |
151 | 155 | ||
@@ -197,7 +201,6 @@ superio_exit(void) | |||
197 | 201 | ||
198 | #define W83627HF_REG_PWM1 0x5A | 202 | #define W83627HF_REG_PWM1 0x5A |
199 | #define W83627HF_REG_PWM2 0x5B | 203 | #define W83627HF_REG_PWM2 0x5B |
200 | #define W83627HF_REG_PWMCLK12 0x5C | ||
201 | 204 | ||
202 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ | 205 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ |
203 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ | 206 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ |
@@ -981,7 +984,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) | |||
981 | superio_select(W83627HF_LD_HWM); | 984 | superio_select(W83627HF_LD_HWM); |
982 | val = (superio_inb(WINB_BASE_REG) << 8) | | 985 | val = (superio_inb(WINB_BASE_REG) << 8) | |
983 | superio_inb(WINB_BASE_REG + 1); | 986 | superio_inb(WINB_BASE_REG + 1); |
984 | *addr = val & ~(WINB_EXTENT - 1); | 987 | *addr = val & WINB_ALIGNMENT; |
985 | if (*addr == 0 && force_addr == 0) { | 988 | if (*addr == 0 && force_addr == 0) { |
986 | superio_exit(); | 989 | superio_exit(); |
987 | return -ENODEV; | 990 | return -ENODEV; |
@@ -1000,9 +1003,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1000 | const char *client_name = ""; | 1003 | const char *client_name = ""; |
1001 | 1004 | ||
1002 | if(force_addr) | 1005 | if(force_addr) |
1003 | address = force_addr & ~(WINB_EXTENT - 1); | 1006 | address = force_addr & WINB_ALIGNMENT; |
1004 | 1007 | ||
1005 | if (!request_region(address, WINB_EXTENT, w83627hf_driver.name)) { | 1008 | if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, |
1009 | w83627hf_driver.name)) { | ||
1006 | err = -EBUSY; | 1010 | err = -EBUSY; |
1007 | goto ERROR0; | 1011 | goto ERROR0; |
1008 | } | 1012 | } |
@@ -1041,11 +1045,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1041 | client structure, even though we cannot fill it completely yet. | 1045 | client structure, even though we cannot fill it completely yet. |
1042 | But it allows us to access w83627hf_{read,write}_value. */ | 1046 | But it allows us to access w83627hf_{read,write}_value. */ |
1043 | 1047 | ||
1044 | if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { | 1048 | if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { |
1045 | err = -ENOMEM; | 1049 | err = -ENOMEM; |
1046 | goto ERROR1; | 1050 | goto ERROR1; |
1047 | } | 1051 | } |
1048 | memset(data, 0, sizeof(struct w83627hf_data)); | ||
1049 | 1052 | ||
1050 | new_client = &data->client; | 1053 | new_client = &data->client; |
1051 | i2c_set_clientdata(new_client, data); | 1054 | i2c_set_clientdata(new_client, data); |
@@ -1148,7 +1151,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1148 | ERROR2: | 1151 | ERROR2: |
1149 | kfree(data); | 1152 | kfree(data); |
1150 | ERROR1: | 1153 | ERROR1: |
1151 | release_region(address, WINB_EXTENT); | 1154 | release_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE); |
1152 | ERROR0: | 1155 | ERROR0: |
1153 | return err; | 1156 | return err; |
1154 | } | 1157 | } |
@@ -1163,7 +1166,7 @@ static int w83627hf_detach_client(struct i2c_client *client) | |||
1163 | if ((err = i2c_detach_client(client))) | 1166 | if ((err = i2c_detach_client(client))) |
1164 | return err; | 1167 | return err; |
1165 | 1168 | ||
1166 | release_region(client->addr, WINB_EXTENT); | 1169 | release_region(client->addr + WINB_REGION_OFFSET, WINB_REGION_SIZE); |
1167 | kfree(data); | 1170 | kfree(data); |
1168 | 1171 | ||
1169 | return 0; | 1172 | return 0; |
@@ -1275,7 +1278,6 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1275 | return 0; | 1278 | return 0; |
1276 | } | 1279 | } |
1277 | 1280 | ||
1278 | /* Called when we have found a new W83781D. It should set limits, etc. */ | ||
1279 | static void w83627hf_init_client(struct i2c_client *client) | 1281 | static void w83627hf_init_client(struct i2c_client *client) |
1280 | { | 1282 | { |
1281 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1283 | struct w83627hf_data *data = i2c_get_clientdata(client); |
@@ -1369,12 +1371,6 @@ static void w83627hf_init_client(struct i2c_client *client) | |||
1369 | } | 1371 | } |
1370 | } | 1372 | } |
1371 | 1373 | ||
1372 | if (type == w83627hf) { | ||
1373 | /* enable PWM2 control (can't hurt since PWM reg | ||
1374 | should have been reset to 0xff) */ | ||
1375 | w83627hf_write_value(client, W83627HF_REG_PWMCLK12, | ||
1376 | 0x19); | ||
1377 | } | ||
1378 | /* enable comparator mode for temp2 and temp3 so | 1374 | /* enable comparator mode for temp2 and temp3 so |
1379 | alarm indication will work correctly */ | 1375 | alarm indication will work correctly */ |
1380 | i = w83627hf_read_value(client, W83781D_REG_IRQ); | 1376 | i = w83627hf_read_value(client, W83781D_REG_IRQ); |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 4c43337ca780..9265f32122fa 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -889,12 +889,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, | |||
889 | const char *client_name = ""; | 889 | const char *client_name = ""; |
890 | struct w83781d_data *data = i2c_get_clientdata(new_client); | 890 | struct w83781d_data *data = i2c_get_clientdata(new_client); |
891 | 891 | ||
892 | data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 892 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
893 | if (!(data->lm75[0])) { | 893 | if (!(data->lm75[0])) { |
894 | err = -ENOMEM; | 894 | err = -ENOMEM; |
895 | goto ERROR_SC_0; | 895 | goto ERROR_SC_0; |
896 | } | 896 | } |
897 | memset(data->lm75[0], 0x00, sizeof (struct i2c_client)); | ||
898 | 897 | ||
899 | id = i2c_adapter_id(adapter); | 898 | id = i2c_adapter_id(adapter); |
900 | 899 | ||
@@ -919,13 +918,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, | |||
919 | } | 918 | } |
920 | 919 | ||
921 | if (kind != w83783s) { | 920 | if (kind != w83783s) { |
922 | 921 | data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | |
923 | data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
924 | if (!(data->lm75[1])) { | 922 | if (!(data->lm75[1])) { |
925 | err = -ENOMEM; | 923 | err = -ENOMEM; |
926 | goto ERROR_SC_1; | 924 | goto ERROR_SC_1; |
927 | } | 925 | } |
928 | memset(data->lm75[1], 0x0, sizeof(struct i2c_client)); | ||
929 | 926 | ||
930 | if (force_subclients[0] == id && | 927 | if (force_subclients[0] == id && |
931 | force_subclients[1] == address) { | 928 | force_subclients[1] == address) { |
@@ -1064,11 +1061,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1064 | client structure, even though we cannot fill it completely yet. | 1061 | client structure, even though we cannot fill it completely yet. |
1065 | But it allows us to access w83781d_{read,write}_value. */ | 1062 | But it allows us to access w83781d_{read,write}_value. */ |
1066 | 1063 | ||
1067 | if (!(data = kmalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { | 1064 | if (!(data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { |
1068 | err = -ENOMEM; | 1065 | err = -ENOMEM; |
1069 | goto ERROR1; | 1066 | goto ERROR1; |
1070 | } | 1067 | } |
1071 | memset(data, 0, sizeof(struct w83781d_data)); | ||
1072 | 1068 | ||
1073 | new_client = &data->client; | 1069 | new_client = &data->client; |
1074 | i2c_set_clientdata(new_client, data); | 1070 | i2c_set_clientdata(new_client, data); |
@@ -1451,7 +1447,6 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1451 | return 0; | 1447 | return 0; |
1452 | } | 1448 | } |
1453 | 1449 | ||
1454 | /* Called when we have found a new W83781D. It should set limits, etc. */ | ||
1455 | static void | 1450 | static void |
1456 | w83781d_init_client(struct i2c_client *client) | 1451 | w83781d_init_client(struct i2c_client *client) |
1457 | { | 1452 | { |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index ba0c28015f6a..4be59dbb78c4 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1086,11 +1086,10 @@ w83792d_create_subclient(struct i2c_adapter *adapter, | |||
1086 | int err; | 1086 | int err; |
1087 | struct i2c_client *sub_client; | 1087 | struct i2c_client *sub_client; |
1088 | 1088 | ||
1089 | (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 1089 | (*sub_cli) = sub_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
1090 | if (!(sub_client)) { | 1090 | if (!(sub_client)) { |
1091 | return -ENOMEM; | 1091 | return -ENOMEM; |
1092 | } | 1092 | } |
1093 | memset(sub_client, 0x00, sizeof(struct i2c_client)); | ||
1094 | sub_client->addr = 0x48 + addr; | 1093 | sub_client->addr = 0x48 + addr; |
1095 | i2c_set_clientdata(sub_client, NULL); | 1094 | i2c_set_clientdata(sub_client, NULL); |
1096 | sub_client->adapter = adapter; | 1095 | sub_client->adapter = adapter; |
@@ -1184,11 +1183,10 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1184 | client structure, even though we cannot fill it completely yet. | 1183 | client structure, even though we cannot fill it completely yet. |
1185 | But it allows us to access w83792d_{read,write}_value. */ | 1184 | But it allows us to access w83792d_{read,write}_value. */ |
1186 | 1185 | ||
1187 | if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { | 1186 | if (!(data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { |
1188 | err = -ENOMEM; | 1187 | err = -ENOMEM; |
1189 | goto ERROR0; | 1188 | goto ERROR0; |
1190 | } | 1189 | } |
1191 | memset(data, 0, sizeof(struct w83792d_data)); | ||
1192 | 1190 | ||
1193 | new_client = &data->client; | 1191 | new_client = &data->client; |
1194 | i2c_set_clientdata(new_client, data); | 1192 | i2c_set_clientdata(new_client, data); |
@@ -1429,7 +1427,6 @@ w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
1429 | return 0; | 1427 | return 0; |
1430 | } | 1428 | } |
1431 | 1429 | ||
1432 | /* Called when we have found a new W83792D. It should set limits, etc. */ | ||
1433 | static void | 1430 | static void |
1434 | w83792d_init_client(struct i2c_client *client) | 1431 | w83792d_init_client(struct i2c_client *client) |
1435 | { | 1432 | { |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 133e34ab1d0a..f495b6378668 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/jiffies.h> | 37 | #include <linux/jiffies.h> |
38 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/hwmon-sysfs.h> | ||
40 | #include <linux/err.h> | 41 | #include <linux/err.h> |
41 | 42 | ||
42 | /* How many retries on register read error */ | 43 | /* How many retries on register read error */ |
@@ -73,7 +74,7 @@ I2C_CLIENT_INSMOD_1(w83l785ts); | |||
73 | * The W83L785TS-S uses signed 8-bit values. | 74 | * The W83L785TS-S uses signed 8-bit values. |
74 | */ | 75 | */ |
75 | 76 | ||
76 | #define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000) | 77 | #define TEMP_FROM_REG(val) ((val) * 1000) |
77 | 78 | ||
78 | /* | 79 | /* |
79 | * Functions declaration | 80 | * Functions declaration |
@@ -111,27 +112,24 @@ struct w83l785ts_data { | |||
111 | unsigned long last_updated; /* in jiffies */ | 112 | unsigned long last_updated; /* in jiffies */ |
112 | 113 | ||
113 | /* registers values */ | 114 | /* registers values */ |
114 | u8 temp, temp_over; | 115 | s8 temp[2]; /* 0: input |
116 | 1: critical limit */ | ||
115 | }; | 117 | }; |
116 | 118 | ||
117 | /* | 119 | /* |
118 | * Sysfs stuff | 120 | * Sysfs stuff |
119 | */ | 121 | */ |
120 | 122 | ||
121 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) | 123 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
124 | char *buf) | ||
122 | { | 125 | { |
126 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
123 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | 127 | struct w83l785ts_data *data = w83l785ts_update_device(dev); |
124 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); | 128 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); |
125 | } | 129 | } |
126 | 130 | ||
127 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) | 131 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
128 | { | 132 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1); |
129 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | ||
130 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); | ||
131 | } | ||
132 | |||
133 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | ||
134 | static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL); | ||
135 | 133 | ||
136 | /* | 134 | /* |
137 | * Real code | 135 | * Real code |
@@ -158,12 +156,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
158 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 156 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
159 | goto exit; | 157 | goto exit; |
160 | 158 | ||
161 | if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { | 159 | if (!(data = kzalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { |
162 | err = -ENOMEM; | 160 | err = -ENOMEM; |
163 | goto exit; | 161 | goto exit; |
164 | } | 162 | } |
165 | memset(data, 0, sizeof(struct w83l785ts_data)); | ||
166 | |||
167 | 163 | ||
168 | /* The common I2C client data is placed right before the | 164 | /* The common I2C client data is placed right before the |
169 | * W83L785TS-specific data. */ | 165 | * W83L785TS-specific data. */ |
@@ -228,7 +224,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
228 | init_MUTEX(&data->update_lock); | 224 | init_MUTEX(&data->update_lock); |
229 | 225 | ||
230 | /* Default values in case the first read fails (unlikely). */ | 226 | /* Default values in case the first read fails (unlikely). */ |
231 | data->temp_over = data->temp = 0; | 227 | data->temp[1] = data->temp[0] = 0; |
232 | 228 | ||
233 | /* Tell the I2C layer a new client has arrived. */ | 229 | /* Tell the I2C layer a new client has arrived. */ |
234 | if ((err = i2c_attach_client(new_client))) | 230 | if ((err = i2c_attach_client(new_client))) |
@@ -246,8 +242,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
246 | goto exit_detach; | 242 | goto exit_detach; |
247 | } | 243 | } |
248 | 244 | ||
249 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 245 | device_create_file(&new_client->dev, |
250 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 246 | &sensor_dev_attr_temp1_input.dev_attr); |
247 | device_create_file(&new_client->dev, | ||
248 | &sensor_dev_attr_temp1_max.dev_attr); | ||
251 | 249 | ||
252 | return 0; | 250 | return 0; |
253 | 251 | ||
@@ -305,10 +303,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
305 | 303 | ||
306 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { | 304 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { |
307 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); | 305 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); |
308 | data->temp = w83l785ts_read_value(client, | 306 | data->temp[0] = w83l785ts_read_value(client, |
309 | W83L785TS_REG_TEMP, data->temp); | 307 | W83L785TS_REG_TEMP, data->temp[0]); |
310 | data->temp_over = w83l785ts_read_value(client, | 308 | data->temp[1] = w83l785ts_read_value(client, |
311 | W83L785TS_REG_TEMP_OVER, data->temp_over); | 309 | W83L785TS_REG_TEMP_OVER, data->temp[1]); |
312 | 310 | ||
313 | data->last_updated = jiffies; | 311 | data->last_updated = jiffies; |
314 | data->valid = 1; | 312 | data->valid = 1; |
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index beb10edfe9c1..82946acab4c7 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0) | 34 | #define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0) |
35 | #define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0) | 35 | #define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0) |
36 | 36 | ||
37 | static int i2c_debug=0; | 37 | static int i2c_debug; |
38 | 38 | ||
39 | #define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val) | 39 | #define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val) |
40 | #define pca_inw(adap, reg) adap->read_byte(adap, reg) | 40 | #define pca_inw(adap, reg) adap->read_byte(adap, reg) |
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 8ed5ad12552f..938848ae162d 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c | |||
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | /* module parameters: | 43 | /* module parameters: |
44 | */ | 44 | */ |
45 | static int bit_scan=0; /* have a look at what's hanging 'round */ | 45 | static int bit_scan; /* have a look at what's hanging 'round */ |
46 | 46 | ||
47 | 47 | ||
48 | static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, | 48 | static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 3badfec75b1c..4010fe92e72b 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -135,11 +135,12 @@ config I2C_I810 | |||
135 | help | 135 | help |
136 | If you say yes to this option, support will be included for the Intel | 136 | If you say yes to this option, support will be included for the Intel |
137 | 810/815 family of mainboard I2C interfaces. Specifically, the | 137 | 810/815 family of mainboard I2C interfaces. Specifically, the |
138 | following versions of the chipset is supported: | 138 | following versions of the chipset are supported: |
139 | i810AA | 139 | i810AA |
140 | i810AB | 140 | i810AB |
141 | i810E | 141 | i810E |
142 | i815 | 142 | i815 |
143 | i845G | ||
143 | 144 | ||
144 | This driver can also be built as a module. If so, the module | 145 | This driver can also be built as a module. If so, the module |
145 | will be called i2c-i810. | 146 | will be called i2c-i810. |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index f021acd2674e..ba90f5140af6 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -134,7 +134,7 @@ | |||
134 | /* -> Read = 1 */ | 134 | /* -> Read = 1 */ |
135 | #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ | 135 | #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ |
136 | 136 | ||
137 | 137 | static struct pci_driver ali1535_driver; | |
138 | static unsigned short ali1535_smba; | 138 | static unsigned short ali1535_smba; |
139 | static DECLARE_MUTEX(i2c_ali1535_sem); | 139 | static DECLARE_MUTEX(i2c_ali1535_sem); |
140 | 140 | ||
@@ -162,7 +162,8 @@ static int ali1535_setup(struct pci_dev *dev) | |||
162 | goto exit; | 162 | goto exit; |
163 | } | 163 | } |
164 | 164 | ||
165 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, "ali1535-smb")) { | 165 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, |
166 | ali1535_driver.name)) { | ||
166 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", | 167 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", |
167 | ali1535_smba); | 168 | ali1535_smba); |
168 | goto exit; | 169 | goto exit; |
@@ -480,7 +481,6 @@ static struct i2c_adapter ali1535_adapter = { | |||
480 | .owner = THIS_MODULE, | 481 | .owner = THIS_MODULE, |
481 | .class = I2C_CLASS_HWMON, | 482 | .class = I2C_CLASS_HWMON, |
482 | .algo = &smbus_algorithm, | 483 | .algo = &smbus_algorithm, |
483 | .name = "unset", | ||
484 | }; | 484 | }; |
485 | 485 | ||
486 | static struct pci_device_id ali1535_ids[] = { | 486 | static struct pci_device_id ali1535_ids[] = { |
@@ -513,6 +513,7 @@ static void __devexit ali1535_remove(struct pci_dev *dev) | |||
513 | } | 513 | } |
514 | 514 | ||
515 | static struct pci_driver ali1535_driver = { | 515 | static struct pci_driver ali1535_driver = { |
516 | .owner = THIS_MODULE, | ||
516 | .name = "ali1535_smbus", | 517 | .name = "ali1535_smbus", |
517 | .id_table = ali1535_ids, | 518 | .id_table = ali1535_ids, |
518 | .probe = ali1535_probe, | 519 | .probe = ali1535_probe, |
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 86947504aea1..f1a62d892425 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -60,6 +60,7 @@ | |||
60 | 60 | ||
61 | #define HST_CNTL2_SIZEMASK 0x38 | 61 | #define HST_CNTL2_SIZEMASK 0x38 |
62 | 62 | ||
63 | static struct pci_driver ali1563_pci_driver; | ||
63 | static unsigned short ali1563_smba; | 64 | static unsigned short ali1563_smba; |
64 | 65 | ||
65 | static int ali1563_transaction(struct i2c_adapter * a, int size) | 66 | static int ali1563_transaction(struct i2c_adapter * a, int size) |
@@ -350,7 +351,8 @@ static int __devinit ali1563_setup(struct pci_dev * dev) | |||
350 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); | 351 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); |
351 | goto Err; | 352 | goto Err; |
352 | } | 353 | } |
353 | if (!request_region(ali1563_smba,ALI1563_SMB_IOSIZE,"i2c-ali1563")) { | 354 | if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, |
355 | ali1563_pci_driver.name)) { | ||
354 | dev_warn(&dev->dev,"Could not allocate I/O space"); | 356 | dev_warn(&dev->dev,"Could not allocate I/O space"); |
355 | goto Err; | 357 | goto Err; |
356 | } | 358 | } |
@@ -406,7 +408,8 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = { | |||
406 | MODULE_DEVICE_TABLE (pci, ali1563_id_table); | 408 | MODULE_DEVICE_TABLE (pci, ali1563_id_table); |
407 | 409 | ||
408 | static struct pci_driver ali1563_pci_driver = { | 410 | static struct pci_driver ali1563_pci_driver = { |
409 | .name = "ali1563_i2c", | 411 | .owner = THIS_MODULE, |
412 | .name = "ali1563_smbus", | ||
410 | .id_table = ali1563_id_table, | 413 | .id_table = ali1563_id_table, |
411 | .probe = ali1563_probe, | 414 | .probe = ali1563_probe, |
412 | .remove = __devexit_p(ali1563_remove), | 415 | .remove = __devexit_p(ali1563_remove), |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index b3f50bff39a0..400b08ed4299 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -125,12 +125,13 @@ | |||
125 | 125 | ||
126 | /* If force_addr is set to anything different from 0, we forcibly enable | 126 | /* If force_addr is set to anything different from 0, we forcibly enable |
127 | the device at the given address. */ | 127 | the device at the given address. */ |
128 | static u16 force_addr = 0; | 128 | static u16 force_addr; |
129 | module_param(force_addr, ushort, 0); | 129 | module_param(force_addr, ushort, 0); |
130 | MODULE_PARM_DESC(force_addr, | 130 | MODULE_PARM_DESC(force_addr, |
131 | "Initialize the base address of the i2c controller"); | 131 | "Initialize the base address of the i2c controller"); |
132 | 132 | ||
133 | static unsigned short ali15x3_smba = 0; | 133 | static struct pci_driver ali15x3_driver; |
134 | static unsigned short ali15x3_smba; | ||
134 | 135 | ||
135 | static int ali15x3_setup(struct pci_dev *ALI15X3_dev) | 136 | static int ali15x3_setup(struct pci_dev *ALI15X3_dev) |
136 | { | 137 | { |
@@ -166,7 +167,8 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev) | |||
166 | if(force_addr) | 167 | if(force_addr) |
167 | ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); | 168 | ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); |
168 | 169 | ||
169 | if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) { | 170 | if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, |
171 | ali15x3_driver.name)) { | ||
170 | dev_err(&ALI15X3_dev->dev, | 172 | dev_err(&ALI15X3_dev->dev, |
171 | "ALI15X3_smb region 0x%x already in use!\n", | 173 | "ALI15X3_smb region 0x%x already in use!\n", |
172 | ali15x3_smba); | 174 | ali15x3_smba); |
@@ -470,7 +472,6 @@ static struct i2c_adapter ali15x3_adapter = { | |||
470 | .owner = THIS_MODULE, | 472 | .owner = THIS_MODULE, |
471 | .class = I2C_CLASS_HWMON, | 473 | .class = I2C_CLASS_HWMON, |
472 | .algo = &smbus_algorithm, | 474 | .algo = &smbus_algorithm, |
473 | .name = "unset", | ||
474 | }; | 475 | }; |
475 | 476 | ||
476 | static struct pci_device_id ali15x3_ids[] = { | 477 | static struct pci_device_id ali15x3_ids[] = { |
@@ -503,6 +504,7 @@ static void __devexit ali15x3_remove(struct pci_dev *dev) | |||
503 | } | 504 | } |
504 | 505 | ||
505 | static struct pci_driver ali15x3_driver = { | 506 | static struct pci_driver ali15x3_driver = { |
507 | .owner = THIS_MODULE, | ||
506 | .name = "ali15x3_smbus", | 508 | .name = "ali15x3_smbus", |
507 | .id_table = ali15x3_ids, | 509 | .id_table = ali15x3_ids, |
508 | .probe = ali15x3_probe, | 510 | .probe = ali15x3_probe, |
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 4e553e8c5cba..f51ab652300a 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void) | |||
169 | init_MUTEX(&amd756_lock); | 169 | init_MUTEX(&amd756_lock); |
170 | 170 | ||
171 | /* Define the 5 virtual adapters and algorithms structures */ | 171 | /* Define the 5 virtual adapters and algorithms structures */ |
172 | if (!(s4882_adapter = kmalloc(5 * sizeof(struct i2c_adapter), | 172 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), |
173 | GFP_KERNEL))) { | 173 | GFP_KERNEL))) { |
174 | error = -ENOMEM; | 174 | error = -ENOMEM; |
175 | goto ERROR1; | 175 | goto ERROR1; |
176 | } | 176 | } |
177 | if (!(s4882_algo = kmalloc(5 * sizeof(struct i2c_algorithm), | 177 | if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm), |
178 | GFP_KERNEL))) { | 178 | GFP_KERNEL))) { |
179 | error = -ENOMEM; | 179 | error = -ENOMEM; |
180 | goto ERROR2; | 180 | goto ERROR2; |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 6ad0603384b8..de035d137c3f 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -85,8 +85,8 @@ | |||
85 | #define AMD756_PROCESS_CALL 0x04 | 85 | #define AMD756_PROCESS_CALL 0x04 |
86 | #define AMD756_BLOCK_DATA 0x05 | 86 | #define AMD756_BLOCK_DATA 0x05 |
87 | 87 | ||
88 | 88 | static struct pci_driver amd756_driver; | |
89 | static unsigned short amd756_ioport = 0; | 89 | static unsigned short amd756_ioport; |
90 | 90 | ||
91 | /* | 91 | /* |
92 | SMBUS event = I/O 28-29 bit 11 | 92 | SMBUS event = I/O 28-29 bit 11 |
@@ -303,7 +303,6 @@ struct i2c_adapter amd756_smbus = { | |||
303 | .owner = THIS_MODULE, | 303 | .owner = THIS_MODULE, |
304 | .class = I2C_CLASS_HWMON, | 304 | .class = I2C_CLASS_HWMON, |
305 | .algo = &smbus_algorithm, | 305 | .algo = &smbus_algorithm, |
306 | .name = "unset", | ||
307 | }; | 306 | }; |
308 | 307 | ||
309 | enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 }; | 308 | enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 }; |
@@ -365,7 +364,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, | |||
365 | amd756_ioport += SMB_ADDR_OFFSET; | 364 | amd756_ioport += SMB_ADDR_OFFSET; |
366 | } | 365 | } |
367 | 366 | ||
368 | if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { | 367 | if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) { |
369 | dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", | 368 | dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", |
370 | amd756_ioport); | 369 | amd756_ioport); |
371 | return -ENODEV; | 370 | return -ENODEV; |
@@ -402,6 +401,7 @@ static void __devexit amd756_remove(struct pci_dev *dev) | |||
402 | } | 401 | } |
403 | 402 | ||
404 | static struct pci_driver amd756_driver = { | 403 | static struct pci_driver amd756_driver = { |
404 | .owner = THIS_MODULE, | ||
405 | .name = "amd756_smbus", | 405 | .name = "amd756_smbus", |
406 | .id_table = amd756_ids, | 406 | .id_table = amd756_ids, |
407 | .probe = amd756_probe, | 407 | .probe = amd756_probe, |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index 45ea24ba14d5..f3b79a68dbec 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -30,6 +30,8 @@ struct amd_smbus { | |||
30 | int size; | 30 | int size; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static struct pci_driver amd8111_driver; | ||
34 | |||
33 | /* | 35 | /* |
34 | * AMD PCI control registers definitions. | 36 | * AMD PCI control registers definitions. |
35 | */ | 37 | */ |
@@ -242,7 +244,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
242 | break; | 244 | break; |
243 | 245 | ||
244 | case I2C_SMBUS_BLOCK_PROC_CALL: | 246 | case I2C_SMBUS_BLOCK_PROC_CALL: |
245 | protocol |= pec; | ||
246 | len = min_t(u8, data->block[0], 31); | 247 | len = min_t(u8, data->block[0], 31); |
247 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 248 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
248 | amd_ec_write(smbus, AMD_SMB_BCNT, len); | 249 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
@@ -252,13 +253,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
252 | read_write = I2C_SMBUS_READ; | 253 | read_write = I2C_SMBUS_READ; |
253 | break; | 254 | break; |
254 | 255 | ||
255 | case I2C_SMBUS_WORD_DATA_PEC: | ||
256 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
257 | case I2C_SMBUS_PROC_CALL_PEC: | ||
258 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
259 | dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size); | ||
260 | return -1; | ||
261 | |||
262 | default: | 256 | default: |
263 | dev_warn(&adap->dev, "Unsupported transaction %d\n", size); | 257 | dev_warn(&adap->dev, "Unsupported transaction %d\n", size); |
264 | return -1; | 258 | return -1; |
@@ -343,16 +337,15 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ | |||
343 | if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) | 337 | if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) |
344 | return -ENODEV; | 338 | return -ENODEV; |
345 | 339 | ||
346 | smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL); | 340 | smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL); |
347 | if (!smbus) | 341 | if (!smbus) |
348 | return -ENOMEM; | 342 | return -ENOMEM; |
349 | memset(smbus, 0, sizeof(struct amd_smbus)); | ||
350 | 343 | ||
351 | smbus->dev = dev; | 344 | smbus->dev = dev; |
352 | smbus->base = pci_resource_start(dev, 0); | 345 | smbus->base = pci_resource_start(dev, 0); |
353 | smbus->size = pci_resource_len(dev, 0); | 346 | smbus->size = pci_resource_len(dev, 0); |
354 | 347 | ||
355 | if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0")) | 348 | if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) |
356 | goto out_kfree; | 349 | goto out_kfree; |
357 | 350 | ||
358 | smbus->adapter.owner = THIS_MODULE; | 351 | smbus->adapter.owner = THIS_MODULE; |
@@ -391,6 +384,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev) | |||
391 | } | 384 | } |
392 | 385 | ||
393 | static struct pci_driver amd8111_driver = { | 386 | static struct pci_driver amd8111_driver = { |
387 | .owner = THIS_MODULE, | ||
394 | .name = "amd8111_smbus2", | 388 | .name = "amd8111_smbus2", |
395 | .id_table = amd8111_ids, | 389 | .id_table = amd8111_ids, |
396 | .probe = amd8111_probe, | 390 | .probe = amd8111_probe, |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 6930b660e508..59f8308c2356 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -22,7 +22,7 @@ | |||
22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | 22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
23 | Frodo Looijaard <frodol@dds.nl> */ | 23 | Frodo Looijaard <frodol@dds.nl> */ |
24 | 24 | ||
25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of | 25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of |
26 | for Alpha Processor Inc. UP-2000(+) boards */ | 26 | for Alpha Processor Inc. UP-2000(+) boards */ |
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -46,12 +46,14 @@ | |||
46 | #define DEFAULT_BASE 0x330 | 46 | #define DEFAULT_BASE 0x330 |
47 | 47 | ||
48 | static int base; | 48 | static int base; |
49 | static u8 __iomem *base_iomem; | ||
50 | |||
49 | static int irq; | 51 | static int irq; |
50 | static int clock = 0x1c; | 52 | static int clock = 0x1c; |
51 | static int own = 0x55; | 53 | static int own = 0x55; |
52 | static int mmapped; | 54 | static int mmapped; |
53 | 55 | ||
54 | /* vdovikin: removed static struct i2c_pcf_isa gpi; code - | 56 | /* vdovikin: removed static struct i2c_pcf_isa gpi; code - |
55 | this module in real supports only one device, due to missing arguments | 57 | this module in real supports only one device, due to missing arguments |
56 | in some functions, called from the algo-pcf module. Sometimes it's | 58 | in some functions, called from the algo-pcf module. Sometimes it's |
57 | need to be rewriten - but for now just remove this for simpler reading */ | 59 | need to be rewriten - but for now just remove this for simpler reading */ |
@@ -60,40 +62,33 @@ static wait_queue_head_t pcf_wait; | |||
60 | static int pcf_pending; | 62 | static int pcf_pending; |
61 | static spinlock_t lock; | 63 | static spinlock_t lock; |
62 | 64 | ||
65 | static struct i2c_adapter pcf_isa_ops; | ||
66 | |||
63 | /* ----- local functions ---------------------------------------------- */ | 67 | /* ----- local functions ---------------------------------------------- */ |
64 | 68 | ||
65 | static void pcf_isa_setbyte(void *data, int ctl, int val) | 69 | static void pcf_isa_setbyte(void *data, int ctl, int val) |
66 | { | 70 | { |
67 | int address = ctl ? (base + 1) : base; | 71 | u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; |
68 | 72 | ||
69 | /* enable irq if any specified for serial operation */ | 73 | /* enable irq if any specified for serial operation */ |
70 | if (ctl && irq && (val & I2C_PCF_ESO)) { | 74 | if (ctl && irq && (val & I2C_PCF_ESO)) { |
71 | val |= I2C_PCF_ENI; | 75 | val |= I2C_PCF_ENI; |
72 | } | 76 | } |
73 | 77 | ||
74 | pr_debug("i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255); | 78 | pr_debug("%s: Write %p 0x%02X\n", pcf_isa_ops.name, address, val); |
75 | 79 | iowrite8(val, address); | |
76 | switch (mmapped) { | 80 | #ifdef __alpha__ |
77 | case 0: /* regular I/O */ | 81 | /* API UP2000 needs some hardware fudging to make the write stick */ |
78 | outb(val, address); | 82 | iowrite8(val, address); |
79 | break; | 83 | #endif |
80 | case 2: /* double mapped I/O needed for UP2000 board, | ||
81 | I don't know why this... */ | ||
82 | writeb(val, (void *)address); | ||
83 | /* fall */ | ||
84 | case 1: /* memory mapped I/O */ | ||
85 | writeb(val, (void *)address); | ||
86 | break; | ||
87 | } | ||
88 | } | 84 | } |
89 | 85 | ||
90 | static int pcf_isa_getbyte(void *data, int ctl) | 86 | static int pcf_isa_getbyte(void *data, int ctl) |
91 | { | 87 | { |
92 | int address = ctl ? (base + 1) : base; | 88 | u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; |
93 | int val = mmapped ? readb((void *)address) : inb(address); | 89 | int val = ioread8(address); |
94 | |||
95 | pr_debug("i2c-elektor: Read 0x%X 0x%02X\n", address, val); | ||
96 | 90 | ||
91 | pr_debug("%s: Read %p 0x%02X\n", pcf_isa_ops.name, address, val); | ||
97 | return (val); | 92 | return (val); |
98 | } | 93 | } |
99 | 94 | ||
@@ -149,16 +144,40 @@ static int pcf_isa_init(void) | |||
149 | { | 144 | { |
150 | spin_lock_init(&lock); | 145 | spin_lock_init(&lock); |
151 | if (!mmapped) { | 146 | if (!mmapped) { |
152 | if (!request_region(base, 2, "i2c (isa bus adapter)")) { | 147 | if (!request_region(base, 2, pcf_isa_ops.name)) { |
153 | printk(KERN_ERR | 148 | printk(KERN_ERR "%s: requested I/O region (%#x:2) is " |
154 | "i2c-elektor: requested I/O region (0x%X:2) " | 149 | "in use\n", pcf_isa_ops.name, base); |
155 | "is in use.\n", base); | 150 | return -ENODEV; |
151 | } | ||
152 | base_iomem = ioport_map(base, 2); | ||
153 | if (!base_iomem) { | ||
154 | printk(KERN_ERR "%s: remap of I/O region %#x failed\n", | ||
155 | pcf_isa_ops.name, base); | ||
156 | release_region(base, 2); | ||
157 | return -ENODEV; | ||
158 | } | ||
159 | } else { | ||
160 | if (!request_mem_region(base, 2, pcf_isa_ops.name)) { | ||
161 | printk(KERN_ERR "%s: requested memory region (%#x:2) " | ||
162 | "is in use\n", pcf_isa_ops.name, base); | ||
163 | return -ENODEV; | ||
164 | } | ||
165 | base_iomem = ioremap(base, 2); | ||
166 | if (base_iomem == NULL) { | ||
167 | printk(KERN_ERR "%s: remap of memory region %#x " | ||
168 | "failed\n", pcf_isa_ops.name, base); | ||
169 | release_mem_region(base, 2); | ||
156 | return -ENODEV; | 170 | return -ENODEV; |
157 | } | 171 | } |
158 | } | 172 | } |
173 | pr_debug("%s: registers %#x remapped to %p\n", pcf_isa_ops.name, base, | ||
174 | base_iomem); | ||
175 | |||
159 | if (irq > 0) { | 176 | if (irq > 0) { |
160 | if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", NULL) < 0) { | 177 | if (request_irq(irq, pcf_isa_handler, 0, pcf_isa_ops.name, |
161 | printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq); | 178 | NULL) < 0) { |
179 | printk(KERN_ERR "%s: Request irq%d failed\n", | ||
180 | pcf_isa_ops.name, irq); | ||
162 | irq = 0; | 181 | irq = 0; |
163 | } else | 182 | } else |
164 | enable_irq(irq); | 183 | enable_irq(irq); |
@@ -186,47 +205,49 @@ static struct i2c_adapter pcf_isa_ops = { | |||
186 | .class = I2C_CLASS_HWMON, | 205 | .class = I2C_CLASS_HWMON, |
187 | .id = I2C_HW_P_ELEK, | 206 | .id = I2C_HW_P_ELEK, |
188 | .algo_data = &pcf_isa_data, | 207 | .algo_data = &pcf_isa_data, |
189 | .name = "PCF8584 ISA adapter", | 208 | .name = "i2c-elektor", |
190 | }; | 209 | }; |
191 | 210 | ||
192 | static int __init i2c_pcfisa_init(void) | 211 | static int __init i2c_pcfisa_init(void) |
193 | { | 212 | { |
194 | #ifdef __alpha__ | 213 | #ifdef __alpha__ |
195 | /* check to see we have memory mapped PCF8584 connected to the | 214 | /* check to see we have memory mapped PCF8584 connected to the |
196 | Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ | 215 | Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ |
197 | if (base == 0) { | 216 | if (base == 0) { |
198 | struct pci_dev *cy693_dev; | 217 | struct pci_dev *cy693_dev; |
199 | 218 | ||
200 | cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, | 219 | cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, |
201 | PCI_DEVICE_ID_CONTAQ_82C693, NULL); | 220 | PCI_DEVICE_ID_CONTAQ_82C693, NULL); |
202 | if (cy693_dev) { | 221 | if (cy693_dev) { |
203 | char config; | 222 | unsigned char config; |
204 | /* yeap, we've found cypress, let's check config */ | 223 | /* yeap, we've found cypress, let's check config */ |
205 | if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { | 224 | if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { |
206 | 225 | ||
207 | pr_debug("i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config); | 226 | pr_debug("%s: found cy82c693, config " |
227 | "register 0x47 = 0x%02x\n", | ||
228 | pcf_isa_ops.name, config); | ||
208 | 229 | ||
209 | /* UP2000 board has this register set to 0xe1, | 230 | /* UP2000 board has this register set to 0xe1, |
210 | but the most significant bit as seems can be | 231 | but the most significant bit as seems can be |
211 | reset during the proper initialisation | 232 | reset during the proper initialisation |
212 | sequence if guys from API decides to do that | 233 | sequence if guys from API decides to do that |
213 | (so, we can even enable Tsunami Pchip | 234 | (so, we can even enable Tsunami Pchip |
214 | window for the upper 1 Gb) */ | 235 | window for the upper 1 Gb) */ |
215 | 236 | ||
216 | /* so just check for ROMCS at 0xe0000, | 237 | /* so just check for ROMCS at 0xe0000, |
217 | ROMCS enabled for writes | 238 | ROMCS enabled for writes |
218 | and external XD Bus buffer in use. */ | 239 | and external XD Bus buffer in use. */ |
219 | if ((config & 0x7f) == 0x61) { | 240 | if ((config & 0x7f) == 0x61) { |
220 | /* seems to be UP2000 like board */ | 241 | /* seems to be UP2000 like board */ |
221 | base = 0xe0000; | 242 | base = 0xe0000; |
222 | /* I don't know why we need to | 243 | mmapped = 1; |
223 | write twice */ | 244 | /* UP2000 drives ISA with |
224 | mmapped = 2; | ||
225 | /* UP2000 drives ISA with | ||
226 | 8.25 MHz (PCI/4) clock | 245 | 8.25 MHz (PCI/4) clock |
227 | (this can be read from cypress) */ | 246 | (this can be read from cypress) */ |
228 | clock = I2C_PCF_CLK | I2C_PCF_TRNS90; | 247 | clock = I2C_PCF_CLK | I2C_PCF_TRNS90; |
229 | printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n"); | 248 | pr_info("%s: found API UP2000 like " |
249 | "board, will probe PCF8584 " | ||
250 | "later\n", pcf_isa_ops.name); | ||
230 | } | 251 | } |
231 | } | 252 | } |
232 | pci_dev_put(cy693_dev); | 253 | pci_dev_put(cy693_dev); |
@@ -236,12 +257,11 @@ static int __init i2c_pcfisa_init(void) | |||
236 | 257 | ||
237 | /* sanity checks for mmapped I/O */ | 258 | /* sanity checks for mmapped I/O */ |
238 | if (mmapped && base < 0xc8000) { | 259 | if (mmapped && base < 0xc8000) { |
239 | printk(KERN_ERR "i2c-elektor: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); | 260 | printk(KERN_ERR "%s: incorrect base address (%#x) specified " |
261 | "for mmapped I/O\n", pcf_isa_ops.name, base); | ||
240 | return -ENODEV; | 262 | return -ENODEV; |
241 | } | 263 | } |
242 | 264 | ||
243 | printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n"); | ||
244 | |||
245 | if (base == 0) { | 265 | if (base == 0) { |
246 | base = DEFAULT_BASE; | 266 | base = DEFAULT_BASE; |
247 | } | 267 | } |
@@ -251,8 +271,8 @@ static int __init i2c_pcfisa_init(void) | |||
251 | return -ENODEV; | 271 | return -ENODEV; |
252 | if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) | 272 | if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) |
253 | goto fail; | 273 | goto fail; |
254 | 274 | ||
255 | printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base); | 275 | dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base); |
256 | 276 | ||
257 | return 0; | 277 | return 0; |
258 | 278 | ||
@@ -262,8 +282,13 @@ static int __init i2c_pcfisa_init(void) | |||
262 | free_irq(irq, NULL); | 282 | free_irq(irq, NULL); |
263 | } | 283 | } |
264 | 284 | ||
265 | if (!mmapped) | 285 | if (!mmapped) { |
266 | release_region(base , 2); | 286 | ioport_unmap(base_iomem); |
287 | release_region(base, 2); | ||
288 | } else { | ||
289 | iounmap(base_iomem); | ||
290 | release_mem_region(base, 2); | ||
291 | } | ||
267 | return -ENODEV; | 292 | return -ENODEV; |
268 | } | 293 | } |
269 | 294 | ||
@@ -276,8 +301,13 @@ static void i2c_pcfisa_exit(void) | |||
276 | free_irq(irq, NULL); | 301 | free_irq(irq, NULL); |
277 | } | 302 | } |
278 | 303 | ||
279 | if (!mmapped) | 304 | if (!mmapped) { |
280 | release_region(base , 2); | 305 | ioport_unmap(base_iomem); |
306 | release_region(base, 2); | ||
307 | } else { | ||
308 | iounmap(base_iomem); | ||
309 | release_mem_region(base, 2); | ||
310 | } | ||
281 | } | 311 | } |
282 | 312 | ||
283 | MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); | 313 | MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); |
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index e0cb3b0f92fa..1b5354e24bf5 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c | |||
@@ -155,6 +155,7 @@ static void __devexit hydra_remove(struct pci_dev *dev) | |||
155 | 155 | ||
156 | 156 | ||
157 | static struct pci_driver hydra_driver = { | 157 | static struct pci_driver hydra_driver = { |
158 | .owner = THIS_MODULE, | ||
158 | .name = "hydra_smbus", | 159 | .name = "hydra_smbus", |
159 | .id_table = hydra_ids, | 160 | .id_table = hydra_ids, |
160 | .probe = hydra_probe, | 161 | .probe = hydra_probe, |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 709beab76609..4f63195069da 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -52,10 +52,6 @@ | |||
52 | #include <linux/i2c.h> | 52 | #include <linux/i2c.h> |
53 | #include <asm/io.h> | 53 | #include <asm/io.h> |
54 | 54 | ||
55 | #ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC | ||
56 | #define HAVE_PEC | ||
57 | #endif | ||
58 | |||
59 | /* I801 SMBus address offsets */ | 55 | /* I801 SMBus address offsets */ |
60 | #define SMBHSTSTS (0 + i801_smba) | 56 | #define SMBHSTSTS (0 + i801_smba) |
61 | #define SMBHSTCNT (2 + i801_smba) | 57 | #define SMBHSTCNT (2 + i801_smba) |
@@ -106,10 +102,11 @@ MODULE_PARM_DESC(force_addr, | |||
106 | "EXTREMELY DANGEROUS!"); | 102 | "EXTREMELY DANGEROUS!"); |
107 | 103 | ||
108 | static int i801_transaction(void); | 104 | static int i801_transaction(void); |
109 | static int i801_block_transaction(union i2c_smbus_data *data, | 105 | static int i801_block_transaction(union i2c_smbus_data *data, char read_write, |
110 | char read_write, int command); | 106 | int command, int hwpec); |
111 | 107 | ||
112 | static unsigned short i801_smba; | 108 | static unsigned short i801_smba; |
109 | static struct pci_driver i801_driver; | ||
113 | static struct pci_dev *I801_dev; | 110 | static struct pci_dev *I801_dev; |
114 | static int isich4; | 111 | static int isich4; |
115 | 112 | ||
@@ -143,7 +140,7 @@ static int i801_setup(struct pci_dev *dev) | |||
143 | } | 140 | } |
144 | } | 141 | } |
145 | 142 | ||
146 | if (!request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus")) { | 143 | if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) { |
147 | dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", | 144 | dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", |
148 | i801_smba); | 145 | i801_smba); |
149 | error_return = -EBUSY; | 146 | error_return = -EBUSY; |
@@ -252,7 +249,7 @@ static int i801_transaction(void) | |||
252 | 249 | ||
253 | /* All-inclusive block transaction function */ | 250 | /* All-inclusive block transaction function */ |
254 | static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | 251 | static int i801_block_transaction(union i2c_smbus_data *data, char read_write, |
255 | int command) | 252 | int command, int hwpec) |
256 | { | 253 | { |
257 | int i, len; | 254 | int i, len; |
258 | int smbcmd; | 255 | int smbcmd; |
@@ -391,8 +388,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
391 | goto END; | 388 | goto END; |
392 | } | 389 | } |
393 | 390 | ||
394 | #ifdef HAVE_PEC | 391 | if (hwpec) { |
395 | if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) { | ||
396 | /* wait for INTR bit as advised by Intel */ | 392 | /* wait for INTR bit as advised by Intel */ |
397 | timeout = 0; | 393 | timeout = 0; |
398 | do { | 394 | do { |
@@ -406,7 +402,6 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
406 | } | 402 | } |
407 | outb_p(temp, SMBHSTSTS); | 403 | outb_p(temp, SMBHSTSTS); |
408 | } | 404 | } |
409 | #endif | ||
410 | result = 0; | 405 | result = 0; |
411 | END: | 406 | END: |
412 | if (command == I2C_SMBUS_I2C_BLOCK_DATA) { | 407 | if (command == I2C_SMBUS_I2C_BLOCK_DATA) { |
@@ -421,14 +416,13 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
421 | unsigned short flags, char read_write, u8 command, | 416 | unsigned short flags, char read_write, u8 command, |
422 | int size, union i2c_smbus_data * data) | 417 | int size, union i2c_smbus_data * data) |
423 | { | 418 | { |
424 | int hwpec = 0; | 419 | int hwpec; |
425 | int block = 0; | 420 | int block = 0; |
426 | int ret, xact = 0; | 421 | int ret, xact = 0; |
427 | 422 | ||
428 | #ifdef HAVE_PEC | 423 | hwpec = isich4 && (flags & I2C_CLIENT_PEC) |
429 | if(isich4) | 424 | && size != I2C_SMBUS_QUICK |
430 | hwpec = (flags & I2C_CLIENT_PEC) != 0; | 425 | && size != I2C_SMBUS_I2C_BLOCK_DATA; |
431 | #endif | ||
432 | 426 | ||
433 | switch (size) { | 427 | switch (size) { |
434 | case I2C_SMBUS_QUICK: | 428 | case I2C_SMBUS_QUICK: |
@@ -463,11 +457,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
463 | break; | 457 | break; |
464 | case I2C_SMBUS_BLOCK_DATA: | 458 | case I2C_SMBUS_BLOCK_DATA: |
465 | case I2C_SMBUS_I2C_BLOCK_DATA: | 459 | case I2C_SMBUS_I2C_BLOCK_DATA: |
466 | #ifdef HAVE_PEC | ||
467 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
468 | if(hwpec && size == I2C_SMBUS_BLOCK_DATA) | ||
469 | size = I2C_SMBUS_BLOCK_DATA_PEC; | ||
470 | #endif | ||
471 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | 460 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), |
472 | SMBHSTADD); | 461 | SMBHSTADD); |
473 | outb_p(command, SMBHSTCMD); | 462 | outb_p(command, SMBHSTCMD); |
@@ -479,27 +468,18 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
479 | return -1; | 468 | return -1; |
480 | } | 469 | } |
481 | 470 | ||
482 | #ifdef HAVE_PEC | 471 | if (hwpec) |
483 | if(isich4 && hwpec) { | 472 | outb_p(1, SMBAUXCTL); /* enable hardware PEC */ |
484 | if(size != I2C_SMBUS_QUICK && | 473 | |
485 | size != I2C_SMBUS_I2C_BLOCK_DATA) | ||
486 | outb_p(1, SMBAUXCTL); /* enable HW PEC */ | ||
487 | } | ||
488 | #endif | ||
489 | if(block) | 474 | if(block) |
490 | ret = i801_block_transaction(data, read_write, size); | 475 | ret = i801_block_transaction(data, read_write, size, hwpec); |
491 | else { | 476 | else { |
492 | outb_p(xact | ENABLE_INT9, SMBHSTCNT); | 477 | outb_p(xact | ENABLE_INT9, SMBHSTCNT); |
493 | ret = i801_transaction(); | 478 | ret = i801_transaction(); |
494 | } | 479 | } |
495 | 480 | ||
496 | #ifdef HAVE_PEC | 481 | if (hwpec) |
497 | if(isich4 && hwpec) { | 482 | outb_p(0, SMBAUXCTL); /* disable hardware PEC */ |
498 | if(size != I2C_SMBUS_QUICK && | ||
499 | size != I2C_SMBUS_I2C_BLOCK_DATA) | ||
500 | outb_p(0, SMBAUXCTL); | ||
501 | } | ||
502 | #endif | ||
503 | 483 | ||
504 | if(block) | 484 | if(block) |
505 | return ret; | 485 | return ret; |
@@ -526,12 +506,7 @@ static u32 i801_func(struct i2c_adapter *adapter) | |||
526 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 506 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
527 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | 507 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
528 | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | 508 | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
529 | #ifdef HAVE_PEC | 509 | | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0); |
530 | | (isich4 ? I2C_FUNC_SMBUS_BLOCK_DATA_PEC | | ||
531 | I2C_FUNC_SMBUS_HWPEC_CALC | ||
532 | : 0) | ||
533 | #endif | ||
534 | ; | ||
535 | } | 510 | } |
536 | 511 | ||
537 | static struct i2c_algorithm smbus_algorithm = { | 512 | static struct i2c_algorithm smbus_algorithm = { |
@@ -543,7 +518,6 @@ static struct i2c_adapter i801_adapter = { | |||
543 | .owner = THIS_MODULE, | 518 | .owner = THIS_MODULE, |
544 | .class = I2C_CLASS_HWMON, | 519 | .class = I2C_CLASS_HWMON, |
545 | .algo = &smbus_algorithm, | 520 | .algo = &smbus_algorithm, |
546 | .name = "unset", | ||
547 | }; | 521 | }; |
548 | 522 | ||
549 | static struct pci_device_id i801_ids[] = { | 523 | static struct pci_device_id i801_ids[] = { |
@@ -586,6 +560,7 @@ static void __devexit i801_remove(struct pci_dev *dev) | |||
586 | } | 560 | } |
587 | 561 | ||
588 | static struct pci_driver i801_driver = { | 562 | static struct pci_driver i801_driver = { |
563 | .owner = THIS_MODULE, | ||
589 | .name = "i801_smbus", | 564 | .name = "i801_smbus", |
590 | .id_table = i801_ids, | 565 | .id_table = i801_ids, |
591 | .probe = i801_probe, | 566 | .probe = i801_probe, |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index 0ff7016e0629..52bc30593bd7 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -32,6 +32,7 @@ | |||
32 | i810AB 7123 | 32 | i810AB 7123 |
33 | i810E 7125 | 33 | i810E 7125 |
34 | i815 1132 | 34 | i815 1132 |
35 | i845G 2562 | ||
35 | */ | 36 | */ |
36 | 37 | ||
37 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
@@ -232,6 +233,7 @@ static void __devexit i810_remove(struct pci_dev *dev) | |||
232 | } | 233 | } |
233 | 234 | ||
234 | static struct pci_driver i810_driver = { | 235 | static struct pci_driver i810_driver = { |
236 | .owner = THIS_MODULE, | ||
235 | .name = "i810_smbus", | 237 | .name = "i810_smbus", |
236 | .id_table = i810_ids, | 238 | .id_table = i810_ids, |
237 | .probe = i810_probe, | 239 | .probe = i810_probe, |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index a3ed9590f028..1a587253d716 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -672,13 +672,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
672 | printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", | 672 | printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", |
673 | ocp->def->index); | 673 | ocp->def->index); |
674 | 674 | ||
675 | if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){ | 675 | if (!(dev = kzalloc(sizeof(*dev), GFP_KERNEL))) { |
676 | printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n", | 676 | printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n", |
677 | ocp->def->index); | 677 | ocp->def->index); |
678 | return -ENOMEM; | 678 | return -ENOMEM; |
679 | } | 679 | } |
680 | 680 | ||
681 | memset(dev, 0, sizeof(*dev)); | ||
682 | dev->idx = ocp->def->index; | 681 | dev->idx = ocp->def->index; |
683 | ocp_set_drvdata(ocp, dev); | 682 | ocp_set_drvdata(ocp, dev); |
684 | 683 | ||
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index 7bd9102db701..9888fae1f37a 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include "i2c-iop3xx.h" | 43 | #include "i2c-iop3xx.h" |
44 | 44 | ||
45 | /* global unit counter */ | 45 | /* global unit counter */ |
46 | static int i2c_id = 0; | 46 | static int i2c_id; |
47 | 47 | ||
48 | static inline unsigned char | 48 | static inline unsigned char |
49 | iic_cook_addr(struct i2c_msg *msg) | 49 | iic_cook_addr(struct i2c_msg *msg) |
@@ -440,19 +440,17 @@ iop3xx_i2c_probe(struct device *dev) | |||
440 | struct i2c_adapter *new_adapter; | 440 | struct i2c_adapter *new_adapter; |
441 | struct i2c_algo_iop3xx_data *adapter_data; | 441 | struct i2c_algo_iop3xx_data *adapter_data; |
442 | 442 | ||
443 | new_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); | 443 | new_adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); |
444 | if (!new_adapter) { | 444 | if (!new_adapter) { |
445 | ret = -ENOMEM; | 445 | ret = -ENOMEM; |
446 | goto out; | 446 | goto out; |
447 | } | 447 | } |
448 | memset((void*)new_adapter, 0, sizeof(*new_adapter)); | ||
449 | 448 | ||
450 | adapter_data = kmalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); | 449 | adapter_data = kzalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); |
451 | if (!adapter_data) { | 450 | if (!adapter_data) { |
452 | ret = -ENOMEM; | 451 | ret = -ENOMEM; |
453 | goto free_adapter; | 452 | goto free_adapter; |
454 | } | 453 | } |
455 | memset((void*)adapter_data, 0, sizeof(*adapter_data)); | ||
456 | 454 | ||
457 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 455 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
458 | if (!res) { | 456 | if (!res) { |
@@ -525,6 +523,7 @@ out: | |||
525 | 523 | ||
526 | 524 | ||
527 | static struct device_driver iop3xx_i2c_driver = { | 525 | static struct device_driver iop3xx_i2c_driver = { |
526 | .owner = THIS_MODULE, | ||
528 | .name = "IOP3xx-I2C", | 527 | .name = "IOP3xx-I2C", |
529 | .bus = &platform_bus_type, | 528 | .bus = &platform_bus_type, |
530 | .probe = iop3xx_i2c_probe, | 529 | .probe = iop3xx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index bdc6806dafae..4fdc02411609 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -92,6 +92,7 @@ int i2c_isa_add_driver(struct i2c_driver *driver) | |||
92 | 92 | ||
93 | /* Add the driver to the list of i2c drivers in the driver core */ | 93 | /* Add the driver to the list of i2c drivers in the driver core */ |
94 | driver->driver.name = driver->name; | 94 | driver->driver.name = driver->name; |
95 | driver->driver.owner = driver->owner; | ||
95 | driver->driver.bus = &i2c_bus_type; | 96 | driver->driver.bus = &i2c_bus_type; |
96 | driver->driver.probe = i2c_isa_device_probe; | 97 | driver->driver.probe = i2c_isa_device_probe; |
97 | driver->driver.remove = i2c_isa_device_remove; | 98 | driver->driver.remove = i2c_isa_device_remove; |
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 1956af382cd8..42016ee6ef13 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <asm/hardware.h> /* Pick up IXP2000-specific bits */ | 36 | #include <asm/hardware.h> /* Pick up IXP2000-specific bits */ |
37 | #include <asm/arch/gpio.h> | 37 | #include <asm/arch/gpio.h> |
38 | 38 | ||
39 | static struct device_driver ixp2000_i2c_driver; | ||
40 | |||
39 | static inline int ixp2000_scl_pin(void *data) | 41 | static inline int ixp2000_scl_pin(void *data) |
40 | { | 42 | { |
41 | return ((struct ixp2000_i2c_pins*)data)->scl_pin; | 43 | return ((struct ixp2000_i2c_pins*)data)->scl_pin; |
@@ -104,11 +106,10 @@ static int ixp2000_i2c_probe(struct device *dev) | |||
104 | struct platform_device *plat_dev = to_platform_device(dev); | 106 | struct platform_device *plat_dev = to_platform_device(dev); |
105 | struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; | 107 | struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; |
106 | struct ixp2000_i2c_data *drv_data = | 108 | struct ixp2000_i2c_data *drv_data = |
107 | kmalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); | 109 | kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); |
108 | 110 | ||
109 | if (!drv_data) | 111 | if (!drv_data) |
110 | return -ENOMEM; | 112 | return -ENOMEM; |
111 | memzero(drv_data, sizeof(*drv_data)); | ||
112 | drv_data->gpio_pins = gpio; | 113 | drv_data->gpio_pins = gpio; |
113 | 114 | ||
114 | drv_data->algo_data.data = gpio; | 115 | drv_data->algo_data.data = gpio; |
@@ -121,6 +122,8 @@ static int ixp2000_i2c_probe(struct device *dev) | |||
121 | drv_data->algo_data.timeout = 100; | 122 | drv_data->algo_data.timeout = 100; |
122 | 123 | ||
123 | drv_data->adapter.id = I2C_HW_B_IXP2000, | 124 | drv_data->adapter.id = I2C_HW_B_IXP2000, |
125 | strlcpy(drv_data->adapter.name, ixp2000_i2c_driver.name, | ||
126 | I2C_NAME_SIZE); | ||
124 | drv_data->adapter.algo_data = &drv_data->algo_data, | 127 | drv_data->adapter.algo_data = &drv_data->algo_data, |
125 | 128 | ||
126 | drv_data->adapter.dev.parent = &plat_dev->dev; | 129 | drv_data->adapter.dev.parent = &plat_dev->dev; |
@@ -142,6 +145,7 @@ static int ixp2000_i2c_probe(struct device *dev) | |||
142 | } | 145 | } |
143 | 146 | ||
144 | static struct device_driver ixp2000_i2c_driver = { | 147 | static struct device_driver ixp2000_i2c_driver = { |
148 | .owner = THIS_MODULE, | ||
145 | .name = "IXP2000-I2C", | 149 | .name = "IXP2000-I2C", |
146 | .bus = &platform_bus_type, | 150 | .bus = &platform_bus_type, |
147 | .probe = ixp2000_i2c_probe, | 151 | .probe = ixp2000_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index f6f5ca31fdba..69303ab65e04 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | #include <asm/hardware.h> /* Pick up IXP4xx-specific bits */ | 36 | #include <asm/hardware.h> /* Pick up IXP4xx-specific bits */ |
37 | 37 | ||
38 | static struct device_driver ixp4xx_i2c_driver; | ||
39 | |||
38 | static inline int ixp4xx_scl_pin(void *data) | 40 | static inline int ixp4xx_scl_pin(void *data) |
39 | { | 41 | { |
40 | return ((struct ixp4xx_i2c_pins*)data)->scl_pin; | 42 | return ((struct ixp4xx_i2c_pins*)data)->scl_pin; |
@@ -105,12 +107,11 @@ static int ixp4xx_i2c_probe(struct device *dev) | |||
105 | struct platform_device *plat_dev = to_platform_device(dev); | 107 | struct platform_device *plat_dev = to_platform_device(dev); |
106 | struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; | 108 | struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; |
107 | struct ixp4xx_i2c_data *drv_data = | 109 | struct ixp4xx_i2c_data *drv_data = |
108 | kmalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); | 110 | kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); |
109 | 111 | ||
110 | if(!drv_data) | 112 | if(!drv_data) |
111 | return -ENOMEM; | 113 | return -ENOMEM; |
112 | 114 | ||
113 | memzero(drv_data, sizeof(struct ixp4xx_i2c_data)); | ||
114 | drv_data->gpio_pins = gpio; | 115 | drv_data->gpio_pins = gpio; |
115 | 116 | ||
116 | /* | 117 | /* |
@@ -129,6 +130,8 @@ static int ixp4xx_i2c_probe(struct device *dev) | |||
129 | drv_data->algo_data.timeout = 100; | 130 | drv_data->algo_data.timeout = 100; |
130 | 131 | ||
131 | drv_data->adapter.id = I2C_HW_B_IXP4XX; | 132 | drv_data->adapter.id = I2C_HW_B_IXP4XX; |
133 | strlcpy(drv_data->adapter.name, ixp4xx_i2c_driver.name, | ||
134 | I2C_NAME_SIZE); | ||
132 | drv_data->adapter.algo_data = &drv_data->algo_data; | 135 | drv_data->adapter.algo_data = &drv_data->algo_data; |
133 | 136 | ||
134 | drv_data->adapter.dev.parent = &plat_dev->dev; | 137 | drv_data->adapter.dev.parent = &plat_dev->dev; |
@@ -151,6 +154,7 @@ static int ixp4xx_i2c_probe(struct device *dev) | |||
151 | } | 154 | } |
152 | 155 | ||
153 | static struct device_driver ixp4xx_i2c_driver = { | 156 | static struct device_driver ixp4xx_i2c_driver = { |
157 | .owner = THIS_MODULE, | ||
154 | .name = "IXP4XX-I2C", | 158 | .name = "IXP4XX-I2C", |
155 | .bus = &platform_bus_type, | 159 | .bus = &platform_bus_type, |
156 | .probe = ixp4xx_i2c_probe, | 160 | .probe = ixp4xx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index eff5896ce865..d61f748278fc 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c | |||
@@ -535,13 +535,12 @@ create_iface(struct device_node *np, struct device *dev) | |||
535 | 535 | ||
536 | tsize = sizeof(struct keywest_iface) + | 536 | tsize = sizeof(struct keywest_iface) + |
537 | (sizeof(struct keywest_chan) + 4) * nchan; | 537 | (sizeof(struct keywest_chan) + 4) * nchan; |
538 | iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL); | 538 | iface = kzalloc(tsize, GFP_KERNEL); |
539 | if (iface == NULL) { | 539 | if (iface == NULL) { |
540 | printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); | 540 | printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); |
541 | pmac_low_i2c_unlock(np); | 541 | pmac_low_i2c_unlock(np); |
542 | return -ENOMEM; | 542 | return -ENOMEM; |
543 | } | 543 | } |
544 | memset(iface, 0, tsize); | ||
545 | spin_lock_init(&iface->lock); | 544 | spin_lock_init(&iface->lock); |
546 | init_completion(&iface->complete); | 545 | init_completion(&iface->complete); |
547 | iface->node = of_node_get(np); | 546 | iface->node = of_node_get(np); |
@@ -716,6 +715,7 @@ static struct of_device_id i2c_keywest_match[] = | |||
716 | 715 | ||
717 | static struct macio_driver i2c_keywest_macio_driver = | 716 | static struct macio_driver i2c_keywest_macio_driver = |
718 | { | 717 | { |
718 | .owner = THIS_MODULE, | ||
719 | .name = "i2c-keywest", | 719 | .name = "i2c-keywest", |
720 | .match_table = i2c_keywest_match, | 720 | .match_table = i2c_keywest_match, |
721 | .probe = create_iface_macio, | 721 | .probe = create_iface_macio, |
@@ -724,6 +724,7 @@ static struct macio_driver i2c_keywest_macio_driver = | |||
724 | 724 | ||
725 | static struct of_platform_driver i2c_keywest_of_platform_driver = | 725 | static struct of_platform_driver i2c_keywest_of_platform_driver = |
726 | { | 726 | { |
727 | .owner = THIS_MODULE, | ||
727 | .name = "i2c-keywest", | 728 | .name = "i2c-keywest", |
728 | .match_table = i2c_keywest_match, | 729 | .match_table = i2c_keywest_match, |
729 | .probe = create_iface_of_platform, | 730 | .probe = create_iface_of_platform, |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index f065583ddcf1..8491633005b8 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -296,10 +296,9 @@ static int fsl_i2c_probe(struct device *device) | |||
296 | 296 | ||
297 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | 297 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; |
298 | 298 | ||
299 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | 299 | if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) { |
300 | return -ENOMEM; | 300 | return -ENOMEM; |
301 | } | 301 | } |
302 | memset(i2c, 0, sizeof(*i2c)); | ||
303 | 302 | ||
304 | i2c->irq = platform_get_irq(pdev, 0); | 303 | i2c->irq = platform_get_irq(pdev, 0); |
305 | i2c->flags = pdata->device_flags; | 304 | i2c->flags = pdata->device_flags; |
@@ -361,6 +360,7 @@ static int fsl_i2c_remove(struct device *device) | |||
361 | 360 | ||
362 | /* Structure for a device driver */ | 361 | /* Structure for a device driver */ |
363 | static struct device_driver fsl_i2c_driver = { | 362 | static struct device_driver fsl_i2c_driver = { |
363 | .owner = THIS_MODULE, | ||
364 | .name = "fsl-i2c", | 364 | .name = "fsl-i2c", |
365 | .bus = &platform_bus_type, | 365 | .bus = &platform_bus_type, |
366 | .probe = fsl_i2c_probe, | 366 | .probe = fsl_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 99abca45fece..d0d2a6f1386e 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -500,13 +500,10 @@ mv64xxx_i2c_probe(struct device *dev) | |||
500 | if ((pd->id != 0) || !pdata) | 500 | if ((pd->id != 0) || !pdata) |
501 | return -ENODEV; | 501 | return -ENODEV; |
502 | 502 | ||
503 | drv_data = kmalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); | 503 | drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); |
504 | |||
505 | if (!drv_data) | 504 | if (!drv_data) |
506 | return -ENOMEM; | 505 | return -ENOMEM; |
507 | 506 | ||
508 | memset(drv_data, 0, sizeof(struct mv64xxx_i2c_data)); | ||
509 | |||
510 | if (mv64xxx_i2c_map_regs(pd, drv_data)) { | 507 | if (mv64xxx_i2c_map_regs(pd, drv_data)) { |
511 | rc = -ENODEV; | 508 | rc = -ENODEV; |
512 | goto exit_kfree; | 509 | goto exit_kfree; |
@@ -570,6 +567,7 @@ mv64xxx_i2c_remove(struct device *dev) | |||
570 | } | 567 | } |
571 | 568 | ||
572 | static struct device_driver mv64xxx_i2c_driver = { | 569 | static struct device_driver mv64xxx_i2c_driver = { |
570 | .owner = THIS_MODULE, | ||
573 | .name = MV64XXX_I2C_CTLR_NAME, | 571 | .name = MV64XXX_I2C_CTLR_NAME, |
574 | .bus = &platform_bus_type, | 572 | .bus = &platform_bus_type, |
575 | .probe = mv64xxx_i2c_probe, | 573 | .probe = mv64xxx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index fe9c0f42a2b7..fd26036e68a3 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -97,6 +97,7 @@ struct nforce2_smbus { | |||
97 | #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a | 97 | #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a |
98 | #define NVIDIA_SMB_PRTCL_PEC 0x80 | 98 | #define NVIDIA_SMB_PRTCL_PEC 0x80 |
99 | 99 | ||
100 | static struct pci_driver nforce2_driver; | ||
100 | 101 | ||
101 | static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, | 102 | static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, |
102 | unsigned short flags, char read_write, | 103 | unsigned short flags, char read_write, |
@@ -113,7 +114,6 @@ static struct i2c_adapter nforce2_adapter = { | |||
113 | .owner = THIS_MODULE, | 114 | .owner = THIS_MODULE, |
114 | .class = I2C_CLASS_HWMON, | 115 | .class = I2C_CLASS_HWMON, |
115 | .algo = &smbus_algorithm, | 116 | .algo = &smbus_algorithm, |
116 | .name = "unset", | ||
117 | }; | 117 | }; |
118 | 118 | ||
119 | /* Return -1 on error. See smbus.h for more information */ | 119 | /* Return -1 on error. See smbus.h for more information */ |
@@ -188,13 +188,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
188 | dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); | 188 | dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); |
189 | return -1; | 189 | return -1; |
190 | 190 | ||
191 | case I2C_SMBUS_WORD_DATA_PEC: | ||
192 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
193 | case I2C_SMBUS_PROC_CALL_PEC: | ||
194 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
195 | dev_err(&adap->dev, "Unexpected software PEC transaction %d\n.", size); | ||
196 | return -1; | ||
197 | |||
198 | default: | 191 | default: |
199 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); | 192 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); |
200 | return -1; | 193 | return -1; |
@@ -285,7 +278,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int reg, | |||
285 | smbus->base = iobase & 0xfffc; | 278 | smbus->base = iobase & 0xfffc; |
286 | smbus->size = 8; | 279 | smbus->size = 8; |
287 | 280 | ||
288 | if (!request_region(smbus->base, smbus->size, "nForce2 SMBus")) { | 281 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { |
289 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", | 282 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", |
290 | smbus->base, smbus->base+smbus->size-1, name); | 283 | smbus->base, smbus->base+smbus->size-1, name); |
291 | return -1; | 284 | return -1; |
@@ -313,10 +306,8 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_ | |||
313 | int res1, res2; | 306 | int res1, res2; |
314 | 307 | ||
315 | /* we support 2 SMBus adapters */ | 308 | /* we support 2 SMBus adapters */ |
316 | if (!(smbuses = (void *)kmalloc(2*sizeof(struct nforce2_smbus), | 309 | if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL))) |
317 | GFP_KERNEL))) | ||
318 | return -ENOMEM; | 310 | return -ENOMEM; |
319 | memset (smbuses, 0, 2*sizeof(struct nforce2_smbus)); | ||
320 | pci_set_drvdata(dev, smbuses); | 311 | pci_set_drvdata(dev, smbuses); |
321 | 312 | ||
322 | /* SMBus adapter 1 */ | 313 | /* SMBus adapter 1 */ |
@@ -356,6 +347,7 @@ static void __devexit nforce2_remove(struct pci_dev *dev) | |||
356 | } | 347 | } |
357 | 348 | ||
358 | static struct pci_driver nforce2_driver = { | 349 | static struct pci_driver nforce2_driver = { |
350 | .owner = THIS_MODULE, | ||
359 | .name = "nForce2_smbus", | 351 | .name = "nForce2_smbus", |
360 | .id_table = nforce2_ids, | 352 | .id_table = nforce2_ids, |
361 | .probe = nforce2_probe, | 353 | .probe = nforce2_probe, |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 71a2502fe069..2854d858fc9b 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -155,12 +155,11 @@ static void i2c_parport_attach (struct parport *port) | |||
155 | { | 155 | { |
156 | struct i2c_par *adapter; | 156 | struct i2c_par *adapter; |
157 | 157 | ||
158 | adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL); | 158 | adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); |
159 | if (adapter == NULL) { | 159 | if (adapter == NULL) { |
160 | printk(KERN_ERR "i2c-parport: Failed to kmalloc\n"); | 160 | printk(KERN_ERR "i2c-parport: Failed to kzalloc\n"); |
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | memset(adapter, 0x00, sizeof(struct i2c_par)); | ||
164 | 163 | ||
165 | pr_debug("i2c-parport: attaching to %s\n", port->name); | 164 | pr_debug("i2c-parport: attaching to %s\n", port->name); |
166 | adapter->pdev = parport_register_device(port, "i2c-parport", | 165 | adapter->pdev = parport_register_device(port, "i2c-parport", |
@@ -232,7 +231,7 @@ static void i2c_parport_detach (struct parport *port) | |||
232 | } | 231 | } |
233 | } | 232 | } |
234 | 233 | ||
235 | static struct parport_driver i2c_driver = { | 234 | static struct parport_driver i2c_parport_driver = { |
236 | .name = "i2c-parport", | 235 | .name = "i2c-parport", |
237 | .attach = i2c_parport_attach, | 236 | .attach = i2c_parport_attach, |
238 | .detach = i2c_parport_detach, | 237 | .detach = i2c_parport_detach, |
@@ -250,12 +249,12 @@ static int __init i2c_parport_init(void) | |||
250 | type = 0; | 249 | type = 0; |
251 | } | 250 | } |
252 | 251 | ||
253 | return parport_register_driver(&i2c_driver); | 252 | return parport_register_driver(&i2c_parport_driver); |
254 | } | 253 | } |
255 | 254 | ||
256 | static void __exit i2c_parport_exit(void) | 255 | static void __exit i2c_parport_exit(void) |
257 | { | 256 | { |
258 | parport_unregister_driver(&i2c_driver); | 257 | parport_unregister_driver(&i2c_parport_driver); |
259 | } | 258 | } |
260 | 259 | ||
261 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | 260 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 6d48a4da7bed..7d63eec423fe 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -90,13 +90,13 @@ struct sd { | |||
90 | 90 | ||
91 | /* If force is set to anything different from 0, we forcibly enable the | 91 | /* If force is set to anything different from 0, we forcibly enable the |
92 | PIIX4. DANGEROUS! */ | 92 | PIIX4. DANGEROUS! */ |
93 | static int force = 0; | 93 | static int force; |
94 | module_param (force, int, 0); | 94 | module_param (force, int, 0); |
95 | MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!"); | 95 | MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!"); |
96 | 96 | ||
97 | /* If force_addr is set to anything different from 0, we forcibly enable | 97 | /* If force_addr is set to anything different from 0, we forcibly enable |
98 | the PIIX4 at the given address. VERY DANGEROUS! */ | 98 | the PIIX4 at the given address. VERY DANGEROUS! */ |
99 | static int force_addr = 0; | 99 | static int force_addr; |
100 | module_param (force_addr, int, 0); | 100 | module_param (force_addr, int, 0); |
101 | MODULE_PARM_DESC(force_addr, | 101 | MODULE_PARM_DESC(force_addr, |
102 | "Forcibly enable the PIIX4 at the given address. " | 102 | "Forcibly enable the PIIX4 at the given address. " |
@@ -104,14 +104,15 @@ MODULE_PARM_DESC(force_addr, | |||
104 | 104 | ||
105 | /* If fix_hstcfg is set to anything different from 0, we reset one of the | 105 | /* If fix_hstcfg is set to anything different from 0, we reset one of the |
106 | registers to be a valid value. */ | 106 | registers to be a valid value. */ |
107 | static int fix_hstcfg = 0; | 107 | static int fix_hstcfg; |
108 | module_param (fix_hstcfg, int, 0); | 108 | module_param (fix_hstcfg, int, 0); |
109 | MODULE_PARM_DESC(fix_hstcfg, | 109 | MODULE_PARM_DESC(fix_hstcfg, |
110 | "Fix config register. Needed on some boards (Force CPCI735)."); | 110 | "Fix config register. Needed on some boards (Force CPCI735)."); |
111 | 111 | ||
112 | static int piix4_transaction(void); | 112 | static int piix4_transaction(void); |
113 | 113 | ||
114 | static unsigned short piix4_smba = 0; | 114 | static unsigned short piix4_smba; |
115 | static struct pci_driver piix4_driver; | ||
115 | static struct i2c_adapter piix4_adapter; | 116 | static struct i2c_adapter piix4_adapter; |
116 | 117 | ||
117 | static struct dmi_system_id __devinitdata piix4_dmi_table[] = { | 118 | static struct dmi_system_id __devinitdata piix4_dmi_table[] = { |
@@ -157,7 +158,7 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, | |||
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | if (!request_region(piix4_smba, SMBIOSIZE, "piix4-smbus")) { | 161 | if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { |
161 | dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", | 162 | dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", |
162 | piix4_smba); | 163 | piix4_smba); |
163 | return -ENODEV; | 164 | return -ENODEV; |
@@ -407,7 +408,6 @@ static struct i2c_adapter piix4_adapter = { | |||
407 | .owner = THIS_MODULE, | 408 | .owner = THIS_MODULE, |
408 | .class = I2C_CLASS_HWMON, | 409 | .class = I2C_CLASS_HWMON, |
409 | .algo = &smbus_algorithm, | 410 | .algo = &smbus_algorithm, |
410 | .name = "unset", | ||
411 | }; | 411 | }; |
412 | 412 | ||
413 | static struct pci_device_id piix4_ids[] = { | 413 | static struct pci_device_id piix4_ids[] = { |
@@ -462,6 +462,7 @@ static void __devexit piix4_remove(struct pci_dev *dev) | |||
462 | } | 462 | } |
463 | 463 | ||
464 | static struct pci_driver piix4_driver = { | 464 | static struct pci_driver piix4_driver = { |
465 | .owner = THIS_MODULE, | ||
465 | .name = "piix4_smbus", | 466 | .name = "piix4_smbus", |
466 | .id_table = piix4_ids, | 467 | .id_table = piix4_ids, |
467 | .probe = piix4_probe, | 468 | .probe = piix4_probe, |
diff --git a/drivers/i2c/busses/i2c-pmac-smu.c b/drivers/i2c/busses/i2c-pmac-smu.c index 8a9f5648a23d..bfefe7f7a53d 100644 --- a/drivers/i2c/busses/i2c-pmac-smu.c +++ b/drivers/i2c/busses/i2c-pmac-smu.c | |||
@@ -211,12 +211,11 @@ static int create_iface(struct device_node *np, struct device *dev) | |||
211 | } | 211 | } |
212 | busid = *reg; | 212 | busid = *reg; |
213 | 213 | ||
214 | iface = kmalloc(sizeof(struct smu_iface), GFP_KERNEL); | 214 | iface = kzalloc(sizeof(struct smu_iface), GFP_KERNEL); |
215 | if (iface == NULL) { | 215 | if (iface == NULL) { |
216 | printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n"); | 216 | printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n"); |
217 | return -ENOMEM; | 217 | return -ENOMEM; |
218 | } | 218 | } |
219 | memset(iface, 0, sizeof(struct smu_iface)); | ||
220 | init_completion(&iface->complete); | 219 | init_completion(&iface->complete); |
221 | iface->busid = busid; | 220 | iface->busid = busid; |
222 | 221 | ||
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index 83fd16d61ce5..42cb1d8ca659 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c | |||
@@ -83,11 +83,6 @@ struct s_i2c_chip { | |||
83 | /* | 83 | /* |
84 | * i2c configuration | 84 | * i2c configuration |
85 | */ | 85 | */ |
86 | #ifndef I2C_HW_B_S3VIA | ||
87 | #define I2C_HW_B_S3VIA 0x18 /* S3VIA ProSavage adapter */ | ||
88 | #endif | ||
89 | |||
90 | /* delays */ | ||
91 | #define CYCLE_DELAY 10 | 86 | #define CYCLE_DELAY 10 |
92 | #define TIMEOUT (HZ / 2) | 87 | #define TIMEOUT (HZ / 2) |
93 | 88 | ||
@@ -241,14 +236,12 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic | |||
241 | struct s_i2c_chip *chip; | 236 | struct s_i2c_chip *chip; |
242 | struct s_i2c_bus *bus; | 237 | struct s_i2c_bus *bus; |
243 | 238 | ||
244 | pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); | 239 | pci_set_drvdata(dev, kzalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); |
245 | chip = (struct s_i2c_chip *)pci_get_drvdata(dev); | 240 | chip = (struct s_i2c_chip *)pci_get_drvdata(dev); |
246 | if (chip == NULL) { | 241 | if (chip == NULL) { |
247 | return -ENOMEM; | 242 | return -ENOMEM; |
248 | } | 243 | } |
249 | 244 | ||
250 | memset(chip, 0, sizeof(struct s_i2c_chip)); | ||
251 | |||
252 | base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK; | 245 | base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK; |
253 | len = dev->resource[0].end - base + 1; | 246 | len = dev->resource[0].end - base + 1; |
254 | chip->mmio = ioremap_nocache(base, len); | 247 | chip->mmio = ioremap_nocache(base, len); |
@@ -308,6 +301,7 @@ static struct pci_device_id prosavage_pci_tbl[] = { | |||
308 | MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); | 301 | MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); |
309 | 302 | ||
310 | static struct pci_driver prosavage_driver = { | 303 | static struct pci_driver prosavage_driver = { |
304 | .owner = THIS_MODULE, | ||
311 | .name = "prosavage_smbus", | 305 | .name = "prosavage_smbus", |
312 | .id_table = prosavage_pci_tbl, | 306 | .id_table = prosavage_pci_tbl, |
313 | .probe = prosavage_probe, | 307 | .probe = prosavage_probe, |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 73a092fb0e7e..6ced28e90070 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -879,14 +879,12 @@ static int s3c24xx_i2c_remove(struct device *dev) | |||
879 | } | 879 | } |
880 | 880 | ||
881 | #ifdef CONFIG_PM | 881 | #ifdef CONFIG_PM |
882 | static int s3c24xx_i2c_resume(struct device *dev, u32 level) | 882 | static int s3c24xx_i2c_resume(struct device *dev) |
883 | { | 883 | { |
884 | struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); | 884 | struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); |
885 | 885 | ||
886 | if (i2c != NULL && level == RESUME_ENABLE) { | 886 | if (i2c != NULL) |
887 | dev_dbg(dev, "resume: level %d\n", level); | ||
888 | s3c24xx_i2c_init(i2c); | 887 | s3c24xx_i2c_init(i2c); |
889 | } | ||
890 | 888 | ||
891 | return 0; | 889 | return 0; |
892 | } | 890 | } |
@@ -898,6 +896,7 @@ static int s3c24xx_i2c_resume(struct device *dev, u32 level) | |||
898 | /* device driver for platform bus bits */ | 896 | /* device driver for platform bus bits */ |
899 | 897 | ||
900 | static struct device_driver s3c2410_i2c_driver = { | 898 | static struct device_driver s3c2410_i2c_driver = { |
899 | .owner = THIS_MODULE, | ||
901 | .name = "s3c2410-i2c", | 900 | .name = "s3c2410-i2c", |
902 | .bus = &platform_bus_type, | 901 | .bus = &platform_bus_type, |
903 | .probe = s3c24xx_i2c_probe, | 902 | .probe = s3c24xx_i2c_probe, |
@@ -906,6 +905,7 @@ static struct device_driver s3c2410_i2c_driver = { | |||
906 | }; | 905 | }; |
907 | 906 | ||
908 | static struct device_driver s3c2440_i2c_driver = { | 907 | static struct device_driver s3c2440_i2c_driver = { |
908 | .owner = THIS_MODULE, | ||
909 | .name = "s3c2440-i2c", | 909 | .name = "s3c2440-i2c", |
910 | .bus = &platform_bus_type, | 910 | .bus = &platform_bus_type, |
911 | .probe = s3c24xx_i2c_probe, | 911 | .probe = s3c24xx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 0c8518298e4d..aebe87ba4033 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -179,6 +179,7 @@ static void __devexit savage4_remove(struct pci_dev *dev) | |||
179 | } | 179 | } |
180 | 180 | ||
181 | static struct pci_driver savage4_driver = { | 181 | static struct pci_driver savage4_driver = { |
182 | .owner = THIS_MODULE, | ||
182 | .name = "savage4_smbus", | 183 | .name = "savage4_smbus", |
183 | .id_table = savage4_ids, | 184 | .id_table = savage4_ids, |
184 | .probe = savage4_probe, | 185 | .probe = savage4_probe, |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 080318d6f54b..3ad27c3ba15b 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -123,11 +123,12 @@ static int blacklist[] = { | |||
123 | 123 | ||
124 | /* If force_addr is set to anything different from 0, we forcibly enable | 124 | /* If force_addr is set to anything different from 0, we forcibly enable |
125 | the device at the given address. */ | 125 | the device at the given address. */ |
126 | static u16 force_addr = 0; | 126 | static u16 force_addr; |
127 | module_param(force_addr, ushort, 0); | 127 | module_param(force_addr, ushort, 0); |
128 | MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); | 128 | MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); |
129 | 129 | ||
130 | static unsigned short sis5595_base = 0; | 130 | static struct pci_driver sis5595_driver; |
131 | static unsigned short sis5595_base; | ||
131 | 132 | ||
132 | static u8 sis5595_read(u8 reg) | 133 | static u8 sis5595_read(u8 reg) |
133 | { | 134 | { |
@@ -172,7 +173,8 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) | |||
172 | 173 | ||
173 | /* NB: We grab just the two SMBus registers here, but this may still | 174 | /* NB: We grab just the two SMBus registers here, but this may still |
174 | * interfere with ACPI :-( */ | 175 | * interfere with ACPI :-( */ |
175 | if (!request_region(sis5595_base + SMB_INDEX, 2, "sis5595-smbus")) { | 176 | if (!request_region(sis5595_base + SMB_INDEX, 2, |
177 | sis5595_driver.name)) { | ||
176 | dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", | 178 | dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", |
177 | sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1); | 179 | sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1); |
178 | return -ENODEV; | 180 | return -ENODEV; |
@@ -364,7 +366,6 @@ static struct i2c_algorithm smbus_algorithm = { | |||
364 | static struct i2c_adapter sis5595_adapter = { | 366 | static struct i2c_adapter sis5595_adapter = { |
365 | .owner = THIS_MODULE, | 367 | .owner = THIS_MODULE, |
366 | .class = I2C_CLASS_HWMON, | 368 | .class = I2C_CLASS_HWMON, |
367 | .name = "unset", | ||
368 | .algo = &smbus_algorithm, | 369 | .algo = &smbus_algorithm, |
369 | }; | 370 | }; |
370 | 371 | ||
@@ -397,6 +398,7 @@ static void __devexit sis5595_remove(struct pci_dev *dev) | |||
397 | } | 398 | } |
398 | 399 | ||
399 | static struct pci_driver sis5595_driver = { | 400 | static struct pci_driver sis5595_driver = { |
401 | .owner = THIS_MODULE, | ||
400 | .name = "sis5595_smbus", | 402 | .name = "sis5595_smbus", |
401 | .id_table = sis5595_ids, | 403 | .id_table = sis5595_ids, |
402 | .probe = sis5595_probe, | 404 | .probe = sis5595_probe, |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 86f0f448fa0b..7f49e5fd3ff0 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -92,6 +92,8 @@ | |||
92 | #define SIS630_PCALL 0x04 | 92 | #define SIS630_PCALL 0x04 |
93 | #define SIS630_BLOCK_DATA 0x05 | 93 | #define SIS630_BLOCK_DATA 0x05 |
94 | 94 | ||
95 | static struct pci_driver sis630_driver; | ||
96 | |||
95 | /* insmod parameters */ | 97 | /* insmod parameters */ |
96 | static int high_clock; | 98 | static int high_clock; |
97 | static int force; | 99 | static int force; |
@@ -101,7 +103,7 @@ module_param(force, bool, 0); | |||
101 | MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); | 103 | MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); |
102 | 104 | ||
103 | /* acpi base address */ | 105 | /* acpi base address */ |
104 | static unsigned short acpi_base = 0; | 106 | static unsigned short acpi_base; |
105 | 107 | ||
106 | /* supported chips */ | 108 | /* supported chips */ |
107 | static int supported[] = { | 109 | static int supported[] = { |
@@ -432,7 +434,8 @@ static int sis630_setup(struct pci_dev *sis630_dev) | |||
432 | dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); | 434 | dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); |
433 | 435 | ||
434 | /* Everything is happy, let's grab the memory and set things up. */ | 436 | /* Everything is happy, let's grab the memory and set things up. */ |
435 | if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus")) { | 437 | if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, |
438 | sis630_driver.name)) { | ||
436 | dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " | 439 | dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " |
437 | "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); | 440 | "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); |
438 | goto exit; | 441 | goto exit; |
@@ -455,7 +458,6 @@ static struct i2c_algorithm smbus_algorithm = { | |||
455 | static struct i2c_adapter sis630_adapter = { | 458 | static struct i2c_adapter sis630_adapter = { |
456 | .owner = THIS_MODULE, | 459 | .owner = THIS_MODULE, |
457 | .class = I2C_CLASS_HWMON, | 460 | .class = I2C_CLASS_HWMON, |
458 | .name = "unset", | ||
459 | .algo = &smbus_algorithm, | 461 | .algo = &smbus_algorithm, |
460 | }; | 462 | }; |
461 | 463 | ||
@@ -494,6 +496,7 @@ static void __devexit sis630_remove(struct pci_dev *dev) | |||
494 | 496 | ||
495 | 497 | ||
496 | static struct pci_driver sis630_driver = { | 498 | static struct pci_driver sis630_driver = { |
499 | .owner = THIS_MODULE, | ||
497 | .name = "sis630_smbus", | 500 | .name = "sis630_smbus", |
498 | .id_table = sis630_ids, | 501 | .id_table = sis630_ids, |
499 | .probe = sis630_probe, | 502 | .probe = sis630_probe, |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index ead2ff3cf60e..6a134c091324 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -82,8 +82,9 @@ | |||
82 | #define SIS96x_PROC_CALL 0x04 | 82 | #define SIS96x_PROC_CALL 0x04 |
83 | #define SIS96x_BLOCK_DATA 0x05 | 83 | #define SIS96x_BLOCK_DATA 0x05 |
84 | 84 | ||
85 | static struct pci_driver sis96x_driver; | ||
85 | static struct i2c_adapter sis96x_adapter; | 86 | static struct i2c_adapter sis96x_adapter; |
86 | static u16 sis96x_smbus_base = 0; | 87 | static u16 sis96x_smbus_base; |
87 | 88 | ||
88 | static inline u8 sis96x_read(u8 reg) | 89 | static inline u8 sis96x_read(u8 reg) |
89 | { | 90 | { |
@@ -257,7 +258,6 @@ static struct i2c_adapter sis96x_adapter = { | |||
257 | .owner = THIS_MODULE, | 258 | .owner = THIS_MODULE, |
258 | .class = I2C_CLASS_HWMON, | 259 | .class = I2C_CLASS_HWMON, |
259 | .algo = &smbus_algorithm, | 260 | .algo = &smbus_algorithm, |
260 | .name = "unset", | ||
261 | }; | 261 | }; |
262 | 262 | ||
263 | static struct pci_device_id sis96x_ids[] = { | 263 | static struct pci_device_id sis96x_ids[] = { |
@@ -294,7 +294,8 @@ static int __devinit sis96x_probe(struct pci_dev *dev, | |||
294 | sis96x_smbus_base); | 294 | sis96x_smbus_base); |
295 | 295 | ||
296 | /* Everything is happy, let's grab the memory and set things up. */ | 296 | /* Everything is happy, let's grab the memory and set things up. */ |
297 | if (!request_region(sis96x_smbus_base, SMB_IOSIZE, "sis96x-smbus")) { | 297 | if (!request_region(sis96x_smbus_base, SMB_IOSIZE, |
298 | sis96x_driver.name)) { | ||
298 | dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x " | 299 | dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x " |
299 | "already in use!\n", sis96x_smbus_base, | 300 | "already in use!\n", sis96x_smbus_base, |
300 | sis96x_smbus_base + SMB_IOSIZE - 1); | 301 | sis96x_smbus_base + SMB_IOSIZE - 1); |
@@ -328,6 +329,7 @@ static void __devexit sis96x_remove(struct pci_dev *dev) | |||
328 | } | 329 | } |
329 | 330 | ||
330 | static struct pci_driver sis96x_driver = { | 331 | static struct pci_driver sis96x_driver = { |
332 | .owner = THIS_MODULE, | ||
331 | .name = "sis96x_smbus", | 333 | .name = "sis96x_smbus", |
332 | .id_table = sis96x_ids, | 334 | .id_table = sis96x_ids, |
333 | .probe = sis96x_probe, | 335 | .probe = sis96x_probe, |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 040b8abeabba..544a38e64394 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -43,9 +43,9 @@ | |||
43 | 43 | ||
44 | /* io-region reservation */ | 44 | /* io-region reservation */ |
45 | #define IOSPACE 0x06 | 45 | #define IOSPACE 0x06 |
46 | #define IOTEXT "via-i2c" | ||
47 | 46 | ||
48 | static u16 pm_io_base = 0; | 47 | static struct pci_driver vt586b_driver; |
48 | static u16 pm_io_base; | ||
49 | 49 | ||
50 | /* | 50 | /* |
51 | It does not appear from the datasheet that the GPIO pins are | 51 | It does not appear from the datasheet that the GPIO pins are |
@@ -130,7 +130,7 @@ static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_i | |||
130 | pci_read_config_word(dev, base, &pm_io_base); | 130 | pci_read_config_word(dev, base, &pm_io_base); |
131 | pm_io_base &= (0xff << 8); | 131 | pm_io_base &= (0xff << 8); |
132 | 132 | ||
133 | if (!request_region(I2C_DIR, IOSPACE, IOTEXT)) { | 133 | if (!request_region(I2C_DIR, IOSPACE, vt586b_driver.name)) { |
134 | dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE); | 134 | dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE); |
135 | return -ENODEV; | 135 | return -ENODEV; |
136 | } | 136 | } |
@@ -159,6 +159,7 @@ static void __devexit vt586b_remove(struct pci_dev *dev) | |||
159 | 159 | ||
160 | 160 | ||
161 | static struct pci_driver vt586b_driver = { | 161 | static struct pci_driver vt586b_driver = { |
162 | .owner = THIS_MODULE, | ||
162 | .name = "vt586b_smbus", | 163 | .name = "vt586b_smbus", |
163 | .id_table = vt586b_ids, | 164 | .id_table = vt586b_ids, |
164 | .probe = vt586b_probe, | 165 | .probe = vt586b_probe, |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 99d209e0485a..c9366b504833 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | monitoring |
4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
5 | Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, | 5 | Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, |
6 | Mark D. Studebaker <mdsxyz123@yahoo.com> | 6 | Mark D. Studebaker <mdsxyz123@yahoo.com> |
7 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | ||
7 | 8 | ||
8 | This program is free software; you can redistribute it and/or modify | 9 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 10 | it under the terms of the GNU General Public License as published by |
@@ -21,15 +22,19 @@ | |||
21 | */ | 22 | */ |
22 | 23 | ||
23 | /* | 24 | /* |
24 | Supports Via devices: | 25 | Supports the following VIA south bridges: |
25 | 82C596A/B (0x3050) | 26 | |
26 | 82C596B (0x3051) | 27 | Chip name PCI ID REV I2C block |
27 | 82C686A/B | 28 | VT82C596A 0x3050 no |
28 | 8231 | 29 | VT82C596B 0x3051 no |
29 | 8233 | 30 | VT82C686A 0x3057 0x30 no |
30 | 8233A (0x3147 and 0x3177) | 31 | VT82C686B 0x3057 0x40 yes |
31 | 8235 | 32 | VT8231 0x8235 no? |
32 | 8237 | 33 | VT8233 0x3074 yes |
34 | VT8233A 0x3147 yes? | ||
35 | VT8235 0x3177 yes | ||
36 | VT8237R 0x3227 yes | ||
37 | |||
33 | Note: we assume there can only be one device, with one SMBus interface. | 38 | Note: we assume there can only be one device, with one SMBus interface. |
34 | */ | 39 | */ |
35 | 40 | ||
@@ -38,7 +43,6 @@ | |||
38 | #include <linux/pci.h> | 43 | #include <linux/pci.h> |
39 | #include <linux/kernel.h> | 44 | #include <linux/kernel.h> |
40 | #include <linux/stddef.h> | 45 | #include <linux/stddef.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/ioport.h> | 46 | #include <linux/ioport.h> |
43 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
44 | #include <linux/init.h> | 48 | #include <linux/init.h> |
@@ -46,48 +50,37 @@ | |||
46 | 50 | ||
47 | static struct pci_dev *vt596_pdev; | 51 | static struct pci_dev *vt596_pdev; |
48 | 52 | ||
49 | #define SMBBA1 0x90 | 53 | #define SMBBA1 0x90 |
50 | #define SMBBA2 0x80 | 54 | #define SMBBA2 0x80 |
51 | #define SMBBA3 0xD0 | 55 | #define SMBBA3 0xD0 |
52 | 56 | ||
53 | /* SMBus address offsets */ | 57 | /* SMBus address offsets */ |
54 | static unsigned short vt596_smba; | 58 | static unsigned short vt596_smba; |
55 | #define SMBHSTSTS (vt596_smba + 0) | 59 | #define SMBHSTSTS (vt596_smba + 0) |
56 | #define SMBHSLVSTS (vt596_smba + 1) | ||
57 | #define SMBHSTCNT (vt596_smba + 2) | 60 | #define SMBHSTCNT (vt596_smba + 2) |
58 | #define SMBHSTCMD (vt596_smba + 3) | 61 | #define SMBHSTCMD (vt596_smba + 3) |
59 | #define SMBHSTADD (vt596_smba + 4) | 62 | #define SMBHSTADD (vt596_smba + 4) |
60 | #define SMBHSTDAT0 (vt596_smba + 5) | 63 | #define SMBHSTDAT0 (vt596_smba + 5) |
61 | #define SMBHSTDAT1 (vt596_smba + 6) | 64 | #define SMBHSTDAT1 (vt596_smba + 6) |
62 | #define SMBBLKDAT (vt596_smba + 7) | 65 | #define SMBBLKDAT (vt596_smba + 7) |
63 | #define SMBSLVCNT (vt596_smba + 8) | ||
64 | #define SMBSHDWCMD (vt596_smba + 9) | ||
65 | #define SMBSLVEVT (vt596_smba + 0xA) | ||
66 | #define SMBSLVDAT (vt596_smba + 0xC) | ||
67 | 66 | ||
68 | /* PCI Address Constants */ | 67 | /* PCI Address Constants */ |
69 | 68 | ||
70 | /* SMBus data in configuration space can be found in two places, | 69 | /* SMBus data in configuration space can be found in two places, |
71 | We try to select the better one*/ | 70 | We try to select the better one */ |
72 | |||
73 | static unsigned short smb_cf_hstcfg = 0xD2; | ||
74 | 71 | ||
75 | #define SMBHSTCFG (smb_cf_hstcfg) | 72 | static unsigned short SMBHSTCFG = 0xD2; |
76 | #define SMBSLVC (smb_cf_hstcfg + 1) | ||
77 | #define SMBSHDW1 (smb_cf_hstcfg + 2) | ||
78 | #define SMBSHDW2 (smb_cf_hstcfg + 3) | ||
79 | #define SMBREV (smb_cf_hstcfg + 4) | ||
80 | 73 | ||
81 | /* Other settings */ | 74 | /* Other settings */ |
82 | #define MAX_TIMEOUT 500 | 75 | #define MAX_TIMEOUT 500 |
83 | #define ENABLE_INT9 0 | ||
84 | 76 | ||
85 | /* VT82C596 constants */ | 77 | /* VT82C596 constants */ |
86 | #define VT596_QUICK 0x00 | 78 | #define VT596_QUICK 0x00 |
87 | #define VT596_BYTE 0x04 | 79 | #define VT596_BYTE 0x04 |
88 | #define VT596_BYTE_DATA 0x08 | 80 | #define VT596_BYTE_DATA 0x08 |
89 | #define VT596_WORD_DATA 0x0C | 81 | #define VT596_WORD_DATA 0x0C |
90 | #define VT596_BLOCK_DATA 0x14 | 82 | #define VT596_BLOCK_DATA 0x14 |
83 | #define VT596_I2C_BLOCK_DATA 0x34 | ||
91 | 84 | ||
92 | 85 | ||
93 | /* If force is set to anything different from 0, we forcibly enable the | 86 | /* If force is set to anything different from 0, we forcibly enable the |
@@ -105,40 +98,65 @@ MODULE_PARM_DESC(force_addr, | |||
105 | "EXTREMELY DANGEROUS!"); | 98 | "EXTREMELY DANGEROUS!"); |
106 | 99 | ||
107 | 100 | ||
101 | static struct pci_driver vt596_driver; | ||
108 | static struct i2c_adapter vt596_adapter; | 102 | static struct i2c_adapter vt596_adapter; |
109 | 103 | ||
110 | /* Another internally used function */ | 104 | #define FEATURE_I2CBLOCK (1<<0) |
111 | static int vt596_transaction(void) | 105 | static unsigned int vt596_features; |
106 | |||
107 | #ifdef DEBUG | ||
108 | static void vt596_dump_regs(const char *msg, u8 size) | ||
109 | { | ||
110 | dev_dbg(&vt596_adapter.dev, "%s: STS=%02x CNT=%02x CMD=%02x ADD=%02x " | ||
111 | "DAT=%02x,%02x\n", msg, inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), | ||
112 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | ||
113 | inb_p(SMBHSTDAT1)); | ||
114 | |||
115 | if (size == VT596_BLOCK_DATA | ||
116 | || size == VT596_I2C_BLOCK_DATA) { | ||
117 | int i; | ||
118 | |||
119 | dev_dbg(&vt596_adapter.dev, "BLK="); | ||
120 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX / 2; i++) | ||
121 | printk("%02x,", inb_p(SMBBLKDAT)); | ||
122 | printk("\n"); | ||
123 | dev_dbg(&vt596_adapter.dev, " "); | ||
124 | for (; i < I2C_SMBUS_BLOCK_MAX - 1; i++) | ||
125 | printk("%02x,", inb_p(SMBBLKDAT)); | ||
126 | printk("%02x\n", inb_p(SMBBLKDAT)); | ||
127 | } | ||
128 | } | ||
129 | #else | ||
130 | static inline void vt596_dump_regs(const char *msg, u8 size) { } | ||
131 | #endif | ||
132 | |||
133 | /* Return -1 on error, 0 on success */ | ||
134 | static int vt596_transaction(u8 size) | ||
112 | { | 135 | { |
113 | int temp; | 136 | int temp; |
114 | int result = 0; | 137 | int result = 0; |
115 | int timeout = 0; | 138 | int timeout = 0; |
116 | 139 | ||
117 | dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " | 140 | vt596_dump_regs("Transaction (pre)", size); |
118 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | ||
119 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | ||
120 | inb_p(SMBHSTDAT1)); | ||
121 | 141 | ||
122 | /* Make sure the SMBus host is ready to start transmitting */ | 142 | /* Make sure the SMBus host is ready to start transmitting */ |
123 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | 143 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { |
124 | dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). " | 144 | dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). " |
125 | "Resetting...\n", temp); | 145 | "Resetting... ", temp); |
126 | 146 | ||
127 | outb_p(temp, SMBHSTSTS); | 147 | outb_p(temp, SMBHSTSTS); |
128 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | 148 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { |
129 | dev_dbg(&vt596_adapter.dev, "Failed! (0x%02x)\n", temp); | 149 | printk("Failed! (0x%02x)\n", temp); |
130 | |||
131 | return -1; | 150 | return -1; |
132 | } else { | 151 | } else { |
133 | dev_dbg(&vt596_adapter.dev, "Successfull!\n"); | 152 | printk("Successful!\n"); |
134 | } | 153 | } |
135 | } | 154 | } |
136 | 155 | ||
137 | /* start the transaction by setting bit 6 */ | 156 | /* Start the transaction by setting bit 6 */ |
138 | outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); | 157 | outb_p(0x40 | (size & 0x3C), SMBHSTCNT); |
139 | 158 | ||
140 | /* We will always wait for a fraction of a second! | 159 | /* We will always wait for a fraction of a second */ |
141 | I don't know if VIA needs this, Intel did */ | ||
142 | do { | 160 | do { |
143 | msleep(1); | 161 | msleep(1); |
144 | temp = inb_p(SMBHSTSTS); | 162 | temp = inb_p(SMBHSTSTS); |
@@ -147,77 +165,61 @@ static int vt596_transaction(void) | |||
147 | /* If the SMBus is still busy, we give up */ | 165 | /* If the SMBus is still busy, we give up */ |
148 | if (timeout >= MAX_TIMEOUT) { | 166 | if (timeout >= MAX_TIMEOUT) { |
149 | result = -1; | 167 | result = -1; |
150 | dev_dbg(&vt596_adapter.dev, "SMBus Timeout!\n"); | 168 | dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); |
151 | } | 169 | } |
152 | 170 | ||
153 | if (temp & 0x10) { | 171 | if (temp & 0x10) { |
154 | result = -1; | 172 | result = -1; |
155 | dev_dbg(&vt596_adapter.dev, "Error: Failed bus transaction\n"); | 173 | dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n", |
174 | inb_p(SMBHSTCNT) & 0x3C); | ||
156 | } | 175 | } |
157 | 176 | ||
158 | if (temp & 0x08) { | 177 | if (temp & 0x08) { |
159 | result = -1; | 178 | result = -1; |
160 | dev_info(&vt596_adapter.dev, "Bus collision! SMBus may be " | 179 | dev_err(&vt596_adapter.dev, "SMBus collision!\n"); |
161 | "locked until next hard\nreset. (sorry!)\n"); | ||
162 | /* Clock stops and slave is stuck in mid-transmission */ | ||
163 | } | 180 | } |
164 | 181 | ||
165 | if (temp & 0x04) { | 182 | if (temp & 0x04) { |
166 | result = -1; | 183 | result = -1; |
167 | dev_dbg(&vt596_adapter.dev, "Error: no response!\n"); | 184 | /* Quick commands are used to probe for chips, so |
185 | errors are expected, and we don't want to frighten the | ||
186 | user. */ | ||
187 | if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK) | ||
188 | dev_err(&vt596_adapter.dev, "Transaction error!\n"); | ||
168 | } | 189 | } |
169 | 190 | ||
170 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | 191 | /* Resetting status register */ |
192 | if (temp & 0x1F) | ||
171 | outb_p(temp, SMBHSTSTS); | 193 | outb_p(temp, SMBHSTSTS); |
172 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | ||
173 | dev_warn(&vt596_adapter.dev, "Failed reset at end " | ||
174 | "of transaction (%02x)\n", temp); | ||
175 | } | ||
176 | } | ||
177 | 194 | ||
178 | dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " | 195 | vt596_dump_regs("Transaction (post)", size); |
179 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | 196 | |
180 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | ||
181 | inb_p(SMBHSTDAT1)); | ||
182 | |||
183 | return result; | 197 | return result; |
184 | } | 198 | } |
185 | 199 | ||
186 | /* Return -1 on error. */ | 200 | /* Return -1 on error, 0 on success */ |
187 | static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | 201 | static s32 vt596_access(struct i2c_adapter *adap, u16 addr, |
188 | unsigned short flags, char read_write, u8 command, | 202 | unsigned short flags, char read_write, u8 command, |
189 | int size, union i2c_smbus_data *data) | 203 | int size, union i2c_smbus_data *data) |
190 | { | 204 | { |
191 | int i, len; | 205 | int i; |
192 | 206 | ||
193 | switch (size) { | 207 | switch (size) { |
194 | case I2C_SMBUS_PROC_CALL: | ||
195 | dev_info(&vt596_adapter.dev, | ||
196 | "I2C_SMBUS_PROC_CALL not supported!\n"); | ||
197 | return -1; | ||
198 | case I2C_SMBUS_QUICK: | 208 | case I2C_SMBUS_QUICK: |
199 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
200 | SMBHSTADD); | ||
201 | size = VT596_QUICK; | 209 | size = VT596_QUICK; |
202 | break; | 210 | break; |
203 | case I2C_SMBUS_BYTE: | 211 | case I2C_SMBUS_BYTE: |
204 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
205 | SMBHSTADD); | ||
206 | if (read_write == I2C_SMBUS_WRITE) | 212 | if (read_write == I2C_SMBUS_WRITE) |
207 | outb_p(command, SMBHSTCMD); | 213 | outb_p(command, SMBHSTCMD); |
208 | size = VT596_BYTE; | 214 | size = VT596_BYTE; |
209 | break; | 215 | break; |
210 | case I2C_SMBUS_BYTE_DATA: | 216 | case I2C_SMBUS_BYTE_DATA: |
211 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
212 | SMBHSTADD); | ||
213 | outb_p(command, SMBHSTCMD); | 217 | outb_p(command, SMBHSTCMD); |
214 | if (read_write == I2C_SMBUS_WRITE) | 218 | if (read_write == I2C_SMBUS_WRITE) |
215 | outb_p(data->byte, SMBHSTDAT0); | 219 | outb_p(data->byte, SMBHSTDAT0); |
216 | size = VT596_BYTE_DATA; | 220 | size = VT596_BYTE_DATA; |
217 | break; | 221 | break; |
218 | case I2C_SMBUS_WORD_DATA: | 222 | case I2C_SMBUS_WORD_DATA: |
219 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
220 | SMBHSTADD); | ||
221 | outb_p(command, SMBHSTCMD); | 223 | outb_p(command, SMBHSTCMD); |
222 | if (read_write == I2C_SMBUS_WRITE) { | 224 | if (read_write == I2C_SMBUS_WRITE) { |
223 | outb_p(data->word & 0xff, SMBHSTDAT0); | 225 | outb_p(data->word & 0xff, SMBHSTDAT0); |
@@ -225,28 +227,33 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
225 | } | 227 | } |
226 | size = VT596_WORD_DATA; | 228 | size = VT596_WORD_DATA; |
227 | break; | 229 | break; |
230 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
231 | if (!(vt596_features & FEATURE_I2CBLOCK)) | ||
232 | goto exit_unsupported; | ||
233 | if (read_write == I2C_SMBUS_READ) | ||
234 | outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0); | ||
235 | /* Fall through */ | ||
228 | case I2C_SMBUS_BLOCK_DATA: | 236 | case I2C_SMBUS_BLOCK_DATA: |
229 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
230 | SMBHSTADD); | ||
231 | outb_p(command, SMBHSTCMD); | 237 | outb_p(command, SMBHSTCMD); |
232 | if (read_write == I2C_SMBUS_WRITE) { | 238 | if (read_write == I2C_SMBUS_WRITE) { |
233 | len = data->block[0]; | 239 | u8 len = data->block[0]; |
234 | if (len < 0) | ||
235 | len = 0; | ||
236 | if (len > I2C_SMBUS_BLOCK_MAX) | 240 | if (len > I2C_SMBUS_BLOCK_MAX) |
237 | len = I2C_SMBUS_BLOCK_MAX; | 241 | len = I2C_SMBUS_BLOCK_MAX; |
238 | outb_p(len, SMBHSTDAT0); | 242 | outb_p(len, SMBHSTDAT0); |
239 | i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ | 243 | inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ |
240 | for (i = 1; i <= len; i++) | 244 | for (i = 1; i <= len; i++) |
241 | outb_p(data->block[i], SMBBLKDAT); | 245 | outb_p(data->block[i], SMBBLKDAT); |
242 | } | 246 | } |
243 | size = VT596_BLOCK_DATA; | 247 | size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ? |
248 | VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA; | ||
244 | break; | 249 | break; |
250 | default: | ||
251 | goto exit_unsupported; | ||
245 | } | 252 | } |
246 | 253 | ||
247 | outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); | 254 | outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD); |
248 | 255 | ||
249 | if (vt596_transaction()) /* Error in transaction */ | 256 | if (vt596_transaction(size)) /* Error in transaction */ |
250 | return -1; | 257 | return -1; |
251 | 258 | ||
252 | if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) | 259 | if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) |
@@ -254,35 +261,39 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
254 | 261 | ||
255 | switch (size) { | 262 | switch (size) { |
256 | case VT596_BYTE: | 263 | case VT596_BYTE: |
257 | /* Where is the result put? I assume here it is in | ||
258 | * SMBHSTDAT0 but it might just as well be in the | ||
259 | * SMBHSTCMD. No clue in the docs | ||
260 | */ | ||
261 | data->byte = inb_p(SMBHSTDAT0); | ||
262 | break; | ||
263 | case VT596_BYTE_DATA: | 264 | case VT596_BYTE_DATA: |
264 | data->byte = inb_p(SMBHSTDAT0); | 265 | data->byte = inb_p(SMBHSTDAT0); |
265 | break; | 266 | break; |
266 | case VT596_WORD_DATA: | 267 | case VT596_WORD_DATA: |
267 | data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); | 268 | data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); |
268 | break; | 269 | break; |
270 | case VT596_I2C_BLOCK_DATA: | ||
269 | case VT596_BLOCK_DATA: | 271 | case VT596_BLOCK_DATA: |
270 | data->block[0] = inb_p(SMBHSTDAT0); | 272 | data->block[0] = inb_p(SMBHSTDAT0); |
271 | if (data->block[0] > I2C_SMBUS_BLOCK_MAX) | 273 | if (data->block[0] > I2C_SMBUS_BLOCK_MAX) |
272 | data->block[0] = I2C_SMBUS_BLOCK_MAX; | 274 | data->block[0] = I2C_SMBUS_BLOCK_MAX; |
273 | i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ | 275 | inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ |
274 | for (i = 1; i <= data->block[0]; i++) | 276 | for (i = 1; i <= data->block[0]; i++) |
275 | data->block[i] = inb_p(SMBBLKDAT); | 277 | data->block[i] = inb_p(SMBBLKDAT); |
276 | break; | 278 | break; |
277 | } | 279 | } |
278 | return 0; | 280 | return 0; |
281 | |||
282 | exit_unsupported: | ||
283 | dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", | ||
284 | size); | ||
285 | return -1; | ||
279 | } | 286 | } |
280 | 287 | ||
281 | static u32 vt596_func(struct i2c_adapter *adapter) | 288 | static u32 vt596_func(struct i2c_adapter *adapter) |
282 | { | 289 | { |
283 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 290 | u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
284 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | 291 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
285 | I2C_FUNC_SMBUS_BLOCK_DATA; | 292 | I2C_FUNC_SMBUS_BLOCK_DATA; |
293 | |||
294 | if (vt596_features & FEATURE_I2CBLOCK) | ||
295 | func |= I2C_FUNC_SMBUS_I2C_BLOCK; | ||
296 | return func; | ||
286 | } | 297 | } |
287 | 298 | ||
288 | static struct i2c_algorithm smbus_algorithm = { | 299 | static struct i2c_algorithm smbus_algorithm = { |
@@ -294,7 +305,6 @@ static struct i2c_adapter vt596_adapter = { | |||
294 | .owner = THIS_MODULE, | 305 | .owner = THIS_MODULE, |
295 | .class = I2C_CLASS_HWMON, | 306 | .class = I2C_CLASS_HWMON, |
296 | .algo = &smbus_algorithm, | 307 | .algo = &smbus_algorithm, |
297 | .name = "unset", | ||
298 | }; | 308 | }; |
299 | 309 | ||
300 | static int __devinit vt596_probe(struct pci_dev *pdev, | 310 | static int __devinit vt596_probe(struct pci_dev *pdev, |
@@ -302,7 +312,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
302 | { | 312 | { |
303 | unsigned char temp; | 313 | unsigned char temp; |
304 | int error = -ENODEV; | 314 | int error = -ENODEV; |
305 | 315 | ||
306 | /* Determine the address of the SMBus areas */ | 316 | /* Determine the address of the SMBus areas */ |
307 | if (force_addr) { | 317 | if (force_addr) { |
308 | vt596_smba = force_addr & 0xfff0; | 318 | vt596_smba = force_addr & 0xfff0; |
@@ -311,12 +321,12 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
311 | } | 321 | } |
312 | 322 | ||
313 | if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || | 323 | if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || |
314 | !(vt596_smba & 0x1)) { | 324 | !(vt596_smba & 0x0001)) { |
315 | /* try 2nd address and config reg. for 596 */ | 325 | /* try 2nd address and config reg. for 596 */ |
316 | if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && | 326 | if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && |
317 | !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && | 327 | !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && |
318 | (vt596_smba & 0x1)) { | 328 | (vt596_smba & 0x0001)) { |
319 | smb_cf_hstcfg = 0x84; | 329 | SMBHSTCFG = 0x84; |
320 | } else { | 330 | } else { |
321 | /* no matches at all */ | 331 | /* no matches at all */ |
322 | dev_err(&pdev->dev, "Cannot configure " | 332 | dev_err(&pdev->dev, "Cannot configure " |
@@ -333,10 +343,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
333 | return -ENODEV; | 343 | return -ENODEV; |
334 | } | 344 | } |
335 | 345 | ||
336 | found: | 346 | found: |
337 | if (!request_region(vt596_smba, 8, "viapro-smbus")) { | 347 | if (!request_region(vt596_smba, 8, vt596_driver.name)) { |
338 | dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", | 348 | dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", |
339 | vt596_smba); | 349 | vt596_smba); |
340 | return -ENODEV; | 350 | return -ENODEV; |
341 | } | 351 | } |
342 | 352 | ||
@@ -348,16 +358,16 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
348 | pci_write_config_word(pdev, id->driver_data, vt596_smba); | 358 | pci_write_config_word(pdev, id->driver_data, vt596_smba); |
349 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); | 359 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); |
350 | dev_warn(&pdev->dev, "WARNING: SMBus interface set to new " | 360 | dev_warn(&pdev->dev, "WARNING: SMBus interface set to new " |
351 | "address 0x%04x!\n", vt596_smba); | 361 | "address 0x%04x!\n", vt596_smba); |
352 | } else if ((temp & 1) == 0) { | 362 | } else if (!(temp & 0x01)) { |
353 | if (force) { | 363 | if (force) { |
354 | /* NOTE: This assumes I/O space and other allocations | 364 | /* NOTE: This assumes I/O space and other allocations |
355 | * WERE done by the Bios! Don't complain if your | 365 | * WERE done by the Bios! Don't complain if your |
356 | * hardware does weird things after enabling this. | 366 | * hardware does weird things after enabling this. |
357 | * :') Check for Bios updates before resorting to | 367 | * :') Check for Bios updates before resorting to |
358 | * this. | 368 | * this. |
359 | */ | 369 | */ |
360 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 1); | 370 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); |
361 | dev_info(&pdev->dev, "Enabling SMBus device\n"); | 371 | dev_info(&pdev->dev, "Enabling SMBus device\n"); |
362 | } else { | 372 | } else { |
363 | dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " | 373 | dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " |
@@ -367,22 +377,28 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
367 | } | 377 | } |
368 | } | 378 | } |
369 | 379 | ||
370 | if ((temp & 0x0E) == 8) | ||
371 | dev_dbg(&pdev->dev, "using Interrupt 9 for SMBus.\n"); | ||
372 | else if ((temp & 0x0E) == 0) | ||
373 | dev_dbg(&pdev->dev, "using Interrupt SMI# for SMBus.\n"); | ||
374 | else | ||
375 | dev_dbg(&pdev->dev, "Illegal Interrupt configuration " | ||
376 | "(or code out of date)!\n"); | ||
377 | |||
378 | pci_read_config_byte(pdev, SMBREV, &temp); | ||
379 | dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp); | ||
380 | dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); | 380 | dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); |
381 | 381 | ||
382 | switch (pdev->device) { | ||
383 | case PCI_DEVICE_ID_VIA_8237: | ||
384 | case PCI_DEVICE_ID_VIA_8235: | ||
385 | case PCI_DEVICE_ID_VIA_8233A: | ||
386 | case PCI_DEVICE_ID_VIA_8233_0: | ||
387 | vt596_features |= FEATURE_I2CBLOCK; | ||
388 | break; | ||
389 | case PCI_DEVICE_ID_VIA_82C686_4: | ||
390 | /* The VT82C686B (rev 0x40) does support I2C block | ||
391 | transactions, but the VT82C686A (rev 0x30) doesn't */ | ||
392 | if (!pci_read_config_byte(pdev, PCI_REVISION_ID, &temp) | ||
393 | && temp >= 0x40) | ||
394 | vt596_features |= FEATURE_I2CBLOCK; | ||
395 | break; | ||
396 | } | ||
397 | |||
382 | vt596_adapter.dev.parent = &pdev->dev; | 398 | vt596_adapter.dev.parent = &pdev->dev; |
383 | snprintf(vt596_adapter.name, I2C_NAME_SIZE, | 399 | snprintf(vt596_adapter.name, I2C_NAME_SIZE, |
384 | "SMBus Via Pro adapter at %04x", vt596_smba); | 400 | "SMBus Via Pro adapter at %04x", vt596_smba); |
385 | 401 | ||
386 | vt596_pdev = pci_dev_get(pdev); | 402 | vt596_pdev = pci_dev_get(pdev); |
387 | if (i2c_add_adapter(&vt596_adapter)) { | 403 | if (i2c_add_adapter(&vt596_adapter)) { |
388 | pci_dev_put(vt596_pdev); | 404 | pci_dev_put(vt596_pdev); |
@@ -395,7 +411,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
395 | */ | 411 | */ |
396 | return -ENODEV; | 412 | return -ENODEV; |
397 | 413 | ||
398 | release_region: | 414 | release_region: |
399 | release_region(vt596_smba, 8); | 415 | release_region(vt596_smba, 8); |
400 | return error; | 416 | return error; |
401 | } | 417 | } |
@@ -420,9 +436,10 @@ static struct pci_device_id vt596_ids[] = { | |||
420 | { 0, } | 436 | { 0, } |
421 | }; | 437 | }; |
422 | 438 | ||
423 | MODULE_DEVICE_TABLE (pci, vt596_ids); | 439 | MODULE_DEVICE_TABLE(pci, vt596_ids); |
424 | 440 | ||
425 | static struct pci_driver vt596_driver = { | 441 | static struct pci_driver vt596_driver = { |
442 | .owner = THIS_MODULE, | ||
426 | .name = "vt596_smbus", | 443 | .name = "vt596_smbus", |
427 | .id_table = vt596_ids, | 444 | .id_table = vt596_ids, |
428 | .probe = vt596_probe, | 445 | .probe = vt596_probe, |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index b675773b0cc1..650c3ebde84c 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -225,6 +225,7 @@ static void __devexit voodoo3_remove(struct pci_dev *dev) | |||
225 | } | 225 | } |
226 | 226 | ||
227 | static struct pci_driver voodoo3_driver = { | 227 | static struct pci_driver voodoo3_driver = { |
228 | .owner = THIS_MODULE, | ||
228 | .name = "voodoo3_smbus", | 229 | .name = "voodoo3_smbus", |
229 | .id_table = voodoo3_ids, | 230 | .id_table = voodoo3_ids, |
230 | .probe = voodoo3_probe, | 231 | .probe = voodoo3_probe, |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index a1d580e05361..d3478e084522 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -442,14 +442,13 @@ static int __init scx200_acb_create(int base, int index) | |||
442 | int rc = 0; | 442 | int rc = 0; |
443 | char description[64]; | 443 | char description[64]; |
444 | 444 | ||
445 | iface = kmalloc(sizeof(*iface), GFP_KERNEL); | 445 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); |
446 | if (!iface) { | 446 | if (!iface) { |
447 | printk(KERN_ERR NAME ": can't allocate memory\n"); | 447 | printk(KERN_ERR NAME ": can't allocate memory\n"); |
448 | rc = -ENOMEM; | 448 | rc = -ENOMEM; |
449 | goto errout; | 449 | goto errout; |
450 | } | 450 | } |
451 | 451 | ||
452 | memset(iface, 0, sizeof(*iface)); | ||
453 | adapter = &iface->adapter; | 452 | adapter = &iface->adapter; |
454 | i2c_set_adapdata(adapter, iface); | 453 | i2c_set_adapdata(adapter, iface); |
455 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); | 454 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 6bd44a44cd28..f9fae28f5612 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -126,4 +126,13 @@ config SENSORS_MAX6875 | |||
126 | This driver can also be built as a module. If so, the module | 126 | This driver can also be built as a module. If so, the module |
127 | will be called max6875. | 127 | will be called max6875. |
128 | 128 | ||
129 | config RTC_X1205_I2C | ||
130 | tristate "Xicor X1205 RTC chip" | ||
131 | depends on I2C && EXPERIMENTAL | ||
132 | help | ||
133 | If you say yes here you get support for the Xicor X1205 RTC chip. | ||
134 | |||
135 | This driver can also be built as a module. If so, the module | ||
136 | will be called x1205. | ||
137 | |||
129 | endmenu | 138 | endmenu |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index a876dd42b860..46178b57b1f1 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
@@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | |||
13 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o | 13 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o |
14 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 14 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
15 | obj-$(CONFIG_TPS65010) += tps65010.o | 15 | obj-$(CONFIG_TPS65010) += tps65010.o |
16 | obj-$(CONFIG_RTC_X1205_I2C) += x1205.o | ||
16 | 17 | ||
17 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 18 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
18 | EXTRA_CFLAGS += -DDEBUG | 19 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 9d3175c03395..01b037007410 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -243,11 +243,10 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) | |||
243 | I2C_FUNC_I2C)) | 243 | I2C_FUNC_I2C)) |
244 | goto exit; | 244 | goto exit; |
245 | 245 | ||
246 | if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { | 246 | if (!(data = kzalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { |
247 | err = -ENOMEM; | 247 | err = -ENOMEM; |
248 | goto exit; | 248 | goto exit; |
249 | } | 249 | } |
250 | memset(data, 0, sizeof(struct ds1337_data)); | ||
251 | INIT_LIST_HEAD(&data->list); | 250 | INIT_LIST_HEAD(&data->list); |
252 | 251 | ||
253 | /* The common I2C client data is placed right before the | 252 | /* The common I2C client data is placed right before the |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0936327a946d..da488b735abf 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -167,7 +167,8 @@ static void ds1374_set_tlet(ulong arg) | |||
167 | 167 | ||
168 | static ulong new_time; | 168 | static ulong new_time; |
169 | 169 | ||
170 | DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); | 170 | static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, |
171 | (ulong) & new_time); | ||
171 | 172 | ||
172 | int ds1374_set_rtc_time(ulong nowtime) | 173 | int ds1374_set_rtc_time(ulong nowtime) |
173 | { | 174 | { |
@@ -193,13 +194,11 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) | |||
193 | struct i2c_client *client; | 194 | struct i2c_client *client; |
194 | int rc; | 195 | int rc; |
195 | 196 | ||
196 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 197 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
197 | if (!client) | 198 | if (!client) |
198 | return -ENOMEM; | 199 | return -ENOMEM; |
199 | 200 | ||
200 | memset(client, 0, sizeof(struct i2c_client)); | ||
201 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); | 201 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); |
202 | client->flags = I2C_DF_NOTIFY; | ||
203 | client->addr = addr; | 202 | client->addr = addr; |
204 | client->adapter = adap; | 203 | client->adapter = adap; |
205 | client->driver = &ds1374_driver; | 204 | client->driver = &ds1374_driver; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index d58403a47908..4baf573fa04f 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -88,8 +88,8 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
88 | dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); | 88 | dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); |
89 | 89 | ||
90 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { | 90 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { |
91 | for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_I2C_BLOCK_MAX) | 91 | for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_BLOCK_MAX) |
92 | if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_I2C_BLOCK_MAX) | 92 | if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_BLOCK_MAX) |
93 | goto exit; | 93 | goto exit; |
94 | } else { | 94 | } else { |
95 | if (i2c_smbus_write_byte(client, slice << 5)) { | 95 | if (i2c_smbus_write_byte(client, slice << 5)) { |
@@ -155,7 +155,7 @@ static int eeprom_attach_adapter(struct i2c_adapter *adapter) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | /* This function is called by i2c_probe */ | 157 | /* This function is called by i2c_probe */ |
158 | int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | 158 | static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) |
159 | { | 159 | { |
160 | struct i2c_client *new_client; | 160 | struct i2c_client *new_client; |
161 | struct eeprom_data *data; | 161 | struct eeprom_data *data; |
@@ -171,11 +171,10 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
171 | | I2C_FUNC_SMBUS_BYTE)) | 171 | | I2C_FUNC_SMBUS_BYTE)) |
172 | goto exit; | 172 | goto exit; |
173 | 173 | ||
174 | if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { | 174 | if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { |
175 | err = -ENOMEM; | 175 | err = -ENOMEM; |
176 | goto exit; | 176 | goto exit; |
177 | } | 177 | } |
178 | memset(data, 0, sizeof(struct eeprom_data)); | ||
179 | 178 | ||
180 | new_client = &data->client; | 179 | new_client = &data->client; |
181 | memset(data->data, 0xff, EEPROM_SIZE); | 180 | memset(data->data, 0xff, EEPROM_SIZE); |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 8ee56d4b3891..eaa4742e04fa 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -888,6 +888,7 @@ static int otg_remove(struct device *dev) | |||
888 | } | 888 | } |
889 | 889 | ||
890 | struct device_driver omap_otg_driver = { | 890 | struct device_driver omap_otg_driver = { |
891 | .owner = THIS_MODULE, | ||
891 | .name = "omap_otg", | 892 | .name = "omap_otg", |
892 | .bus = &platform_bus_type, | 893 | .bus = &platform_bus_type, |
893 | .probe = otg_probe, | 894 | .probe = otg_probe, |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 3f14528a52a9..3df309ae44a6 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -174,13 +174,11 @@ m41t00_probe(struct i2c_adapter *adap, int addr, int kind) | |||
174 | struct i2c_client *client; | 174 | struct i2c_client *client; |
175 | int rc; | 175 | int rc; |
176 | 176 | ||
177 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 177 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
178 | if (!client) | 178 | if (!client) |
179 | return -ENOMEM; | 179 | return -ENOMEM; |
180 | 180 | ||
181 | memset(client, 0, sizeof(struct i2c_client)); | ||
182 | strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE); | 181 | strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE); |
183 | client->flags = I2C_DF_NOTIFY; | ||
184 | client->addr = addr; | 182 | client->addr = addr; |
185 | client->adapter = adap; | 183 | client->adapter = adap; |
186 | client->driver = &m41t00_driver; | 184 | client->driver = &m41t00_driver; |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 9e1aeb69abf9..b376a006883c 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -179,16 +179,14 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
179 | if (address & 1) | 179 | if (address & 1) |
180 | return 0; | 180 | return 0; |
181 | 181 | ||
182 | if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) | 182 | if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL))) |
183 | return -ENOMEM; | 183 | return -ENOMEM; |
184 | memset(data, 0, sizeof(struct max6875_data)); | ||
185 | 184 | ||
186 | /* A fake client is created on the odd address */ | 185 | /* A fake client is created on the odd address */ |
187 | if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) { | 186 | if (!(fake_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { |
188 | err = -ENOMEM; | 187 | err = -ENOMEM; |
189 | goto exit_kfree1; | 188 | goto exit_kfree1; |
190 | } | 189 | } |
191 | memset(fake_client, 0, sizeof(struct i2c_client)); | ||
192 | 190 | ||
193 | /* Init real i2c_client */ | 191 | /* Init real i2c_client */ |
194 | real_client = &data->client; | 192 | real_client = &data->client; |
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 225577fdda4d..59a930346229 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c | |||
@@ -122,11 +122,10 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) | |||
122 | 122 | ||
123 | /* OK. For now, we presume we have a valid client. We now create the | 123 | /* OK. For now, we presume we have a valid client. We now create the |
124 | client structure, even though we cannot fill it completely yet. */ | 124 | client structure, even though we cannot fill it completely yet. */ |
125 | if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { | 125 | if (!(data = kzalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { |
126 | err = -ENOMEM; | 126 | err = -ENOMEM; |
127 | goto exit; | 127 | goto exit; |
128 | } | 128 | } |
129 | memset(data, 0, sizeof(struct pca9539_data)); | ||
130 | 129 | ||
131 | new_client = &data->client; | 130 | new_client = &data->client; |
132 | i2c_set_clientdata(new_client, data); | 131 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 6525743ff9fd..c323c2de236c 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c | |||
@@ -115,7 +115,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter) | |||
115 | } | 115 | } |
116 | 116 | ||
117 | /* This function is called by i2c_probe */ | 117 | /* This function is called by i2c_probe */ |
118 | int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) | 118 | static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) |
119 | { | 119 | { |
120 | struct i2c_client *new_client; | 120 | struct i2c_client *new_client; |
121 | struct pcf8574_data *data; | 121 | struct pcf8574_data *data; |
@@ -127,11 +127,10 @@ int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) | |||
127 | 127 | ||
128 | /* OK. For now, we presume we have a valid client. We now create the | 128 | /* OK. For now, we presume we have a valid client. We now create the |
129 | client structure, even though we cannot fill it completely yet. */ | 129 | client structure, even though we cannot fill it completely yet. */ |
130 | if (!(data = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { | 130 | if (!(data = kzalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { |
131 | err = -ENOMEM; | 131 | err = -ENOMEM; |
132 | goto exit; | 132 | goto exit; |
133 | } | 133 | } |
134 | memset(data, 0, sizeof(struct pcf8574_data)); | ||
135 | 134 | ||
136 | new_client = &data->client; | 135 | new_client = &data->client; |
137 | i2c_set_clientdata(new_client, data); | 136 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 80f1df9a4500..ce420a67560b 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -166,7 +166,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter) | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* This function is called by i2c_probe */ | 168 | /* This function is called by i2c_probe */ |
169 | int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | 169 | static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) |
170 | { | 170 | { |
171 | struct i2c_client *new_client; | 171 | struct i2c_client *new_client; |
172 | struct pcf8591_data *data; | 172 | struct pcf8591_data *data; |
@@ -178,11 +178,10 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
178 | 178 | ||
179 | /* OK. For now, we presume we have a valid client. We now create the | 179 | /* OK. For now, we presume we have a valid client. We now create the |
180 | client structure, even though we cannot fill it completely yet. */ | 180 | client structure, even though we cannot fill it completely yet. */ |
181 | if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { | 181 | if (!(data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { |
182 | err = -ENOMEM; | 182 | err = -ENOMEM; |
183 | goto exit; | 183 | goto exit; |
184 | } | 184 | } |
185 | memset(data, 0, sizeof(struct pcf8591_data)); | ||
186 | 185 | ||
187 | new_client = &data->client; | 186 | new_client = &data->client; |
188 | i2c_set_clientdata(new_client, data); | 187 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 0b5385c892b1..916cdc1af23c 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c | |||
@@ -148,17 +148,16 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind) | |||
148 | {addr, I2C_M_RD, 2, data} | 148 | {addr, I2C_M_RD, 2, data} |
149 | }; | 149 | }; |
150 | 150 | ||
151 | d = kmalloc(sizeof(struct rtc8564_data), GFP_KERNEL); | 151 | d = kzalloc(sizeof(struct rtc8564_data), GFP_KERNEL); |
152 | if (!d) { | 152 | if (!d) { |
153 | ret = -ENOMEM; | 153 | ret = -ENOMEM; |
154 | goto done; | 154 | goto done; |
155 | } | 155 | } |
156 | memset(d, 0, sizeof(struct rtc8564_data)); | ||
157 | new_client = &d->client; | 156 | new_client = &d->client; |
158 | 157 | ||
159 | strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); | 158 | strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); |
160 | i2c_set_clientdata(new_client, d); | 159 | i2c_set_clientdata(new_client, d); |
161 | new_client->flags = I2C_CLIENT_ALLOW_USE | I2C_DF_NOTIFY; | 160 | new_client->flags = I2C_CLIENT_ALLOW_USE; |
162 | new_client->addr = addr; | 161 | new_client->addr = addr; |
163 | new_client->adapter = adap; | 162 | new_client->adapter = adap; |
164 | new_client->driver = &rtc8564_driver; | 163 | new_client->driver = &rtc8564_driver; |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 280e9638c0f8..280dd7a45db6 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -500,11 +500,10 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
500 | return 0; | 500 | return 0; |
501 | } | 501 | } |
502 | 502 | ||
503 | tps = kmalloc(sizeof *tps, GFP_KERNEL); | 503 | tps = kzalloc(sizeof *tps, GFP_KERNEL); |
504 | if (!tps) | 504 | if (!tps) |
505 | return 0; | 505 | return 0; |
506 | 506 | ||
507 | memset(tps, 0, sizeof *tps); | ||
508 | init_MUTEX(&tps->lock); | 507 | init_MUTEX(&tps->lock); |
509 | INIT_WORK(&tps->work, tps65010_work, tps); | 508 | INIT_WORK(&tps->work, tps65010_work, tps); |
510 | tps->irq = -1; | 509 | tps->irq = -1; |
diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c new file mode 100644 index 000000000000..7da366cdc18c --- /dev/null +++ b/drivers/i2c/chips/x1205.c | |||
@@ -0,0 +1,698 @@ | |||
1 | /* | ||
2 | * x1205.c - An i2c driver for the Xicor X1205 RTC | ||
3 | * Copyright 2004 Karen Spearel | ||
4 | * Copyright 2005 Alessandro Zummo | ||
5 | * | ||
6 | * please send all reports to: | ||
7 | * kas11 at tampabay dot rr dot com | ||
8 | * a dot zummo at towertech dot it | ||
9 | * | ||
10 | * based on the other drivers in this same directory. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/i2c.h> | ||
22 | #include <linux/string.h> | ||
23 | #include <linux/bcd.h> | ||
24 | #include <linux/rtc.h> | ||
25 | #include <linux/list.h> | ||
26 | |||
27 | #include <linux/x1205.h> | ||
28 | |||
29 | #define DRV_VERSION "0.9.9" | ||
30 | |||
31 | /* Addresses to scan: none. This chip is located at | ||
32 | * 0x6f and uses a two bytes register addressing. | ||
33 | * Two bytes need to be written to read a single register, | ||
34 | * while most other chips just require one and take the second | ||
35 | * one as the data to be written. To prevent corrupting | ||
36 | * unknown chips, the user must explicitely set the probe parameter. | ||
37 | */ | ||
38 | |||
39 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
40 | |||
41 | /* Insmod parameters */ | ||
42 | I2C_CLIENT_INSMOD; | ||
43 | I2C_CLIENT_MODULE_PARM(hctosys, | ||
44 | "Set the system time from the hardware clock upon initialization"); | ||
45 | |||
46 | /* offsets into CCR area */ | ||
47 | |||
48 | #define CCR_SEC 0 | ||
49 | #define CCR_MIN 1 | ||
50 | #define CCR_HOUR 2 | ||
51 | #define CCR_MDAY 3 | ||
52 | #define CCR_MONTH 4 | ||
53 | #define CCR_YEAR 5 | ||
54 | #define CCR_WDAY 6 | ||
55 | #define CCR_Y2K 7 | ||
56 | |||
57 | #define X1205_REG_SR 0x3F /* status register */ | ||
58 | #define X1205_REG_Y2K 0x37 | ||
59 | #define X1205_REG_DW 0x36 | ||
60 | #define X1205_REG_YR 0x35 | ||
61 | #define X1205_REG_MO 0x34 | ||
62 | #define X1205_REG_DT 0x33 | ||
63 | #define X1205_REG_HR 0x32 | ||
64 | #define X1205_REG_MN 0x31 | ||
65 | #define X1205_REG_SC 0x30 | ||
66 | #define X1205_REG_DTR 0x13 | ||
67 | #define X1205_REG_ATR 0x12 | ||
68 | #define X1205_REG_INT 0x11 | ||
69 | #define X1205_REG_0 0x10 | ||
70 | #define X1205_REG_Y2K1 0x0F | ||
71 | #define X1205_REG_DWA1 0x0E | ||
72 | #define X1205_REG_YRA1 0x0D | ||
73 | #define X1205_REG_MOA1 0x0C | ||
74 | #define X1205_REG_DTA1 0x0B | ||
75 | #define X1205_REG_HRA1 0x0A | ||
76 | #define X1205_REG_MNA1 0x09 | ||
77 | #define X1205_REG_SCA1 0x08 | ||
78 | #define X1205_REG_Y2K0 0x07 | ||
79 | #define X1205_REG_DWA0 0x06 | ||
80 | #define X1205_REG_YRA0 0x05 | ||
81 | #define X1205_REG_MOA0 0x04 | ||
82 | #define X1205_REG_DTA0 0x03 | ||
83 | #define X1205_REG_HRA0 0x02 | ||
84 | #define X1205_REG_MNA0 0x01 | ||
85 | #define X1205_REG_SCA0 0x00 | ||
86 | |||
87 | #define X1205_CCR_BASE 0x30 /* Base address of CCR */ | ||
88 | #define X1205_ALM0_BASE 0x00 /* Base address of ALARM0 */ | ||
89 | |||
90 | #define X1205_SR_RTCF 0x01 /* Clock failure */ | ||
91 | #define X1205_SR_WEL 0x02 /* Write Enable Latch */ | ||
92 | #define X1205_SR_RWEL 0x04 /* Register Write Enable */ | ||
93 | |||
94 | #define X1205_DTR_DTR0 0x01 | ||
95 | #define X1205_DTR_DTR1 0x02 | ||
96 | #define X1205_DTR_DTR2 0x04 | ||
97 | |||
98 | #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ | ||
99 | |||
100 | /* Prototypes */ | ||
101 | static int x1205_attach(struct i2c_adapter *adapter); | ||
102 | static int x1205_detach(struct i2c_client *client); | ||
103 | static int x1205_probe(struct i2c_adapter *adapter, int address, int kind); | ||
104 | static int x1205_command(struct i2c_client *client, unsigned int cmd, | ||
105 | void *arg); | ||
106 | |||
107 | static struct i2c_driver x1205_driver = { | ||
108 | .owner = THIS_MODULE, | ||
109 | .name = "x1205", | ||
110 | .flags = I2C_DF_NOTIFY, | ||
111 | .attach_adapter = &x1205_attach, | ||
112 | .detach_client = &x1205_detach, | ||
113 | }; | ||
114 | |||
115 | struct x1205_data { | ||
116 | struct i2c_client client; | ||
117 | struct list_head list; | ||
118 | unsigned int epoch; | ||
119 | }; | ||
120 | |||
121 | static const unsigned char days_in_mo[] = | ||
122 | { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
123 | |||
124 | static LIST_HEAD(x1205_clients); | ||
125 | |||
126 | /* Workaround until the I2C subsytem will allow to send | ||
127 | * commands to a specific client. This function will send the command | ||
128 | * to the first client. | ||
129 | */ | ||
130 | int x1205_do_command(unsigned int cmd, void *arg) | ||
131 | { | ||
132 | struct list_head *walk; | ||
133 | struct list_head *tmp; | ||
134 | struct x1205_data *data; | ||
135 | |||
136 | list_for_each_safe(walk, tmp, &x1205_clients) { | ||
137 | data = list_entry(walk, struct x1205_data, list); | ||
138 | return x1205_command(&data->client, cmd, arg); | ||
139 | } | ||
140 | |||
141 | return -ENODEV; | ||
142 | } | ||
143 | |||
144 | #define is_leap(year) \ | ||
145 | ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) | ||
146 | |||
147 | /* make sure the rtc_time values are in bounds */ | ||
148 | static int x1205_validate_tm(struct rtc_time *tm) | ||
149 | { | ||
150 | int year = tm->tm_year + 1900; | ||
151 | |||
152 | if ((tm->tm_year < 70) || (tm->tm_year > 255)) | ||
153 | return -EINVAL; | ||
154 | |||
155 | if ((tm->tm_mon > 11) || (tm->tm_mday == 0)) | ||
156 | return -EINVAL; | ||
157 | |||
158 | if (tm->tm_mday > days_in_mo[tm->tm_mon] | ||
159 | + ((tm->tm_mon == 1) && is_leap(year))) | ||
160 | return -EINVAL; | ||
161 | |||
162 | if ((tm->tm_hour >= 24) || (tm->tm_min >= 60) || (tm->tm_sec >= 60)) | ||
163 | return -EINVAL; | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | /* | ||
169 | * In the routines that deal directly with the x1205 hardware, we use | ||
170 | * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch | ||
171 | * Epoch is initialized as 2000. Time is set to UTC. | ||
172 | */ | ||
173 | static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, | ||
174 | u8 reg_base) | ||
175 | { | ||
176 | unsigned char dt_addr[2] = { 0, reg_base }; | ||
177 | static unsigned char sr_addr[2] = { 0, X1205_REG_SR }; | ||
178 | |||
179 | unsigned char buf[8], sr; | ||
180 | |||
181 | struct i2c_msg msgs[] = { | ||
182 | { client->addr, 0, 2, sr_addr }, /* setup read ptr */ | ||
183 | { client->addr, I2C_M_RD, 1, &sr }, /* read status */ | ||
184 | { client->addr, 0, 2, dt_addr }, /* setup read ptr */ | ||
185 | { client->addr, I2C_M_RD, 8, buf }, /* read date */ | ||
186 | }; | ||
187 | |||
188 | struct x1205_data *data = i2c_get_clientdata(client); | ||
189 | |||
190 | /* read status register */ | ||
191 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | ||
192 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
193 | return -EIO; | ||
194 | } | ||
195 | |||
196 | /* check for battery failure */ | ||
197 | if (sr & X1205_SR_RTCF) { | ||
198 | dev_warn(&client->dev, | ||
199 | "Clock had a power failure, you must set the date.\n"); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | |||
203 | /* read date registers */ | ||
204 | if ((i2c_transfer(client->adapter, &msgs[2], 2)) != 2) { | ||
205 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
206 | return -EIO; | ||
207 | } | ||
208 | |||
209 | dev_dbg(&client->dev, | ||
210 | "%s: raw read data - sec=%02x, min=%02x, hr=%02x, " | ||
211 | "mday=%02x, mon=%02x, year=%02x, wday=%02x, y2k=%02x\n", | ||
212 | __FUNCTION__, | ||
213 | buf[0], buf[1], buf[2], buf[3], | ||
214 | buf[4], buf[5], buf[6], buf[7]); | ||
215 | |||
216 | tm->tm_sec = BCD2BIN(buf[CCR_SEC]); | ||
217 | tm->tm_min = BCD2BIN(buf[CCR_MIN]); | ||
218 | tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ | ||
219 | tm->tm_mday = BCD2BIN(buf[CCR_MDAY]); | ||
220 | tm->tm_mon = BCD2BIN(buf[CCR_MONTH]); | ||
221 | data->epoch = BCD2BIN(buf[CCR_Y2K]) * 100; | ||
222 | tm->tm_year = BCD2BIN(buf[CCR_YEAR]) + data->epoch - 1900; | ||
223 | tm->tm_wday = buf[CCR_WDAY]; | ||
224 | |||
225 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | ||
226 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
227 | __FUNCTION__, | ||
228 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
229 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
230 | |||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | ||
235 | int datetoo, u8 reg_base) | ||
236 | { | ||
237 | int i, err, xfer; | ||
238 | |||
239 | unsigned char buf[8]; | ||
240 | |||
241 | static const unsigned char wel[3] = { 0, X1205_REG_SR, | ||
242 | X1205_SR_WEL }; | ||
243 | |||
244 | static const unsigned char rwel[3] = { 0, X1205_REG_SR, | ||
245 | X1205_SR_WEL | X1205_SR_RWEL }; | ||
246 | |||
247 | static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 }; | ||
248 | |||
249 | struct x1205_data *data = i2c_get_clientdata(client); | ||
250 | |||
251 | /* check if all values in the tm struct are correct */ | ||
252 | if ((err = x1205_validate_tm(tm)) < 0) | ||
253 | return err; | ||
254 | |||
255 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " | ||
256 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
257 | __FUNCTION__, | ||
258 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
259 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
260 | |||
261 | buf[CCR_SEC] = BIN2BCD(tm->tm_sec); | ||
262 | buf[CCR_MIN] = BIN2BCD(tm->tm_min); | ||
263 | |||
264 | /* set hour and 24hr bit */ | ||
265 | buf[CCR_HOUR] = BIN2BCD(tm->tm_hour) | X1205_HR_MIL; | ||
266 | |||
267 | /* should we also set the date? */ | ||
268 | if (datetoo) { | ||
269 | buf[CCR_MDAY] = BIN2BCD(tm->tm_mday); | ||
270 | |||
271 | /* month, 0 - 11 */ | ||
272 | buf[CCR_MONTH] = BIN2BCD(tm->tm_mon); | ||
273 | |||
274 | /* year, since 1900 */ | ||
275 | buf[CCR_YEAR] = BIN2BCD(tm->tm_year + 1900 - data->epoch); | ||
276 | buf[CCR_WDAY] = tm->tm_wday & 0x07; | ||
277 | buf[CCR_Y2K] = BIN2BCD(data->epoch / 100); | ||
278 | } | ||
279 | |||
280 | /* this sequence is required to unlock the chip */ | ||
281 | xfer = i2c_master_send(client, wel, 3); | ||
282 | if (xfer != 3) { | ||
283 | dev_err(&client->dev, "%s: wel - %d\n", __FUNCTION__, xfer); | ||
284 | return -EIO; | ||
285 | } | ||
286 | |||
287 | xfer = i2c_master_send(client, rwel, 3); | ||
288 | if (xfer != 3) { | ||
289 | dev_err(&client->dev, "%s: rwel - %d\n", __FUNCTION__, xfer); | ||
290 | return -EIO; | ||
291 | } | ||
292 | |||
293 | /* write register's data */ | ||
294 | for (i = 0; i < (datetoo ? 8 : 3); i++) { | ||
295 | unsigned char rdata[3] = { 0, reg_base + i, buf[i] }; | ||
296 | |||
297 | xfer = i2c_master_send(client, rdata, 3); | ||
298 | if (xfer != 3) { | ||
299 | dev_err(&client->dev, | ||
300 | "%s: xfer=%d addr=%02x, data=%02x\n", | ||
301 | __FUNCTION__, | ||
302 | xfer, rdata[1], rdata[2]); | ||
303 | return -EIO; | ||
304 | } | ||
305 | }; | ||
306 | |||
307 | /* disable further writes */ | ||
308 | xfer = i2c_master_send(client, diswe, 3); | ||
309 | if (xfer != 3) { | ||
310 | dev_err(&client->dev, "%s: diswe - %d\n", __FUNCTION__, xfer); | ||
311 | return -EIO; | ||
312 | } | ||
313 | |||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | static int x1205_get_dtrim(struct i2c_client *client, int *trim) | ||
318 | { | ||
319 | unsigned char dtr; | ||
320 | static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR }; | ||
321 | |||
322 | struct i2c_msg msgs[] = { | ||
323 | { client->addr, 0, 2, dtr_addr }, /* setup read ptr */ | ||
324 | { client->addr, I2C_M_RD, 1, &dtr }, /* read dtr */ | ||
325 | }; | ||
326 | |||
327 | /* read dtr register */ | ||
328 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | ||
329 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
330 | return -EIO; | ||
331 | } | ||
332 | |||
333 | dev_dbg(&client->dev, "%s: raw dtr=%x\n", __FUNCTION__, dtr); | ||
334 | |||
335 | *trim = 0; | ||
336 | |||
337 | if (dtr & X1205_DTR_DTR0) | ||
338 | *trim += 20; | ||
339 | |||
340 | if (dtr & X1205_DTR_DTR1) | ||
341 | *trim += 10; | ||
342 | |||
343 | if (dtr & X1205_DTR_DTR2) | ||
344 | *trim = -*trim; | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | static int x1205_get_atrim(struct i2c_client *client, int *trim) | ||
350 | { | ||
351 | s8 atr; | ||
352 | static unsigned char atr_addr[2] = { 0, X1205_REG_ATR }; | ||
353 | |||
354 | struct i2c_msg msgs[] = { | ||
355 | { client->addr, 0, 2, atr_addr }, /* setup read ptr */ | ||
356 | { client->addr, I2C_M_RD, 1, &atr }, /* read atr */ | ||
357 | }; | ||
358 | |||
359 | /* read atr register */ | ||
360 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | ||
361 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
362 | return -EIO; | ||
363 | } | ||
364 | |||
365 | dev_dbg(&client->dev, "%s: raw atr=%x\n", __FUNCTION__, atr); | ||
366 | |||
367 | /* atr is a two's complement value on 6 bits, | ||
368 | * perform sign extension. The formula is | ||
369 | * Catr = (atr * 0.25pF) + 11.00pF. | ||
370 | */ | ||
371 | if (atr & 0x20) | ||
372 | atr |= 0xC0; | ||
373 | |||
374 | dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __FUNCTION__, atr, atr); | ||
375 | |||
376 | *trim = (atr * 250) + 11000; | ||
377 | |||
378 | dev_dbg(&client->dev, "%s: real=%d\n", __FUNCTION__, *trim); | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static int x1205_hctosys(struct i2c_client *client) | ||
384 | { | ||
385 | int err; | ||
386 | |||
387 | struct rtc_time tm; | ||
388 | struct timespec tv; | ||
389 | |||
390 | err = x1205_command(client, X1205_CMD_GETDATETIME, &tm); | ||
391 | |||
392 | if (err) { | ||
393 | dev_err(&client->dev, | ||
394 | "Unable to set the system clock\n"); | ||
395 | return err; | ||
396 | } | ||
397 | |||
398 | /* IMPORTANT: the RTC only stores whole seconds. It is arbitrary | ||
399 | * whether it stores the most close value or the value with partial | ||
400 | * seconds truncated. However, it is important that we use it to store | ||
401 | * the truncated value. This is because otherwise it is necessary, | ||
402 | * in an rtc sync function, to read both xtime.tv_sec and | ||
403 | * xtime.tv_nsec. On some processors (i.e. ARM), an atomic read | ||
404 | * of >32bits is not possible. So storing the most close value would | ||
405 | * slow down the sync API. So here we have the truncated value and | ||
406 | * the best guess is to add 0.5s. | ||
407 | */ | ||
408 | |||
409 | tv.tv_nsec = NSEC_PER_SEC >> 1; | ||
410 | |||
411 | /* WARNING: this is not the C library 'mktime' call, it is a built in | ||
412 | * inline function from include/linux/time.h. It expects (requires) | ||
413 | * the month to be in the range 1-12 | ||
414 | */ | ||
415 | |||
416 | tv.tv_sec = mktime(tm.tm_year + 1900, tm.tm_mon + 1, | ||
417 | tm.tm_mday, tm.tm_hour, | ||
418 | tm.tm_min, tm.tm_sec); | ||
419 | |||
420 | do_settimeofday(&tv); | ||
421 | |||
422 | dev_info(&client->dev, | ||
423 | "setting the system clock to %d-%d-%d %d:%d:%d\n", | ||
424 | tm.tm_year + 1900, tm.tm_mon + 1, | ||
425 | tm.tm_mday, tm.tm_hour, tm.tm_min, | ||
426 | tm.tm_sec); | ||
427 | |||
428 | return 0; | ||
429 | } | ||
430 | |||
431 | struct x1205_limit | ||
432 | { | ||
433 | unsigned char reg; | ||
434 | unsigned char mask; | ||
435 | unsigned char min; | ||
436 | unsigned char max; | ||
437 | }; | ||
438 | |||
439 | static int x1205_validate_client(struct i2c_client *client) | ||
440 | { | ||
441 | int i, xfer; | ||
442 | |||
443 | /* Probe array. We will read the register at the specified | ||
444 | * address and check if the given bits are zero. | ||
445 | */ | ||
446 | static const unsigned char probe_zero_pattern[] = { | ||
447 | /* register, mask */ | ||
448 | X1205_REG_SR, 0x18, | ||
449 | X1205_REG_DTR, 0xF8, | ||
450 | X1205_REG_ATR, 0xC0, | ||
451 | X1205_REG_INT, 0x18, | ||
452 | X1205_REG_0, 0xFF, | ||
453 | }; | ||
454 | |||
455 | static const struct x1205_limit probe_limits_pattern[] = { | ||
456 | /* register, mask, min, max */ | ||
457 | { X1205_REG_Y2K, 0xFF, 19, 20 }, | ||
458 | { X1205_REG_DW, 0xFF, 0, 6 }, | ||
459 | { X1205_REG_YR, 0xFF, 0, 99 }, | ||
460 | { X1205_REG_MO, 0xFF, 0, 12 }, | ||
461 | { X1205_REG_DT, 0xFF, 0, 31 }, | ||
462 | { X1205_REG_HR, 0x7F, 0, 23 }, | ||
463 | { X1205_REG_MN, 0xFF, 0, 59 }, | ||
464 | { X1205_REG_SC, 0xFF, 0, 59 }, | ||
465 | { X1205_REG_Y2K1, 0xFF, 19, 20 }, | ||
466 | { X1205_REG_Y2K0, 0xFF, 19, 20 }, | ||
467 | }; | ||
468 | |||
469 | /* check that registers have bits a 0 where expected */ | ||
470 | for (i = 0; i < ARRAY_SIZE(probe_zero_pattern); i += 2) { | ||
471 | unsigned char buf; | ||
472 | |||
473 | unsigned char addr[2] = { 0, probe_zero_pattern[i] }; | ||
474 | |||
475 | struct i2c_msg msgs[2] = { | ||
476 | { client->addr, 0, 2, addr }, | ||
477 | { client->addr, I2C_M_RD, 1, &buf }, | ||
478 | }; | ||
479 | |||
480 | xfer = i2c_transfer(client->adapter, msgs, 2); | ||
481 | if (xfer != 2) { | ||
482 | dev_err(&client->adapter->dev, | ||
483 | "%s: could not read register %x\n", | ||
484 | __FUNCTION__, addr[1]); | ||
485 | |||
486 | return -EIO; | ||
487 | } | ||
488 | |||
489 | if ((buf & probe_zero_pattern[i+1]) != 0) { | ||
490 | dev_err(&client->adapter->dev, | ||
491 | "%s: register=%02x, zero pattern=%d, value=%x\n", | ||
492 | __FUNCTION__, addr[1], i, buf); | ||
493 | |||
494 | return -ENODEV; | ||
495 | } | ||
496 | } | ||
497 | |||
498 | /* check limits (only registers with bcd values) */ | ||
499 | for (i = 0; i < ARRAY_SIZE(probe_limits_pattern); i++) { | ||
500 | unsigned char reg, value; | ||
501 | |||
502 | unsigned char addr[2] = { 0, probe_limits_pattern[i].reg }; | ||
503 | |||
504 | struct i2c_msg msgs[2] = { | ||
505 | { client->addr, 0, 2, addr }, | ||
506 | { client->addr, I2C_M_RD, 1, ® }, | ||
507 | }; | ||
508 | |||
509 | xfer = i2c_transfer(client->adapter, msgs, 2); | ||
510 | |||
511 | if (xfer != 2) { | ||
512 | dev_err(&client->adapter->dev, | ||
513 | "%s: could not read register %x\n", | ||
514 | __FUNCTION__, addr[1]); | ||
515 | |||
516 | return -EIO; | ||
517 | } | ||
518 | |||
519 | value = BCD2BIN(reg & probe_limits_pattern[i].mask); | ||
520 | |||
521 | if (value > probe_limits_pattern[i].max || | ||
522 | value < probe_limits_pattern[i].min) { | ||
523 | dev_dbg(&client->adapter->dev, | ||
524 | "%s: register=%x, lim pattern=%d, value=%d\n", | ||
525 | __FUNCTION__, addr[1], i, value); | ||
526 | |||
527 | return -ENODEV; | ||
528 | } | ||
529 | } | ||
530 | |||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int x1205_attach(struct i2c_adapter *adapter) | ||
535 | { | ||
536 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); | ||
537 | |||
538 | return i2c_probe(adapter, &addr_data, x1205_probe); | ||
539 | } | ||
540 | |||
541 | int x1205_direct_attach(int adapter_id, | ||
542 | struct i2c_client_address_data *address_data) | ||
543 | { | ||
544 | int err; | ||
545 | struct i2c_adapter *adapter = i2c_get_adapter(adapter_id); | ||
546 | |||
547 | if (adapter) { | ||
548 | err = i2c_probe(adapter, | ||
549 | address_data, x1205_probe); | ||
550 | |||
551 | i2c_put_adapter(adapter); | ||
552 | |||
553 | return err; | ||
554 | } | ||
555 | |||
556 | return -ENODEV; | ||
557 | } | ||
558 | |||
559 | static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) | ||
560 | { | ||
561 | struct i2c_client *client; | ||
562 | struct x1205_data *data; | ||
563 | |||
564 | int err = 0; | ||
565 | |||
566 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); | ||
567 | |||
568 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { | ||
569 | err = -ENODEV; | ||
570 | goto exit; | ||
571 | } | ||
572 | |||
573 | if (!(data = kzalloc(sizeof(struct x1205_data), GFP_KERNEL))) { | ||
574 | err = -ENOMEM; | ||
575 | goto exit; | ||
576 | } | ||
577 | |||
578 | /* Initialize our structures */ | ||
579 | data->epoch = 2000; | ||
580 | |||
581 | client = &data->client; | ||
582 | client->addr = address; | ||
583 | client->driver = &x1205_driver; | ||
584 | client->adapter = adapter; | ||
585 | |||
586 | strlcpy(client->name, "x1205", I2C_NAME_SIZE); | ||
587 | |||
588 | i2c_set_clientdata(client, data); | ||
589 | |||
590 | /* Verify the chip is really an X1205 */ | ||
591 | if (kind < 0) { | ||
592 | if (x1205_validate_client(client) < 0) { | ||
593 | err = -ENODEV; | ||
594 | goto exit_kfree; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | /* Inform the i2c layer */ | ||
599 | if ((err = i2c_attach_client(client))) | ||
600 | goto exit_kfree; | ||
601 | |||
602 | list_add(&data->list, &x1205_clients); | ||
603 | |||
604 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | ||
605 | |||
606 | /* If requested, set the system time */ | ||
607 | if (hctosys) | ||
608 | x1205_hctosys(client); | ||
609 | |||
610 | return 0; | ||
611 | |||
612 | exit_kfree: | ||
613 | kfree(data); | ||
614 | |||
615 | exit: | ||
616 | return err; | ||
617 | } | ||
618 | |||
619 | static int x1205_detach(struct i2c_client *client) | ||
620 | { | ||
621 | int err; | ||
622 | struct x1205_data *data = i2c_get_clientdata(client); | ||
623 | |||
624 | dev_dbg(&client->dev, "%s\n", __FUNCTION__); | ||
625 | |||
626 | if ((err = i2c_detach_client(client))) | ||
627 | return err; | ||
628 | |||
629 | list_del(&data->list); | ||
630 | |||
631 | kfree(data); | ||
632 | |||
633 | return 0; | ||
634 | } | ||
635 | |||
636 | static int x1205_command(struct i2c_client *client, unsigned int cmd, | ||
637 | void *param) | ||
638 | { | ||
639 | if (param == NULL) | ||
640 | return -EINVAL; | ||
641 | |||
642 | if (!capable(CAP_SYS_TIME)) | ||
643 | return -EACCES; | ||
644 | |||
645 | dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); | ||
646 | |||
647 | switch (cmd) { | ||
648 | case X1205_CMD_GETDATETIME: | ||
649 | return x1205_get_datetime(client, param, X1205_CCR_BASE); | ||
650 | |||
651 | case X1205_CMD_SETTIME: | ||
652 | return x1205_set_datetime(client, param, 0, | ||
653 | X1205_CCR_BASE); | ||
654 | |||
655 | case X1205_CMD_SETDATETIME: | ||
656 | return x1205_set_datetime(client, param, 1, | ||
657 | X1205_CCR_BASE); | ||
658 | |||
659 | case X1205_CMD_GETALARM: | ||
660 | return x1205_get_datetime(client, param, X1205_ALM0_BASE); | ||
661 | |||
662 | case X1205_CMD_SETALARM: | ||
663 | return x1205_set_datetime(client, param, 1, | ||
664 | X1205_ALM0_BASE); | ||
665 | |||
666 | case X1205_CMD_GETDTRIM: | ||
667 | return x1205_get_dtrim(client, param); | ||
668 | |||
669 | case X1205_CMD_GETATRIM: | ||
670 | return x1205_get_atrim(client, param); | ||
671 | |||
672 | default: | ||
673 | return -EINVAL; | ||
674 | } | ||
675 | } | ||
676 | |||
677 | static int __init x1205_init(void) | ||
678 | { | ||
679 | return i2c_add_driver(&x1205_driver); | ||
680 | } | ||
681 | |||
682 | static void __exit x1205_exit(void) | ||
683 | { | ||
684 | i2c_del_driver(&x1205_driver); | ||
685 | } | ||
686 | |||
687 | MODULE_AUTHOR( | ||
688 | "Karen Spearel <kas11@tampabay.rr.com>, " | ||
689 | "Alessandro Zummo <a.zummo@towertech.it>"); | ||
690 | MODULE_DESCRIPTION("Xicor X1205 RTC driver"); | ||
691 | MODULE_LICENSE("GPL"); | ||
692 | MODULE_VERSION(DRV_VERSION); | ||
693 | |||
694 | EXPORT_SYMBOL_GPL(x1205_do_command); | ||
695 | EXPORT_SYMBOL_GPL(x1205_direct_attach); | ||
696 | |||
697 | module_init(x1205_init); | ||
698 | module_exit(x1205_exit); | ||
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index dda472e5e8be..02e335a04f09 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -19,7 +19,8 @@ | |||
19 | 19 | ||
20 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. | 20 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. |
21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> | 21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> |
22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ | 22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and |
23 | Jean Delvare <khali@linux-fr.org> */ | ||
23 | 24 | ||
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
@@ -48,7 +49,7 @@ static int i2c_bus_suspend(struct device * dev, pm_message_t state) | |||
48 | int rc = 0; | 49 | int rc = 0; |
49 | 50 | ||
50 | if (dev->driver && dev->driver->suspend) | 51 | if (dev->driver && dev->driver->suspend) |
51 | rc = dev->driver->suspend(dev,state,0); | 52 | rc = dev->driver->suspend(dev, state); |
52 | return rc; | 53 | return rc; |
53 | } | 54 | } |
54 | 55 | ||
@@ -57,7 +58,7 @@ static int i2c_bus_resume(struct device * dev) | |||
57 | int rc = 0; | 58 | int rc = 0; |
58 | 59 | ||
59 | if (dev->driver && dev->driver->resume) | 60 | if (dev->driver && dev->driver->resume) |
60 | rc = dev->driver->resume(dev,0); | 61 | rc = dev->driver->resume(dev); |
61 | return rc; | 62 | return rc; |
62 | } | 63 | } |
63 | 64 | ||
@@ -85,6 +86,7 @@ void i2c_adapter_dev_release(struct device *dev) | |||
85 | } | 86 | } |
86 | 87 | ||
87 | struct device_driver i2c_adapter_driver = { | 88 | struct device_driver i2c_adapter_driver = { |
89 | .owner = THIS_MODULE, | ||
88 | .name = "i2c_adapter", | 90 | .name = "i2c_adapter", |
89 | .bus = &i2c_bus_type, | 91 | .bus = &i2c_bus_type, |
90 | .probe = i2c_device_probe, | 92 | .probe = i2c_device_probe, |
@@ -98,6 +100,7 @@ static void i2c_adapter_class_dev_release(struct class_device *dev) | |||
98 | } | 100 | } |
99 | 101 | ||
100 | struct class i2c_adapter_class = { | 102 | struct class i2c_adapter_class = { |
103 | .owner = THIS_MODULE, | ||
101 | .name = "i2c-adapter", | 104 | .name = "i2c-adapter", |
102 | .release = &i2c_adapter_class_dev_release, | 105 | .release = &i2c_adapter_class_dev_release, |
103 | }; | 106 | }; |
@@ -291,6 +294,7 @@ int i2c_add_driver(struct i2c_driver *driver) | |||
291 | down(&core_lists); | 294 | down(&core_lists); |
292 | 295 | ||
293 | /* add the driver to the list of i2c drivers in the driver core */ | 296 | /* add the driver to the list of i2c drivers in the driver core */ |
297 | driver->driver.owner = driver->owner; | ||
294 | driver->driver.name = driver->name; | 298 | driver->driver.name = driver->name; |
295 | driver->driver.bus = &i2c_bus_type; | 299 | driver->driver.bus = &i2c_bus_type; |
296 | driver->driver.probe = i2c_device_probe; | 300 | driver->driver.probe = i2c_device_probe; |
@@ -706,10 +710,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
706 | int i, err; | 710 | int i, err; |
707 | int adap_id = i2c_adapter_id(adapter); | 711 | int adap_id = i2c_adapter_id(adapter); |
708 | 712 | ||
709 | /* Forget it if we can't probe using SMBUS_QUICK */ | ||
710 | if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) | ||
711 | return -1; | ||
712 | |||
713 | /* Force entries are done first, and are not affected by ignore | 713 | /* Force entries are done first, and are not affected by ignore |
714 | entries */ | 714 | entries */ |
715 | if (address_data->forces) { | 715 | if (address_data->forces) { |
@@ -736,6 +736,17 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | /* Stop here if we can't use SMBUS_QUICK */ | ||
740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { | ||
741 | if (address_data->probe[0] == I2C_CLIENT_END | ||
742 | && address_data->normal_i2c[0] == I2C_CLIENT_END) | ||
743 | return 0; | ||
744 | |||
745 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " | ||
746 | "can't probe for chips\n"); | ||
747 | return -1; | ||
748 | } | ||
749 | |||
739 | /* Probe entries are done second, and are not affected by ignore | 750 | /* Probe entries are done second, and are not affected by ignore |
740 | entries either */ | 751 | entries either */ |
741 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { | 752 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { |
@@ -820,101 +831,44 @@ crc8(u16 data) | |||
820 | return (u8)(data >> 8); | 831 | return (u8)(data >> 8); |
821 | } | 832 | } |
822 | 833 | ||
823 | /* CRC over count bytes in the first array plus the bytes in the rest | 834 | /* Incremental CRC8 over count bytes in the array pointed to by p */ |
824 | array if it is non-null. rest[0] is the (length of rest) - 1 | 835 | static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) |
825 | and is included. */ | ||
826 | static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest) | ||
827 | { | 836 | { |
828 | int i; | 837 | int i; |
829 | 838 | ||
830 | for(i = 0; i < count; i++) | 839 | for(i = 0; i < count; i++) |
831 | crc = crc8((crc ^ first[i]) << 8); | 840 | crc = crc8((crc ^ p[i]) << 8); |
832 | if(rest != NULL) | ||
833 | for(i = 0; i <= rest[0]; i++) | ||
834 | crc = crc8((crc ^ rest[i]) << 8); | ||
835 | return crc; | 841 | return crc; |
836 | } | 842 | } |
837 | 843 | ||
838 | static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) | 844 | /* Assume a 7-bit address, which is reasonable for SMBus */ |
845 | static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg) | ||
839 | { | 846 | { |
840 | return i2c_smbus_partial_pec(0, count, first, rest); | 847 | /* The address will be sent first */ |
848 | u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD); | ||
849 | pec = i2c_smbus_pec(pec, &addr, 1); | ||
850 | |||
851 | /* The data buffer follows */ | ||
852 | return i2c_smbus_pec(pec, msg->buf, msg->len); | ||
841 | } | 853 | } |
842 | 854 | ||
843 | /* Returns new "size" (transaction type) | 855 | /* Used for write only transactions */ |
844 | Note that we convert byte to byte_data and byte_data to word_data | 856 | static inline void i2c_smbus_add_pec(struct i2c_msg *msg) |
845 | rather than invent new xxx_PEC transactions. */ | ||
846 | static int i2c_smbus_add_pec(u16 addr, u8 command, int size, | ||
847 | union i2c_smbus_data *data) | ||
848 | { | 857 | { |
849 | u8 buf[3]; | 858 | msg->buf[msg->len] = i2c_smbus_msg_pec(0, msg); |
850 | 859 | msg->len++; | |
851 | buf[0] = addr << 1; | ||
852 | buf[1] = command; | ||
853 | switch(size) { | ||
854 | case I2C_SMBUS_BYTE: | ||
855 | data->byte = i2c_smbus_pec(2, buf, NULL); | ||
856 | size = I2C_SMBUS_BYTE_DATA; | ||
857 | break; | ||
858 | case I2C_SMBUS_BYTE_DATA: | ||
859 | buf[2] = data->byte; | ||
860 | data->word = buf[2] || | ||
861 | (i2c_smbus_pec(3, buf, NULL) << 8); | ||
862 | size = I2C_SMBUS_WORD_DATA; | ||
863 | break; | ||
864 | case I2C_SMBUS_WORD_DATA: | ||
865 | /* unsupported */ | ||
866 | break; | ||
867 | case I2C_SMBUS_BLOCK_DATA: | ||
868 | data->block[data->block[0] + 1] = | ||
869 | i2c_smbus_pec(2, buf, data->block); | ||
870 | size = I2C_SMBUS_BLOCK_DATA_PEC; | ||
871 | break; | ||
872 | } | ||
873 | return size; | ||
874 | } | 860 | } |
875 | 861 | ||
876 | static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, | 862 | /* Return <0 on CRC error |
877 | union i2c_smbus_data *data) | 863 | If there was a write before this read (most cases) we need to take the |
864 | partial CRC from the write part into account. | ||
865 | Note that this function does modify the message (we need to decrease the | ||
866 | message length to hide the CRC byte from the caller). */ | ||
867 | static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg) | ||
878 | { | 868 | { |
879 | u8 buf[3], rpec, cpec; | 869 | u8 rpec = msg->buf[--msg->len]; |
870 | cpec = i2c_smbus_msg_pec(cpec, msg); | ||
880 | 871 | ||
881 | buf[1] = command; | ||
882 | switch(size) { | ||
883 | case I2C_SMBUS_BYTE_DATA: | ||
884 | buf[0] = (addr << 1) | 1; | ||
885 | cpec = i2c_smbus_pec(2, buf, NULL); | ||
886 | rpec = data->byte; | ||
887 | break; | ||
888 | case I2C_SMBUS_WORD_DATA: | ||
889 | buf[0] = (addr << 1) | 1; | ||
890 | buf[2] = data->word & 0xff; | ||
891 | cpec = i2c_smbus_pec(3, buf, NULL); | ||
892 | rpec = data->word >> 8; | ||
893 | break; | ||
894 | case I2C_SMBUS_WORD_DATA_PEC: | ||
895 | /* unsupported */ | ||
896 | cpec = rpec = 0; | ||
897 | break; | ||
898 | case I2C_SMBUS_PROC_CALL_PEC: | ||
899 | /* unsupported */ | ||
900 | cpec = rpec = 0; | ||
901 | break; | ||
902 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
903 | buf[0] = (addr << 1); | ||
904 | buf[2] = (addr << 1) | 1; | ||
905 | cpec = i2c_smbus_pec(3, buf, data->block); | ||
906 | rpec = data->block[data->block[0] + 1]; | ||
907 | break; | ||
908 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
909 | buf[0] = (addr << 1) | 1; | ||
910 | rpec = i2c_smbus_partial_pec(partial, 1, | ||
911 | buf, data->block); | ||
912 | cpec = data->block[data->block[0] + 1]; | ||
913 | break; | ||
914 | default: | ||
915 | cpec = rpec = 0; | ||
916 | break; | ||
917 | } | ||
918 | if (rpec != cpec) { | 872 | if (rpec != cpec) { |
919 | pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", | 873 | pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", |
920 | rpec, cpec); | 874 | rpec, cpec); |
@@ -941,9 +895,8 @@ s32 i2c_smbus_read_byte(struct i2c_client *client) | |||
941 | 895 | ||
942 | s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) | 896 | s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) |
943 | { | 897 | { |
944 | union i2c_smbus_data data; /* only for PEC */ | ||
945 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 898 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
946 | I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,&data); | 899 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); |
947 | } | 900 | } |
948 | 901 | ||
949 | s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) | 902 | s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) |
@@ -1026,13 +979,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1026 | need to use only one message; when reading, we need two. We initialize | 979 | need to use only one message; when reading, we need two. We initialize |
1027 | most things with sane defaults, to keep the code below somewhat | 980 | most things with sane defaults, to keep the code below somewhat |
1028 | simpler. */ | 981 | simpler. */ |
1029 | unsigned char msgbuf0[34]; | 982 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; |
1030 | unsigned char msgbuf1[34]; | 983 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; |
1031 | int num = read_write == I2C_SMBUS_READ?2:1; | 984 | int num = read_write == I2C_SMBUS_READ?2:1; |
1032 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, | 985 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, |
1033 | { addr, flags | I2C_M_RD, 0, msgbuf1 } | 986 | { addr, flags | I2C_M_RD, 0, msgbuf1 } |
1034 | }; | 987 | }; |
1035 | int i; | 988 | int i; |
989 | u8 partial_pec = 0; | ||
1036 | 990 | ||
1037 | msgbuf0[0] = command; | 991 | msgbuf0[0] = command; |
1038 | switch(size) { | 992 | switch(size) { |
@@ -1075,7 +1029,6 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1075 | msgbuf0[2] = (data->word >> 8) & 0xff; | 1029 | msgbuf0[2] = (data->word >> 8) & 0xff; |
1076 | break; | 1030 | break; |
1077 | case I2C_SMBUS_BLOCK_DATA: | 1031 | case I2C_SMBUS_BLOCK_DATA: |
1078 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
1079 | if (read_write == I2C_SMBUS_READ) { | 1032 | if (read_write == I2C_SMBUS_READ) { |
1080 | dev_err(&adapter->dev, "Block read not supported " | 1033 | dev_err(&adapter->dev, "Block read not supported " |
1081 | "under I2C emulation!\n"); | 1034 | "under I2C emulation!\n"); |
@@ -1088,23 +1041,20 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1088 | data->block[0]); | 1041 | data->block[0]); |
1089 | return -1; | 1042 | return -1; |
1090 | } | 1043 | } |
1091 | if(size == I2C_SMBUS_BLOCK_DATA_PEC) | 1044 | for (i = 1; i < msg[0].len; i++) |
1092 | (msg[0].len)++; | ||
1093 | for (i = 1; i <= msg[0].len; i++) | ||
1094 | msgbuf0[i] = data->block[i-1]; | 1045 | msgbuf0[i] = data->block[i-1]; |
1095 | } | 1046 | } |
1096 | break; | 1047 | break; |
1097 | case I2C_SMBUS_BLOCK_PROC_CALL: | 1048 | case I2C_SMBUS_BLOCK_PROC_CALL: |
1098 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
1099 | dev_dbg(&adapter->dev, "Block process call not supported " | 1049 | dev_dbg(&adapter->dev, "Block process call not supported " |
1100 | "under I2C emulation!\n"); | 1050 | "under I2C emulation!\n"); |
1101 | return -1; | 1051 | return -1; |
1102 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1052 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1103 | if (read_write == I2C_SMBUS_READ) { | 1053 | if (read_write == I2C_SMBUS_READ) { |
1104 | msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; | 1054 | msg[1].len = I2C_SMBUS_BLOCK_MAX; |
1105 | } else { | 1055 | } else { |
1106 | msg[0].len = data->block[0] + 1; | 1056 | msg[0].len = data->block[0] + 1; |
1107 | if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { | 1057 | if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { |
1108 | dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " | 1058 | dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " |
1109 | "invalid block write size (%d)\n", | 1059 | "invalid block write size (%d)\n", |
1110 | data->block[0]); | 1060 | data->block[0]); |
@@ -1120,9 +1070,30 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1120 | return -1; | 1070 | return -1; |
1121 | } | 1071 | } |
1122 | 1072 | ||
1073 | i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK | ||
1074 | && size != I2C_SMBUS_I2C_BLOCK_DATA); | ||
1075 | if (i) { | ||
1076 | /* Compute PEC if first message is a write */ | ||
1077 | if (!(msg[0].flags & I2C_M_RD)) { | ||
1078 | if (num == 1) /* Write only */ | ||
1079 | i2c_smbus_add_pec(&msg[0]); | ||
1080 | else /* Write followed by read */ | ||
1081 | partial_pec = i2c_smbus_msg_pec(0, &msg[0]); | ||
1082 | } | ||
1083 | /* Ask for PEC if last message is a read */ | ||
1084 | if (msg[num-1].flags & I2C_M_RD) | ||
1085 | msg[num-1].len++; | ||
1086 | } | ||
1087 | |||
1123 | if (i2c_transfer(adapter, msg, num) < 0) | 1088 | if (i2c_transfer(adapter, msg, num) < 0) |
1124 | return -1; | 1089 | return -1; |
1125 | 1090 | ||
1091 | /* Check PEC if last message is a read */ | ||
1092 | if (i && (msg[num-1].flags & I2C_M_RD)) { | ||
1093 | if (i2c_smbus_check_pec(partial_pec, &msg[num-1]) < 0) | ||
1094 | return -1; | ||
1095 | } | ||
1096 | |||
1126 | if (read_write == I2C_SMBUS_READ) | 1097 | if (read_write == I2C_SMBUS_READ) |
1127 | switch(size) { | 1098 | switch(size) { |
1128 | case I2C_SMBUS_BYTE: | 1099 | case I2C_SMBUS_BYTE: |
@@ -1137,8 +1108,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1137 | break; | 1108 | break; |
1138 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1109 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1139 | /* fixed at 32 for now */ | 1110 | /* fixed at 32 for now */ |
1140 | data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; | 1111 | data->block[0] = I2C_SMBUS_BLOCK_MAX; |
1141 | for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) | 1112 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) |
1142 | data->block[i+1] = msgbuf1[i]; | 1113 | data->block[i+1] = msgbuf1[i]; |
1143 | break; | 1114 | break; |
1144 | } | 1115 | } |
@@ -1151,28 +1122,8 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1151 | union i2c_smbus_data * data) | 1122 | union i2c_smbus_data * data) |
1152 | { | 1123 | { |
1153 | s32 res; | 1124 | s32 res; |
1154 | int swpec = 0; | ||
1155 | u8 partial = 0; | ||
1156 | 1125 | ||
1157 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 1126 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; |
1158 | if((flags & I2C_CLIENT_PEC) && | ||
1159 | !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) { | ||
1160 | swpec = 1; | ||
1161 | if(read_write == I2C_SMBUS_READ && | ||
1162 | size == I2C_SMBUS_BLOCK_DATA) | ||
1163 | size = I2C_SMBUS_BLOCK_DATA_PEC; | ||
1164 | else if(size == I2C_SMBUS_PROC_CALL) | ||
1165 | size = I2C_SMBUS_PROC_CALL_PEC; | ||
1166 | else if(size == I2C_SMBUS_BLOCK_PROC_CALL) { | ||
1167 | i2c_smbus_add_pec(addr, command, | ||
1168 | I2C_SMBUS_BLOCK_DATA, data); | ||
1169 | partial = data->block[data->block[0] + 1]; | ||
1170 | size = I2C_SMBUS_BLOCK_PROC_CALL_PEC; | ||
1171 | } else if(read_write == I2C_SMBUS_WRITE && | ||
1172 | size != I2C_SMBUS_QUICK && | ||
1173 | size != I2C_SMBUS_I2C_BLOCK_DATA) | ||
1174 | size = i2c_smbus_add_pec(addr, command, size, data); | ||
1175 | } | ||
1176 | 1127 | ||
1177 | if (adapter->algo->smbus_xfer) { | 1128 | if (adapter->algo->smbus_xfer) { |
1178 | down(&adapter->bus_lock); | 1129 | down(&adapter->bus_lock); |
@@ -1183,13 +1134,6 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1183 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1134 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, |
1184 | command,size,data); | 1135 | command,size,data); |
1185 | 1136 | ||
1186 | if(res >= 0 && swpec && | ||
1187 | size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA && | ||
1188 | (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC || | ||
1189 | size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) { | ||
1190 | if(i2c_smbus_check_pec(addr, command, size, partial, data)) | ||
1191 | return -1; | ||
1192 | } | ||
1193 | return res; | 1137 | return res; |
1194 | } | 1138 | } |
1195 | 1139 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index aa7a4fadef64..ea14c8f1c82b 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -26,15 +26,11 @@ | |||
26 | 26 | ||
27 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ | 27 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ |
28 | 28 | ||
29 | /* The devfs code is contributed by Philipp Matthias Hahn | ||
30 | <pmhahn@titan.lahn.de> */ | ||
31 | |||
32 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 30 | #include <linux/module.h> |
34 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
35 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
36 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
37 | #include <linux/devfs_fs_kernel.h> | ||
38 | #include <linux/init.h> | 34 | #include <linux/init.h> |
39 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
40 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
@@ -80,10 +76,9 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap) | |||
80 | { | 76 | { |
81 | struct i2c_dev *i2c_dev; | 77 | struct i2c_dev *i2c_dev; |
82 | 78 | ||
83 | i2c_dev = kmalloc(sizeof(*i2c_dev), GFP_KERNEL); | 79 | i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL); |
84 | if (!i2c_dev) | 80 | if (!i2c_dev) |
85 | return ERR_PTR(-ENOMEM); | 81 | return ERR_PTR(-ENOMEM); |
86 | memset(i2c_dev, 0x00, sizeof(*i2c_dev)); | ||
87 | 82 | ||
88 | spin_lock(&i2c_dev_array_lock); | 83 | spin_lock(&i2c_dev_array_lock); |
89 | if (i2c_dev_array[adap->nr]) { | 84 | if (i2c_dev_array[adap->nr]) { |
@@ -177,8 +172,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
177 | int i,datasize,res; | 172 | int i,datasize,res; |
178 | unsigned long funcs; | 173 | unsigned long funcs; |
179 | 174 | ||
180 | dev_dbg(&client->adapter->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", | 175 | dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", |
181 | iminor(inode),cmd, arg); | 176 | cmd, arg); |
182 | 177 | ||
183 | switch ( cmd ) { | 178 | switch ( cmd ) { |
184 | case I2C_SLAVE: | 179 | case I2C_SLAVE: |
@@ -432,8 +427,6 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
432 | if (IS_ERR(i2c_dev)) | 427 | if (IS_ERR(i2c_dev)) |
433 | return PTR_ERR(i2c_dev); | 428 | return PTR_ERR(i2c_dev); |
434 | 429 | ||
435 | devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), | ||
436 | S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); | ||
437 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", | 430 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", |
438 | adap->name, i2c_dev->minor); | 431 | adap->name, i2c_dev->minor); |
439 | 432 | ||
@@ -466,7 +459,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
466 | return -ENODEV; | 459 | return -ENODEV; |
467 | 460 | ||
468 | init_completion(&i2c_dev->released); | 461 | init_completion(&i2c_dev->released); |
469 | devfs_remove("i2c/%d", i2c_dev->minor); | ||
470 | return_i2c_dev(i2c_dev); | 462 | return_i2c_dev(i2c_dev); |
471 | class_device_unregister(&i2c_dev->class_dev); | 463 | class_device_unregister(&i2c_dev->class_dev); |
472 | wait_for_completion(&i2c_dev->released); | 464 | wait_for_completion(&i2c_dev->released); |
@@ -522,8 +514,6 @@ static int __init i2c_dev_init(void) | |||
522 | if (res) | 514 | if (res) |
523 | goto out_unreg_class; | 515 | goto out_unreg_class; |
524 | 516 | ||
525 | devfs_mk_dir("i2c"); | ||
526 | |||
527 | return 0; | 517 | return 0; |
528 | 518 | ||
529 | out_unreg_class: | 519 | out_unreg_class: |
@@ -539,7 +529,6 @@ static void __exit i2c_dev_exit(void) | |||
539 | { | 529 | { |
540 | i2c_del_driver(&i2cdev_driver); | 530 | i2c_del_driver(&i2cdev_driver); |
541 | class_unregister(&i2c_dev_class); | 531 | class_unregister(&i2c_dev_class); |
542 | devfs_remove("i2c"); | ||
543 | unregister_chrdev(I2C_MAJOR,"i2c"); | 532 | unregister_chrdev(I2C_MAJOR,"i2c"); |
544 | } | 533 | } |
545 | 534 | ||
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index ee38e6b143a4..47f2b832555f 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -1013,6 +1013,8 @@ typedef struct ide_tape_obj { | |||
1013 | 1013 | ||
1014 | static DECLARE_MUTEX(idetape_ref_sem); | 1014 | static DECLARE_MUTEX(idetape_ref_sem); |
1015 | 1015 | ||
1016 | static struct class *idetape_sysfs_class; | ||
1017 | |||
1016 | #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) | 1018 | #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) |
1017 | 1019 | ||
1018 | #define ide_tape_g(disk) \ | 1020 | #define ide_tape_g(disk) \ |
@@ -4704,6 +4706,10 @@ static void ide_tape_release(struct kref *kref) | |||
4704 | 4706 | ||
4705 | drive->dsc_overlap = 0; | 4707 | drive->dsc_overlap = 0; |
4706 | drive->driver_data = NULL; | 4708 | drive->driver_data = NULL; |
4709 | class_device_destroy(idetape_sysfs_class, | ||
4710 | MKDEV(IDETAPE_MAJOR, tape->minor)); | ||
4711 | class_device_destroy(idetape_sysfs_class, | ||
4712 | MKDEV(IDETAPE_MAJOR, tape->minor + 128)); | ||
4707 | devfs_remove("%s/mt", drive->devfs_name); | 4713 | devfs_remove("%s/mt", drive->devfs_name); |
4708 | devfs_remove("%s/mtn", drive->devfs_name); | 4714 | devfs_remove("%s/mtn", drive->devfs_name); |
4709 | devfs_unregister_tape(g->number); | 4715 | devfs_unregister_tape(g->number); |
@@ -4878,6 +4884,11 @@ static int ide_tape_probe(struct device *dev) | |||
4878 | 4884 | ||
4879 | idetape_setup(drive, tape, minor); | 4885 | idetape_setup(drive, tape, minor); |
4880 | 4886 | ||
4887 | class_device_create(idetape_sysfs_class, NULL, | ||
4888 | MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name); | ||
4889 | class_device_create(idetape_sysfs_class, NULL, | ||
4890 | MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name); | ||
4891 | |||
4881 | devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), | 4892 | devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), |
4882 | S_IFCHR | S_IRUGO | S_IWUGO, | 4893 | S_IFCHR | S_IRUGO | S_IWUGO, |
4883 | "%s/mt", drive->devfs_name); | 4894 | "%s/mt", drive->devfs_name); |
@@ -4903,6 +4914,7 @@ MODULE_LICENSE("GPL"); | |||
4903 | static void __exit idetape_exit (void) | 4914 | static void __exit idetape_exit (void) |
4904 | { | 4915 | { |
4905 | driver_unregister(&idetape_driver.gen_driver); | 4916 | driver_unregister(&idetape_driver.gen_driver); |
4917 | class_destroy(idetape_sysfs_class); | ||
4906 | unregister_chrdev(IDETAPE_MAJOR, "ht"); | 4918 | unregister_chrdev(IDETAPE_MAJOR, "ht"); |
4907 | } | 4919 | } |
4908 | 4920 | ||
@@ -4911,11 +4923,33 @@ static void __exit idetape_exit (void) | |||
4911 | */ | 4923 | */ |
4912 | static int idetape_init (void) | 4924 | static int idetape_init (void) |
4913 | { | 4925 | { |
4926 | int error = 1; | ||
4927 | idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape"); | ||
4928 | if (IS_ERR(idetape_sysfs_class)) { | ||
4929 | idetape_sysfs_class = NULL; | ||
4930 | printk(KERN_ERR "Unable to create sysfs class for ide tapes\n"); | ||
4931 | error = -EBUSY; | ||
4932 | goto out; | ||
4933 | } | ||
4934 | |||
4914 | if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { | 4935 | if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { |
4915 | printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); | 4936 | printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); |
4916 | return -EBUSY; | 4937 | error = -EBUSY; |
4938 | goto out_free_class; | ||
4917 | } | 4939 | } |
4918 | return driver_register(&idetape_driver.gen_driver); | 4940 | |
4941 | error = driver_register(&idetape_driver.gen_driver); | ||
4942 | if (error) | ||
4943 | goto out_free_driver; | ||
4944 | |||
4945 | return 0; | ||
4946 | |||
4947 | out_free_driver: | ||
4948 | driver_unregister(&idetape_driver.gen_driver); | ||
4949 | out_free_class: | ||
4950 | class_destroy(idetape_sysfs_class); | ||
4951 | out: | ||
4952 | return error; | ||
4919 | } | 4953 | } |
4920 | 4954 | ||
4921 | module_init(idetape_init); | 4955 | module_init(idetape_init); |
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index e34730c7a874..cbbbe14b8849 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c | |||
@@ -2361,7 +2361,7 @@ static void dv1394_add_host (struct hpsb_host *host) | |||
2361 | 2361 | ||
2362 | ohci = (struct ti_ohci *)host->hostdata; | 2362 | ohci = (struct ti_ohci *)host->hostdata; |
2363 | 2363 | ||
2364 | class_device_create(hpsb_protocol_class, MKDEV( | 2364 | class_device_create(hpsb_protocol_class, NULL, MKDEV( |
2365 | IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), | 2365 | IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), |
2366 | NULL, "dv1394-%d", id); | 2366 | NULL, "dv1394-%d", id); |
2367 | devfs_mk_dir("ieee1394/dv/host%d", id); | 2367 | devfs_mk_dir("ieee1394/dv/host%d", id); |
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 347ece6b583c..7fff5a1d2ea4 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -1292,7 +1292,7 @@ static void nodemgr_suspend_ne(struct node_entry *ne) | |||
1292 | 1292 | ||
1293 | if (ud->device.driver && | 1293 | if (ud->device.driver && |
1294 | (!ud->device.driver->suspend || | 1294 | (!ud->device.driver->suspend || |
1295 | ud->device.driver->suspend(&ud->device, PMSG_SUSPEND, 0))) | 1295 | ud->device.driver->suspend(&ud->device, PMSG_SUSPEND))) |
1296 | device_release_driver(&ud->device); | 1296 | device_release_driver(&ud->device); |
1297 | } | 1297 | } |
1298 | up_write(&ne->device.bus->subsys.rwsem); | 1298 | up_write(&ne->device.bus->subsys.rwsem); |
@@ -1315,7 +1315,7 @@ static void nodemgr_resume_ne(struct node_entry *ne) | |||
1315 | continue; | 1315 | continue; |
1316 | 1316 | ||
1317 | if (ud->device.driver && ud->device.driver->resume) | 1317 | if (ud->device.driver && ud->device.driver->resume) |
1318 | ud->device.driver->resume(&ud->device, 0); | 1318 | ud->device.driver->resume(&ud->device); |
1319 | } | 1319 | } |
1320 | up_read(&ne->device.bus->subsys.rwsem); | 1320 | up_read(&ne->device.bus->subsys.rwsem); |
1321 | 1321 | ||
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 0470f77a9cd1..24411e666b21 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c | |||
@@ -2912,7 +2912,7 @@ static int __init init_raw1394(void) | |||
2912 | 2912 | ||
2913 | hpsb_register_highlevel(&raw1394_highlevel); | 2913 | hpsb_register_highlevel(&raw1394_highlevel); |
2914 | 2914 | ||
2915 | if (IS_ERR(class_device_create(hpsb_protocol_class, MKDEV( | 2915 | if (IS_ERR(class_device_create(hpsb_protocol_class, NULL, MKDEV( |
2916 | IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), | 2916 | IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), |
2917 | NULL, RAW1394_DEVICE_NAME))) { | 2917 | NULL, RAW1394_DEVICE_NAME))) { |
2918 | ret = -EFAULT; | 2918 | ret = -EFAULT; |
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 11be9c9c82a8..23911da50154 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c | |||
@@ -1370,7 +1370,7 @@ static void video1394_add_host (struct hpsb_host *host) | |||
1370 | hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); | 1370 | hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); |
1371 | 1371 | ||
1372 | minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; | 1372 | minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; |
1373 | class_device_create(hpsb_protocol_class, MKDEV( | 1373 | class_device_create(hpsb_protocol_class, NULL, MKDEV( |
1374 | IEEE1394_MAJOR, minor), | 1374 | IEEE1394_MAJOR, minor), |
1375 | NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); | 1375 | NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); |
1376 | devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor), | 1376 | devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor), |
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index d0f0b0a2edd3..021b8f1d36d3 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -1300,7 +1300,7 @@ static int __init ib_ucm_init(void) | |||
1300 | goto err_class; | 1300 | goto err_class; |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | class_device_create(ib_ucm_class, IB_UCM_DEV, NULL, "ucm"); | 1303 | class_device_create(ib_ucm_class, NULL, IB_UCM_DEV, NULL, "ucm"); |
1304 | 1304 | ||
1305 | idr_init(&ctx_id_table); | 1305 | idr_init(&ctx_id_table); |
1306 | init_MUTEX(&ctx_id_mutex); | 1306 | init_MUTEX(&ctx_id_mutex); |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 3738d173f9a6..a4696cd0978c 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/major.h> | 20 | #include <linux/major.h> |
21 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/devfs_fs_kernel.h> | ||
24 | #include <linux/compat.h> | 23 | #include <linux/compat.h> |
25 | 24 | ||
26 | struct evdev { | 25 | struct evdev { |
@@ -662,6 +661,7 @@ static struct file_operations evdev_fops = { | |||
662 | static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) | 661 | static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
663 | { | 662 | { |
664 | struct evdev *evdev; | 663 | struct evdev *evdev; |
664 | struct class_device *cdev; | ||
665 | int minor; | 665 | int minor; |
666 | 666 | ||
667 | for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++); | 667 | for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++); |
@@ -687,11 +687,13 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct | |||
687 | 687 | ||
688 | evdev_table[minor] = evdev; | 688 | evdev_table[minor] = evdev; |
689 | 689 | ||
690 | devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), | 690 | cdev = class_device_create(&input_class, &dev->cdev, |
691 | S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor); | ||
692 | class_device_create(input_class, | ||
693 | MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), | 691 | MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), |
694 | dev->dev, "event%d", minor); | 692 | dev->cdev.dev, evdev->name); |
693 | |||
694 | /* temporary symlink to keep userspace happy */ | ||
695 | sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, | ||
696 | evdev->name); | ||
695 | 697 | ||
696 | return &evdev->handle; | 698 | return &evdev->handle; |
697 | } | 699 | } |
@@ -701,9 +703,9 @@ static void evdev_disconnect(struct input_handle *handle) | |||
701 | struct evdev *evdev = handle->private; | 703 | struct evdev *evdev = handle->private; |
702 | struct evdev_list *list; | 704 | struct evdev_list *list; |
703 | 705 | ||
704 | class_device_destroy(input_class, | 706 | sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name); |
707 | class_device_destroy(&input_class, | ||
705 | MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor)); | 708 | MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor)); |
706 | devfs_remove("input/event%d", evdev->minor); | ||
707 | evdev->exist = 0; | 709 | evdev->exist = 0; |
708 | 710 | ||
709 | if (evdev->open) { | 711 | if (evdev->open) { |
diff --git a/drivers/input/input.c b/drivers/input/input.c index 14ae5583e198..3b1685ff9d10 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -22,12 +22,12 @@ | |||
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/poll.h> | 23 | #include <linux/poll.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/devfs_fs_kernel.h> | ||
26 | 25 | ||
27 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); | 26 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); |
28 | MODULE_DESCRIPTION("Input core"); | 27 | MODULE_DESCRIPTION("Input core"); |
29 | MODULE_LICENSE("GPL"); | 28 | MODULE_LICENSE("GPL"); |
30 | 29 | ||
30 | EXPORT_SYMBOL(input_allocate_device); | ||
31 | EXPORT_SYMBOL(input_register_device); | 31 | EXPORT_SYMBOL(input_register_device); |
32 | EXPORT_SYMBOL(input_unregister_device); | 32 | EXPORT_SYMBOL(input_unregister_device); |
33 | EXPORT_SYMBOL(input_register_handler); | 33 | EXPORT_SYMBOL(input_register_handler); |
@@ -39,7 +39,7 @@ EXPORT_SYMBOL(input_close_device); | |||
39 | EXPORT_SYMBOL(input_accept_process); | 39 | EXPORT_SYMBOL(input_accept_process); |
40 | EXPORT_SYMBOL(input_flush_device); | 40 | EXPORT_SYMBOL(input_flush_device); |
41 | EXPORT_SYMBOL(input_event); | 41 | EXPORT_SYMBOL(input_event); |
42 | EXPORT_SYMBOL(input_class); | 42 | EXPORT_SYMBOL_GPL(input_class); |
43 | 43 | ||
44 | #define INPUT_DEVICES 256 | 44 | #define INPUT_DEVICES 256 |
45 | 45 | ||
@@ -316,124 +316,21 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st | |||
316 | return NULL; | 316 | return NULL; |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, int max) | |
320 | /* | ||
321 | * Input hotplugging interface - loading event handlers based on | ||
322 | * device bitfields. | ||
323 | */ | ||
324 | |||
325 | #ifdef CONFIG_HOTPLUG | ||
326 | |||
327 | /* | ||
328 | * Input hotplugging invokes what /proc/sys/kernel/hotplug says | ||
329 | * (normally /sbin/hotplug) when input devices get added or removed. | ||
330 | * | ||
331 | * This invokes a user mode policy agent, typically helping to load driver | ||
332 | * or other modules, configure the device, and more. Drivers can provide | ||
333 | * a MODULE_DEVICE_TABLE to help with module loading subtasks. | ||
334 | * | ||
335 | */ | ||
336 | |||
337 | #define SPRINTF_BIT_A(bit, name, max) \ | ||
338 | do { \ | ||
339 | envp[i++] = scratch; \ | ||
340 | scratch += sprintf(scratch, name); \ | ||
341 | for (j = NBITS(max) - 1; j >= 0; j--) \ | ||
342 | if (dev->bit[j]) break; \ | ||
343 | for (; j >= 0; j--) \ | ||
344 | scratch += sprintf(scratch, "%lx ", dev->bit[j]); \ | ||
345 | scratch++; \ | ||
346 | } while (0) | ||
347 | |||
348 | #define SPRINTF_BIT_A2(bit, name, max, ev) \ | ||
349 | do { \ | ||
350 | if (test_bit(ev, dev->evbit)) \ | ||
351 | SPRINTF_BIT_A(bit, name, max); \ | ||
352 | } while (0) | ||
353 | |||
354 | static void input_call_hotplug(char *verb, struct input_dev *dev) | ||
355 | { | 320 | { |
356 | char *argv[3], **envp, *buf, *scratch; | 321 | int i; |
357 | int i = 0, j, value; | 322 | int len = 0; |
358 | |||
359 | if (!hotplug_path[0]) { | ||
360 | printk(KERN_ERR "input.c: calling hotplug without a hotplug agent defined\n"); | ||
361 | return; | ||
362 | } | ||
363 | if (in_interrupt()) { | ||
364 | printk(KERN_ERR "input.c: calling hotplug from interrupt\n"); | ||
365 | return; | ||
366 | } | ||
367 | if (!current->fs->root) { | ||
368 | printk(KERN_WARNING "input.c: calling hotplug without valid filesystem\n"); | ||
369 | return; | ||
370 | } | ||
371 | if (!(envp = (char **) kmalloc(20 * sizeof(char *), GFP_KERNEL))) { | ||
372 | printk(KERN_ERR "input.c: not enough memory allocating hotplug environment\n"); | ||
373 | return; | ||
374 | } | ||
375 | if (!(buf = kmalloc(1024, GFP_KERNEL))) { | ||
376 | kfree (envp); | ||
377 | printk(KERN_ERR "input.c: not enough memory allocating hotplug environment\n"); | ||
378 | return; | ||
379 | } | ||
380 | |||
381 | argv[0] = hotplug_path; | ||
382 | argv[1] = "input"; | ||
383 | argv[2] = NULL; | ||
384 | |||
385 | envp[i++] = "HOME=/"; | ||
386 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | ||
387 | |||
388 | scratch = buf; | ||
389 | |||
390 | envp[i++] = scratch; | ||
391 | scratch += sprintf(scratch, "ACTION=%s", verb) + 1; | ||
392 | |||
393 | envp[i++] = scratch; | ||
394 | scratch += sprintf(scratch, "PRODUCT=%x/%x/%x/%x", | ||
395 | dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version) + 1; | ||
396 | |||
397 | if (dev->name) { | ||
398 | envp[i++] = scratch; | ||
399 | scratch += sprintf(scratch, "NAME=%s", dev->name) + 1; | ||
400 | } | ||
401 | |||
402 | if (dev->phys) { | ||
403 | envp[i++] = scratch; | ||
404 | scratch += sprintf(scratch, "PHYS=%s", dev->phys) + 1; | ||
405 | } | ||
406 | |||
407 | SPRINTF_BIT_A(evbit, "EV=", EV_MAX); | ||
408 | SPRINTF_BIT_A2(keybit, "KEY=", KEY_MAX, EV_KEY); | ||
409 | SPRINTF_BIT_A2(relbit, "REL=", REL_MAX, EV_REL); | ||
410 | SPRINTF_BIT_A2(absbit, "ABS=", ABS_MAX, EV_ABS); | ||
411 | SPRINTF_BIT_A2(mscbit, "MSC=", MSC_MAX, EV_MSC); | ||
412 | SPRINTF_BIT_A2(ledbit, "LED=", LED_MAX, EV_LED); | ||
413 | SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND); | ||
414 | SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF); | ||
415 | SPRINTF_BIT_A2(swbit, "SW=", SW_MAX, EV_SW); | ||
416 | |||
417 | envp[i++] = NULL; | ||
418 | |||
419 | #ifdef INPUT_DEBUG | ||
420 | printk(KERN_DEBUG "input.c: calling %s %s [%s %s %s %s %s]\n", | ||
421 | argv[0], argv[1], envp[0], envp[1], envp[2], envp[3], envp[4]); | ||
422 | #endif | ||
423 | |||
424 | value = call_usermodehelper(argv [0], argv, envp, 0); | ||
425 | 323 | ||
426 | kfree(buf); | 324 | for (i = NBITS(max) - 1; i > 0; i--) |
427 | kfree(envp); | 325 | if (bitmap[i]) |
326 | break; | ||
428 | 327 | ||
429 | #ifdef INPUT_DEBUG | 328 | for (; i >= 0; i--) |
430 | if (value != 0) | 329 | len += snprintf(buf + len, max(buf_size - len, 0), |
431 | printk(KERN_DEBUG "input.c: hotplug returned %d\n", value); | 330 | "%lx%s", bitmap[i], i > 0 ? " " : ""); |
432 | #endif | 331 | return len; |
433 | } | 332 | } |
434 | 333 | ||
435 | #endif | ||
436 | |||
437 | #ifdef CONFIG_PROC_FS | 334 | #ifdef CONFIG_PROC_FS |
438 | 335 | ||
439 | static struct proc_dir_entry *proc_bus_input_dir; | 336 | static struct proc_dir_entry *proc_bus_input_dir; |
@@ -455,37 +352,39 @@ static unsigned int input_devices_poll(struct file *file, poll_table *wait) | |||
455 | return 0; | 352 | return 0; |
456 | } | 353 | } |
457 | 354 | ||
458 | #define SPRINTF_BIT_B(bit, name, max) \ | 355 | #define SPRINTF_BIT(ev, bm) \ |
459 | do { \ | 356 | do { \ |
460 | len += sprintf(buf + len, "B: %s", name); \ | 357 | len += sprintf(buf + len, "B: %s=", #ev); \ |
461 | for (i = NBITS(max) - 1; i >= 0; i--) \ | 358 | len += input_print_bitmap(buf + len, INT_MAX, \ |
462 | if (dev->bit[i]) break; \ | 359 | dev->bm##bit, ev##_MAX); \ |
463 | for (; i >= 0; i--) \ | 360 | len += sprintf(buf + len, "\n"); \ |
464 | len += sprintf(buf + len, "%lx ", dev->bit[i]); \ | ||
465 | len += sprintf(buf + len, "\n"); \ | ||
466 | } while (0) | 361 | } while (0) |
467 | 362 | ||
468 | #define SPRINTF_BIT_B2(bit, name, max, ev) \ | 363 | #define TEST_AND_SPRINTF_BIT(ev, bm) \ |
469 | do { \ | 364 | do { \ |
470 | if (test_bit(ev, dev->evbit)) \ | 365 | if (test_bit(EV_##ev, dev->evbit)) \ |
471 | SPRINTF_BIT_B(bit, name, max); \ | 366 | SPRINTF_BIT(ev, bm); \ |
472 | } while (0) | 367 | } while (0) |
473 | 368 | ||
474 | static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) | 369 | static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) |
475 | { | 370 | { |
476 | struct input_dev *dev; | 371 | struct input_dev *dev; |
477 | struct input_handle *handle; | 372 | struct input_handle *handle; |
373 | const char *path; | ||
478 | 374 | ||
479 | off_t at = 0; | 375 | off_t at = 0; |
480 | int i, len, cnt = 0; | 376 | int len, cnt = 0; |
481 | 377 | ||
482 | list_for_each_entry(dev, &input_dev_list, node) { | 378 | list_for_each_entry(dev, &input_dev_list, node) { |
483 | 379 | ||
380 | path = dev->dynalloc ? kobject_get_path(&dev->cdev.kobj, GFP_KERNEL) : NULL; | ||
381 | |||
484 | len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", | 382 | len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", |
485 | dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); | 383 | dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); |
486 | 384 | ||
487 | len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); | 385 | len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); |
488 | len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : ""); | 386 | len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : ""); |
387 | len += sprintf(buf + len, "S: Sysfs=%s\n", path ? path : ""); | ||
489 | len += sprintf(buf + len, "H: Handlers="); | 388 | len += sprintf(buf + len, "H: Handlers="); |
490 | 389 | ||
491 | list_for_each_entry(handle, &dev->h_list, d_node) | 390 | list_for_each_entry(handle, &dev->h_list, d_node) |
@@ -493,15 +392,15 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int | |||
493 | 392 | ||
494 | len += sprintf(buf + len, "\n"); | 393 | len += sprintf(buf + len, "\n"); |
495 | 394 | ||
496 | SPRINTF_BIT_B(evbit, "EV=", EV_MAX); | 395 | SPRINTF_BIT(EV, ev); |
497 | SPRINTF_BIT_B2(keybit, "KEY=", KEY_MAX, EV_KEY); | 396 | TEST_AND_SPRINTF_BIT(KEY, key); |
498 | SPRINTF_BIT_B2(relbit, "REL=", REL_MAX, EV_REL); | 397 | TEST_AND_SPRINTF_BIT(REL, rel); |
499 | SPRINTF_BIT_B2(absbit, "ABS=", ABS_MAX, EV_ABS); | 398 | TEST_AND_SPRINTF_BIT(ABS, abs); |
500 | SPRINTF_BIT_B2(mscbit, "MSC=", MSC_MAX, EV_MSC); | 399 | TEST_AND_SPRINTF_BIT(MSC, msc); |
501 | SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED); | 400 | TEST_AND_SPRINTF_BIT(LED, led); |
502 | SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND); | 401 | TEST_AND_SPRINTF_BIT(SND, snd); |
503 | SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF); | 402 | TEST_AND_SPRINTF_BIT(FF, ff); |
504 | SPRINTF_BIT_B2(swbit, "SW=", SW_MAX, EV_SW); | 403 | TEST_AND_SPRINTF_BIT(SW, sw); |
505 | 404 | ||
506 | len += sprintf(buf + len, "\n"); | 405 | len += sprintf(buf + len, "\n"); |
507 | 406 | ||
@@ -516,6 +415,8 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int | |||
516 | if (cnt >= count) | 415 | if (cnt >= count) |
517 | break; | 416 | break; |
518 | } | 417 | } |
418 | |||
419 | kfree(path); | ||
519 | } | 420 | } |
520 | 421 | ||
521 | if (&dev->node == &input_dev_list) | 422 | if (&dev->node == &input_dev_list) |
@@ -606,6 +507,240 @@ static inline int input_proc_init(void) { return 0; } | |||
606 | static inline void input_proc_exit(void) { } | 507 | static inline void input_proc_exit(void) { } |
607 | #endif | 508 | #endif |
608 | 509 | ||
510 | #define INPUT_DEV_STRING_ATTR_SHOW(name) \ | ||
511 | static ssize_t input_dev_show_##name(struct class_device *dev, char *buf) \ | ||
512 | { \ | ||
513 | struct input_dev *input_dev = to_input_dev(dev); \ | ||
514 | int retval; \ | ||
515 | \ | ||
516 | retval = down_interruptible(&input_dev->sem); \ | ||
517 | if (retval) \ | ||
518 | return retval; \ | ||
519 | \ | ||
520 | retval = sprintf(buf, "%s\n", input_dev->name ? input_dev->name : ""); \ | ||
521 | \ | ||
522 | up(&input_dev->sem); \ | ||
523 | \ | ||
524 | return retval; \ | ||
525 | } \ | ||
526 | static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_##name, NULL); | ||
527 | |||
528 | INPUT_DEV_STRING_ATTR_SHOW(name); | ||
529 | INPUT_DEV_STRING_ATTR_SHOW(phys); | ||
530 | INPUT_DEV_STRING_ATTR_SHOW(uniq); | ||
531 | |||
532 | static struct attribute *input_dev_attrs[] = { | ||
533 | &class_device_attr_name.attr, | ||
534 | &class_device_attr_phys.attr, | ||
535 | &class_device_attr_uniq.attr, | ||
536 | NULL | ||
537 | }; | ||
538 | |||
539 | static struct attribute_group input_dev_group = { | ||
540 | .attrs = input_dev_attrs, | ||
541 | }; | ||
542 | |||
543 | #define INPUT_DEV_ID_ATTR(name) \ | ||
544 | static ssize_t input_dev_show_id_##name(struct class_device *dev, char *buf) \ | ||
545 | { \ | ||
546 | struct input_dev *input_dev = to_input_dev(dev); \ | ||
547 | return sprintf(buf, "%04x\n", input_dev->id.name); \ | ||
548 | } \ | ||
549 | static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_id_##name, NULL); | ||
550 | |||
551 | INPUT_DEV_ID_ATTR(bustype); | ||
552 | INPUT_DEV_ID_ATTR(vendor); | ||
553 | INPUT_DEV_ID_ATTR(product); | ||
554 | INPUT_DEV_ID_ATTR(version); | ||
555 | |||
556 | static struct attribute *input_dev_id_attrs[] = { | ||
557 | &class_device_attr_bustype.attr, | ||
558 | &class_device_attr_vendor.attr, | ||
559 | &class_device_attr_product.attr, | ||
560 | &class_device_attr_version.attr, | ||
561 | NULL | ||
562 | }; | ||
563 | |||
564 | static struct attribute_group input_dev_id_attr_group = { | ||
565 | .name = "id", | ||
566 | .attrs = input_dev_id_attrs, | ||
567 | }; | ||
568 | |||
569 | #define INPUT_DEV_CAP_ATTR(ev, bm) \ | ||
570 | static ssize_t input_dev_show_cap_##bm(struct class_device *dev, char *buf) \ | ||
571 | { \ | ||
572 | struct input_dev *input_dev = to_input_dev(dev); \ | ||
573 | return input_print_bitmap(buf, PAGE_SIZE, input_dev->bm##bit, ev##_MAX);\ | ||
574 | } \ | ||
575 | static CLASS_DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL); | ||
576 | |||
577 | INPUT_DEV_CAP_ATTR(EV, ev); | ||
578 | INPUT_DEV_CAP_ATTR(KEY, key); | ||
579 | INPUT_DEV_CAP_ATTR(REL, rel); | ||
580 | INPUT_DEV_CAP_ATTR(ABS, abs); | ||
581 | INPUT_DEV_CAP_ATTR(MSC, msc); | ||
582 | INPUT_DEV_CAP_ATTR(LED, led); | ||
583 | INPUT_DEV_CAP_ATTR(SND, snd); | ||
584 | INPUT_DEV_CAP_ATTR(FF, ff); | ||
585 | INPUT_DEV_CAP_ATTR(SW, sw); | ||
586 | |||
587 | static struct attribute *input_dev_caps_attrs[] = { | ||
588 | &class_device_attr_ev.attr, | ||
589 | &class_device_attr_key.attr, | ||
590 | &class_device_attr_rel.attr, | ||
591 | &class_device_attr_abs.attr, | ||
592 | &class_device_attr_msc.attr, | ||
593 | &class_device_attr_led.attr, | ||
594 | &class_device_attr_snd.attr, | ||
595 | &class_device_attr_ff.attr, | ||
596 | &class_device_attr_sw.attr, | ||
597 | NULL | ||
598 | }; | ||
599 | |||
600 | static struct attribute_group input_dev_caps_attr_group = { | ||
601 | .name = "capabilities", | ||
602 | .attrs = input_dev_caps_attrs, | ||
603 | }; | ||
604 | |||
605 | static void input_dev_release(struct class_device *class_dev) | ||
606 | { | ||
607 | struct input_dev *dev = to_input_dev(class_dev); | ||
608 | |||
609 | kfree(dev); | ||
610 | module_put(THIS_MODULE); | ||
611 | } | ||
612 | |||
613 | /* | ||
614 | * Input hotplugging interface - loading event handlers based on | ||
615 | * device bitfields. | ||
616 | */ | ||
617 | static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, | ||
618 | char *buffer, int buffer_size, int *cur_len, | ||
619 | const char *name, unsigned long *bitmap, int max) | ||
620 | { | ||
621 | if (*cur_index >= num_envp - 1) | ||
622 | return -ENOMEM; | ||
623 | |||
624 | envp[*cur_index] = buffer + *cur_len; | ||
625 | |||
626 | *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), name); | ||
627 | if (*cur_len > buffer_size) | ||
628 | return -ENOMEM; | ||
629 | |||
630 | *cur_len += input_print_bitmap(buffer + *cur_len, | ||
631 | max(buffer_size - *cur_len, 0), | ||
632 | bitmap, max) + 1; | ||
633 | if (*cur_len > buffer_size) | ||
634 | return -ENOMEM; | ||
635 | |||
636 | (*cur_index)++; | ||
637 | return 0; | ||
638 | } | ||
639 | |||
640 | #define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ | ||
641 | do { \ | ||
642 | int err = add_hotplug_env_var(envp, num_envp, &i, \ | ||
643 | buffer, buffer_size, &len, \ | ||
644 | fmt, val); \ | ||
645 | if (err) \ | ||
646 | return err; \ | ||
647 | } while (0) | ||
648 | |||
649 | #define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \ | ||
650 | do { \ | ||
651 | int err = input_add_hotplug_bm_var(envp, num_envp, &i, \ | ||
652 | buffer, buffer_size, &len, \ | ||
653 | name, bm, max); \ | ||
654 | if (err) \ | ||
655 | return err; \ | ||
656 | } while (0) | ||
657 | |||
658 | static int input_dev_hotplug(struct class_device *cdev, char **envp, | ||
659 | int num_envp, char *buffer, int buffer_size) | ||
660 | { | ||
661 | struct input_dev *dev = to_input_dev(cdev); | ||
662 | int i = 0; | ||
663 | int len = 0; | ||
664 | |||
665 | INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x", | ||
666 | dev->id.bustype, dev->id.vendor, | ||
667 | dev->id.product, dev->id.version); | ||
668 | if (dev->name) | ||
669 | INPUT_ADD_HOTPLUG_VAR("NAME=\"%s\"", dev->name); | ||
670 | if (dev->phys) | ||
671 | INPUT_ADD_HOTPLUG_VAR("PHYS=\"%s\"", dev->phys); | ||
672 | if (dev->phys) | ||
673 | INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq); | ||
674 | |||
675 | INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX); | ||
676 | if (test_bit(EV_KEY, dev->evbit)) | ||
677 | INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX); | ||
678 | if (test_bit(EV_REL, dev->evbit)) | ||
679 | INPUT_ADD_HOTPLUG_BM_VAR("REL=", dev->relbit, REL_MAX); | ||
680 | if (test_bit(EV_ABS, dev->evbit)) | ||
681 | INPUT_ADD_HOTPLUG_BM_VAR("ABS=", dev->absbit, ABS_MAX); | ||
682 | if (test_bit(EV_MSC, dev->evbit)) | ||
683 | INPUT_ADD_HOTPLUG_BM_VAR("MSC=", dev->mscbit, MSC_MAX); | ||
684 | if (test_bit(EV_LED, dev->evbit)) | ||
685 | INPUT_ADD_HOTPLUG_BM_VAR("LED=", dev->ledbit, LED_MAX); | ||
686 | if (test_bit(EV_SND, dev->evbit)) | ||
687 | INPUT_ADD_HOTPLUG_BM_VAR("SND=", dev->sndbit, SND_MAX); | ||
688 | if (test_bit(EV_FF, dev->evbit)) | ||
689 | INPUT_ADD_HOTPLUG_BM_VAR("FF=", dev->ffbit, FF_MAX); | ||
690 | if (test_bit(EV_SW, dev->evbit)) | ||
691 | INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX); | ||
692 | |||
693 | envp[i] = NULL; | ||
694 | |||
695 | return 0; | ||
696 | } | ||
697 | |||
698 | struct class input_class = { | ||
699 | .name = "input", | ||
700 | .release = input_dev_release, | ||
701 | .hotplug = input_dev_hotplug, | ||
702 | }; | ||
703 | |||
704 | struct input_dev *input_allocate_device(void) | ||
705 | { | ||
706 | struct input_dev *dev; | ||
707 | |||
708 | dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); | ||
709 | if (dev) { | ||
710 | dev->dynalloc = 1; | ||
711 | dev->cdev.class = &input_class; | ||
712 | class_device_initialize(&dev->cdev); | ||
713 | INIT_LIST_HEAD(&dev->h_list); | ||
714 | INIT_LIST_HEAD(&dev->node); | ||
715 | } | ||
716 | |||
717 | return dev; | ||
718 | } | ||
719 | |||
720 | static void input_register_classdevice(struct input_dev *dev) | ||
721 | { | ||
722 | static atomic_t input_no = ATOMIC_INIT(0); | ||
723 | const char *path; | ||
724 | |||
725 | __module_get(THIS_MODULE); | ||
726 | |||
727 | dev->dev = dev->cdev.dev; | ||
728 | |||
729 | snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id), | ||
730 | "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); | ||
731 | |||
732 | path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL); | ||
733 | printk(KERN_INFO "input: %s/%s as %s\n", | ||
734 | dev->name ? dev->name : "Unspecified device", | ||
735 | path ? path : "", dev->cdev.class_id); | ||
736 | kfree(path); | ||
737 | |||
738 | class_device_add(&dev->cdev); | ||
739 | sysfs_create_group(&dev->cdev.kobj, &input_dev_group); | ||
740 | sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
741 | sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | ||
742 | } | ||
743 | |||
609 | void input_register_device(struct input_dev *dev) | 744 | void input_register_device(struct input_dev *dev) |
610 | { | 745 | { |
611 | struct input_handle *handle; | 746 | struct input_handle *handle; |
@@ -632,15 +767,15 @@ void input_register_device(struct input_dev *dev) | |||
632 | INIT_LIST_HEAD(&dev->h_list); | 767 | INIT_LIST_HEAD(&dev->h_list); |
633 | list_add_tail(&dev->node, &input_dev_list); | 768 | list_add_tail(&dev->node, &input_dev_list); |
634 | 769 | ||
770 | if (dev->dynalloc) | ||
771 | input_register_classdevice(dev); | ||
772 | |||
635 | list_for_each_entry(handler, &input_handler_list, node) | 773 | list_for_each_entry(handler, &input_handler_list, node) |
636 | if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) | 774 | if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) |
637 | if ((id = input_match_device(handler->id_table, dev))) | 775 | if ((id = input_match_device(handler->id_table, dev))) |
638 | if ((handle = handler->connect(handler, dev, id))) | 776 | if ((handle = handler->connect(handler, dev, id))) |
639 | input_link_handle(handle); | 777 | input_link_handle(handle); |
640 | 778 | ||
641 | #ifdef CONFIG_HOTPLUG | ||
642 | input_call_hotplug("add", dev); | ||
643 | #endif | ||
644 | 779 | ||
645 | input_wakeup_procfs_readers(); | 780 | input_wakeup_procfs_readers(); |
646 | } | 781 | } |
@@ -660,12 +795,14 @@ void input_unregister_device(struct input_dev *dev) | |||
660 | handle->handler->disconnect(handle); | 795 | handle->handler->disconnect(handle); |
661 | } | 796 | } |
662 | 797 | ||
663 | #ifdef CONFIG_HOTPLUG | ||
664 | input_call_hotplug("remove", dev); | ||
665 | #endif | ||
666 | |||
667 | list_del_init(&dev->node); | 798 | list_del_init(&dev->node); |
668 | 799 | ||
800 | if (dev->dynalloc) { | ||
801 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | ||
802 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
803 | class_device_unregister(&dev->cdev); | ||
804 | } | ||
805 | |||
669 | input_wakeup_procfs_readers(); | 806 | input_wakeup_procfs_readers(); |
670 | } | 807 | } |
671 | 808 | ||
@@ -748,16 +885,14 @@ static struct file_operations input_fops = { | |||
748 | .open = input_open_file, | 885 | .open = input_open_file, |
749 | }; | 886 | }; |
750 | 887 | ||
751 | struct class *input_class; | ||
752 | |||
753 | static int __init input_init(void) | 888 | static int __init input_init(void) |
754 | { | 889 | { |
755 | int err; | 890 | int err; |
756 | 891 | ||
757 | input_class = class_create(THIS_MODULE, "input"); | 892 | err = class_register(&input_class); |
758 | if (IS_ERR(input_class)) { | 893 | if (err) { |
759 | printk(KERN_ERR "input: unable to register input class\n"); | 894 | printk(KERN_ERR "input: unable to register input_dev class\n"); |
760 | return PTR_ERR(input_class); | 895 | return err; |
761 | } | 896 | } |
762 | 897 | ||
763 | err = input_proc_init(); | 898 | err = input_proc_init(); |
@@ -770,24 +905,18 @@ static int __init input_init(void) | |||
770 | goto fail2; | 905 | goto fail2; |
771 | } | 906 | } |
772 | 907 | ||
773 | err = devfs_mk_dir("input"); | ||
774 | if (err) | ||
775 | goto fail3; | ||
776 | |||
777 | return 0; | 908 | return 0; |
778 | 909 | ||
779 | fail3: unregister_chrdev(INPUT_MAJOR, "input"); | ||
780 | fail2: input_proc_exit(); | 910 | fail2: input_proc_exit(); |
781 | fail1: class_destroy(input_class); | 911 | fail1: class_unregister(&input_class); |
782 | return err; | 912 | return err; |
783 | } | 913 | } |
784 | 914 | ||
785 | static void __exit input_exit(void) | 915 | static void __exit input_exit(void) |
786 | { | 916 | { |
787 | input_proc_exit(); | 917 | input_proc_exit(); |
788 | devfs_remove("input"); | ||
789 | unregister_chrdev(INPUT_MAJOR, "input"); | 918 | unregister_chrdev(INPUT_MAJOR, "input"); |
790 | class_destroy(input_class); | 919 | class_unregister(&input_class); |
791 | } | 920 | } |
792 | 921 | ||
793 | subsys_initcall(input_init); | 922 | subsys_initcall(input_init); |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index e0938d1d3ad7..20e2972b9204 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/smp_lock.h> | 27 | #include <linux/smp_lock.h> |
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/devfs_fs_kernel.h> | ||
30 | 29 | ||
31 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 30 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
32 | MODULE_DESCRIPTION("Joystick device interfaces"); | 31 | MODULE_DESCRIPTION("Joystick device interfaces"); |
@@ -449,6 +448,7 @@ static struct file_operations joydev_fops = { | |||
449 | static struct input_handle *joydev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) | 448 | static struct input_handle *joydev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
450 | { | 449 | { |
451 | struct joydev *joydev; | 450 | struct joydev *joydev; |
451 | struct class_device *cdev; | ||
452 | int i, j, t, minor; | 452 | int i, j, t, minor; |
453 | 453 | ||
454 | for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++); | 454 | for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++); |
@@ -514,11 +514,13 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct | |||
514 | 514 | ||
515 | joydev_table[minor] = joydev; | 515 | joydev_table[minor] = joydev; |
516 | 516 | ||
517 | devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), | 517 | cdev = class_device_create(&input_class, &dev->cdev, |
518 | S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor); | ||
519 | class_device_create(input_class, | ||
520 | MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), | 518 | MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), |
521 | dev->dev, "js%d", minor); | 519 | dev->cdev.dev, joydev->name); |
520 | |||
521 | /* temporary symlink to keep userspace happy */ | ||
522 | sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, | ||
523 | joydev->name); | ||
522 | 524 | ||
523 | return &joydev->handle; | 525 | return &joydev->handle; |
524 | } | 526 | } |
@@ -528,8 +530,8 @@ static void joydev_disconnect(struct input_handle *handle) | |||
528 | struct joydev *joydev = handle->private; | 530 | struct joydev *joydev = handle->private; |
529 | struct joydev_list *list; | 531 | struct joydev_list *list; |
530 | 532 | ||
531 | class_device_destroy(input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor)); | 533 | sysfs_remove_link(&input_class.subsys.kset.kobj, joydev->name); |
532 | devfs_remove("input/js%d", joydev->minor); | 534 | class_device_destroy(&input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor)); |
533 | joydev->exist = 0; | 535 | joydev->exist = 0; |
534 | 536 | ||
535 | if (joydev->open) { | 537 | if (joydev->open) { |
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index cf35ae638a0d..9d95459f4bcb 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c | |||
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL"); | |||
54 | #define ADI_MIN_LENGTH 8 | 54 | #define ADI_MIN_LENGTH 8 |
55 | #define ADI_MIN_LEN_LENGTH 10 | 55 | #define ADI_MIN_LEN_LENGTH 10 |
56 | #define ADI_MIN_ID_LENGTH 66 | 56 | #define ADI_MIN_ID_LENGTH 66 |
57 | #define ADI_MAX_NAME_LENGTH 48 | 57 | #define ADI_MAX_NAME_LENGTH 64 |
58 | #define ADI_MAX_CNAME_LENGTH 16 | 58 | #define ADI_MAX_CNAME_LENGTH 16 |
59 | #define ADI_MAX_PHYS_LENGTH 64 | 59 | #define ADI_MAX_PHYS_LENGTH 64 |
60 | 60 | ||
@@ -106,7 +106,7 @@ static struct { | |||
106 | */ | 106 | */ |
107 | 107 | ||
108 | struct adi { | 108 | struct adi { |
109 | struct input_dev dev; | 109 | struct input_dev *dev; |
110 | int length; | 110 | int length; |
111 | int ret; | 111 | int ret; |
112 | int idx; | 112 | int idx; |
@@ -215,7 +215,7 @@ static inline int adi_get_bits(struct adi *adi, int count) | |||
215 | 215 | ||
216 | static int adi_decode(struct adi *adi) | 216 | static int adi_decode(struct adi *adi) |
217 | { | 217 | { |
218 | struct input_dev *dev = &adi->dev; | 218 | struct input_dev *dev = adi->dev; |
219 | char *abs = adi->abs; | 219 | char *abs = adi->abs; |
220 | short *key = adi->key; | 220 | short *key = adi->key; |
221 | int i, t; | 221 | int i, t; |
@@ -318,7 +318,8 @@ static void adi_init_digital(struct gameport *gameport) | |||
318 | 318 | ||
319 | for (i = 0; seq[i]; i++) { | 319 | for (i = 0; seq[i]; i++) { |
320 | gameport_trigger(gameport); | 320 | gameport_trigger(gameport); |
321 | if (seq[i] > 0) msleep(seq[i]); | 321 | if (seq[i] > 0) |
322 | msleep(seq[i]); | ||
322 | if (seq[i] < 0) { | 323 | if (seq[i] < 0) { |
323 | mdelay(-seq[i]); | 324 | mdelay(-seq[i]); |
324 | udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */ | 325 | udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */ |
@@ -397,42 +398,46 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port) | |||
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | static void adi_init_input(struct adi *adi, struct adi_port *port, int half) | 401 | static int adi_init_input(struct adi *adi, struct adi_port *port, int half) |
401 | { | 402 | { |
402 | int i, t; | 403 | struct input_dev *input_dev; |
403 | char buf[ADI_MAX_NAME_LENGTH]; | 404 | char buf[ADI_MAX_NAME_LENGTH]; |
405 | int i, t; | ||
404 | 406 | ||
405 | if (!adi->length) return; | 407 | adi->dev = input_dev = input_allocate_device(); |
406 | 408 | if (!input_dev) | |
407 | init_input_dev(&adi->dev); | 409 | return -ENOMEM; |
408 | 410 | ||
409 | t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX; | 411 | t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX; |
410 | 412 | ||
411 | snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id); | 413 | snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id); |
412 | snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s", buf); | 414 | snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname); |
413 | snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half); | 415 | snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half); |
414 | 416 | ||
415 | adi->abs = adi_abs[t]; | 417 | adi->abs = adi_abs[t]; |
416 | adi->key = adi_key[t]; | 418 | adi->key = adi_key[t]; |
417 | 419 | ||
418 | adi->dev.open = adi_open; | 420 | input_dev->name = adi->name; |
419 | adi->dev.close = adi_close; | 421 | input_dev->phys = adi->phys; |
422 | input_dev->id.bustype = BUS_GAMEPORT; | ||
423 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_LOGITECH; | ||
424 | input_dev->id.product = adi->id; | ||
425 | input_dev->id.version = 0x0100; | ||
426 | input_dev->cdev.dev = &port->gameport->dev; | ||
427 | input_dev->private = port; | ||
420 | 428 | ||
421 | adi->dev.name = adi->name; | 429 | input_dev->open = adi_open; |
422 | adi->dev.phys = adi->phys; | 430 | input_dev->close = adi_close; |
423 | adi->dev.id.bustype = BUS_GAMEPORT; | ||
424 | adi->dev.id.vendor = GAMEPORT_ID_VENDOR_LOGITECH; | ||
425 | adi->dev.id.product = adi->id; | ||
426 | adi->dev.id.version = 0x0100; | ||
427 | 431 | ||
428 | adi->dev.private = port; | 432 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
429 | adi->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
430 | 433 | ||
431 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) | 434 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) |
432 | set_bit(adi->abs[i], adi->dev.absbit); | 435 | set_bit(adi->abs[i], input_dev->absbit); |
433 | 436 | ||
434 | for (i = 0; i < adi->buttons; i++) | 437 | for (i = 0; i < adi->buttons; i++) |
435 | set_bit(adi->key[i], adi->dev.keybit); | 438 | set_bit(adi->key[i], input_dev->keybit); |
439 | |||
440 | return 0; | ||
436 | } | 441 | } |
437 | 442 | ||
438 | static void adi_init_center(struct adi *adi) | 443 | static void adi_init_center(struct adi *adi) |
@@ -445,17 +450,17 @@ static void adi_init_center(struct adi *adi) | |||
445 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) { | 450 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) { |
446 | 451 | ||
447 | t = adi->abs[i]; | 452 | t = adi->abs[i]; |
448 | x = adi->dev.abs[t]; | 453 | x = adi->dev->abs[t]; |
449 | 454 | ||
450 | if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) | 455 | if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) |
451 | x = i < adi->axes10 ? 512 : 128; | 456 | x = i < adi->axes10 ? 512 : 128; |
452 | 457 | ||
453 | if (i < adi->axes10) | 458 | if (i < adi->axes10) |
454 | input_set_abs_params(&adi->dev, t, 64, x * 2 - 64, 2, 16); | 459 | input_set_abs_params(adi->dev, t, 64, x * 2 - 64, 2, 16); |
455 | else if (i < adi->axes10 + adi->axes8) | 460 | else if (i < adi->axes10 + adi->axes8) |
456 | input_set_abs_params(&adi->dev, t, 48, x * 2 - 48, 1, 16); | 461 | input_set_abs_params(adi->dev, t, 48, x * 2 - 48, 1, 16); |
457 | else | 462 | else |
458 | input_set_abs_params(&adi->dev, t, -1, 1, 0, 0); | 463 | input_set_abs_params(adi->dev, t, -1, 1, 0, 0); |
459 | } | 464 | } |
460 | } | 465 | } |
461 | 466 | ||
@@ -469,7 +474,8 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
469 | int i; | 474 | int i; |
470 | int err; | 475 | int err; |
471 | 476 | ||
472 | if (!(port = kzalloc(sizeof(struct adi_port), GFP_KERNEL))) | 477 | port = kzalloc(sizeof(struct adi_port), GFP_KERNEL); |
478 | if (!port) | ||
473 | return -ENOMEM; | 479 | return -ENOMEM; |
474 | 480 | ||
475 | port->gameport = gameport; | 481 | port->gameport = gameport; |
@@ -477,10 +483,8 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
477 | gameport_set_drvdata(gameport, port); | 483 | gameport_set_drvdata(gameport, port); |
478 | 484 | ||
479 | err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW); | 485 | err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW); |
480 | if (err) { | 486 | if (err) |
481 | kfree(port); | 487 | goto fail1; |
482 | return err; | ||
483 | } | ||
484 | 488 | ||
485 | adi_init_digital(gameport); | 489 | adi_init_digital(gameport); |
486 | adi_read_packet(port); | 490 | adi_read_packet(port); |
@@ -490,13 +494,18 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
490 | 494 | ||
491 | for (i = 0; i < 2; i++) { | 495 | for (i = 0; i < 2; i++) { |
492 | adi_id_decode(port->adi + i, port); | 496 | adi_id_decode(port->adi + i, port); |
493 | adi_init_input(port->adi + i, port, i); | 497 | |
498 | if (!port->adi[i].length) | ||
499 | continue; | ||
500 | |||
501 | err = adi_init_input(port->adi + i, port, i); | ||
502 | if (err) | ||
503 | goto fail2; | ||
494 | } | 504 | } |
495 | 505 | ||
496 | if (!port->adi[0].length && !port->adi[1].length) { | 506 | if (!port->adi[0].length && !port->adi[1].length) { |
497 | gameport_close(gameport); | 507 | err = -ENODEV; |
498 | kfree(port); | 508 | goto fail2; |
499 | return -ENODEV; | ||
500 | } | 509 | } |
501 | 510 | ||
502 | gameport_set_poll_handler(gameport, adi_poll); | 511 | gameport_set_poll_handler(gameport, adi_poll); |
@@ -511,12 +520,18 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
511 | for (i = 0; i < 2; i++) | 520 | for (i = 0; i < 2; i++) |
512 | if (port->adi[i].length > 0) { | 521 | if (port->adi[i].length > 0) { |
513 | adi_init_center(port->adi + i); | 522 | adi_init_center(port->adi + i); |
514 | input_register_device(&port->adi[i].dev); | 523 | input_register_device(port->adi[i].dev); |
515 | printk(KERN_INFO "input: %s [%s] on %s\n", | ||
516 | port->adi[i].name, port->adi[i].cname, gameport->phys); | ||
517 | } | 524 | } |
518 | 525 | ||
519 | return 0; | 526 | return 0; |
527 | |||
528 | fail2: for (i = 0; i < 2; i++) | ||
529 | if (port->adi[i].dev) | ||
530 | input_free_device(port->adi[i].dev); | ||
531 | gameport_close(gameport); | ||
532 | fail1: gameport_set_drvdata(gameport, NULL); | ||
533 | kfree(port); | ||
534 | return err; | ||
520 | } | 535 | } |
521 | 536 | ||
522 | static void adi_disconnect(struct gameport *gameport) | 537 | static void adi_disconnect(struct gameport *gameport) |
@@ -526,7 +541,7 @@ static void adi_disconnect(struct gameport *gameport) | |||
526 | 541 | ||
527 | for (i = 0; i < 2; i++) | 542 | for (i = 0; i < 2; i++) |
528 | if (port->adi[i].length > 0) | 543 | if (port->adi[i].length > 0) |
529 | input_unregister_device(&port->adi[i].dev); | 544 | input_unregister_device(port->adi[i].dev); |
530 | gameport_close(gameport); | 545 | gameport_close(gameport); |
531 | gameport_set_drvdata(gameport, NULL); | 546 | gameport_set_drvdata(gameport, NULL); |
532 | kfree(port); | 547 | kfree(port); |
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c index e996183c5b06..8558a99f6635 100644 --- a/drivers/input/joystick/amijoy.c +++ b/drivers/input/joystick/amijoy.c | |||
@@ -53,11 +53,9 @@ __obsolete_setup("amijoy="); | |||
53 | 53 | ||
54 | static int amijoy_used; | 54 | static int amijoy_used; |
55 | static DECLARE_MUTEX(amijoy_sem); | 55 | static DECLARE_MUTEX(amijoy_sem); |
56 | static struct input_dev amijoy_dev[2]; | 56 | static struct input_dev *amijoy_dev[2]; |
57 | static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; | 57 | static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; |
58 | 58 | ||
59 | static char *amijoy_name = "Amiga joystick"; | ||
60 | |||
61 | static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp) | 59 | static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp) |
62 | { | 60 | { |
63 | int i, data = 0, button = 0; | 61 | int i, data = 0, button = 0; |
@@ -70,15 +68,15 @@ static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp) | |||
70 | case 1: data = ~custom.joy1dat; button = (~ciaa.pra >> 7) & 1; break; | 68 | case 1: data = ~custom.joy1dat; button = (~ciaa.pra >> 7) & 1; break; |
71 | } | 69 | } |
72 | 70 | ||
73 | input_regs(amijoy_dev + i, fp); | 71 | input_regs(amijoy_dev[i], fp); |
74 | 72 | ||
75 | input_report_key(amijoy_dev + i, BTN_TRIGGER, button); | 73 | input_report_key(amijoy_dev[i], BTN_TRIGGER, button); |
76 | 74 | ||
77 | input_report_abs(amijoy_dev + i, ABS_X, ((data >> 1) & 1) - ((data >> 9) & 1)); | 75 | input_report_abs(amijoy_dev[i], ABS_X, ((data >> 1) & 1) - ((data >> 9) & 1)); |
78 | data = ~(data ^ (data << 1)); | 76 | data = ~(data ^ (data << 1)); |
79 | input_report_abs(amijoy_dev + i, ABS_Y, ((data >> 1) & 1) - ((data >> 9) & 1)); | 77 | input_report_abs(amijoy_dev[i], ABS_Y, ((data >> 1) & 1) - ((data >> 9) & 1)); |
80 | 78 | ||
81 | input_sync(amijoy_dev + i); | 79 | input_sync(amijoy_dev[i]); |
82 | } | 80 | } |
83 | return IRQ_HANDLED; | 81 | return IRQ_HANDLED; |
84 | } | 82 | } |
@@ -114,39 +112,52 @@ static void amijoy_close(struct input_dev *dev) | |||
114 | static int __init amijoy_init(void) | 112 | static int __init amijoy_init(void) |
115 | { | 113 | { |
116 | int i, j; | 114 | int i, j; |
115 | int err; | ||
117 | 116 | ||
118 | for (i = 0; i < 2; i++) | 117 | for (i = 0; i < 2; i++) { |
119 | if (amijoy[i]) { | 118 | if (!amijoy[i]) |
120 | if (!request_mem_region(CUSTOM_PHYSADDR+10+i*2, 2, | 119 | continue; |
121 | "amijoy [Denise]")) { | ||
122 | if (i == 1 && amijoy[0]) { | ||
123 | input_unregister_device(amijoy_dev); | ||
124 | release_mem_region(CUSTOM_PHYSADDR+10, 2); | ||
125 | } | ||
126 | return -EBUSY; | ||
127 | } | ||
128 | 120 | ||
129 | amijoy_dev[i].open = amijoy_open; | 121 | amijoy_dev[i] = input_allocate_device(); |
130 | amijoy_dev[i].close = amijoy_close; | 122 | if (!amijoy_dev[i]) { |
131 | amijoy_dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 123 | err = -ENOMEM; |
132 | amijoy_dev[i].absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 124 | goto fail; |
133 | amijoy_dev[i].keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 125 | } |
134 | for (j = 0; j < 2; j++) { | ||
135 | amijoy_dev[i].absmin[ABS_X + j] = -1; | ||
136 | amijoy_dev[i].absmax[ABS_X + j] = 1; | ||
137 | } | ||
138 | 126 | ||
139 | amijoy_dev[i].name = amijoy_name; | 127 | if (!request_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2, "amijoy [Denise]")) { |
140 | amijoy_dev[i].phys = amijoy_phys[i]; | 128 | input_free_device(amijoy_dev[i]); |
141 | amijoy_dev[i].id.bustype = BUS_AMIGA; | 129 | err = -EBUSY; |
142 | amijoy_dev[i].id.vendor = 0x0001; | 130 | goto fail; |
143 | amijoy_dev[i].id.product = 0x0003; | 131 | } |
144 | amijoy_dev[i].id.version = 0x0100; | ||
145 | 132 | ||
146 | input_register_device(amijoy_dev + i); | 133 | amijoy_dev[i]->name = "Amiga joystick"; |
147 | printk(KERN_INFO "input: %s at joy%ddat\n", amijoy_name, i); | 134 | amijoy_dev[i]->phys = amijoy_phys[i]; |
135 | amijoy_dev[i]->id.bustype = BUS_AMIGA; | ||
136 | amijoy_dev[i]->id.vendor = 0x0001; | ||
137 | amijoy_dev[i]->id.product = 0x0003; | ||
138 | amijoy_dev[i]->id.version = 0x0100; | ||
139 | |||
140 | amijoy_dev[i]->open = amijoy_open; | ||
141 | amijoy_dev[i]->close = amijoy_close; | ||
142 | |||
143 | amijoy_dev[i]->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
144 | amijoy_dev[i]->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
145 | amijoy_dev[i]->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
146 | for (j = 0; j < 2; j++) { | ||
147 | amijoy_dev[i]->absmin[ABS_X + j] = -1; | ||
148 | amijoy_dev[i]->absmax[ABS_X + j] = 1; | ||
148 | } | 149 | } |
150 | |||
151 | input_register_device(amijoy_dev[i]); | ||
152 | } | ||
149 | return 0; | 153 | return 0; |
154 | |||
155 | fail: while (--i >= 0) | ||
156 | if (amijoy[i]) { | ||
157 | input_unregister_device(amijoy_dev[i]); | ||
158 | release_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2); | ||
159 | } | ||
160 | return err; | ||
150 | } | 161 | } |
151 | 162 | ||
152 | static void __exit amijoy_exit(void) | 163 | static void __exit amijoy_exit(void) |
@@ -155,8 +166,8 @@ static void __exit amijoy_exit(void) | |||
155 | 166 | ||
156 | for (i = 0; i < 2; i++) | 167 | for (i = 0; i < 2; i++) |
157 | if (amijoy[i]) { | 168 | if (amijoy[i]) { |
158 | input_unregister_device(amijoy_dev + i); | 169 | input_unregister_device(amijoy_dev[i]); |
159 | release_mem_region(CUSTOM_PHYSADDR+10+i*2, 2); | 170 | release_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2); |
160 | } | 171 | } |
161 | } | 172 | } |
162 | 173 | ||
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index 64b1313a3c66..c75ac6eb1ffb 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c | |||
@@ -111,7 +111,7 @@ static short analog_joy_btn[] = { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN | |||
111 | static unsigned char analog_chf[] = { 0xf, 0x0, 0x1, 0x9, 0x2, 0x4, 0xc, 0x8, 0x3, 0x5, 0xb, 0x7, 0xd, 0xe, 0xa, 0x6 }; | 111 | static unsigned char analog_chf[] = { 0xf, 0x0, 0x1, 0x9, 0x2, 0x4, 0xc, 0x8, 0x3, 0x5, 0xb, 0x7, 0xd, 0xe, 0xa, 0x6 }; |
112 | 112 | ||
113 | struct analog { | 113 | struct analog { |
114 | struct input_dev dev; | 114 | struct input_dev *dev; |
115 | int mask; | 115 | int mask; |
116 | short *buttons; | 116 | short *buttons; |
117 | char name[ANALOG_MAX_NAME_LENGTH]; | 117 | char name[ANALOG_MAX_NAME_LENGTH]; |
@@ -182,7 +182,7 @@ static unsigned long analog_faketime = 0; | |||
182 | 182 | ||
183 | static void analog_decode(struct analog *analog, int *axes, int *initial, int buttons) | 183 | static void analog_decode(struct analog *analog, int *axes, int *initial, int buttons) |
184 | { | 184 | { |
185 | struct input_dev *dev = &analog->dev; | 185 | struct input_dev *dev = analog->dev; |
186 | int i, j; | 186 | int i, j; |
187 | 187 | ||
188 | if (analog->mask & ANALOG_HAT_FCS) | 188 | if (analog->mask & ANALOG_HAT_FCS) |
@@ -428,27 +428,30 @@ static void analog_name(struct analog *analog) | |||
428 | * analog_init_device() | 428 | * analog_init_device() |
429 | */ | 429 | */ |
430 | 430 | ||
431 | static void analog_init_device(struct analog_port *port, struct analog *analog, int index) | 431 | static int analog_init_device(struct analog_port *port, struct analog *analog, int index) |
432 | { | 432 | { |
433 | struct input_dev *input_dev; | ||
433 | int i, j, t, v, w, x, y, z; | 434 | int i, j, t, v, w, x, y, z; |
434 | 435 | ||
435 | analog_name(analog); | 436 | analog_name(analog); |
436 | sprintf(analog->phys, "%s/input%d", port->gameport->phys, index); | 437 | sprintf(analog->phys, "%s/input%d", port->gameport->phys, index); |
437 | analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; | 438 | analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; |
438 | 439 | ||
439 | init_input_dev(&analog->dev); | 440 | analog->dev = input_dev = input_allocate_device(); |
441 | if (!input_dev) | ||
442 | return -ENOMEM; | ||
440 | 443 | ||
441 | analog->dev.name = analog->name; | 444 | input_dev->name = analog->name; |
442 | analog->dev.phys = analog->phys; | 445 | input_dev->phys = analog->phys; |
443 | analog->dev.id.bustype = BUS_GAMEPORT; | 446 | input_dev->id.bustype = BUS_GAMEPORT; |
444 | analog->dev.id.vendor = GAMEPORT_ID_VENDOR_ANALOG; | 447 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_ANALOG; |
445 | analog->dev.id.product = analog->mask >> 4; | 448 | input_dev->id.product = analog->mask >> 4; |
446 | analog->dev.id.version = 0x0100; | 449 | input_dev->id.version = 0x0100; |
447 | 450 | ||
448 | analog->dev.open = analog_open; | 451 | input_dev->open = analog_open; |
449 | analog->dev.close = analog_close; | 452 | input_dev->close = analog_close; |
450 | analog->dev.private = port; | 453 | input_dev->private = port; |
451 | analog->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 454 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
452 | 455 | ||
453 | for (i = j = 0; i < 4; i++) | 456 | for (i = j = 0; i < 4; i++) |
454 | if (analog->mask & (1 << i)) { | 457 | if (analog->mask & (1 << i)) { |
@@ -461,8 +464,6 @@ static void analog_init_device(struct analog_port *port, struct analog *analog, | |||
461 | v = (x >> 3); | 464 | v = (x >> 3); |
462 | w = (x >> 3); | 465 | w = (x >> 3); |
463 | 466 | ||
464 | set_bit(t, analog->dev.absbit); | ||
465 | |||
466 | if ((i == 2 || i == 3) && (j == 2 || j == 3) && (z > (y >> 3))) | 467 | if ((i == 2 || i == 3) && (j == 2 || j == 3) && (z > (y >> 3))) |
467 | x = y; | 468 | x = y; |
468 | 469 | ||
@@ -472,11 +473,7 @@ static void analog_init_device(struct analog_port *port, struct analog *analog, | |||
472 | w = (x >> 4); | 473 | w = (x >> 4); |
473 | } | 474 | } |
474 | 475 | ||
475 | analog->dev.absmax[t] = (x << 1) - v; | 476 | input_set_abs_params(input_dev, t, v, (x << 1) - v, port->fuzz, w); |
476 | analog->dev.absmin[t] = v; | ||
477 | analog->dev.absfuzz[t] = port->fuzz; | ||
478 | analog->dev.absflat[t] = w; | ||
479 | |||
480 | j++; | 477 | j++; |
481 | } | 478 | } |
482 | 479 | ||
@@ -484,41 +481,30 @@ static void analog_init_device(struct analog_port *port, struct analog *analog, | |||
484 | if (analog->mask & analog_exts[i]) | 481 | if (analog->mask & analog_exts[i]) |
485 | for (x = 0; x < 2; x++) { | 482 | for (x = 0; x < 2; x++) { |
486 | t = analog_hats[j++]; | 483 | t = analog_hats[j++]; |
487 | set_bit(t, analog->dev.absbit); | 484 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
488 | analog->dev.absmax[t] = 1; | ||
489 | analog->dev.absmin[t] = -1; | ||
490 | } | 485 | } |
491 | 486 | ||
492 | for (i = j = 0; i < 4; i++) | 487 | for (i = j = 0; i < 4; i++) |
493 | if (analog->mask & (0x10 << i)) | 488 | if (analog->mask & (0x10 << i)) |
494 | set_bit(analog->buttons[j++], analog->dev.keybit); | 489 | set_bit(analog->buttons[j++], input_dev->keybit); |
495 | 490 | ||
496 | if (analog->mask & ANALOG_BTNS_CHF) | 491 | if (analog->mask & ANALOG_BTNS_CHF) |
497 | for (i = 0; i < 2; i++) | 492 | for (i = 0; i < 2; i++) |
498 | set_bit(analog->buttons[j++], analog->dev.keybit); | 493 | set_bit(analog->buttons[j++], input_dev->keybit); |
499 | 494 | ||
500 | if (analog->mask & ANALOG_HBTN_CHF) | 495 | if (analog->mask & ANALOG_HBTN_CHF) |
501 | for (i = 0; i < 4; i++) | 496 | for (i = 0; i < 4; i++) |
502 | set_bit(analog->buttons[j++], analog->dev.keybit); | 497 | set_bit(analog->buttons[j++], input_dev->keybit); |
503 | 498 | ||
504 | for (i = 0; i < 4; i++) | 499 | for (i = 0; i < 4; i++) |
505 | if (analog->mask & (ANALOG_BTN_TL << i)) | 500 | if (analog->mask & (ANALOG_BTN_TL << i)) |
506 | set_bit(analog_pads[i], analog->dev.keybit); | 501 | set_bit(analog_pads[i], input_dev->keybit); |
507 | 502 | ||
508 | analog_decode(analog, port->axes, port->initial, port->buttons); | 503 | analog_decode(analog, port->axes, port->initial, port->buttons); |
509 | 504 | ||
510 | input_register_device(&analog->dev); | 505 | input_register_device(analog->dev); |
511 | 506 | ||
512 | printk(KERN_INFO "input: %s at %s", analog->name, port->gameport->phys); | 507 | return 0; |
513 | |||
514 | if (port->cooked) | ||
515 | printk(" [ADC port]\n"); | ||
516 | else | ||
517 | printk(" [%s timer, %d %sHz clock, %d ns res]\n", TIME_NAME, | ||
518 | port->speed > 10000 ? (port->speed + 800) / 1000 : port->speed, | ||
519 | port->speed > 10000 ? "M" : "k", | ||
520 | port->speed > 10000 ? (port->loop * 1000) / (port->speed / 1000) | ||
521 | : (port->loop * 1000000) / port->speed); | ||
522 | } | 508 | } |
523 | 509 | ||
524 | /* | 510 | /* |
@@ -659,37 +645,41 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv | |||
659 | return - ENOMEM; | 645 | return - ENOMEM; |
660 | 646 | ||
661 | err = analog_init_port(gameport, drv, port); | 647 | err = analog_init_port(gameport, drv, port); |
662 | if (err) { | 648 | if (err) |
663 | kfree(port); | 649 | goto fail1; |
664 | return err; | ||
665 | } | ||
666 | 650 | ||
667 | err = analog_init_masks(port); | 651 | err = analog_init_masks(port); |
668 | if (err) { | 652 | if (err) |
669 | gameport_close(gameport); | 653 | goto fail2; |
670 | gameport_set_drvdata(gameport, NULL); | ||
671 | kfree(port); | ||
672 | return err; | ||
673 | } | ||
674 | 654 | ||
675 | gameport_set_poll_handler(gameport, analog_poll); | 655 | gameport_set_poll_handler(gameport, analog_poll); |
676 | gameport_set_poll_interval(gameport, 10); | 656 | gameport_set_poll_interval(gameport, 10); |
677 | 657 | ||
678 | for (i = 0; i < 2; i++) | 658 | for (i = 0; i < 2; i++) |
679 | if (port->analog[i].mask) | 659 | if (port->analog[i].mask) { |
680 | analog_init_device(port, port->analog + i, i); | 660 | err = analog_init_device(port, port->analog + i, i); |
661 | if (err) | ||
662 | goto fail3; | ||
663 | } | ||
681 | 664 | ||
682 | return 0; | 665 | return 0; |
666 | |||
667 | fail3: while (--i >= 0) | ||
668 | input_unregister_device(port->analog[i].dev); | ||
669 | fail2: gameport_close(gameport); | ||
670 | fail1: gameport_set_drvdata(gameport, NULL); | ||
671 | kfree(port); | ||
672 | return err; | ||
683 | } | 673 | } |
684 | 674 | ||
685 | static void analog_disconnect(struct gameport *gameport) | 675 | static void analog_disconnect(struct gameport *gameport) |
686 | { | 676 | { |
687 | int i; | ||
688 | struct analog_port *port = gameport_get_drvdata(gameport); | 677 | struct analog_port *port = gameport_get_drvdata(gameport); |
678 | int i; | ||
689 | 679 | ||
690 | for (i = 0; i < 2; i++) | 680 | for (i = 0; i < 2; i++) |
691 | if (port->analog[i].mask) | 681 | if (port->analog[i].mask) |
692 | input_unregister_device(&port->analog[i].dev); | 682 | input_unregister_device(port->analog[i].dev); |
693 | gameport_close(gameport); | 683 | gameport_close(gameport); |
694 | gameport_set_drvdata(gameport, NULL); | 684 | gameport_set_drvdata(gameport, NULL); |
695 | printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n", | 685 | printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n", |
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c index 0b2e9fa26579..9a3dfc724a41 100644 --- a/drivers/input/joystick/cobra.c +++ b/drivers/input/joystick/cobra.c | |||
@@ -44,13 +44,11 @@ MODULE_LICENSE("GPL"); | |||
44 | #define COBRA_MAX_STROBE 45 /* 45 us max wait for first strobe */ | 44 | #define COBRA_MAX_STROBE 45 /* 45 us max wait for first strobe */ |
45 | #define COBRA_LENGTH 36 | 45 | #define COBRA_LENGTH 36 |
46 | 46 | ||
47 | static char* cobra_name = "Creative Labs Blaster GamePad Cobra"; | ||
48 | |||
49 | static int cobra_btn[] = { BTN_START, BTN_SELECT, BTN_TL, BTN_TR, BTN_X, BTN_Y, BTN_Z, BTN_A, BTN_B, BTN_C, BTN_TL2, BTN_TR2, 0 }; | 47 | static int cobra_btn[] = { BTN_START, BTN_SELECT, BTN_TL, BTN_TR, BTN_X, BTN_Y, BTN_Z, BTN_A, BTN_B, BTN_C, BTN_TL2, BTN_TR2, 0 }; |
50 | 48 | ||
51 | struct cobra { | 49 | struct cobra { |
52 | struct gameport *gameport; | 50 | struct gameport *gameport; |
53 | struct input_dev dev[2]; | 51 | struct input_dev *dev[2]; |
54 | int reads; | 52 | int reads; |
55 | int bads; | 53 | int bads; |
56 | unsigned char exists; | 54 | unsigned char exists; |
@@ -128,7 +126,7 @@ static void cobra_poll(struct gameport *gameport) | |||
128 | for (i = 0; i < 2; i++) | 126 | for (i = 0; i < 2; i++) |
129 | if (cobra->exists & r & (1 << i)) { | 127 | if (cobra->exists & r & (1 << i)) { |
130 | 128 | ||
131 | dev = cobra->dev + i; | 129 | dev = cobra->dev[i]; |
132 | 130 | ||
133 | input_report_abs(dev, ABS_X, ((data[i] >> 4) & 1) - ((data[i] >> 3) & 1)); | 131 | input_report_abs(dev, ABS_X, ((data[i] >> 4) & 1) - ((data[i] >> 3) & 1)); |
134 | input_report_abs(dev, ABS_Y, ((data[i] >> 2) & 1) - ((data[i] >> 1) & 1)); | 132 | input_report_abs(dev, ABS_Y, ((data[i] >> 2) & 1) - ((data[i] >> 1) & 1)); |
@@ -159,11 +157,13 @@ static void cobra_close(struct input_dev *dev) | |||
159 | static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) | 157 | static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) |
160 | { | 158 | { |
161 | struct cobra *cobra; | 159 | struct cobra *cobra; |
160 | struct input_dev *input_dev; | ||
162 | unsigned int data[2]; | 161 | unsigned int data[2]; |
163 | int i, j; | 162 | int i, j; |
164 | int err; | 163 | int err; |
165 | 164 | ||
166 | if (!(cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL))) | 165 | cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL); |
166 | if (!cobra) | ||
167 | return -ENOMEM; | 167 | return -ENOMEM; |
168 | 168 | ||
169 | cobra->gameport = gameport; | 169 | cobra->gameport = gameport; |
@@ -191,38 +191,46 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
191 | gameport_set_poll_handler(gameport, cobra_poll); | 191 | gameport_set_poll_handler(gameport, cobra_poll); |
192 | gameport_set_poll_interval(gameport, 20); | 192 | gameport_set_poll_interval(gameport, 20); |
193 | 193 | ||
194 | for (i = 0; i < 2; i++) | 194 | for (i = 0; i < 2; i++) { |
195 | if ((cobra->exists >> i) & 1) { | 195 | if (~(cobra->exists >> i) & 1) |
196 | 196 | continue; | |
197 | sprintf(cobra->phys[i], "%s/input%d", gameport->phys, i); | ||
198 | 197 | ||
199 | cobra->dev[i].private = cobra; | 198 | cobra->dev[i] = input_dev = input_allocate_device(); |
200 | cobra->dev[i].open = cobra_open; | 199 | if (!input_dev) { |
201 | cobra->dev[i].close = cobra_close; | 200 | err = -ENOMEM; |
201 | goto fail3; | ||
202 | } | ||
202 | 203 | ||
203 | cobra->dev[i].name = cobra_name; | 204 | sprintf(cobra->phys[i], "%s/input%d", gameport->phys, i); |
204 | cobra->dev[i].phys = cobra->phys[i]; | ||
205 | cobra->dev[i].id.bustype = BUS_GAMEPORT; | ||
206 | cobra->dev[i].id.vendor = GAMEPORT_ID_VENDOR_CREATIVE; | ||
207 | cobra->dev[i].id.product = 0x0008; | ||
208 | cobra->dev[i].id.version = 0x0100; | ||
209 | 205 | ||
210 | cobra->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 206 | input_dev->name = "Creative Labs Blaster GamePad Cobra"; |
207 | input_dev->phys = cobra->phys[i]; | ||
208 | input_dev->id.bustype = BUS_GAMEPORT; | ||
209 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_CREATIVE; | ||
210 | input_dev->id.product = 0x0008; | ||
211 | input_dev->id.version = 0x0100; | ||
212 | input_dev->cdev.dev = &gameport->dev; | ||
213 | input_dev->private = cobra; | ||
211 | 214 | ||
212 | input_set_abs_params(&cobra->dev[i], ABS_X, -1, 1, 0, 0); | 215 | input_dev->open = cobra_open; |
213 | input_set_abs_params(&cobra->dev[i], ABS_Y, -1, 1, 0, 0); | 216 | input_dev->close = cobra_close; |
214 | 217 | ||
215 | for (j = 0; cobra_btn[j]; j++) | 218 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
216 | set_bit(cobra_btn[j], cobra->dev[i].keybit); | 219 | input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0); |
220 | input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0); | ||
221 | for (j = 0; cobra_btn[j]; j++) | ||
222 | set_bit(cobra_btn[j], input_dev->keybit); | ||
217 | 223 | ||
218 | input_register_device(&cobra->dev[i]); | 224 | input_register_device(cobra->dev[i]); |
219 | printk(KERN_INFO "input: %s on %s\n", cobra_name, gameport->phys); | 225 | } |
220 | } | ||
221 | 226 | ||
222 | return 0; | 227 | return 0; |
223 | 228 | ||
224 | fail2: gameport_close(gameport); | 229 | fail3: for (i = 0; i < 2; i++) |
225 | fail1: gameport_set_drvdata(gameport, NULL); | 230 | if (cobra->dev[i]) |
231 | input_unregister_device(cobra->dev[i]); | ||
232 | fail2: gameport_close(gameport); | ||
233 | fail1: gameport_set_drvdata(gameport, NULL); | ||
226 | kfree(cobra); | 234 | kfree(cobra); |
227 | return err; | 235 | return err; |
228 | } | 236 | } |
@@ -234,7 +242,7 @@ static void cobra_disconnect(struct gameport *gameport) | |||
234 | 242 | ||
235 | for (i = 0; i < 2; i++) | 243 | for (i = 0; i < 2; i++) |
236 | if ((cobra->exists >> i) & 1) | 244 | if ((cobra->exists >> i) & 1) |
237 | input_unregister_device(cobra->dev + i); | 245 | input_unregister_device(cobra->dev[i]); |
238 | gameport_close(gameport); | 246 | gameport_close(gameport); |
239 | gameport_set_drvdata(gameport, NULL); | 247 | gameport_set_drvdata(gameport, NULL); |
240 | kfree(cobra); | 248 | kfree(cobra); |
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index 2a3e4bb2da50..499344c72756 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c | |||
@@ -43,25 +43,28 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | |||
43 | MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); | 43 | MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); |
44 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
45 | 45 | ||
46 | static int db9[] __initdata = { -1, 0 }; | 46 | struct db9_config { |
47 | static int db9_nargs __initdata = 0; | 47 | int args[2]; |
48 | module_param_array_named(dev, db9, int, &db9_nargs, 0); | 48 | int nargs; |
49 | MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)"); | 49 | }; |
50 | 50 | ||
51 | static int db9_2[] __initdata = { -1, 0 }; | 51 | #define DB9_MAX_PORTS 3 |
52 | static int db9_nargs_2 __initdata = 0; | 52 | static struct db9_config db9[DB9_MAX_PORTS] __initdata; |
53 | module_param_array_named(dev2, db9_2, int, &db9_nargs_2, 0); | ||
54 | MODULE_PARM_DESC(dev2, "Describes second attached device (<parport#>,<type>)"); | ||
55 | 53 | ||
56 | static int db9_3[] __initdata = { -1, 0 }; | 54 | module_param_array_named(dev, db9[0].args, int, &db9[0].nargs, 0); |
57 | static int db9_nargs_3 __initdata = 0; | 55 | MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)"); |
58 | module_param_array_named(dev3, db9_3, int, &db9_nargs_3, 0); | 56 | module_param_array_named(dev2, db9[1].args, int, &db9[0].nargs, 0); |
57 | MODULE_PARM_DESC(dev2, "Describes second attached device (<parport#>,<type>)"); | ||
58 | module_param_array_named(dev3, db9[2].args, int, &db9[2].nargs, 0); | ||
59 | MODULE_PARM_DESC(dev3, "Describes third attached device (<parport#>,<type>)"); | 59 | MODULE_PARM_DESC(dev3, "Describes third attached device (<parport#>,<type>)"); |
60 | 60 | ||
61 | __obsolete_setup("db9="); | 61 | __obsolete_setup("db9="); |
62 | __obsolete_setup("db9_2="); | 62 | __obsolete_setup("db9_2="); |
63 | __obsolete_setup("db9_3="); | 63 | __obsolete_setup("db9_3="); |
64 | 64 | ||
65 | #define DB9_ARG_PARPORT 0 | ||
66 | #define DB9_ARG_MODE 1 | ||
67 | |||
65 | #define DB9_MULTI_STICK 0x01 | 68 | #define DB9_MULTI_STICK 0x01 |
66 | #define DB9_MULTI2_STICK 0x02 | 69 | #define DB9_MULTI2_STICK 0x02 |
67 | #define DB9_GENESIS_PAD 0x03 | 70 | #define DB9_GENESIS_PAD 0x03 |
@@ -87,40 +90,53 @@ __obsolete_setup("db9_3="); | |||
87 | #define DB9_NORMAL 0x0a | 90 | #define DB9_NORMAL 0x0a |
88 | #define DB9_NOSELECT 0x08 | 91 | #define DB9_NOSELECT 0x08 |
89 | 92 | ||
90 | #define DB9_MAX_DEVICES 2 | ||
91 | |||
92 | #define DB9_GENESIS6_DELAY 14 | 93 | #define DB9_GENESIS6_DELAY 14 |
93 | #define DB9_REFRESH_TIME HZ/100 | 94 | #define DB9_REFRESH_TIME HZ/100 |
94 | 95 | ||
96 | #define DB9_MAX_DEVICES 2 | ||
97 | |||
98 | struct db9_mode_data { | ||
99 | const char *name; | ||
100 | const short *buttons; | ||
101 | int n_buttons; | ||
102 | int n_pads; | ||
103 | int n_axis; | ||
104 | int bidirectional; | ||
105 | int reverse; | ||
106 | }; | ||
107 | |||
95 | struct db9 { | 108 | struct db9 { |
96 | struct input_dev dev[DB9_MAX_DEVICES]; | 109 | struct input_dev *dev[DB9_MAX_DEVICES]; |
97 | struct timer_list timer; | 110 | struct timer_list timer; |
98 | struct pardevice *pd; | 111 | struct pardevice *pd; |
99 | int mode; | 112 | int mode; |
100 | int used; | 113 | int used; |
101 | struct semaphore sem; | 114 | struct semaphore sem; |
102 | char phys[2][32]; | 115 | char phys[DB9_MAX_DEVICES][32]; |
103 | }; | 116 | }; |
104 | 117 | ||
105 | static struct db9 *db9_base[3]; | 118 | static struct db9 *db9_base[3]; |
106 | 119 | ||
107 | static short db9_multi_btn[] = { BTN_TRIGGER, BTN_THUMB }; | 120 | static const short db9_multi_btn[] = { BTN_TRIGGER, BTN_THUMB }; |
108 | static short db9_genesis_btn[] = { BTN_START, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_MODE }; | 121 | static const short db9_genesis_btn[] = { BTN_START, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_MODE }; |
109 | static short db9_cd32_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START }; | 122 | static const short db9_cd32_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START }; |
110 | |||
111 | static char db9_buttons[DB9_MAX_PAD] = { 0, 1, 2, 4, 0, 6, 8, 9, 1, 1, 7, 9, 9 }; | ||
112 | static short *db9_btn[DB9_MAX_PAD] = { NULL, db9_multi_btn, db9_multi_btn, db9_genesis_btn, NULL, db9_genesis_btn, | ||
113 | db9_genesis_btn, db9_cd32_btn, db9_multi_btn, db9_multi_btn, db9_cd32_btn, | ||
114 | db9_cd32_btn, db9_cd32_btn }; | ||
115 | static char *db9_name[DB9_MAX_PAD] = { NULL, "Multisystem joystick", "Multisystem joystick (2 fire)", "Genesis pad", | ||
116 | NULL, "Genesis 5 pad", "Genesis 6 pad", "Saturn pad", "Multisystem (0.8.0.2) joystick", | ||
117 | "Multisystem (0.8.0.2-dual) joystick", "Amiga CD-32 pad", "Saturn dpp", "Saturn dpp dual" }; | ||
118 | |||
119 | static const int db9_max_pads[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 6, 1, 2, 1, 6, 12 }; | ||
120 | static const int db9_num_axis[DB9_MAX_PAD] = { 0, 2, 2, 2, 0, 2, 2, 7, 2, 2, 2 ,7, 7 }; | ||
121 | static const short db9_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_RZ, ABS_Z, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y }; | 123 | static const short db9_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_RZ, ABS_Z, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y }; |
122 | static const int db9_bidirectional[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0 }; | 124 | |
123 | static const int db9_reverse[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0 }; | 125 | static const struct db9_mode_data db9_modes[] = { |
126 | { NULL, NULL, 0, 0, 0, 0, 0 }, | ||
127 | { "Multisystem joystick", db9_multi_btn, 1, 1, 2, 1, 1 }, | ||
128 | { "Multisystem joystick (2 fire)", db9_multi_btn, 2, 1, 2, 1, 1 }, | ||
129 | { "Genesis pad", db9_genesis_btn, 4, 1, 2, 1, 1 }, | ||
130 | { NULL, NULL, 0, 0, 0, 0, 0 }, | ||
131 | { "Genesis 5 pad", db9_genesis_btn, 6, 1, 2, 1, 1 }, | ||
132 | { "Genesis 6 pad", db9_genesis_btn, 8, 1, 2, 1, 1 }, | ||
133 | { "Saturn pad", db9_cd32_btn, 9, 6, 7, 0, 1 }, | ||
134 | { "Multisystem (0.8.0.2) joystick", db9_multi_btn, 1, 1, 2, 1, 1 }, | ||
135 | { "Multisystem (0.8.0.2-dual) joystick", db9_multi_btn, 1, 2, 2, 1, 1 }, | ||
136 | { "Amiga CD-32 pad", db9_cd32_btn, 7, 1, 2, 1, 1 }, | ||
137 | { "Saturn dpp", db9_cd32_btn, 9, 6, 7, 0, 0 }, | ||
138 | { "Saturn dpp dual", db9_cd32_btn, 9, 12, 7, 0, 0 }, | ||
139 | }; | ||
124 | 140 | ||
125 | /* | 141 | /* |
126 | * Saturn controllers | 142 | * Saturn controllers |
@@ -342,7 +358,7 @@ static int db9_saturn(int mode, struct parport *port, struct input_dev *dev) | |||
342 | default: | 358 | default: |
343 | return -1; | 359 | return -1; |
344 | } | 360 | } |
345 | max_pads = min(db9_max_pads[mode], DB9_MAX_DEVICES); | 361 | max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES); |
346 | for (tmp = 0, i = 0; i < n; i++) { | 362 | for (tmp = 0, i = 0; i < n; i++) { |
347 | id = db9_saturn_read_packet(port, data, type + i, 1); | 363 | id = db9_saturn_read_packet(port, data, type + i, 1); |
348 | tmp = db9_saturn_report(id, data, dev, tmp, max_pads); | 364 | tmp = db9_saturn_report(id, data, dev, tmp, max_pads); |
@@ -354,17 +370,18 @@ static void db9_timer(unsigned long private) | |||
354 | { | 370 | { |
355 | struct db9 *db9 = (void *) private; | 371 | struct db9 *db9 = (void *) private; |
356 | struct parport *port = db9->pd->port; | 372 | struct parport *port = db9->pd->port; |
357 | struct input_dev *dev = db9->dev; | 373 | struct input_dev *dev = db9->dev[0]; |
374 | struct input_dev *dev2 = db9->dev[1]; | ||
358 | int data, i; | 375 | int data, i; |
359 | 376 | ||
360 | switch(db9->mode) { | 377 | switch (db9->mode) { |
361 | case DB9_MULTI_0802_2: | 378 | case DB9_MULTI_0802_2: |
362 | 379 | ||
363 | data = parport_read_data(port) >> 3; | 380 | data = parport_read_data(port) >> 3; |
364 | 381 | ||
365 | input_report_abs(dev + 1, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); | 382 | input_report_abs(dev2, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); |
366 | input_report_abs(dev + 1, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); | 383 | input_report_abs(dev2, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); |
367 | input_report_key(dev + 1, BTN_TRIGGER, ~data & DB9_FIRE1); | 384 | input_report_key(dev2, BTN_TRIGGER, ~data & DB9_FIRE1); |
368 | 385 | ||
369 | case DB9_MULTI_0802: | 386 | case DB9_MULTI_0802: |
370 | 387 | ||
@@ -405,7 +422,7 @@ static void db9_timer(unsigned long private) | |||
405 | input_report_key(dev, BTN_C, ~data & DB9_FIRE2); | 422 | input_report_key(dev, BTN_C, ~data & DB9_FIRE2); |
406 | 423 | ||
407 | parport_write_control(port, DB9_NORMAL); | 424 | parport_write_control(port, DB9_NORMAL); |
408 | data=parport_read_data(port); | 425 | data = parport_read_data(port); |
409 | 426 | ||
410 | input_report_key(dev, BTN_A, ~data & DB9_FIRE1); | 427 | input_report_key(dev, BTN_A, ~data & DB9_FIRE1); |
411 | input_report_key(dev, BTN_START, ~data & DB9_FIRE2); | 428 | input_report_key(dev, BTN_START, ~data & DB9_FIRE2); |
@@ -414,7 +431,7 @@ static void db9_timer(unsigned long private) | |||
414 | case DB9_GENESIS5_PAD: | 431 | case DB9_GENESIS5_PAD: |
415 | 432 | ||
416 | parport_write_control(port, DB9_NOSELECT); | 433 | parport_write_control(port, DB9_NOSELECT); |
417 | data=parport_read_data(port); | 434 | data = parport_read_data(port); |
418 | 435 | ||
419 | input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); | 436 | input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); |
420 | input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); | 437 | input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); |
@@ -422,7 +439,7 @@ static void db9_timer(unsigned long private) | |||
422 | input_report_key(dev, BTN_C, ~data & DB9_FIRE2); | 439 | input_report_key(dev, BTN_C, ~data & DB9_FIRE2); |
423 | 440 | ||
424 | parport_write_control(port, DB9_NORMAL); | 441 | parport_write_control(port, DB9_NORMAL); |
425 | data=parport_read_data(port); | 442 | data = parport_read_data(port); |
426 | 443 | ||
427 | input_report_key(dev, BTN_A, ~data & DB9_FIRE1); | 444 | input_report_key(dev, BTN_A, ~data & DB9_FIRE1); |
428 | input_report_key(dev, BTN_X, ~data & DB9_FIRE2); | 445 | input_report_key(dev, BTN_X, ~data & DB9_FIRE2); |
@@ -434,7 +451,7 @@ static void db9_timer(unsigned long private) | |||
434 | 451 | ||
435 | parport_write_control(port, DB9_NOSELECT); /* 1 */ | 452 | parport_write_control(port, DB9_NOSELECT); /* 1 */ |
436 | udelay(DB9_GENESIS6_DELAY); | 453 | udelay(DB9_GENESIS6_DELAY); |
437 | data=parport_read_data(port); | 454 | data = parport_read_data(port); |
438 | 455 | ||
439 | input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); | 456 | input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); |
440 | input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); | 457 | input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); |
@@ -443,7 +460,7 @@ static void db9_timer(unsigned long private) | |||
443 | 460 | ||
444 | parport_write_control(port, DB9_NORMAL); | 461 | parport_write_control(port, DB9_NORMAL); |
445 | udelay(DB9_GENESIS6_DELAY); | 462 | udelay(DB9_GENESIS6_DELAY); |
446 | data=parport_read_data(port); | 463 | data = parport_read_data(port); |
447 | 464 | ||
448 | input_report_key(dev, BTN_A, ~data & DB9_FIRE1); | 465 | input_report_key(dev, BTN_A, ~data & DB9_FIRE1); |
449 | input_report_key(dev, BTN_START, ~data & DB9_FIRE2); | 466 | input_report_key(dev, BTN_START, ~data & DB9_FIRE2); |
@@ -477,7 +494,7 @@ static void db9_timer(unsigned long private) | |||
477 | 494 | ||
478 | case DB9_CD32_PAD: | 495 | case DB9_CD32_PAD: |
479 | 496 | ||
480 | data=parport_read_data(port); | 497 | data = parport_read_data(port); |
481 | 498 | ||
482 | input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); | 499 | input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); |
483 | input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); | 500 | input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); |
@@ -489,7 +506,7 @@ static void db9_timer(unsigned long private) | |||
489 | parport_write_control(port, 0x02); | 506 | parport_write_control(port, 0x02); |
490 | parport_write_control(port, 0x0a); | 507 | parport_write_control(port, 0x0a); |
491 | input_report_key(dev, db9_cd32_btn[i], ~data & DB9_FIRE2); | 508 | input_report_key(dev, db9_cd32_btn[i], ~data & DB9_FIRE2); |
492 | } | 509 | } |
493 | 510 | ||
494 | parport_write_control(port, 0x00); | 511 | parport_write_control(port, 0x00); |
495 | break; | 512 | break; |
@@ -513,7 +530,7 @@ static int db9_open(struct input_dev *dev) | |||
513 | if (!db9->used++) { | 530 | if (!db9->used++) { |
514 | parport_claim(db9->pd); | 531 | parport_claim(db9->pd); |
515 | parport_write_data(port, 0xff); | 532 | parport_write_data(port, 0xff); |
516 | if (db9_reverse[db9->mode]) { | 533 | if (db9_modes[db9->mode].reverse) { |
517 | parport_data_reverse(port); | 534 | parport_data_reverse(port); |
518 | parport_write_control(port, DB9_NORMAL); | 535 | parport_write_control(port, DB9_NORMAL); |
519 | } | 536 | } |
@@ -539,117 +556,160 @@ static void db9_close(struct input_dev *dev) | |||
539 | up(&db9->sem); | 556 | up(&db9->sem); |
540 | } | 557 | } |
541 | 558 | ||
542 | static struct db9 __init *db9_probe(int *config, int nargs) | 559 | static struct db9 __init *db9_probe(int parport, int mode) |
543 | { | 560 | { |
544 | struct db9 *db9; | 561 | struct db9 *db9; |
562 | const struct db9_mode_data *db9_mode; | ||
545 | struct parport *pp; | 563 | struct parport *pp; |
564 | struct pardevice *pd; | ||
565 | struct input_dev *input_dev; | ||
546 | int i, j; | 566 | int i, j; |
567 | int err; | ||
547 | 568 | ||
548 | if (config[0] < 0) | 569 | if (mode < 1 || mode >= DB9_MAX_PAD || !db9_modes[mode].n_buttons) { |
549 | return NULL; | 570 | printk(KERN_ERR "db9.c: Bad device type %d\n", mode); |
550 | 571 | err = -EINVAL; | |
551 | if (nargs < 2) { | 572 | goto err_out; |
552 | printk(KERN_ERR "db9.c: Device type must be specified.\n"); | ||
553 | return NULL; | ||
554 | } | 573 | } |
555 | 574 | ||
556 | if (config[1] < 1 || config[1] >= DB9_MAX_PAD || !db9_buttons[config[1]]) { | 575 | db9_mode = &db9_modes[mode]; |
557 | printk(KERN_ERR "db9.c: bad config\n"); | ||
558 | return NULL; | ||
559 | } | ||
560 | 576 | ||
561 | pp = parport_find_number(config[0]); | 577 | pp = parport_find_number(parport); |
562 | if (!pp) { | 578 | if (!pp) { |
563 | printk(KERN_ERR "db9.c: no such parport\n"); | 579 | printk(KERN_ERR "db9.c: no such parport\n"); |
564 | return NULL; | 580 | err = -ENODEV; |
581 | goto err_out; | ||
565 | } | 582 | } |
566 | 583 | ||
567 | if (db9_bidirectional[config[1]]) { | 584 | if (db9_mode[mode].bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) { |
568 | if (!(pp->modes & PARPORT_MODE_TRISTATE)) { | 585 | printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); |
569 | printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); | 586 | err = -EINVAL; |
570 | parport_put_port(pp); | 587 | goto err_put_pp; |
571 | return NULL; | 588 | } |
572 | } | 589 | |
590 | pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | ||
591 | if (!pd) { | ||
592 | printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n"); | ||
593 | err = -EBUSY; | ||
594 | goto err_put_pp; | ||
573 | } | 595 | } |
574 | 596 | ||
575 | if (!(db9 = kzalloc(sizeof(struct db9), GFP_KERNEL))) { | 597 | db9 = kzalloc(sizeof(struct db9), GFP_KERNEL); |
576 | parport_put_port(pp); | 598 | if (!db9) { |
577 | return NULL; | 599 | printk(KERN_ERR "db9.c: Not enough memory\n"); |
600 | err = -ENOMEM; | ||
601 | goto err_unreg_pardev; | ||
578 | } | 602 | } |
579 | 603 | ||
580 | init_MUTEX(&db9->sem); | 604 | init_MUTEX(&db9->sem); |
581 | db9->mode = config[1]; | 605 | db9->pd = pd; |
606 | db9->mode = mode; | ||
582 | init_timer(&db9->timer); | 607 | init_timer(&db9->timer); |
583 | db9->timer.data = (long) db9; | 608 | db9->timer.data = (long) db9; |
584 | db9->timer.function = db9_timer; | 609 | db9->timer.function = db9_timer; |
585 | 610 | ||
586 | db9->pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | 611 | for (i = 0; i < (min(db9_mode->n_pads, DB9_MAX_DEVICES)); i++) { |
587 | parport_put_port(pp); | ||
588 | |||
589 | if (!db9->pd) { | ||
590 | printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n"); | ||
591 | kfree(db9); | ||
592 | return NULL; | ||
593 | } | ||
594 | 612 | ||
595 | for (i = 0; i < (min(db9_max_pads[db9->mode], DB9_MAX_DEVICES)); i++) { | 613 | db9->dev[i] = input_dev = input_allocate_device(); |
614 | if (!input_dev) { | ||
615 | printk(KERN_ERR "db9.c: Not enough memory for input device\n"); | ||
616 | err = -ENOMEM; | ||
617 | goto err_free_devs; | ||
618 | } | ||
596 | 619 | ||
597 | sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); | 620 | sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); |
598 | 621 | ||
599 | db9->dev[i].private = db9; | 622 | input_dev->name = db9_mode->name; |
600 | db9->dev[i].open = db9_open; | 623 | input_dev->phys = db9->phys[i]; |
601 | db9->dev[i].close = db9_close; | 624 | input_dev->id.bustype = BUS_PARPORT; |
602 | 625 | input_dev->id.vendor = 0x0002; | |
603 | db9->dev[i].name = db9_name[db9->mode]; | 626 | input_dev->id.product = mode; |
604 | db9->dev[i].phys = db9->phys[i]; | 627 | input_dev->id.version = 0x0100; |
605 | db9->dev[i].id.bustype = BUS_PARPORT; | 628 | input_dev->private = db9; |
606 | db9->dev[i].id.vendor = 0x0002; | 629 | |
607 | db9->dev[i].id.product = config[1]; | 630 | input_dev->open = db9_open; |
608 | db9->dev[i].id.version = 0x0100; | 631 | input_dev->close = db9_close; |
609 | 632 | ||
610 | db9->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 633 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
611 | for (j = 0; j < db9_buttons[db9->mode]; j++) | 634 | for (j = 0; j < db9_mode->n_buttons; j++) |
612 | set_bit(db9_btn[db9->mode][j], db9->dev[i].keybit); | 635 | set_bit(db9_mode->buttons[j], input_dev->keybit); |
613 | for (j = 0; j < db9_num_axis[db9->mode]; j++) { | 636 | for (j = 0; j < db9_mode->n_axis; j++) { |
614 | set_bit(db9_abs[j], db9->dev[i].absbit); | 637 | if (j < 2) |
615 | if (j < 2) { | 638 | input_set_abs_params(input_dev, db9_abs[j], -1, 1, 0, 0); |
616 | db9->dev[i].absmin[db9_abs[j]] = -1; | 639 | else |
617 | db9->dev[i].absmax[db9_abs[j]] = 1; | 640 | input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0); |
618 | } else { | ||
619 | db9->dev[i].absmin[db9_abs[j]] = 1; | ||
620 | db9->dev[i].absmax[db9_abs[j]] = 255; | ||
621 | db9->dev[i].absflat[db9_abs[j]] = 0; | ||
622 | } | ||
623 | } | 641 | } |
624 | input_register_device(db9->dev + i); | 642 | |
625 | printk(KERN_INFO "input: %s on %s\n", db9->dev[i].name, db9->pd->port->name); | 643 | input_register_device(input_dev); |
626 | } | 644 | } |
627 | 645 | ||
646 | parport_put_port(pp); | ||
628 | return db9; | 647 | return db9; |
648 | |||
649 | err_free_devs: | ||
650 | while (--i >= 0) | ||
651 | input_unregister_device(db9->dev[i]); | ||
652 | kfree(db9); | ||
653 | err_unreg_pardev: | ||
654 | parport_unregister_device(pd); | ||
655 | err_put_pp: | ||
656 | parport_put_port(pp); | ||
657 | err_out: | ||
658 | return ERR_PTR(err); | ||
659 | } | ||
660 | |||
661 | static void __exit db9_remove(struct db9 *db9) | ||
662 | { | ||
663 | int i; | ||
664 | |||
665 | for (i = 0; i < min(db9_modes[db9->mode].n_pads, DB9_MAX_DEVICES); i++) | ||
666 | input_unregister_device(db9->dev[i]); | ||
667 | parport_unregister_device(db9->pd); | ||
668 | kfree(db9); | ||
629 | } | 669 | } |
630 | 670 | ||
631 | static int __init db9_init(void) | 671 | static int __init db9_init(void) |
632 | { | 672 | { |
633 | db9_base[0] = db9_probe(db9, db9_nargs); | 673 | int i; |
634 | db9_base[1] = db9_probe(db9_2, db9_nargs_2); | 674 | int have_dev = 0; |
635 | db9_base[2] = db9_probe(db9_3, db9_nargs_3); | 675 | int err = 0; |
676 | |||
677 | for (i = 0; i < DB9_MAX_PORTS; i++) { | ||
678 | if (db9[i].nargs == 0 || db9[i].args[DB9_ARG_PARPORT] < 0) | ||
679 | continue; | ||
680 | |||
681 | if (db9[i].nargs < 2) { | ||
682 | printk(KERN_ERR "db9.c: Device type must be specified.\n"); | ||
683 | err = -EINVAL; | ||
684 | break; | ||
685 | } | ||
686 | |||
687 | db9_base[i] = db9_probe(db9[i].args[DB9_ARG_PARPORT], | ||
688 | db9[i].args[DB9_ARG_MODE]); | ||
689 | if (IS_ERR(db9_base[i])) { | ||
690 | err = PTR_ERR(db9_base[i]); | ||
691 | break; | ||
692 | } | ||
693 | |||
694 | have_dev = 1; | ||
695 | } | ||
636 | 696 | ||
637 | if (db9_base[0] || db9_base[1] || db9_base[2]) | 697 | if (err) { |
638 | return 0; | 698 | while (--i >= 0) |
699 | db9_remove(db9_base[i]); | ||
700 | return err; | ||
701 | } | ||
639 | 702 | ||
640 | return -ENODEV; | 703 | return have_dev ? 0 : -ENODEV; |
641 | } | 704 | } |
642 | 705 | ||
643 | static void __exit db9_exit(void) | 706 | static void __exit db9_exit(void) |
644 | { | 707 | { |
645 | int i, j; | 708 | int i; |
646 | 709 | ||
647 | for (i = 0; i < 3; i++) | 710 | for (i = 0; i < DB9_MAX_PORTS; i++) |
648 | if (db9_base[i]) { | 711 | if (db9_base[i]) |
649 | for (j = 0; j < min(db9_max_pads[db9_base[i]->mode], DB9_MAX_DEVICES); j++) | 712 | db9_remove(db9_base[i]); |
650 | input_unregister_device(db9_base[i]->dev + j); | ||
651 | parport_unregister_device(db9_base[i]->pd); | ||
652 | } | ||
653 | } | 713 | } |
654 | 714 | ||
655 | module_init(db9_init); | 715 | module_init(db9_init); |
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 5427bf9fc862..7df2d82f2c83 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -41,20 +41,22 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | |||
41 | MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); | 41 | MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); |
42 | MODULE_LICENSE("GPL"); | 42 | MODULE_LICENSE("GPL"); |
43 | 43 | ||
44 | static int gc[] __initdata = { -1, 0, 0, 0, 0, 0 }; | 44 | #define GC_MAX_PORTS 3 |
45 | static int gc_nargs __initdata = 0; | 45 | #define GC_MAX_DEVICES 5 |
46 | module_param_array_named(map, gc, int, &gc_nargs, 0); | ||
47 | MODULE_PARM_DESC(map, "Describers first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)"); | ||
48 | 46 | ||
49 | static int gc_2[] __initdata = { -1, 0, 0, 0, 0, 0 }; | 47 | struct gc_config { |
50 | static int gc_nargs_2 __initdata = 0; | 48 | int args[GC_MAX_DEVICES + 1]; |
51 | module_param_array_named(map2, gc_2, int, &gc_nargs_2, 0); | 49 | int nargs; |
52 | MODULE_PARM_DESC(map2, "Describers second set of devices"); | 50 | }; |
51 | |||
52 | static struct gc_config gc[GC_MAX_PORTS] __initdata; | ||
53 | 53 | ||
54 | static int gc_3[] __initdata = { -1, 0, 0, 0, 0, 0 }; | 54 | module_param_array_named(map, gc[0].args, int, &gc[0].nargs, 0); |
55 | static int gc_nargs_3 __initdata = 0; | 55 | MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)"); |
56 | module_param_array_named(map3, gc_3, int, &gc_nargs_3, 0); | 56 | module_param_array_named(map2, gc[1].args, int, &gc[1].nargs, 0); |
57 | MODULE_PARM_DESC(map3, "Describers third set of devices"); | 57 | MODULE_PARM_DESC(map2, "Describes second set of devices"); |
58 | module_param_array_named(map3, gc[2].args, int, &gc[2].nargs, 0); | ||
59 | MODULE_PARM_DESC(map3, "Describes third set of devices"); | ||
58 | 60 | ||
59 | __obsolete_setup("gc="); | 61 | __obsolete_setup("gc="); |
60 | __obsolete_setup("gc_2="); | 62 | __obsolete_setup("gc_2="); |
@@ -77,12 +79,12 @@ __obsolete_setup("gc_3="); | |||
77 | 79 | ||
78 | struct gc { | 80 | struct gc { |
79 | struct pardevice *pd; | 81 | struct pardevice *pd; |
80 | struct input_dev dev[5]; | 82 | struct input_dev *dev[GC_MAX_DEVICES]; |
81 | struct timer_list timer; | 83 | struct timer_list timer; |
82 | unsigned char pads[GC_MAX + 1]; | 84 | unsigned char pads[GC_MAX + 1]; |
83 | int used; | 85 | int used; |
84 | struct semaphore sem; | 86 | struct semaphore sem; |
85 | char phys[5][32]; | 87 | char phys[GC_MAX_DEVICES][32]; |
86 | }; | 88 | }; |
87 | 89 | ||
88 | static struct gc *gc_base[3]; | 90 | static struct gc *gc_base[3]; |
@@ -330,7 +332,6 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES | |||
330 | static void gc_timer(unsigned long private) | 332 | static void gc_timer(unsigned long private) |
331 | { | 333 | { |
332 | struct gc *gc = (void *) private; | 334 | struct gc *gc = (void *) private; |
333 | struct input_dev *dev = gc->dev; | ||
334 | unsigned char data[GC_MAX_LENGTH]; | 335 | unsigned char data[GC_MAX_LENGTH]; |
335 | unsigned char data_psx[5][GC_PSX_BYTES]; | 336 | unsigned char data_psx[5][GC_PSX_BYTES]; |
336 | int i, j, s; | 337 | int i, j, s; |
@@ -357,16 +358,16 @@ static void gc_timer(unsigned long private) | |||
357 | if (data[31 - j] & s) axes[1] |= 1 << j; | 358 | if (data[31 - j] & s) axes[1] |= 1 << j; |
358 | } | 359 | } |
359 | 360 | ||
360 | input_report_abs(dev + i, ABS_X, axes[0]); | 361 | input_report_abs(gc->dev[i], ABS_X, axes[0]); |
361 | input_report_abs(dev + i, ABS_Y, -axes[1]); | 362 | input_report_abs(gc->dev[i], ABS_Y, -axes[1]); |
362 | 363 | ||
363 | input_report_abs(dev + i, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); | 364 | input_report_abs(gc->dev[i], ABS_HAT0X, !(s & data[6]) - !(s & data[7])); |
364 | input_report_abs(dev + i, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); | 365 | input_report_abs(gc->dev[i], ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); |
365 | 366 | ||
366 | for (j = 0; j < 10; j++) | 367 | for (j = 0; j < 10; j++) |
367 | input_report_key(dev + i, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); | 368 | input_report_key(gc->dev[i], gc_n64_btn[j], s & data[gc_n64_bytes[j]]); |
368 | 369 | ||
369 | input_sync(dev + i); | 370 | input_sync(gc->dev[i]); |
370 | } | 371 | } |
371 | } | 372 | } |
372 | } | 373 | } |
@@ -384,19 +385,19 @@ static void gc_timer(unsigned long private) | |||
384 | s = gc_status_bit[i]; | 385 | s = gc_status_bit[i]; |
385 | 386 | ||
386 | if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { | 387 | if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { |
387 | input_report_abs(dev + i, ABS_X, !(s & data[6]) - !(s & data[7])); | 388 | input_report_abs(gc->dev[i], ABS_X, !(s & data[6]) - !(s & data[7])); |
388 | input_report_abs(dev + i, ABS_Y, !(s & data[4]) - !(s & data[5])); | 389 | input_report_abs(gc->dev[i], ABS_Y, !(s & data[4]) - !(s & data[5])); |
389 | } | 390 | } |
390 | 391 | ||
391 | if (s & gc->pads[GC_NES]) | 392 | if (s & gc->pads[GC_NES]) |
392 | for (j = 0; j < 4; j++) | 393 | for (j = 0; j < 4; j++) |
393 | input_report_key(dev + i, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); | 394 | input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_nes_bytes[j]]); |
394 | 395 | ||
395 | if (s & gc->pads[GC_SNES]) | 396 | if (s & gc->pads[GC_SNES]) |
396 | for (j = 0; j < 8; j++) | 397 | for (j = 0; j < 8; j++) |
397 | input_report_key(dev + i, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); | 398 | input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_snes_bytes[j]]); |
398 | 399 | ||
399 | input_sync(dev + i); | 400 | input_sync(gc->dev[i]); |
400 | } | 401 | } |
401 | } | 402 | } |
402 | 403 | ||
@@ -413,15 +414,15 @@ static void gc_timer(unsigned long private) | |||
413 | s = gc_status_bit[i]; | 414 | s = gc_status_bit[i]; |
414 | 415 | ||
415 | if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { | 416 | if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { |
416 | input_report_abs(dev + i, ABS_X, !(s & data[2]) - !(s & data[3])); | 417 | input_report_abs(gc->dev[i], ABS_X, !(s & data[2]) - !(s & data[3])); |
417 | input_report_abs(dev + i, ABS_Y, !(s & data[0]) - !(s & data[1])); | 418 | input_report_abs(gc->dev[i], ABS_Y, !(s & data[0]) - !(s & data[1])); |
418 | input_report_key(dev + i, BTN_TRIGGER, s & data[4]); | 419 | input_report_key(gc->dev[i], BTN_TRIGGER, s & data[4]); |
419 | } | 420 | } |
420 | 421 | ||
421 | if (s & gc->pads[GC_MULTI2]) | 422 | if (s & gc->pads[GC_MULTI2]) |
422 | input_report_key(dev + i, BTN_THUMB, s & data[5]); | 423 | input_report_key(gc->dev[i], BTN_THUMB, s & data[5]); |
423 | 424 | ||
424 | input_sync(dev + i); | 425 | input_sync(gc->dev[i]); |
425 | } | 426 | } |
426 | } | 427 | } |
427 | 428 | ||
@@ -438,44 +439,44 @@ static void gc_timer(unsigned long private) | |||
438 | 439 | ||
439 | case GC_PSX_RUMBLE: | 440 | case GC_PSX_RUMBLE: |
440 | 441 | ||
441 | input_report_key(dev + i, BTN_THUMBL, ~data_psx[i][0] & 0x04); | 442 | input_report_key(gc->dev[i], BTN_THUMBL, ~data_psx[i][0] & 0x04); |
442 | input_report_key(dev + i, BTN_THUMBR, ~data_psx[i][0] & 0x02); | 443 | input_report_key(gc->dev[i], BTN_THUMBR, ~data_psx[i][0] & 0x02); |
443 | 444 | ||
444 | case GC_PSX_NEGCON: | 445 | case GC_PSX_NEGCON: |
445 | case GC_PSX_ANALOG: | 446 | case GC_PSX_ANALOG: |
446 | 447 | ||
447 | if(gc->pads[GC_DDR] & gc_status_bit[i]) { | 448 | if (gc->pads[GC_DDR] & gc_status_bit[i]) { |
448 | for(j = 0; j < 4; j++) | 449 | for(j = 0; j < 4; j++) |
449 | input_report_key(dev + i, gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); | 450 | input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); |
450 | } else { | 451 | } else { |
451 | for (j = 0; j < 4; j++) | 452 | for (j = 0; j < 4; j++) |
452 | input_report_abs(dev + i, gc_psx_abs[j+2], data_psx[i][j + 2]); | 453 | input_report_abs(gc->dev[i], gc_psx_abs[j+2], data_psx[i][j + 2]); |
453 | 454 | ||
454 | input_report_abs(dev + i, ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); | 455 | input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); |
455 | input_report_abs(dev + i, ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); | 456 | input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); |
456 | } | 457 | } |
457 | 458 | ||
458 | for (j = 0; j < 8; j++) | 459 | for (j = 0; j < 8; j++) |
459 | input_report_key(dev + i, gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); | 460 | input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); |
460 | 461 | ||
461 | input_report_key(dev + i, BTN_START, ~data_psx[i][0] & 0x08); | 462 | input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08); |
462 | input_report_key(dev + i, BTN_SELECT, ~data_psx[i][0] & 0x01); | 463 | input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01); |
463 | 464 | ||
464 | input_sync(dev + i); | 465 | input_sync(gc->dev[i]); |
465 | 466 | ||
466 | break; | 467 | break; |
467 | 468 | ||
468 | case GC_PSX_NORMAL: | 469 | case GC_PSX_NORMAL: |
469 | if(gc->pads[GC_DDR] & gc_status_bit[i]) { | 470 | if (gc->pads[GC_DDR] & gc_status_bit[i]) { |
470 | for(j = 0; j < 4; j++) | 471 | for(j = 0; j < 4; j++) |
471 | input_report_key(dev + i, gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); | 472 | input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); |
472 | } else { | 473 | } else { |
473 | input_report_abs(dev + i, ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); | 474 | input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); |
474 | input_report_abs(dev + i, ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); | 475 | input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); |
475 | 476 | ||
476 | /* for some reason if the extra axes are left unset they drift */ | 477 | /* for some reason if the extra axes are left unset they drift */ |
477 | /* for (j = 0; j < 4; j++) | 478 | /* for (j = 0; j < 4; j++) |
478 | input_report_abs(dev + i, gc_psx_abs[j+2], 128); | 479 | input_report_abs(gc->dev[i], gc_psx_abs[j+2], 128); |
479 | * This needs to be debugged properly, | 480 | * This needs to be debugged properly, |
480 | * maybe fuzz processing needs to be done in input_sync() | 481 | * maybe fuzz processing needs to be done in input_sync() |
481 | * --vojtech | 482 | * --vojtech |
@@ -483,12 +484,12 @@ static void gc_timer(unsigned long private) | |||
483 | } | 484 | } |
484 | 485 | ||
485 | for (j = 0; j < 8; j++) | 486 | for (j = 0; j < 8; j++) |
486 | input_report_key(dev + i, gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); | 487 | input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); |
487 | 488 | ||
488 | input_report_key(dev + i, BTN_START, ~data_psx[i][0] & 0x08); | 489 | input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08); |
489 | input_report_key(dev + i, BTN_SELECT, ~data_psx[i][0] & 0x01); | 490 | input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01); |
490 | 491 | ||
491 | input_sync(dev + i); | 492 | input_sync(gc->dev[i]); |
492 | 493 | ||
493 | break; | 494 | break; |
494 | 495 | ||
@@ -533,177 +534,212 @@ static void gc_close(struct input_dev *dev) | |||
533 | up(&gc->sem); | 534 | up(&gc->sem); |
534 | } | 535 | } |
535 | 536 | ||
536 | static struct gc __init *gc_probe(int *config, int nargs) | 537 | static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) |
537 | { | 538 | { |
538 | struct gc *gc; | 539 | struct input_dev *input_dev; |
539 | struct parport *pp; | 540 | int i; |
540 | int i, j; | ||
541 | 541 | ||
542 | if (config[0] < 0) | 542 | if (!pad_type) |
543 | return NULL; | 543 | return 0; |
544 | 544 | ||
545 | if (nargs < 2) { | 545 | if (pad_type < 1 || pad_type > GC_MAX) { |
546 | printk(KERN_ERR "gamecon.c: at least one device must be specified\n"); | 546 | printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type); |
547 | return NULL; | 547 | return -EINVAL; |
548 | } | 548 | } |
549 | 549 | ||
550 | pp = parport_find_number(config[0]); | 550 | gc->dev[idx] = input_dev = input_allocate_device(); |
551 | 551 | if (!input_dev) { | |
552 | if (!pp) { | 552 | printk(KERN_ERR "gamecon.c: Not enough memory for input device\n"); |
553 | printk(KERN_ERR "gamecon.c: no such parport\n"); | 553 | return -ENOMEM; |
554 | return NULL; | ||
555 | } | 554 | } |
556 | 555 | ||
557 | if (!(gc = kzalloc(sizeof(struct gc), GFP_KERNEL))) { | 556 | input_dev->name = gc_names[pad_type]; |
558 | parport_put_port(pp); | 557 | input_dev->phys = gc->phys[idx]; |
559 | return NULL; | 558 | input_dev->id.bustype = BUS_PARPORT; |
559 | input_dev->id.vendor = 0x0001; | ||
560 | input_dev->id.product = pad_type; | ||
561 | input_dev->id.version = 0x0100; | ||
562 | input_dev->private = gc; | ||
563 | |||
564 | input_dev->open = gc_open; | ||
565 | input_dev->close = gc_close; | ||
566 | |||
567 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
568 | |||
569 | for (i = 0; i < 2; i++) | ||
570 | input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); | ||
571 | |||
572 | gc->pads[0] |= gc_status_bit[idx]; | ||
573 | gc->pads[pad_type] |= gc_status_bit[idx]; | ||
574 | |||
575 | switch (pad_type) { | ||
576 | |||
577 | case GC_N64: | ||
578 | for (i = 0; i < 10; i++) | ||
579 | set_bit(gc_n64_btn[i], input_dev->keybit); | ||
580 | |||
581 | for (i = 0; i < 2; i++) { | ||
582 | input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2); | ||
583 | input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); | ||
584 | } | ||
585 | |||
586 | break; | ||
587 | |||
588 | case GC_SNES: | ||
589 | for (i = 4; i < 8; i++) | ||
590 | set_bit(gc_snes_btn[i], input_dev->keybit); | ||
591 | case GC_NES: | ||
592 | for (i = 0; i < 4; i++) | ||
593 | set_bit(gc_snes_btn[i], input_dev->keybit); | ||
594 | break; | ||
595 | |||
596 | case GC_MULTI2: | ||
597 | set_bit(BTN_THUMB, input_dev->keybit); | ||
598 | case GC_MULTI: | ||
599 | set_bit(BTN_TRIGGER, input_dev->keybit); | ||
600 | break; | ||
601 | |||
602 | case GC_PSX: | ||
603 | for (i = 0; i < 6; i++) | ||
604 | input_set_abs_params(input_dev, gc_psx_abs[i], 4, 252, 0, 2); | ||
605 | for (i = 0; i < 12; i++) | ||
606 | set_bit(gc_psx_btn[i], input_dev->keybit); | ||
607 | |||
608 | break; | ||
609 | |||
610 | case GC_DDR: | ||
611 | for (i = 0; i < 4; i++) | ||
612 | set_bit(gc_psx_ddr_btn[i], input_dev->keybit); | ||
613 | for (i = 0; i < 12; i++) | ||
614 | set_bit(gc_psx_btn[i], input_dev->keybit); | ||
615 | |||
616 | break; | ||
560 | } | 617 | } |
561 | 618 | ||
562 | init_MUTEX(&gc->sem); | 619 | return 0; |
620 | } | ||
563 | 621 | ||
564 | gc->pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | 622 | static struct gc __init *gc_probe(int parport, int *pads, int n_pads) |
623 | { | ||
624 | struct gc *gc; | ||
625 | struct parport *pp; | ||
626 | struct pardevice *pd; | ||
627 | int i; | ||
628 | int err; | ||
565 | 629 | ||
566 | parport_put_port(pp); | 630 | pp = parport_find_number(parport); |
631 | if (!pp) { | ||
632 | printk(KERN_ERR "gamecon.c: no such parport\n"); | ||
633 | err = -EINVAL; | ||
634 | goto err_out; | ||
635 | } | ||
567 | 636 | ||
568 | if (!gc->pd) { | 637 | pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); |
638 | if (!pd) { | ||
569 | printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); | 639 | printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); |
570 | kfree(gc); | 640 | err = -EBUSY; |
571 | return NULL; | 641 | goto err_put_pp; |
572 | } | 642 | } |
573 | 643 | ||
574 | parport_claim(gc->pd); | 644 | gc = kzalloc(sizeof(struct gc), GFP_KERNEL); |
645 | if (!gc) { | ||
646 | printk(KERN_ERR "gamecon.c: Not enough memory\n"); | ||
647 | err = -ENOMEM; | ||
648 | goto err_unreg_pardev; | ||
649 | } | ||
575 | 650 | ||
651 | init_MUTEX(&gc->sem); | ||
652 | gc->pd = pd; | ||
576 | init_timer(&gc->timer); | 653 | init_timer(&gc->timer); |
577 | gc->timer.data = (long) gc; | 654 | gc->timer.data = (long) gc; |
578 | gc->timer.function = gc_timer; | 655 | gc->timer.function = gc_timer; |
579 | 656 | ||
580 | for (i = 0; i < nargs - 1; i++) { | 657 | for (i = 0; i < n_pads; i++) { |
581 | 658 | if (!pads[i]) | |
582 | if (!config[i + 1]) | ||
583 | continue; | 659 | continue; |
584 | 660 | ||
585 | if (config[i + 1] < 1 || config[i + 1] > GC_MAX) { | 661 | sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); |
586 | printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", config[i + 1]); | 662 | err = gc_setup_pad(gc, i, pads[i]); |
587 | continue; | 663 | if (err) |
588 | } | 664 | goto err_free_devs; |
589 | |||
590 | gc->dev[i].private = gc; | ||
591 | gc->dev[i].open = gc_open; | ||
592 | gc->dev[i].close = gc_close; | ||
593 | 665 | ||
594 | gc->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 666 | input_register_device(gc->dev[i]); |
667 | } | ||
595 | 668 | ||
596 | for (j = 0; j < 2; j++) { | 669 | if (!gc->pads[0]) { |
597 | set_bit(ABS_X + j, gc->dev[i].absbit); | 670 | printk(KERN_ERR "gamecon.c: No valid devices specified\n"); |
598 | gc->dev[i].absmin[ABS_X + j] = -1; | 671 | err = -EINVAL; |
599 | gc->dev[i].absmax[ABS_X + j] = 1; | 672 | goto err_free_gc; |
600 | } | 673 | } |
601 | 674 | ||
602 | gc->pads[0] |= gc_status_bit[i]; | 675 | parport_put_port(pp); |
603 | gc->pads[config[i + 1]] |= gc_status_bit[i]; | 676 | return gc; |
604 | 677 | ||
605 | switch(config[i + 1]) { | 678 | err_free_devs: |
679 | while (--i >= 0) | ||
680 | input_unregister_device(gc->dev[i]); | ||
681 | err_free_gc: | ||
682 | kfree(gc); | ||
683 | err_unreg_pardev: | ||
684 | parport_unregister_device(pd); | ||
685 | err_put_pp: | ||
686 | parport_put_port(pp); | ||
687 | err_out: | ||
688 | return ERR_PTR(err); | ||
689 | } | ||
606 | 690 | ||
607 | case GC_N64: | 691 | static void __exit gc_remove(struct gc *gc) |
608 | for (j = 0; j < 10; j++) | 692 | { |
609 | set_bit(gc_n64_btn[j], gc->dev[i].keybit); | 693 | int i; |
610 | |||
611 | for (j = 0; j < 2; j++) { | ||
612 | set_bit(ABS_X + j, gc->dev[i].absbit); | ||
613 | gc->dev[i].absmin[ABS_X + j] = -127; | ||
614 | gc->dev[i].absmax[ABS_X + j] = 126; | ||
615 | gc->dev[i].absflat[ABS_X + j] = 2; | ||
616 | set_bit(ABS_HAT0X + j, gc->dev[i].absbit); | ||
617 | gc->dev[i].absmin[ABS_HAT0X + j] = -1; | ||
618 | gc->dev[i].absmax[ABS_HAT0X + j] = 1; | ||
619 | } | ||
620 | 694 | ||
621 | break; | 695 | for (i = 0; i < GC_MAX_DEVICES; i++) |
696 | if (gc->dev[i]) | ||
697 | input_unregister_device(gc->dev[i]); | ||
698 | parport_unregister_device(gc->pd); | ||
699 | kfree(gc); | ||
700 | } | ||
622 | 701 | ||
623 | case GC_SNES: | 702 | static int __init gc_init(void) |
624 | for (j = 4; j < 8; j++) | 703 | { |
625 | set_bit(gc_snes_btn[j], gc->dev[i].keybit); | 704 | int i; |
626 | case GC_NES: | 705 | int have_dev = 0; |
627 | for (j = 0; j < 4; j++) | 706 | int err = 0; |
628 | set_bit(gc_snes_btn[j], gc->dev[i].keybit); | ||
629 | break; | ||
630 | |||
631 | case GC_MULTI2: | ||
632 | set_bit(BTN_THUMB, gc->dev[i].keybit); | ||
633 | case GC_MULTI: | ||
634 | set_bit(BTN_TRIGGER, gc->dev[i].keybit); | ||
635 | break; | ||
636 | |||
637 | case GC_PSX: | ||
638 | case GC_DDR: | ||
639 | if(config[i + 1] == GC_DDR) { | ||
640 | for (j = 0; j < 4; j++) | ||
641 | set_bit(gc_psx_ddr_btn[j], gc->dev[i].keybit); | ||
642 | } else { | ||
643 | for (j = 0; j < 6; j++) { | ||
644 | set_bit(gc_psx_abs[j], gc->dev[i].absbit); | ||
645 | gc->dev[i].absmin[gc_psx_abs[j]] = 4; | ||
646 | gc->dev[i].absmax[gc_psx_abs[j]] = 252; | ||
647 | gc->dev[i].absflat[gc_psx_abs[j]] = 2; | ||
648 | } | ||
649 | } | ||
650 | 707 | ||
651 | for (j = 0; j < 12; j++) | 708 | for (i = 0; i < GC_MAX_PORTS; i++) { |
652 | set_bit(gc_psx_btn[j], gc->dev[i].keybit); | 709 | if (gc[i].nargs == 0 || gc[i].args[0] < 0) |
710 | continue; | ||
653 | 711 | ||
654 | break; | 712 | if (gc[i].nargs < 2) { |
713 | printk(KERN_ERR "gamecon.c: at least one device must be specified\n"); | ||
714 | err = -EINVAL; | ||
715 | break; | ||
655 | } | 716 | } |
656 | 717 | ||
657 | sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); | 718 | gc_base[i] = gc_probe(gc[i].args[0], gc[i].args + 1, gc[i].nargs - 1); |
719 | if (IS_ERR(gc_base[i])) { | ||
720 | err = PTR_ERR(gc_base[i]); | ||
721 | break; | ||
722 | } | ||
658 | 723 | ||
659 | gc->dev[i].name = gc_names[config[i + 1]]; | 724 | have_dev = 1; |
660 | gc->dev[i].phys = gc->phys[i]; | ||
661 | gc->dev[i].id.bustype = BUS_PARPORT; | ||
662 | gc->dev[i].id.vendor = 0x0001; | ||
663 | gc->dev[i].id.product = config[i + 1]; | ||
664 | gc->dev[i].id.version = 0x0100; | ||
665 | } | 725 | } |
666 | 726 | ||
667 | parport_release(gc->pd); | 727 | if (err) { |
668 | 728 | while (--i >= 0) | |
669 | if (!gc->pads[0]) { | 729 | gc_remove(gc_base[i]); |
670 | parport_unregister_device(gc->pd); | 730 | return err; |
671 | kfree(gc); | ||
672 | return NULL; | ||
673 | } | 731 | } |
674 | 732 | ||
675 | for (i = 0; i < 5; i++) | 733 | return have_dev ? 0 : -ENODEV; |
676 | if (gc->pads[0] & gc_status_bit[i]) { | ||
677 | input_register_device(gc->dev + i); | ||
678 | printk(KERN_INFO "input: %s on %s\n", gc->dev[i].name, gc->pd->port->name); | ||
679 | } | ||
680 | |||
681 | return gc; | ||
682 | } | ||
683 | |||
684 | static int __init gc_init(void) | ||
685 | { | ||
686 | gc_base[0] = gc_probe(gc, gc_nargs); | ||
687 | gc_base[1] = gc_probe(gc_2, gc_nargs_2); | ||
688 | gc_base[2] = gc_probe(gc_3, gc_nargs_3); | ||
689 | |||
690 | if (gc_base[0] || gc_base[1] || gc_base[2]) | ||
691 | return 0; | ||
692 | |||
693 | return -ENODEV; | ||
694 | } | 734 | } |
695 | 735 | ||
696 | static void __exit gc_exit(void) | 736 | static void __exit gc_exit(void) |
697 | { | 737 | { |
698 | int i, j; | 738 | int i; |
699 | 739 | ||
700 | for (i = 0; i < 3; i++) | 740 | for (i = 0; i < GC_MAX_PORTS; i++) |
701 | if (gc_base[i]) { | 741 | if (gc_base[i]) |
702 | for (j = 0; j < 5; j++) | 742 | gc_remove(gc_base[i]); |
703 | if (gc_base[i]->pads[0] & gc_status_bit[j]) | ||
704 | input_unregister_device(gc_base[i]->dev + j); | ||
705 | parport_unregister_device(gc_base[i]->pd); | ||
706 | } | ||
707 | } | 743 | } |
708 | 744 | ||
709 | module_init(gc_init); | 745 | module_init(gc_init); |
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 | ||
82 | struct gf2k { | 82 | struct 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 | ||
176 | static void gf2k_read(struct gf2k *gf2k, unsigned char *data) | 176 | static 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) | |||
239 | static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) | 239 | static 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 | ||
343 | fail2: gameport_close(gameport); | 347 | fail2: gameport_close(gameport); |
344 | fail1: 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); |
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index 9d3f910dd568..e206bb56e53c 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c | |||
@@ -55,7 +55,7 @@ MODULE_LICENSE("GPL"); | |||
55 | 55 | ||
56 | struct grip { | 56 | struct grip { |
57 | struct gameport *gameport; | 57 | struct gameport *gameport; |
58 | struct input_dev dev[2]; | 58 | struct input_dev *dev[2]; |
59 | unsigned char mode[2]; | 59 | unsigned char mode[2]; |
60 | int reads; | 60 | int reads; |
61 | int bads; | 61 | int bads; |
@@ -190,7 +190,7 @@ static void grip_poll(struct gameport *gameport) | |||
190 | 190 | ||
191 | for (i = 0; i < 2; i++) { | 191 | for (i = 0; i < 2; i++) { |
192 | 192 | ||
193 | dev = grip->dev + i; | 193 | dev = grip->dev[i]; |
194 | grip->reads++; | 194 | grip->reads++; |
195 | 195 | ||
196 | switch (grip->mode[i]) { | 196 | switch (grip->mode[i]) { |
@@ -297,6 +297,7 @@ static void grip_close(struct input_dev *dev) | |||
297 | static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | 297 | static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) |
298 | { | 298 | { |
299 | struct grip *grip; | 299 | struct grip *grip; |
300 | struct input_dev *input_dev; | ||
300 | unsigned int data[GRIP_LENGTH_XT]; | 301 | unsigned int data[GRIP_LENGTH_XT]; |
301 | int i, j, t; | 302 | int i, j, t; |
302 | int err; | 303 | int err; |
@@ -339,48 +340,56 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
339 | gameport_set_poll_handler(gameport, grip_poll); | 340 | gameport_set_poll_handler(gameport, grip_poll); |
340 | gameport_set_poll_interval(gameport, 20); | 341 | gameport_set_poll_interval(gameport, 20); |
341 | 342 | ||
342 | for (i = 0; i < 2; i++) | 343 | for (i = 0; i < 2; i++) { |
343 | if (grip->mode[i]) { | 344 | if (!grip->mode[i]) |
345 | continue; | ||
344 | 346 | ||
345 | sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); | 347 | grip->dev[i] = input_dev = input_allocate_device(); |
348 | if (!input_dev) { | ||
349 | err = -ENOMEM; | ||
350 | goto fail3; | ||
351 | } | ||
346 | 352 | ||
347 | grip->dev[i].private = grip; | 353 | sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); |
348 | 354 | ||
349 | grip->dev[i].open = grip_open; | 355 | input_dev->name = grip_name[grip->mode[i]]; |
350 | grip->dev[i].close = grip_close; | 356 | input_dev->phys = grip->phys[i]; |
357 | input_dev->id.bustype = BUS_GAMEPORT; | ||
358 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; | ||
359 | input_dev->id.product = grip->mode[i]; | ||
360 | input_dev->id.version = 0x0100; | ||
361 | input_dev->cdev.dev = &gameport->dev; | ||
362 | input_dev->private = grip; | ||
351 | 363 | ||
352 | grip->dev[i].name = grip_name[grip->mode[i]]; | 364 | input_dev->open = grip_open; |
353 | grip->dev[i].phys = grip->phys[i]; | 365 | input_dev->close = grip_close; |
354 | grip->dev[i].id.bustype = BUS_GAMEPORT; | ||
355 | grip->dev[i].id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; | ||
356 | grip->dev[i].id.product = grip->mode[i]; | ||
357 | grip->dev[i].id.version = 0x0100; | ||
358 | 366 | ||
359 | grip->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 367 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
360 | 368 | ||
361 | for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { | 369 | for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { |
362 | 370 | ||
363 | if (j < grip_cen[grip->mode[i]]) | 371 | if (j < grip_cen[grip->mode[i]]) |
364 | input_set_abs_params(&grip->dev[i], t, 14, 52, 1, 2); | 372 | input_set_abs_params(input_dev, t, 14, 52, 1, 2); |
365 | else if (j < grip_anx[grip->mode[i]]) | 373 | else if (j < grip_anx[grip->mode[i]]) |
366 | input_set_abs_params(&grip->dev[i], t, 3, 57, 1, 0); | 374 | input_set_abs_params(input_dev, t, 3, 57, 1, 0); |
367 | else | 375 | else |
368 | input_set_abs_params(&grip->dev[i], t, -1, 1, 0, 0); | 376 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
369 | } | 377 | } |
370 | 378 | ||
371 | for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++) | 379 | for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++) |
372 | if (t > 0) | 380 | if (t > 0) |
373 | set_bit(t, grip->dev[i].keybit); | 381 | set_bit(t, input_dev->keybit); |
374 | 382 | ||
375 | printk(KERN_INFO "input: %s on %s\n", | 383 | input_register_device(grip->dev[i]); |
376 | grip_name[grip->mode[i]], gameport->phys); | 384 | } |
377 | input_register_device(grip->dev + i); | ||
378 | } | ||
379 | 385 | ||
380 | return 0; | 386 | return 0; |
381 | 387 | ||
382 | fail2: gameport_close(gameport); | 388 | fail3: for (i = 0; i < 2; i++) |
383 | fail1: gameport_set_drvdata(gameport, NULL); | 389 | if (grip->dev[i]) |
390 | input_unregister_device(grip->dev[i]); | ||
391 | fail2: gameport_close(gameport); | ||
392 | fail1: gameport_set_drvdata(gameport, NULL); | ||
384 | kfree(grip); | 393 | kfree(grip); |
385 | return err; | 394 | return err; |
386 | } | 395 | } |
@@ -391,8 +400,8 @@ static void grip_disconnect(struct gameport *gameport) | |||
391 | int i; | 400 | int i; |
392 | 401 | ||
393 | for (i = 0; i < 2; i++) | 402 | for (i = 0; i < 2; i++) |
394 | if (grip->mode[i]) | 403 | if (grip->dev[i]) |
395 | input_unregister_device(grip->dev + i); | 404 | input_unregister_device(grip->dev[i]); |
396 | gameport_close(gameport); | 405 | gameport_close(gameport); |
397 | gameport_set_drvdata(gameport, NULL); | 406 | gameport_set_drvdata(gameport, NULL); |
398 | kfree(grip); | 407 | kfree(grip); |
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c index da17eee6f574..a0ba93ccac72 100644 --- a/drivers/input/joystick/grip_mp.c +++ b/drivers/input/joystick/grip_mp.c | |||
@@ -32,23 +32,37 @@ MODULE_LICENSE("GPL"); | |||
32 | #define dbg(format, arg...) do {} while (0) | 32 | #define dbg(format, arg...) do {} while (0) |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #define GRIP_MAX_PORTS 4 | ||
35 | /* | 36 | /* |
36 | * Grip multiport state | 37 | * Grip multiport state |
37 | */ | 38 | */ |
38 | 39 | ||
40 | struct grip_port { | ||
41 | struct input_dev *dev; | ||
42 | int mode; | ||
43 | int registered; | ||
44 | |||
45 | /* individual gamepad states */ | ||
46 | int buttons; | ||
47 | int xaxes; | ||
48 | int yaxes; | ||
49 | int dirty; /* has the state been updated? */ | ||
50 | }; | ||
51 | |||
39 | struct grip_mp { | 52 | struct grip_mp { |
40 | struct gameport *gameport; | 53 | struct gameport *gameport; |
41 | struct input_dev dev[4]; | 54 | struct grip_port *port[GRIP_MAX_PORTS]; |
42 | int mode[4]; | 55 | // struct input_dev *dev[4]; |
43 | int registered[4]; | 56 | // int mode[4]; |
57 | // int registered[4]; | ||
44 | int reads; | 58 | int reads; |
45 | int bads; | 59 | int bads; |
46 | 60 | ||
47 | /* individual gamepad states */ | 61 | /* individual gamepad states */ |
48 | int buttons[4]; | 62 | // int buttons[4]; |
49 | int xaxes[4]; | 63 | // int xaxes[4]; |
50 | int yaxes[4]; | 64 | // int yaxes[4]; |
51 | int dirty[4]; /* has the state been updated? */ | 65 | // int dirty[4]; /* has the state been updated? */ |
52 | }; | 66 | }; |
53 | 67 | ||
54 | /* | 68 | /* |
@@ -85,16 +99,16 @@ struct grip_mp { | |||
85 | #define GRIP_MODE_GP 2 | 99 | #define GRIP_MODE_GP 2 |
86 | #define GRIP_MODE_C64 3 | 100 | #define GRIP_MODE_C64 3 |
87 | 101 | ||
88 | static int grip_btn_gp[] = { BTN_TR, BTN_TL, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, -1 }; | 102 | static const int grip_btn_gp[] = { BTN_TR, BTN_TL, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, -1 }; |
89 | static int grip_btn_c64[] = { BTN_JOYSTICK, -1 }; | 103 | static const int grip_btn_c64[] = { BTN_JOYSTICK, -1 }; |
90 | 104 | ||
91 | static int grip_abs_gp[] = { ABS_X, ABS_Y, -1 }; | 105 | static const int grip_abs_gp[] = { ABS_X, ABS_Y, -1 }; |
92 | static int grip_abs_c64[] = { ABS_X, ABS_Y, -1 }; | 106 | static const int grip_abs_c64[] = { ABS_X, ABS_Y, -1 }; |
93 | 107 | ||
94 | static int *grip_abs[] = { NULL, NULL, grip_abs_gp, grip_abs_c64 }; | 108 | static const int *grip_abs[] = { NULL, NULL, grip_abs_gp, grip_abs_c64 }; |
95 | static int *grip_btn[] = { NULL, NULL, grip_btn_gp, grip_btn_c64 }; | 109 | static const int *grip_btn[] = { NULL, NULL, grip_btn_gp, grip_btn_c64 }; |
96 | 110 | ||
97 | static char *grip_name[] = { NULL, NULL, "Gravis Grip Pad", "Commodore 64 Joystick" }; | 111 | static const char *grip_name[] = { NULL, NULL, "Gravis Grip Pad", "Commodore 64 Joystick" }; |
98 | 112 | ||
99 | static const int init_seq[] = { | 113 | static const int init_seq[] = { |
100 | 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, | 114 | 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, |
@@ -104,9 +118,9 @@ static const int init_seq[] = { | |||
104 | 118 | ||
105 | /* Maps multiport directional values to X,Y axis values (each axis encoded in 3 bits) */ | 119 | /* Maps multiport directional values to X,Y axis values (each axis encoded in 3 bits) */ |
106 | 120 | ||
107 | static int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5 }; | 121 | static const int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5 }; |
108 | 122 | ||
109 | static void register_slot(int i, struct grip_mp *grip); | 123 | static int register_slot(int i, struct grip_mp *grip); |
110 | 124 | ||
111 | /* | 125 | /* |
112 | * Returns whether an odd or even number of bits are on in pkt. | 126 | * Returns whether an odd or even number of bits are on in pkt. |
@@ -353,9 +367,10 @@ static int dig_mode_start(struct gameport *gameport, u32 *packet) | |||
353 | 367 | ||
354 | static int get_and_decode_packet(struct grip_mp *grip, int flags) | 368 | static int get_and_decode_packet(struct grip_mp *grip, int flags) |
355 | { | 369 | { |
370 | struct grip_port *port; | ||
356 | u32 packet; | 371 | u32 packet; |
357 | int joytype = 0; | 372 | int joytype = 0; |
358 | int slot = 0; | 373 | int slot; |
359 | 374 | ||
360 | /* Get a packet and check for validity */ | 375 | /* Get a packet and check for validity */ |
361 | 376 | ||
@@ -377,6 +392,8 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags) | |||
377 | if ((slot < 0) || (slot > 3)) | 392 | if ((slot < 0) || (slot > 3)) |
378 | return flags; | 393 | return flags; |
379 | 394 | ||
395 | port = grip->port[slot]; | ||
396 | |||
380 | /* | 397 | /* |
381 | * Handle "reset" packets, which occur at startup, and when gamepads | 398 | * Handle "reset" packets, which occur at startup, and when gamepads |
382 | * are removed or plugged in. May contain configuration of a new gamepad. | 399 | * are removed or plugged in. May contain configuration of a new gamepad. |
@@ -385,14 +402,14 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags) | |||
385 | joytype = (packet >> 16) & 0x1f; | 402 | joytype = (packet >> 16) & 0x1f; |
386 | if (!joytype) { | 403 | if (!joytype) { |
387 | 404 | ||
388 | if (grip->registered[slot]) { | 405 | if (port->registered) { |
389 | printk(KERN_INFO "grip_mp: removing %s, slot %d\n", | 406 | printk(KERN_INFO "grip_mp: removing %s, slot %d\n", |
390 | grip_name[grip->mode[slot]], slot); | 407 | grip_name[port->mode], slot); |
391 | input_unregister_device(grip->dev + slot); | 408 | input_unregister_device(port->dev); |
392 | grip->registered[slot] = 0; | 409 | port->registered = 0; |
393 | } | 410 | } |
394 | dbg("Reset: grip multiport slot %d\n", slot); | 411 | dbg("Reset: grip multiport slot %d\n", slot); |
395 | grip->mode[slot] = GRIP_MODE_RESET; | 412 | port->mode = GRIP_MODE_RESET; |
396 | flags |= IO_SLOT_CHANGE; | 413 | flags |= IO_SLOT_CHANGE; |
397 | return flags; | 414 | return flags; |
398 | } | 415 | } |
@@ -402,17 +419,17 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags) | |||
402 | if (joytype == 0x1f) { | 419 | if (joytype == 0x1f) { |
403 | 420 | ||
404 | int dir = (packet >> 8) & 0xf; /* eight way directional value */ | 421 | int dir = (packet >> 8) & 0xf; /* eight way directional value */ |
405 | grip->buttons[slot] = (~packet) & 0xff; | 422 | port->buttons = (~packet) & 0xff; |
406 | grip->yaxes[slot] = ((axis_map[dir] >> 2) & 3) - 1; | 423 | port->yaxes = ((axis_map[dir] >> 2) & 3) - 1; |
407 | grip->xaxes[slot] = (axis_map[dir] & 3) - 1; | 424 | port->xaxes = (axis_map[dir] & 3) - 1; |
408 | grip->dirty[slot] = 1; | 425 | port->dirty = 1; |
409 | 426 | ||
410 | if (grip->mode[slot] == GRIP_MODE_RESET) | 427 | if (port->mode == GRIP_MODE_RESET) |
411 | flags |= IO_SLOT_CHANGE; | 428 | flags |= IO_SLOT_CHANGE; |
412 | 429 | ||
413 | grip->mode[slot] = GRIP_MODE_GP; | 430 | port->mode = GRIP_MODE_GP; |
414 | 431 | ||
415 | if (!grip->registered[slot]) { | 432 | if (!port->registered) { |
416 | dbg("New Grip pad in multiport slot %d.\n", slot); | 433 | dbg("New Grip pad in multiport slot %d.\n", slot); |
417 | register_slot(slot, grip); | 434 | register_slot(slot, grip); |
418 | } | 435 | } |
@@ -445,9 +462,9 @@ static int slots_valid(struct grip_mp *grip) | |||
445 | return 0; | 462 | return 0; |
446 | 463 | ||
447 | for (slot = 0; slot < 4; slot++) { | 464 | for (slot = 0; slot < 4; slot++) { |
448 | if (grip->mode[slot] == GRIP_MODE_RESET) | 465 | if (grip->port[slot]->mode == GRIP_MODE_RESET) |
449 | invalid = 1; | 466 | invalid = 1; |
450 | if (grip->mode[slot] != GRIP_MODE_NONE) | 467 | if (grip->port[slot]->mode != GRIP_MODE_NONE) |
451 | active = 1; | 468 | active = 1; |
452 | } | 469 | } |
453 | 470 | ||
@@ -484,7 +501,7 @@ static int multiport_init(struct grip_mp *grip) | |||
484 | 501 | ||
485 | /* Get packets, store multiport state, and check state's validity */ | 502 | /* Get packets, store multiport state, and check state's validity */ |
486 | for (tries = 0; tries < 4096; tries++) { | 503 | for (tries = 0; tries < 4096; tries++) { |
487 | if ( slots_valid(grip) ) { | 504 | if (slots_valid(grip)) { |
488 | initialized = 1; | 505 | initialized = 1; |
489 | break; | 506 | break; |
490 | } | 507 | } |
@@ -499,24 +516,24 @@ static int multiport_init(struct grip_mp *grip) | |||
499 | 516 | ||
500 | static void report_slot(struct grip_mp *grip, int slot) | 517 | static void report_slot(struct grip_mp *grip, int slot) |
501 | { | 518 | { |
502 | struct input_dev *dev = &(grip->dev[slot]); | 519 | struct grip_port *port = grip->port[slot]; |
503 | int i, buttons = grip->buttons[slot]; | 520 | int i; |
504 | 521 | ||
505 | /* Store button states with linux input driver */ | 522 | /* Store button states with linux input driver */ |
506 | 523 | ||
507 | for (i = 0; i < 8; i++) | 524 | for (i = 0; i < 8; i++) |
508 | input_report_key(dev, grip_btn_gp[i], (buttons >> i) & 1); | 525 | input_report_key(port->dev, grip_btn_gp[i], (port->buttons >> i) & 1); |
509 | 526 | ||
510 | /* Store axis states with linux driver */ | 527 | /* Store axis states with linux driver */ |
511 | 528 | ||
512 | input_report_abs(dev, ABS_X, grip->xaxes[slot]); | 529 | input_report_abs(port->dev, ABS_X, port->xaxes); |
513 | input_report_abs(dev, ABS_Y, grip->yaxes[slot]); | 530 | input_report_abs(port->dev, ABS_Y, port->yaxes); |
514 | 531 | ||
515 | /* Tell the receiver of the events to process them */ | 532 | /* Tell the receiver of the events to process them */ |
516 | 533 | ||
517 | input_sync(dev); | 534 | input_sync(port->dev); |
518 | 535 | ||
519 | grip->dirty[slot] = 0; | 536 | port->dirty = 0; |
520 | } | 537 | } |
521 | 538 | ||
522 | /* | 539 | /* |
@@ -540,7 +557,7 @@ static void grip_poll(struct gameport *gameport) | |||
540 | } | 557 | } |
541 | 558 | ||
542 | for (i = 0; i < 4; i++) | 559 | for (i = 0; i < 4; i++) |
543 | if (grip->dirty[i]) | 560 | if (grip->port[i]->dirty) |
544 | report_slot(grip, i); | 561 | report_slot(grip, i); |
545 | } | 562 | } |
546 | 563 | ||
@@ -571,35 +588,43 @@ static void grip_close(struct input_dev *dev) | |||
571 | * Tell the linux input layer about a newly plugged-in gamepad. | 588 | * Tell the linux input layer about a newly plugged-in gamepad. |
572 | */ | 589 | */ |
573 | 590 | ||
574 | static void register_slot(int slot, struct grip_mp *grip) | 591 | static int register_slot(int slot, struct grip_mp *grip) |
575 | { | 592 | { |
593 | struct grip_port *port = grip->port[slot]; | ||
594 | struct input_dev *input_dev; | ||
576 | int j, t; | 595 | int j, t; |
577 | 596 | ||
578 | grip->dev[slot].private = grip; | 597 | port->dev = input_dev = input_allocate_device(); |
579 | grip->dev[slot].open = grip_open; | 598 | if (!input_dev) |
580 | grip->dev[slot].close = grip_close; | 599 | return -ENOMEM; |
581 | grip->dev[slot].name = grip_name[grip->mode[slot]]; | 600 | |
582 | grip->dev[slot].id.bustype = BUS_GAMEPORT; | 601 | input_dev->name = grip_name[port->mode]; |
583 | grip->dev[slot].id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; | 602 | input_dev->id.bustype = BUS_GAMEPORT; |
584 | grip->dev[slot].id.product = 0x0100 + grip->mode[slot]; | 603 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; |
585 | grip->dev[slot].id.version = 0x0100; | 604 | input_dev->id.product = 0x0100 + port->mode; |
586 | grip->dev[slot].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 605 | input_dev->id.version = 0x0100; |
606 | input_dev->cdev.dev = &grip->gameport->dev; | ||
607 | input_dev->private = grip; | ||
608 | |||
609 | input_dev->open = grip_open; | ||
610 | input_dev->close = grip_close; | ||
587 | 611 | ||
588 | for (j = 0; (t = grip_abs[grip->mode[slot]][j]) >= 0; j++) | 612 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
589 | input_set_abs_params(&grip->dev[slot], t, -1, 1, 0, 0); | ||
590 | 613 | ||
591 | for (j = 0; (t = grip_btn[grip->mode[slot]][j]) >= 0; j++) | 614 | for (j = 0; (t = grip_abs[port->mode][j]) >= 0; j++) |
615 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); | ||
616 | |||
617 | for (j = 0; (t = grip_btn[port->mode][j]) >= 0; j++) | ||
592 | if (t > 0) | 618 | if (t > 0) |
593 | set_bit(t, grip->dev[slot].keybit); | 619 | set_bit(t, input_dev->keybit); |
594 | 620 | ||
595 | input_register_device(grip->dev + slot); | 621 | input_register_device(port->dev); |
596 | grip->registered[slot] = 1; | 622 | port->registered = 1; |
597 | 623 | ||
598 | if (grip->dirty[slot]) /* report initial state, if any */ | 624 | if (port->dirty) /* report initial state, if any */ |
599 | report_slot(grip, slot); | 625 | report_slot(grip, slot); |
600 | 626 | ||
601 | printk(KERN_INFO "grip_mp: added %s, slot %d\n", | 627 | return 0; |
602 | grip_name[grip->mode[slot]], slot); | ||
603 | } | 628 | } |
604 | 629 | ||
605 | static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | 630 | static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) |
@@ -626,7 +651,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
626 | goto fail2; | 651 | goto fail2; |
627 | } | 652 | } |
628 | 653 | ||
629 | if (!grip->mode[0] && !grip->mode[1] && !grip->mode[2] && !grip->mode[3]) { | 654 | if (!grip->port[0]->mode && !grip->port[1]->mode && !grip->port[2]->mode && !grip->port[3]->mode) { |
630 | /* nothing plugged in */ | 655 | /* nothing plugged in */ |
631 | err = -ENODEV; | 656 | err = -ENODEV; |
632 | goto fail2; | 657 | goto fail2; |
@@ -646,8 +671,8 @@ static void grip_disconnect(struct gameport *gameport) | |||
646 | int i; | 671 | int i; |
647 | 672 | ||
648 | for (i = 0; i < 4; i++) | 673 | for (i = 0; i < 4; i++) |
649 | if (grip->registered[i]) | 674 | if (grip->port[i]->registered) |
650 | input_unregister_device(grip->dev + i); | 675 | input_unregister_device(grip->port[i]->dev); |
651 | gameport_close(gameport); | 676 | gameport_close(gameport); |
652 | gameport_set_drvdata(gameport, NULL); | 677 | gameport_set_drvdata(gameport, NULL); |
653 | kfree(grip); | 678 | kfree(grip); |
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 | ||
68 | struct guillemot { | 68 | struct 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) | |||
123 | static void guillemot_poll(struct gameport *gameport) | 123 | static 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) | |||
179 | static int guillemot_connect(struct gameport *gameport, struct gameport_driver *drv) | 179 | static 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 | ||
252 | fail2: gameport_close(gameport); | 256 | fail2: gameport_close(gameport); |
253 | fail1: gameport_set_drvdata(gameport, NULL); | 257 | fail1: 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 | } |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index e31b7b93fde2..64b9c31c47fc 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
@@ -144,7 +144,7 @@ static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect) | |||
144 | int is_update; | 144 | int is_update; |
145 | 145 | ||
146 | /* Check this effect type is supported by this device */ | 146 | /* Check this effect type is supported by this device */ |
147 | if (!test_bit(effect->type, iforce->dev.ffbit)) | 147 | if (!test_bit(effect->type, iforce->dev->ffbit)) |
148 | return -EINVAL; | 148 | return -EINVAL; |
149 | 149 | ||
150 | /* | 150 | /* |
@@ -152,30 +152,31 @@ static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect) | |||
152 | */ | 152 | */ |
153 | if (effect->id == -1) { | 153 | if (effect->id == -1) { |
154 | 154 | ||
155 | for (id=0; id < FF_EFFECTS_MAX; ++id) | 155 | for (id = 0; id < FF_EFFECTS_MAX; ++id) |
156 | if (!test_and_set_bit(FF_CORE_IS_USED, iforce->core_effects[id].flags)) break; | 156 | if (!test_and_set_bit(FF_CORE_IS_USED, iforce->core_effects[id].flags)) |
157 | break; | ||
157 | 158 | ||
158 | if ( id == FF_EFFECTS_MAX || id >= iforce->dev.ff_effects_max) | 159 | if (id == FF_EFFECTS_MAX || id >= iforce->dev->ff_effects_max) |
159 | return -ENOMEM; | 160 | return -ENOMEM; |
160 | 161 | ||
161 | effect->id = id; | 162 | effect->id = id; |
162 | iforce->core_effects[id].owner = current->pid; | 163 | iforce->core_effects[id].owner = current->pid; |
163 | iforce->core_effects[id].flags[0] = (1<<FF_CORE_IS_USED); /* Only IS_USED bit must be set */ | 164 | iforce->core_effects[id].flags[0] = (1 << FF_CORE_IS_USED); /* Only IS_USED bit must be set */ |
164 | 165 | ||
165 | is_update = FALSE; | 166 | is_update = FALSE; |
166 | } | 167 | } |
167 | else { | 168 | else { |
168 | /* We want to update an effect */ | 169 | /* We want to update an effect */ |
169 | if (!CHECK_OWNERSHIP(effect->id, iforce)) return -EACCES; | 170 | if (!CHECK_OWNERSHIP(effect->id, iforce)) |
171 | return -EACCES; | ||
170 | 172 | ||
171 | /* Parameter type cannot be updated */ | 173 | /* Parameter type cannot be updated */ |
172 | if (effect->type != iforce->core_effects[effect->id].effect.type) | 174 | if (effect->type != iforce->core_effects[effect->id].effect.type) |
173 | return -EINVAL; | 175 | return -EINVAL; |
174 | 176 | ||
175 | /* Check the effect is not already being updated */ | 177 | /* Check the effect is not already being updated */ |
176 | if (test_bit(FF_CORE_UPDATE, iforce->core_effects[effect->id].flags)) { | 178 | if (test_bit(FF_CORE_UPDATE, iforce->core_effects[effect->id].flags)) |
177 | return -EAGAIN; | 179 | return -EAGAIN; |
178 | } | ||
179 | 180 | ||
180 | is_update = TRUE; | 181 | is_update = TRUE; |
181 | } | 182 | } |
@@ -339,15 +340,19 @@ void iforce_delete_device(struct iforce *iforce) | |||
339 | 340 | ||
340 | int iforce_init_device(struct iforce *iforce) | 341 | int iforce_init_device(struct iforce *iforce) |
341 | { | 342 | { |
343 | struct input_dev *input_dev; | ||
342 | unsigned char c[] = "CEOV"; | 344 | unsigned char c[] = "CEOV"; |
343 | int i; | 345 | int i; |
344 | 346 | ||
347 | input_dev = input_allocate_device(); | ||
348 | if (input_dev) | ||
349 | return -ENOMEM; | ||
350 | |||
345 | init_waitqueue_head(&iforce->wait); | 351 | init_waitqueue_head(&iforce->wait); |
346 | spin_lock_init(&iforce->xmit_lock); | 352 | spin_lock_init(&iforce->xmit_lock); |
347 | init_MUTEX(&iforce->mem_mutex); | 353 | init_MUTEX(&iforce->mem_mutex); |
348 | iforce->xmit.buf = iforce->xmit_data; | 354 | iforce->xmit.buf = iforce->xmit_data; |
349 | 355 | iforce->dev = input_dev; | |
350 | iforce->dev.ff_effects_max = 10; | ||
351 | 356 | ||
352 | /* | 357 | /* |
353 | * Input device fields. | 358 | * Input device fields. |
@@ -356,26 +361,27 @@ int iforce_init_device(struct iforce *iforce) | |||
356 | switch (iforce->bus) { | 361 | switch (iforce->bus) { |
357 | #ifdef CONFIG_JOYSTICK_IFORCE_USB | 362 | #ifdef CONFIG_JOYSTICK_IFORCE_USB |
358 | case IFORCE_USB: | 363 | case IFORCE_USB: |
359 | iforce->dev.id.bustype = BUS_USB; | 364 | input_dev->id.bustype = BUS_USB; |
360 | iforce->dev.dev = &iforce->usbdev->dev; | 365 | input_dev->cdev.dev = &iforce->usbdev->dev; |
361 | break; | 366 | break; |
362 | #endif | 367 | #endif |
363 | #ifdef CONFIG_JOYSTICK_IFORCE_232 | 368 | #ifdef CONFIG_JOYSTICK_IFORCE_232 |
364 | case IFORCE_232: | 369 | case IFORCE_232: |
365 | iforce->dev.id.bustype = BUS_RS232; | 370 | input_dev->id.bustype = BUS_RS232; |
366 | iforce->dev.dev = &iforce->serio->dev; | 371 | input_dev->cdev.dev = &iforce->serio->dev; |
367 | break; | 372 | break; |
368 | #endif | 373 | #endif |
369 | } | 374 | } |
370 | 375 | ||
371 | iforce->dev.private = iforce; | 376 | input_dev->private = iforce; |
372 | iforce->dev.name = "Unknown I-Force device"; | 377 | input_dev->name = "Unknown I-Force device"; |
373 | iforce->dev.open = iforce_open; | 378 | input_dev->open = iforce_open; |
374 | iforce->dev.close = iforce_release; | 379 | input_dev->close = iforce_release; |
375 | iforce->dev.flush = iforce_flush; | 380 | input_dev->flush = iforce_flush; |
376 | iforce->dev.event = iforce_input_event; | 381 | input_dev->event = iforce_input_event; |
377 | iforce->dev.upload_effect = iforce_upload_effect; | 382 | input_dev->upload_effect = iforce_upload_effect; |
378 | iforce->dev.erase_effect = iforce_erase_effect; | 383 | input_dev->erase_effect = iforce_erase_effect; |
384 | input_dev->ff_effects_max = 10; | ||
379 | 385 | ||
380 | /* | 386 | /* |
381 | * On-device memory allocation. | 387 | * On-device memory allocation. |
@@ -399,7 +405,8 @@ int iforce_init_device(struct iforce *iforce) | |||
399 | 405 | ||
400 | if (i == 20) { /* 5 seconds */ | 406 | if (i == 20) { /* 5 seconds */ |
401 | printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); | 407 | printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); |
402 | return -1; | 408 | input_free_device(input_dev); |
409 | return -ENODEV; | ||
403 | } | 410 | } |
404 | 411 | ||
405 | /* | 412 | /* |
@@ -407,12 +414,12 @@ int iforce_init_device(struct iforce *iforce) | |||
407 | */ | 414 | */ |
408 | 415 | ||
409 | if (!iforce_get_id_packet(iforce, "M")) | 416 | if (!iforce_get_id_packet(iforce, "M")) |
410 | iforce->dev.id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; | 417 | input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; |
411 | else | 418 | else |
412 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet M\n"); | 419 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet M\n"); |
413 | 420 | ||
414 | if (!iforce_get_id_packet(iforce, "P")) | 421 | if (!iforce_get_id_packet(iforce, "P")) |
415 | iforce->dev.id.product = (iforce->edata[2] << 8) | iforce->edata[1]; | 422 | input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; |
416 | else | 423 | else |
417 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet P\n"); | 424 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet P\n"); |
418 | 425 | ||
@@ -422,15 +429,15 @@ int iforce_init_device(struct iforce *iforce) | |||
422 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet B\n"); | 429 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet B\n"); |
423 | 430 | ||
424 | if (!iforce_get_id_packet(iforce, "N")) | 431 | if (!iforce_get_id_packet(iforce, "N")) |
425 | iforce->dev.ff_effects_max = iforce->edata[1]; | 432 | iforce->dev->ff_effects_max = iforce->edata[1]; |
426 | else | 433 | else |
427 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet N\n"); | 434 | printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet N\n"); |
428 | 435 | ||
429 | /* Check if the device can store more effects than the driver can really handle */ | 436 | /* Check if the device can store more effects than the driver can really handle */ |
430 | if (iforce->dev.ff_effects_max > FF_EFFECTS_MAX) { | 437 | if (iforce->dev->ff_effects_max > FF_EFFECTS_MAX) { |
431 | printk(KERN_WARNING "input??: Device can handle %d effects, but N_EFFECTS_MAX is set to %d in iforce.h\n", | 438 | printk(KERN_WARNING "input??: Device can handle %d effects, but N_EFFECTS_MAX is set to %d in iforce.h\n", |
432 | iforce->dev.ff_effects_max, FF_EFFECTS_MAX); | 439 | iforce->dev->ff_effects_max, FF_EFFECTS_MAX); |
433 | iforce->dev.ff_effects_max = FF_EFFECTS_MAX; | 440 | iforce->dev->ff_effects_max = FF_EFFECTS_MAX; |
434 | } | 441 | } |
435 | 442 | ||
436 | /* | 443 | /* |
@@ -453,29 +460,28 @@ int iforce_init_device(struct iforce *iforce) | |||
453 | */ | 460 | */ |
454 | 461 | ||
455 | for (i = 0; iforce_device[i].idvendor; i++) | 462 | for (i = 0; iforce_device[i].idvendor; i++) |
456 | if (iforce_device[i].idvendor == iforce->dev.id.vendor && | 463 | if (iforce_device[i].idvendor == input_dev->id.vendor && |
457 | iforce_device[i].idproduct == iforce->dev.id.product) | 464 | iforce_device[i].idproduct == input_dev->id.product) |
458 | break; | 465 | break; |
459 | 466 | ||
460 | iforce->type = iforce_device + i; | 467 | iforce->type = iforce_device + i; |
461 | iforce->dev.name = iforce->type->name; | 468 | input_dev->name = iforce->type->name; |
462 | 469 | ||
463 | /* | 470 | /* |
464 | * Set input device bitfields and ranges. | 471 | * Set input device bitfields and ranges. |
465 | */ | 472 | */ |
466 | 473 | ||
467 | iforce->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_FF) | BIT(EV_FF_STATUS); | 474 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_FF) | BIT(EV_FF_STATUS); |
468 | 475 | ||
469 | for (i = 0; iforce->type->btn[i] >= 0; i++) { | 476 | for (i = 0; iforce->type->btn[i] >= 0; i++) { |
470 | signed short t = iforce->type->btn[i]; | 477 | signed short t = iforce->type->btn[i]; |
471 | set_bit(t, iforce->dev.keybit); | 478 | set_bit(t, input_dev->keybit); |
472 | } | 479 | } |
473 | set_bit(BTN_DEAD, iforce->dev.keybit); | 480 | set_bit(BTN_DEAD, input_dev->keybit); |
474 | 481 | ||
475 | for (i = 0; iforce->type->abs[i] >= 0; i++) { | 482 | for (i = 0; iforce->type->abs[i] >= 0; i++) { |
476 | 483 | ||
477 | signed short t = iforce->type->abs[i]; | 484 | signed short t = iforce->type->abs[i]; |
478 | set_bit(t, iforce->dev.absbit); | ||
479 | 485 | ||
480 | switch (t) { | 486 | switch (t) { |
481 | 487 | ||
@@ -483,52 +489,42 @@ int iforce_init_device(struct iforce *iforce) | |||
483 | case ABS_Y: | 489 | case ABS_Y: |
484 | case ABS_WHEEL: | 490 | case ABS_WHEEL: |
485 | 491 | ||
486 | iforce->dev.absmax[t] = 1920; | 492 | input_set_abs_params(input_dev, t, -1920, 1920, 16, 128); |
487 | iforce->dev.absmin[t] = -1920; | 493 | set_bit(t, input_dev->ffbit); |
488 | iforce->dev.absflat[t] = 128; | ||
489 | iforce->dev.absfuzz[t] = 16; | ||
490 | |||
491 | set_bit(t, iforce->dev.ffbit); | ||
492 | break; | 494 | break; |
493 | 495 | ||
494 | case ABS_THROTTLE: | 496 | case ABS_THROTTLE: |
495 | case ABS_GAS: | 497 | case ABS_GAS: |
496 | case ABS_BRAKE: | 498 | case ABS_BRAKE: |
497 | 499 | ||
498 | iforce->dev.absmax[t] = 255; | 500 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
499 | iforce->dev.absmin[t] = 0; | ||
500 | break; | 501 | break; |
501 | 502 | ||
502 | case ABS_RUDDER: | 503 | case ABS_RUDDER: |
503 | 504 | ||
504 | iforce->dev.absmax[t] = 127; | 505 | input_set_abs_params(input_dev, t, -128, 127, 0, 0); |
505 | iforce->dev.absmin[t] = -128; | ||
506 | break; | 506 | break; |
507 | 507 | ||
508 | case ABS_HAT0X: | 508 | case ABS_HAT0X: |
509 | case ABS_HAT0Y: | 509 | case ABS_HAT0Y: |
510 | case ABS_HAT1X: | 510 | case ABS_HAT1X: |
511 | case ABS_HAT1Y: | 511 | case ABS_HAT1Y: |
512 | iforce->dev.absmax[t] = 1; | 512 | |
513 | iforce->dev.absmin[t] = -1; | 513 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
514 | break; | 514 | break; |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | for (i = 0; iforce->type->ff[i] >= 0; i++) | 518 | for (i = 0; iforce->type->ff[i] >= 0; i++) |
519 | set_bit(iforce->type->ff[i], iforce->dev.ffbit); | 519 | set_bit(iforce->type->ff[i], input_dev->ffbit); |
520 | 520 | ||
521 | /* | 521 | /* |
522 | * Register input device. | 522 | * Register input device. |
523 | */ | 523 | */ |
524 | 524 | ||
525 | input_register_device(&iforce->dev); | 525 | input_register_device(iforce->dev); |
526 | |||
527 | printk(KERN_DEBUG "iforce->dev.open = %p\n", iforce->dev.open); | ||
528 | 526 | ||
529 | printk(KERN_INFO "input: %s [%d effects, %ld bytes memory]\n", | 527 | printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open); |
530 | iforce->dev.name, iforce->dev.ff_effects_max, | ||
531 | iforce->device_memory.end); | ||
532 | 528 | ||
533 | return 0; | 529 | return 0; |
534 | } | 530 | } |
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index e5a31e55d3e2..4a2629243e19 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c | |||
@@ -139,7 +139,8 @@ printk(KERN_DEBUG "iforce-packets.c: control_playback %d %d\n", id, value); | |||
139 | static int mark_core_as_ready(struct iforce *iforce, unsigned short addr) | 139 | static int mark_core_as_ready(struct iforce *iforce, unsigned short addr) |
140 | { | 140 | { |
141 | int i; | 141 | int i; |
142 | for (i=0; i<iforce->dev.ff_effects_max; ++i) { | 142 | |
143 | for (i = 0; i < iforce->dev->ff_effects_max; ++i) { | ||
143 | if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags) && | 144 | if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags) && |
144 | (iforce->core_effects[i].mod1_chunk.start == addr || | 145 | (iforce->core_effects[i].mod1_chunk.start == addr || |
145 | iforce->core_effects[i].mod2_chunk.start == addr)) { | 146 | iforce->core_effects[i].mod2_chunk.start == addr)) { |
@@ -153,7 +154,7 @@ static int mark_core_as_ready(struct iforce *iforce, unsigned short addr) | |||
153 | 154 | ||
154 | void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, struct pt_regs *regs) | 155 | void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, struct pt_regs *regs) |
155 | { | 156 | { |
156 | struct input_dev *dev = &iforce->dev; | 157 | struct input_dev *dev = iforce->dev; |
157 | int i; | 158 | int i; |
158 | static int being_used = 0; | 159 | static int being_used = 0; |
159 | 160 | ||
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c index 11f51905cba7..64a78c515484 100644 --- a/drivers/input/joystick/iforce/iforce-serio.c +++ b/drivers/input/joystick/iforce/iforce-serio.c | |||
@@ -131,11 +131,10 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv) | |||
131 | struct iforce *iforce; | 131 | struct iforce *iforce; |
132 | int err; | 132 | int err; |
133 | 133 | ||
134 | if (!(iforce = kmalloc(sizeof(struct iforce), GFP_KERNEL))) | 134 | iforce = kzalloc(sizeof(struct iforce), GFP_KERNEL); |
135 | if (!iforce) | ||
135 | return -ENOMEM; | 136 | return -ENOMEM; |
136 | 137 | ||
137 | memset(iforce, 0, sizeof(struct iforce)); | ||
138 | |||
139 | iforce->bus = IFORCE_232; | 138 | iforce->bus = IFORCE_232; |
140 | iforce->serio = serio; | 139 | iforce->serio = serio; |
141 | 140 | ||
@@ -148,7 +147,8 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv) | |||
148 | return err; | 147 | return err; |
149 | } | 148 | } |
150 | 149 | ||
151 | if (iforce_init_device(iforce)) { | 150 | err = iforce_init_device(iforce); |
151 | if (err) { | ||
152 | serio_close(serio); | 152 | serio_close(serio); |
153 | serio_set_drvdata(serio, NULL); | 153 | serio_set_drvdata(serio, NULL); |
154 | kfree(iforce); | 154 | kfree(iforce); |
@@ -162,7 +162,7 @@ static void iforce_serio_disconnect(struct serio *serio) | |||
162 | { | 162 | { |
163 | struct iforce *iforce = serio_get_drvdata(serio); | 163 | struct iforce *iforce = serio_get_drvdata(serio); |
164 | 164 | ||
165 | input_unregister_device(&iforce->dev); | 165 | input_unregister_device(iforce->dev); |
166 | serio_close(serio); | 166 | serio_close(serio); |
167 | serio_set_drvdata(serio, NULL); | 167 | serio_set_drvdata(serio, NULL); |
168 | kfree(iforce); | 168 | kfree(iforce); |
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 58600f91eff5..64b4a3080985 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c | |||
@@ -135,28 +135,24 @@ static int iforce_usb_probe(struct usb_interface *intf, | |||
135 | struct usb_host_interface *interface; | 135 | struct usb_host_interface *interface; |
136 | struct usb_endpoint_descriptor *epirq, *epout; | 136 | struct usb_endpoint_descriptor *epirq, *epout; |
137 | struct iforce *iforce; | 137 | struct iforce *iforce; |
138 | int err = -ENOMEM; | ||
138 | 139 | ||
139 | interface = intf->cur_altsetting; | 140 | interface = intf->cur_altsetting; |
140 | 141 | ||
141 | epirq = &interface->endpoint[0].desc; | 142 | epirq = &interface->endpoint[0].desc; |
142 | epout = &interface->endpoint[1].desc; | 143 | epout = &interface->endpoint[1].desc; |
143 | 144 | ||
144 | if (!(iforce = kmalloc(sizeof(struct iforce) + 32, GFP_KERNEL))) | 145 | if (!(iforce = kzalloc(sizeof(struct iforce) + 32, GFP_KERNEL))) |
145 | goto fail; | 146 | goto fail; |
146 | 147 | ||
147 | memset(iforce, 0, sizeof(struct iforce)); | 148 | if (!(iforce->irq = usb_alloc_urb(0, GFP_KERNEL))) |
148 | |||
149 | if (!(iforce->irq = usb_alloc_urb(0, GFP_KERNEL))) { | ||
150 | goto fail; | 149 | goto fail; |
151 | } | ||
152 | 150 | ||
153 | if (!(iforce->out = usb_alloc_urb(0, GFP_KERNEL))) { | 151 | if (!(iforce->out = usb_alloc_urb(0, GFP_KERNEL))) |
154 | goto fail; | 152 | goto fail; |
155 | } | ||
156 | 153 | ||
157 | if (!(iforce->ctrl = usb_alloc_urb(0, GFP_KERNEL))) { | 154 | if (!(iforce->ctrl = usb_alloc_urb(0, GFP_KERNEL))) |
158 | goto fail; | 155 | goto fail; |
159 | } | ||
160 | 156 | ||
161 | iforce->bus = IFORCE_USB; | 157 | iforce->bus = IFORCE_USB; |
162 | iforce->usbdev = dev; | 158 | iforce->usbdev = dev; |
@@ -174,7 +170,9 @@ static int iforce_usb_probe(struct usb_interface *intf, | |||
174 | usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0), | 170 | usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0), |
175 | (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce); | 171 | (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce); |
176 | 172 | ||
177 | if (iforce_init_device(iforce)) goto fail; | 173 | err = iforce_init_device(iforce); |
174 | if (err) | ||
175 | goto fail; | ||
178 | 176 | ||
179 | usb_set_intfdata(intf, iforce); | 177 | usb_set_intfdata(intf, iforce); |
180 | return 0; | 178 | return 0; |
@@ -187,7 +185,7 @@ fail: | |||
187 | kfree(iforce); | 185 | kfree(iforce); |
188 | } | 186 | } |
189 | 187 | ||
190 | return -ENODEV; | 188 | return err; |
191 | } | 189 | } |
192 | 190 | ||
193 | /* Called by iforce_delete() */ | 191 | /* Called by iforce_delete() */ |
@@ -211,7 +209,7 @@ static void iforce_usb_disconnect(struct usb_interface *intf) | |||
211 | usb_set_intfdata(intf, NULL); | 209 | usb_set_intfdata(intf, NULL); |
212 | if (iforce) { | 210 | if (iforce) { |
213 | iforce->usbdev = NULL; | 211 | iforce->usbdev = NULL; |
214 | input_unregister_device(&iforce->dev); | 212 | input_unregister_device(iforce->dev); |
215 | 213 | ||
216 | if (!open) { | 214 | if (!open) { |
217 | iforce_delete_device(iforce); | 215 | iforce_delete_device(iforce); |
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h index bce247bc300b..146f406b8f8a 100644 --- a/drivers/input/joystick/iforce/iforce.h +++ b/drivers/input/joystick/iforce/iforce.h | |||
@@ -117,7 +117,7 @@ struct iforce_device { | |||
117 | }; | 117 | }; |
118 | 118 | ||
119 | struct iforce { | 119 | struct iforce { |
120 | struct input_dev dev; /* Input device interface */ | 120 | struct input_dev *dev; /* Input device interface */ |
121 | struct iforce_device *type; | 121 | struct iforce_device *type; |
122 | int bus; | 122 | int bus; |
123 | 123 | ||
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c index d7b3472bd686..8511ee7bb263 100644 --- a/drivers/input/joystick/interact.c +++ b/drivers/input/joystick/interact.c | |||
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL"); | |||
54 | 54 | ||
55 | struct interact { | 55 | struct interact { |
56 | struct gameport *gameport; | 56 | struct gameport *gameport; |
57 | struct input_dev dev; | 57 | struct input_dev *dev; |
58 | int bads; | 58 | int bads; |
59 | int reads; | 59 | int reads; |
60 | unsigned char type; | 60 | unsigned char type; |
@@ -130,7 +130,7 @@ static int interact_read_packet(struct gameport *gameport, int length, u32 *data | |||
130 | static void interact_poll(struct gameport *gameport) | 130 | static void interact_poll(struct gameport *gameport) |
131 | { | 131 | { |
132 | struct interact *interact = gameport_get_drvdata(gameport); | 132 | struct interact *interact = gameport_get_drvdata(gameport); |
133 | struct input_dev *dev = &interact->dev; | 133 | struct input_dev *dev = interact->dev; |
134 | u32 data[3]; | 134 | u32 data[3]; |
135 | int i; | 135 | int i; |
136 | 136 | ||
@@ -208,14 +208,20 @@ static void interact_close(struct input_dev *dev) | |||
208 | static int interact_connect(struct gameport *gameport, struct gameport_driver *drv) | 208 | static int interact_connect(struct gameport *gameport, struct gameport_driver *drv) |
209 | { | 209 | { |
210 | struct interact *interact; | 210 | struct interact *interact; |
211 | struct input_dev *input_dev; | ||
211 | __u32 data[3]; | 212 | __u32 data[3]; |
212 | int i, t; | 213 | int i, t; |
213 | int err; | 214 | int err; |
214 | 215 | ||
215 | if (!(interact = kzalloc(sizeof(struct interact), GFP_KERNEL))) | 216 | interact = kzalloc(sizeof(struct interact), GFP_KERNEL); |
216 | return -ENOMEM; | 217 | input_dev = input_allocate_device(); |
218 | if (!interact || !input_dev) { | ||
219 | err = -ENOMEM; | ||
220 | goto fail1; | ||
221 | } | ||
217 | 222 | ||
218 | interact->gameport = gameport; | 223 | interact->gameport = gameport; |
224 | interact->dev = input_dev; | ||
219 | 225 | ||
220 | gameport_set_drvdata(gameport, interact); | 226 | gameport_set_drvdata(gameport, interact); |
221 | 227 | ||
@@ -249,41 +255,40 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d | |||
249 | interact->type = i; | 255 | interact->type = i; |
250 | interact->length = interact_type[i].length; | 256 | interact->length = interact_type[i].length; |
251 | 257 | ||
252 | interact->dev.private = interact; | 258 | input_dev->name = interact_type[i].name; |
253 | interact->dev.open = interact_open; | 259 | input_dev->phys = interact->phys; |
254 | interact->dev.close = interact_close; | 260 | input_dev->id.bustype = BUS_GAMEPORT; |
261 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT; | ||
262 | input_dev->id.product = interact_type[i].id; | ||
263 | input_dev->id.version = 0x0100; | ||
264 | input_dev->private = interact; | ||
255 | 265 | ||
256 | interact->dev.name = interact_type[i].name; | 266 | input_dev->open = interact_open; |
257 | interact->dev.phys = interact->phys; | 267 | input_dev->close = interact_close; |
258 | interact->dev.id.bustype = BUS_GAMEPORT; | ||
259 | interact->dev.id.vendor = GAMEPORT_ID_VENDOR_INTERACT; | ||
260 | interact->dev.id.product = interact_type[i].id; | ||
261 | interact->dev.id.version = 0x0100; | ||
262 | 268 | ||
263 | interact->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 269 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
264 | 270 | ||
265 | for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { | 271 | for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { |
266 | set_bit(t, interact->dev.absbit); | 272 | set_bit(t, input_dev->absbit); |
267 | if (i < interact_type[interact->type].b8) { | 273 | if (i < interact_type[interact->type].b8) { |
268 | interact->dev.absmin[t] = 0; | 274 | input_dev->absmin[t] = 0; |
269 | interact->dev.absmax[t] = 255; | 275 | input_dev->absmax[t] = 255; |
270 | } else { | 276 | } else { |
271 | interact->dev.absmin[t] = -1; | 277 | input_dev->absmin[t] = -1; |
272 | interact->dev.absmax[t] = 1; | 278 | input_dev->absmax[t] = 1; |
273 | } | 279 | } |
274 | } | 280 | } |
275 | 281 | ||
276 | for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) | 282 | for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) |
277 | set_bit(t, interact->dev.keybit); | 283 | set_bit(t, input_dev->keybit); |
278 | 284 | ||
279 | input_register_device(&interact->dev); | 285 | input_register_device(interact->dev); |
280 | printk(KERN_INFO "input: %s on %s\n", | ||
281 | interact_type[interact->type].name, gameport->phys); | ||
282 | 286 | ||
283 | return 0; | 287 | return 0; |
284 | 288 | ||
285 | fail2: gameport_close(gameport); | 289 | fail2: gameport_close(gameport); |
286 | fail1: gameport_set_drvdata(gameport, NULL); | 290 | fail1: gameport_set_drvdata(gameport, NULL); |
291 | input_free_device(input_dev); | ||
287 | kfree(interact); | 292 | kfree(interact); |
288 | return err; | 293 | return err; |
289 | } | 294 | } |
@@ -292,7 +297,7 @@ static void interact_disconnect(struct gameport *gameport) | |||
292 | { | 297 | { |
293 | struct interact *interact = gameport_get_drvdata(gameport); | 298 | struct interact *interact = gameport_get_drvdata(gameport); |
294 | 299 | ||
295 | input_unregister_device(&interact->dev); | 300 | input_unregister_device(interact->dev); |
296 | gameport_close(gameport); | 301 | gameport_close(gameport); |
297 | gameport_set_drvdata(gameport, NULL); | 302 | gameport_set_drvdata(gameport, NULL); |
298 | kfree(interact); | 303 | kfree(interact); |
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 | ||
50 | static int magellan_buttons[] = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; | 50 | static int magellan_buttons[] = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; |
51 | static int magellan_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; | 51 | static int magellan_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; |
52 | static char *magellan_name = "LogiCad3D Magellan / SpaceMouse"; | ||
53 | 52 | ||
54 | /* | 53 | /* |
55 | * Per-Magellan data. | 54 | * Per-Magellan data. |
56 | */ | 55 | */ |
57 | 56 | ||
58 | struct magellan { | 57 | struct 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 | ||
86 | static void magellan_process_packet(struct magellan* magellan, struct pt_regs *regs) | 85 | static 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) | |||
153 | static int magellan_connect(struct serio *serio, struct serio_driver *drv) | 152 | static 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 | /* |
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 9e0353721a35..eaaad45cc750 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c | |||
@@ -113,7 +113,7 @@ static struct { | |||
113 | 113 | ||
114 | struct sw { | 114 | struct sw { |
115 | struct gameport *gameport; | 115 | struct gameport *gameport; |
116 | struct input_dev dev[4]; | 116 | struct input_dev *dev[4]; |
117 | char name[64]; | 117 | char name[64]; |
118 | char phys[4][32]; | 118 | char phys[4][32]; |
119 | int length; | 119 | int length; |
@@ -301,7 +301,7 @@ static int sw_check(__u64 t) | |||
301 | static int sw_parse(unsigned char *buf, struct sw *sw) | 301 | static int sw_parse(unsigned char *buf, struct sw *sw) |
302 | { | 302 | { |
303 | int hat, i, j; | 303 | int hat, i, j; |
304 | struct input_dev *dev = sw->dev; | 304 | struct input_dev *dev; |
305 | 305 | ||
306 | switch (sw->type) { | 306 | switch (sw->type) { |
307 | 307 | ||
@@ -310,6 +310,8 @@ static int sw_parse(unsigned char *buf, struct sw *sw) | |||
310 | if (sw_check(GB(0,64)) || (hat = (GB(6,1) << 3) | GB(60,3)) > 8) | 310 | if (sw_check(GB(0,64)) || (hat = (GB(6,1) << 3) | GB(60,3)) > 8) |
311 | return -1; | 311 | return -1; |
312 | 312 | ||
313 | dev = sw->dev[0]; | ||
314 | |||
313 | input_report_abs(dev, ABS_X, (GB( 3,3) << 7) | GB(16,7)); | 315 | input_report_abs(dev, ABS_X, (GB( 3,3) << 7) | GB(16,7)); |
314 | input_report_abs(dev, ABS_Y, (GB( 0,3) << 7) | GB(24,7)); | 316 | input_report_abs(dev, ABS_Y, (GB( 0,3) << 7) | GB(24,7)); |
315 | input_report_abs(dev, ABS_RZ, (GB(35,2) << 7) | GB(40,7)); | 317 | input_report_abs(dev, ABS_RZ, (GB(35,2) << 7) | GB(40,7)); |
@@ -335,13 +337,13 @@ static int sw_parse(unsigned char *buf, struct sw *sw) | |||
335 | if (sw_parity(GB(i*15,15))) | 337 | if (sw_parity(GB(i*15,15))) |
336 | return -1; | 338 | return -1; |
337 | 339 | ||
338 | input_report_abs(dev + i, ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); | 340 | input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); |
339 | input_report_abs(dev + i, ABS_Y, GB(i*15+0,1) - GB(i*15+1,1)); | 341 | input_report_abs(sw->dev[i], ABS_Y, GB(i*15+0,1) - GB(i*15+1,1)); |
340 | 342 | ||
341 | for (j = 0; j < 10; j++) | 343 | for (j = 0; j < 10; j++) |
342 | input_report_key(dev + i, sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1)); | 344 | input_report_key(sw->dev[i], sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1)); |
343 | 345 | ||
344 | input_sync(dev + i); | 346 | input_sync(sw->dev[i]); |
345 | } | 347 | } |
346 | 348 | ||
347 | return 0; | 349 | return 0; |
@@ -352,6 +354,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) | |||
352 | if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8) | 354 | if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8) |
353 | return -1; | 355 | return -1; |
354 | 356 | ||
357 | dev = sw->dev[0]; | ||
355 | input_report_abs(dev, ABS_X, GB( 9,10)); | 358 | input_report_abs(dev, ABS_X, GB( 9,10)); |
356 | input_report_abs(dev, ABS_Y, GB(19,10)); | 359 | input_report_abs(dev, ABS_Y, GB(19,10)); |
357 | input_report_abs(dev, ABS_RZ, GB(36, 6)); | 360 | input_report_abs(dev, ABS_RZ, GB(36, 6)); |
@@ -372,6 +375,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) | |||
372 | if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8) | 375 | if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8) |
373 | return -1; | 376 | return -1; |
374 | 377 | ||
378 | dev = sw->dev[0]; | ||
375 | input_report_abs(dev, ABS_X, GB( 0,10)); | 379 | input_report_abs(dev, ABS_X, GB( 0,10)); |
376 | input_report_abs(dev, ABS_Y, GB(16,10)); | 380 | input_report_abs(dev, ABS_Y, GB(16,10)); |
377 | input_report_abs(dev, ABS_THROTTLE, GB(32, 6)); | 381 | input_report_abs(dev, ABS_THROTTLE, GB(32, 6)); |
@@ -396,6 +400,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) | |||
396 | if (!sw_parity(GB(0,33))) | 400 | if (!sw_parity(GB(0,33))) |
397 | return -1; | 401 | return -1; |
398 | 402 | ||
403 | dev = sw->dev[0]; | ||
399 | input_report_abs(dev, ABS_RX, GB( 0,10)); | 404 | input_report_abs(dev, ABS_RX, GB( 0,10)); |
400 | input_report_abs(dev, ABS_RUDDER, GB(10, 6)); | 405 | input_report_abs(dev, ABS_RUDDER, GB(10, 6)); |
401 | input_report_abs(dev, ABS_THROTTLE, GB(16, 6)); | 406 | input_report_abs(dev, ABS_THROTTLE, GB(16, 6)); |
@@ -581,6 +586,7 @@ static int sw_guess_mode(unsigned char *buf, int len) | |||
581 | static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | 586 | static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) |
582 | { | 587 | { |
583 | struct sw *sw; | 588 | struct sw *sw; |
589 | struct input_dev *input_dev; | ||
584 | int i, j, k, l; | 590 | int i, j, k, l; |
585 | int err; | 591 | int err; |
586 | unsigned char *buf = NULL; /* [SW_LENGTH] */ | 592 | unsigned char *buf = NULL; /* [SW_LENGTH] */ |
@@ -729,42 +735,50 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
729 | sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); | 735 | sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); |
730 | sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); | 736 | sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); |
731 | 737 | ||
732 | sw->dev[i].private = sw; | 738 | input_dev = input_allocate_device(); |
739 | if (!input_dev) { | ||
740 | err = -ENOMEM; | ||
741 | goto fail3; | ||
742 | } | ||
733 | 743 | ||
734 | sw->dev[i].open = sw_open; | 744 | input_dev->name = sw->name; |
735 | sw->dev[i].close = sw_close; | 745 | input_dev->phys = sw->phys[i]; |
746 | input_dev->id.bustype = BUS_GAMEPORT; | ||
747 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT; | ||
748 | input_dev->id.product = sw->type; | ||
749 | input_dev->id.version = 0x0100; | ||
750 | input_dev->cdev.dev = &gameport->dev; | ||
751 | input_dev->private = sw; | ||
736 | 752 | ||
737 | sw->dev[i].name = sw->name; | 753 | input_dev->open = sw_open; |
738 | sw->dev[i].phys = sw->phys[i]; | 754 | input_dev->close = sw_close; |
739 | sw->dev[i].id.bustype = BUS_GAMEPORT; | ||
740 | sw->dev[i].id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT; | ||
741 | sw->dev[i].id.product = sw->type; | ||
742 | sw->dev[i].id.version = 0x0100; | ||
743 | 755 | ||
744 | sw->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 756 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
745 | 757 | ||
746 | for (j = 0; (bits = sw_bit[sw->type][j]); j++) { | 758 | for (j = 0; (bits = sw_bit[sw->type][j]); j++) { |
747 | code = sw_abs[sw->type][j]; | 759 | code = sw_abs[sw->type][j]; |
748 | set_bit(code, sw->dev[i].absbit); | 760 | set_bit(code, input_dev->absbit); |
749 | sw->dev[i].absmax[code] = (1 << bits) - 1; | 761 | input_dev->absmax[code] = (1 << bits) - 1; |
750 | sw->dev[i].absmin[code] = (bits == 1) ? -1 : 0; | 762 | input_dev->absmin[code] = (bits == 1) ? -1 : 0; |
751 | sw->dev[i].absfuzz[code] = ((bits >> 1) >= 2) ? (1 << ((bits >> 1) - 2)) : 0; | 763 | input_dev->absfuzz[code] = ((bits >> 1) >= 2) ? (1 << ((bits >> 1) - 2)) : 0; |
752 | if (code != ABS_THROTTLE) | 764 | if (code != ABS_THROTTLE) |
753 | sw->dev[i].absflat[code] = (bits >= 5) ? (1 << (bits - 5)) : 0; | 765 | input_dev->absflat[code] = (bits >= 5) ? (1 << (bits - 5)) : 0; |
754 | } | 766 | } |
755 | 767 | ||
756 | for (j = 0; (code = sw_btn[sw->type][j]); j++) | 768 | for (j = 0; (code = sw_btn[sw->type][j]); j++) |
757 | set_bit(code, sw->dev[i].keybit); | 769 | set_bit(code, input_dev->keybit); |
770 | |||
771 | dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); | ||
758 | 772 | ||
759 | input_register_device(sw->dev + i); | 773 | input_register_device(sw->dev[i]); |
760 | printk(KERN_INFO "input: %s%s on %s [%d-bit id %d data %d]\n", | ||
761 | sw->name, comment, gameport->phys, m, l, k); | ||
762 | } | 774 | } |
763 | 775 | ||
764 | return 0; | 776 | return 0; |
765 | 777 | ||
766 | fail2: gameport_close(gameport); | 778 | fail3: while (--i >= 0) |
767 | fail1: gameport_set_drvdata(gameport, NULL); | 779 | input_unregister_device(sw->dev[i]); |
780 | fail2: gameport_close(gameport); | ||
781 | fail1: gameport_set_drvdata(gameport, NULL); | ||
768 | kfree(sw); | 782 | kfree(sw); |
769 | kfree(buf); | 783 | kfree(buf); |
770 | kfree(idbuf); | 784 | kfree(idbuf); |
@@ -777,7 +791,7 @@ static void sw_disconnect(struct gameport *gameport) | |||
777 | int i; | 791 | int i; |
778 | 792 | ||
779 | for (i = 0; i < sw->number; i++) | 793 | for (i = 0; i < sw->number; i++) |
780 | input_unregister_device(sw->dev + i); | 794 | input_unregister_device(sw->dev[i]); |
781 | gameport_close(gameport); | 795 | gameport_close(gameport); |
782 | gameport_set_drvdata(gameport, NULL); | 796 | gameport_set_drvdata(gameport, NULL); |
783 | kfree(sw); | 797 | kfree(sw); |
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index a436f2220856..d6f8db8ec3fd 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c | |||
@@ -70,8 +70,7 @@ static char *spaceball_names[] = { | |||
70 | */ | 70 | */ |
71 | 71 | ||
72 | struct spaceball { | 72 | struct spaceball { |
73 | struct input_dev dev; | 73 | struct input_dev *dev; |
74 | struct serio *serio; | ||
75 | int idx; | 74 | int idx; |
76 | int escape; | 75 | int escape; |
77 | unsigned char data[SPACEBALL_MAX_LENGTH]; | 76 | unsigned char data[SPACEBALL_MAX_LENGTH]; |
@@ -85,7 +84,7 @@ struct spaceball { | |||
85 | 84 | ||
86 | static void spaceball_process_packet(struct spaceball* spaceball, struct pt_regs *regs) | 85 | static void spaceball_process_packet(struct spaceball* spaceball, struct pt_regs *regs) |
87 | { | 86 | { |
88 | struct input_dev *dev = &spaceball->dev; | 87 | struct input_dev *dev = spaceball->dev; |
89 | unsigned char *data = spaceball->data; | 88 | unsigned char *data = spaceball->data; |
90 | int i; | 89 | int i; |
91 | 90 | ||
@@ -193,9 +192,9 @@ static void spaceball_disconnect(struct serio *serio) | |||
193 | { | 192 | { |
194 | struct spaceball* spaceball = serio_get_drvdata(serio); | 193 | struct spaceball* spaceball = serio_get_drvdata(serio); |
195 | 194 | ||
196 | input_unregister_device(&spaceball->dev); | ||
197 | serio_close(serio); | 195 | serio_close(serio); |
198 | serio_set_drvdata(serio, NULL); | 196 | serio_set_drvdata(serio, NULL); |
197 | input_unregister_device(spaceball->dev); | ||
199 | kfree(spaceball); | 198 | kfree(spaceball); |
200 | } | 199 | } |
201 | 200 | ||
@@ -208,69 +207,62 @@ static void spaceball_disconnect(struct serio *serio) | |||
208 | static int spaceball_connect(struct serio *serio, struct serio_driver *drv) | 207 | static int spaceball_connect(struct serio *serio, struct serio_driver *drv) |
209 | { | 208 | { |
210 | struct spaceball *spaceball; | 209 | struct spaceball *spaceball; |
211 | int i, t, id; | 210 | struct input_dev *input_dev; |
212 | int err; | 211 | int err = -ENOMEM; |
212 | int i, id; | ||
213 | 213 | ||
214 | if ((id = serio->id.id) > SPACEBALL_MAX_ID) | 214 | if ((id = serio->id.id) > SPACEBALL_MAX_ID) |
215 | return -ENODEV; | 215 | return -ENODEV; |
216 | 216 | ||
217 | if (!(spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL))) | 217 | spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL); |
218 | return - ENOMEM; | 218 | input_dev = input_allocate_device(); |
219 | if (!spaceball || !input_dev) | ||
220 | goto fail; | ||
219 | 221 | ||
220 | memset(spaceball, 0, sizeof(struct spaceball)); | 222 | spaceball->dev = input_dev; |
223 | sprintf(spaceball->phys, "%s/input0", serio->phys); | ||
224 | |||
225 | input_dev->name = spaceball_names[id]; | ||
226 | input_dev->phys = spaceball->phys; | ||
227 | input_dev->id.bustype = BUS_RS232; | ||
228 | input_dev->id.vendor = SERIO_SPACEBALL; | ||
229 | input_dev->id.product = id; | ||
230 | input_dev->id.version = 0x0100; | ||
231 | input_dev->cdev.dev = &serio->dev; | ||
232 | input_dev->private = spaceball; | ||
221 | 233 | ||
222 | spaceball->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 234 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
223 | 235 | ||
224 | switch (id) { | 236 | switch (id) { |
225 | case SPACEBALL_4000FLX: | 237 | case SPACEBALL_4000FLX: |
226 | case SPACEBALL_4000FLX_L: | 238 | case SPACEBALL_4000FLX_L: |
227 | spaceball->dev.keybit[LONG(BTN_0)] |= BIT(BTN_9); | 239 | input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_9); |
228 | spaceball->dev.keybit[LONG(BTN_A)] |= BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_MODE); | 240 | input_dev->keybit[LONG(BTN_A)] |= BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_MODE); |
229 | default: | 241 | default: |
230 | spaceball->dev.keybit[LONG(BTN_0)] |= BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | 242 | input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) |
231 | | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7) | BIT(BTN_8); | 243 | | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7) | BIT(BTN_8); |
232 | case SPACEBALL_3003C: | 244 | case SPACEBALL_3003C: |
233 | spaceball->dev.keybit[LONG(BTN_0)] |= BIT(BTN_1) | BIT(BTN_8); | 245 | input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_1) | BIT(BTN_8); |
234 | } | 246 | } |
235 | 247 | ||
236 | for (i = 0; i < 6; i++) { | 248 | for (i = 0; i < 3; i++) { |
237 | t = spaceball_axes[i]; | 249 | input_set_abs_params(input_dev, ABS_X + i, -8000, 8000, 8, 40); |
238 | set_bit(t, spaceball->dev.absbit); | 250 | input_set_abs_params(input_dev, ABS_RX + i, -1600, 1600, 2, 8); |
239 | spaceball->dev.absmin[t] = i < 3 ? -8000 : -1600; | ||
240 | spaceball->dev.absmax[t] = i < 3 ? 8000 : 1600; | ||
241 | spaceball->dev.absflat[t] = i < 3 ? 40 : 8; | ||
242 | spaceball->dev.absfuzz[t] = i < 3 ? 8 : 2; | ||
243 | } | 251 | } |
244 | 252 | ||
245 | spaceball->serio = serio; | ||
246 | spaceball->dev.private = spaceball; | ||
247 | |||
248 | sprintf(spaceball->phys, "%s/input0", serio->phys); | ||
249 | |||
250 | init_input_dev(&spaceball->dev); | ||
251 | spaceball->dev.name = spaceball_names[id]; | ||
252 | spaceball->dev.phys = spaceball->phys; | ||
253 | spaceball->dev.id.bustype = BUS_RS232; | ||
254 | spaceball->dev.id.vendor = SERIO_SPACEBALL; | ||
255 | spaceball->dev.id.product = id; | ||
256 | spaceball->dev.id.version = 0x0100; | ||
257 | spaceball->dev.dev = &serio->dev; | ||
258 | |||
259 | serio_set_drvdata(serio, spaceball); | 253 | serio_set_drvdata(serio, spaceball); |
260 | 254 | ||
261 | err = serio_open(serio, drv); | 255 | err = serio_open(serio, drv); |
262 | if (err) { | 256 | if (err) |
263 | serio_set_drvdata(serio, NULL); | 257 | goto fail; |
264 | kfree(spaceball); | ||
265 | return err; | ||
266 | } | ||
267 | |||
268 | input_register_device(&spaceball->dev); | ||
269 | |||
270 | printk(KERN_INFO "input: %s on serio%s\n", | ||
271 | spaceball_names[id], serio->phys); | ||
272 | 258 | ||
259 | input_register_device(spaceball->dev); | ||
273 | return 0; | 260 | return 0; |
261 | |||
262 | fail: serio_set_drvdata(serio, NULL); | ||
263 | input_free_device(input_dev); | ||
264 | kfree(spaceball); | ||
265 | return err; | ||
274 | } | 266 | } |
275 | 267 | ||
276 | /* | 268 | /* |
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index 01fd2e4791ae..7c123a01c58e 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c | |||
@@ -52,15 +52,13 @@ MODULE_LICENSE("GPL"); | |||
52 | 52 | ||
53 | static int spaceorb_buttons[] = { BTN_TL, BTN_TR, BTN_Y, BTN_X, BTN_B, BTN_A }; | 53 | static int spaceorb_buttons[] = { BTN_TL, BTN_TR, BTN_Y, BTN_X, BTN_B, BTN_A }; |
54 | static int spaceorb_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; | 54 | static int spaceorb_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; |
55 | static char *spaceorb_name = "SpaceTec SpaceOrb 360 / Avenger"; | ||
56 | 55 | ||
57 | /* | 56 | /* |
58 | * Per-Orb data. | 57 | * Per-Orb data. |
59 | */ | 58 | */ |
60 | 59 | ||
61 | struct spaceorb { | 60 | struct spaceorb { |
62 | struct input_dev dev; | 61 | struct input_dev *dev; |
63 | struct serio *serio; | ||
64 | int idx; | 62 | int idx; |
65 | unsigned char data[SPACEORB_MAX_LENGTH]; | 63 | unsigned char data[SPACEORB_MAX_LENGTH]; |
66 | char phys[32]; | 64 | char phys[32]; |
@@ -78,7 +76,7 @@ static unsigned char *spaceorb_errors[] = { "EEPROM storing 0 failed", "Receive | |||
78 | 76 | ||
79 | static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *regs) | 77 | static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *regs) |
80 | { | 78 | { |
81 | struct input_dev *dev = &spaceorb->dev; | 79 | struct input_dev *dev = spaceorb->dev; |
82 | unsigned char *data = spaceorb->data; | 80 | unsigned char *data = spaceorb->data; |
83 | unsigned char c = 0; | 81 | unsigned char c = 0; |
84 | int axes[6]; | 82 | int axes[6]; |
@@ -95,8 +93,8 @@ static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *r | |||
95 | case 'R': /* Reset packet */ | 93 | case 'R': /* Reset packet */ |
96 | spaceorb->data[spaceorb->idx - 1] = 0; | 94 | spaceorb->data[spaceorb->idx - 1] = 0; |
97 | for (i = 1; i < spaceorb->idx && spaceorb->data[i] == ' '; i++); | 95 | for (i = 1; i < spaceorb->idx && spaceorb->data[i] == ' '; i++); |
98 | printk(KERN_INFO "input: %s [%s] on %s\n", | 96 | printk(KERN_INFO "input: %s [%s] is %s\n", |
99 | spaceorb_name, spaceorb->data + i, spaceorb->serio->phys); | 97 | dev->name, spaceorb->data + i, spaceorb->phys); |
100 | break; | 98 | break; |
101 | 99 | ||
102 | case 'D': /* Ball + button data */ | 100 | case 'D': /* Ball + button data */ |
@@ -123,7 +121,7 @@ static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *r | |||
123 | 121 | ||
124 | case 'E': /* Error packet */ | 122 | case 'E': /* Error packet */ |
125 | if (spaceorb->idx != 4) return; | 123 | if (spaceorb->idx != 4) return; |
126 | printk(KERN_ERR "joy-spaceorb: Device error. [ "); | 124 | printk(KERN_ERR "spaceorb: Device error. [ "); |
127 | for (i = 0; i < 7; i++) if (data[1] & (1 << i)) printk("%s ", spaceorb_errors[i]); | 125 | for (i = 0; i < 7; i++) if (data[1] & (1 << i)) printk("%s ", spaceorb_errors[i]); |
128 | printk("]\n"); | 126 | printk("]\n"); |
129 | break; | 127 | break; |
@@ -154,9 +152,9 @@ static void spaceorb_disconnect(struct serio *serio) | |||
154 | { | 152 | { |
155 | struct spaceorb* spaceorb = serio_get_drvdata(serio); | 153 | struct spaceorb* spaceorb = serio_get_drvdata(serio); |
156 | 154 | ||
157 | input_unregister_device(&spaceorb->dev); | ||
158 | serio_close(serio); | 155 | serio_close(serio); |
159 | serio_set_drvdata(serio, NULL); | 156 | serio_set_drvdata(serio, NULL); |
157 | input_unregister_device(spaceorb->dev); | ||
160 | kfree(spaceorb); | 158 | kfree(spaceorb); |
161 | } | 159 | } |
162 | 160 | ||
@@ -169,52 +167,48 @@ static void spaceorb_disconnect(struct serio *serio) | |||
169 | static int spaceorb_connect(struct serio *serio, struct serio_driver *drv) | 167 | static int spaceorb_connect(struct serio *serio, struct serio_driver *drv) |
170 | { | 168 | { |
171 | struct spaceorb *spaceorb; | 169 | struct spaceorb *spaceorb; |
172 | int i, t; | 170 | struct input_dev *input_dev; |
173 | int err; | 171 | int err = -ENOMEM; |
174 | 172 | int i; | |
175 | if (!(spaceorb = kmalloc(sizeof(struct spaceorb), GFP_KERNEL))) | ||
176 | return -ENOMEM; | ||
177 | |||
178 | memset(spaceorb, 0, sizeof(struct spaceorb)); | ||
179 | 173 | ||
180 | spaceorb->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 174 | spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL); |
175 | input_dev = input_allocate_device(); | ||
176 | if (!spaceorb || !input_dev) | ||
177 | goto fail; | ||
181 | 178 | ||
182 | for (i = 0; i < 6; i++) | 179 | spaceorb->dev = input_dev; |
183 | set_bit(spaceorb_buttons[i], spaceorb->dev.keybit); | 180 | sprintf(spaceorb->phys, "%s/input0", serio->phys); |
184 | 181 | ||
185 | for (i = 0; i < 6; i++) { | 182 | input_dev->name = "SpaceTec SpaceOrb 360 / Avenger"; |
186 | t = spaceorb_axes[i]; | 183 | input_dev->phys = spaceorb->phys; |
187 | set_bit(t, spaceorb->dev.absbit); | 184 | input_dev->id.bustype = BUS_RS232; |
188 | spaceorb->dev.absmin[t] = -508; | 185 | input_dev->id.vendor = SERIO_SPACEORB; |
189 | spaceorb->dev.absmax[t] = 508; | 186 | input_dev->id.product = 0x0001; |
190 | } | 187 | input_dev->id.version = 0x0100; |
188 | input_dev->cdev.dev = &serio->dev; | ||
189 | input_dev->private = spaceorb; | ||
191 | 190 | ||
192 | spaceorb->serio = serio; | 191 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
193 | spaceorb->dev.private = spaceorb; | ||
194 | 192 | ||
195 | sprintf(spaceorb->phys, "%s/input0", serio->phys); | 193 | for (i = 0; i < 6; i++) |
194 | set_bit(spaceorb_buttons[i], input_dev->keybit); | ||
196 | 195 | ||
197 | init_input_dev(&spaceorb->dev); | 196 | for (i = 0; i < 6; i++) |
198 | spaceorb->dev.name = spaceorb_name; | 197 | input_set_abs_params(input_dev, spaceorb_axes[i], -508, 508, 0, 0); |
199 | spaceorb->dev.phys = spaceorb->phys; | ||
200 | spaceorb->dev.id.bustype = BUS_RS232; | ||
201 | spaceorb->dev.id.vendor = SERIO_SPACEORB; | ||
202 | spaceorb->dev.id.product = 0x0001; | ||
203 | spaceorb->dev.id.version = 0x0100; | ||
204 | spaceorb->dev.dev = &serio->dev; | ||
205 | 198 | ||
206 | serio_set_drvdata(serio, spaceorb); | 199 | serio_set_drvdata(serio, spaceorb); |
207 | 200 | ||
208 | err = serio_open(serio, drv); | 201 | err = serio_open(serio, drv); |
209 | if (err) { | 202 | if (err) |
210 | serio_set_drvdata(serio, NULL); | 203 | goto fail; |
211 | kfree(spaceorb); | ||
212 | return err; | ||
213 | } | ||
214 | |||
215 | input_register_device(&spaceorb->dev); | ||
216 | 204 | ||
205 | input_register_device(spaceorb->dev); | ||
217 | return 0; | 206 | return 0; |
207 | |||
208 | fail: serio_set_drvdata(serio, NULL); | ||
209 | input_free_device(input_dev); | ||
210 | kfree(spaceorb); | ||
211 | return err; | ||
218 | } | 212 | } |
219 | 213 | ||
220 | /* | 214 | /* |
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index 6f6e6753d590..0a9ed1d30636 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c | |||
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL"); | |||
48 | 48 | ||
49 | #define STINGER_MAX_LENGTH 8 | 49 | #define STINGER_MAX_LENGTH 8 |
50 | 50 | ||
51 | static char *stinger_name = "Gravis Stinger"; | ||
52 | |||
53 | /* | 51 | /* |
54 | * Per-Stinger data. | 52 | * Per-Stinger data. |
55 | */ | 53 | */ |
56 | 54 | ||
57 | struct stinger { | 55 | struct stinger { |
58 | struct input_dev dev; | 56 | struct input_dev *dev; |
59 | int idx; | 57 | int idx; |
60 | unsigned char data[STINGER_MAX_LENGTH]; | 58 | unsigned char data[STINGER_MAX_LENGTH]; |
61 | char phys[32]; | 59 | char phys[32]; |
@@ -68,7 +66,7 @@ struct stinger { | |||
68 | 66 | ||
69 | static void stinger_process_packet(struct stinger *stinger, struct pt_regs *regs) | 67 | static void stinger_process_packet(struct stinger *stinger, struct pt_regs *regs) |
70 | { | 68 | { |
71 | struct input_dev *dev = &stinger->dev; | 69 | struct input_dev *dev = stinger->dev; |
72 | unsigned char *data = stinger->data; | 70 | unsigned char *data = stinger->data; |
73 | 71 | ||
74 | if (!stinger->idx) return; | 72 | if (!stinger->idx) return; |
@@ -126,9 +124,9 @@ static void stinger_disconnect(struct serio *serio) | |||
126 | { | 124 | { |
127 | struct stinger *stinger = serio_get_drvdata(serio); | 125 | struct stinger *stinger = serio_get_drvdata(serio); |
128 | 126 | ||
129 | input_unregister_device(&stinger->dev); | ||
130 | serio_close(serio); | 127 | serio_close(serio); |
131 | serio_set_drvdata(serio, NULL); | 128 | serio_set_drvdata(serio, NULL); |
129 | input_unregister_device(stinger->dev); | ||
132 | kfree(stinger); | 130 | kfree(stinger); |
133 | } | 131 | } |
134 | 132 | ||
@@ -141,53 +139,46 @@ static void stinger_disconnect(struct serio *serio) | |||
141 | static int stinger_connect(struct serio *serio, struct serio_driver *drv) | 139 | static int stinger_connect(struct serio *serio, struct serio_driver *drv) |
142 | { | 140 | { |
143 | struct stinger *stinger; | 141 | struct stinger *stinger; |
144 | int i; | 142 | struct input_dev *input_dev; |
145 | int err; | 143 | int err = -ENOMEM; |
146 | |||
147 | if (!(stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL))) | ||
148 | return -ENOMEM; | ||
149 | |||
150 | memset(stinger, 0, sizeof(struct stinger)); | ||
151 | 144 | ||
152 | stinger->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 145 | stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); |
153 | stinger->dev.keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | \ | 146 | input_dev = input_allocate_device(); |
154 | BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) | \ | 147 | if (!stinger || !input_dev) |
155 | BIT(BTN_START) | BIT(BTN_SELECT); | 148 | goto fail; |
156 | stinger->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
157 | 149 | ||
150 | stinger->dev = input_dev; | ||
158 | sprintf(stinger->phys, "%s/serio0", serio->phys); | 151 | sprintf(stinger->phys, "%s/serio0", serio->phys); |
159 | 152 | ||
160 | init_input_dev(&stinger->dev); | 153 | input_dev->name = "Gravis Stinger"; |
161 | stinger->dev.name = stinger_name; | 154 | input_dev->phys = stinger->phys; |
162 | stinger->dev.phys = stinger->phys; | 155 | input_dev->id.bustype = BUS_RS232; |
163 | stinger->dev.id.bustype = BUS_RS232; | 156 | input_dev->id.vendor = SERIO_STINGER; |
164 | stinger->dev.id.vendor = SERIO_STINGER; | 157 | input_dev->id.product = 0x0001; |
165 | stinger->dev.id.product = 0x0001; | 158 | input_dev->id.version = 0x0100; |
166 | stinger->dev.id.version = 0x0100; | 159 | input_dev->cdev.dev = &serio->dev; |
167 | stinger->dev.dev = &serio->dev; | 160 | input_dev->private = stinger; |
168 | 161 | ||
169 | for (i = 0; i < 2; i++) { | 162 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
170 | stinger->dev.absmax[ABS_X+i] = 64; | 163 | input_dev->keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | |
171 | stinger->dev.absmin[ABS_X+i] = -64; | 164 | BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) | |
172 | stinger->dev.absflat[ABS_X+i] = 4; | 165 | BIT(BTN_START) | BIT(BTN_SELECT); |
173 | } | 166 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 4); |
174 | 167 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 4); | |
175 | stinger->dev.private = stinger; | ||
176 | 168 | ||
177 | serio_set_drvdata(serio, stinger); | 169 | serio_set_drvdata(serio, stinger); |
178 | 170 | ||
179 | err = serio_open(serio, drv); | 171 | err = serio_open(serio, drv); |
180 | if (err) { | 172 | if (err) |
181 | serio_set_drvdata(serio, NULL); | 173 | goto fail; |
182 | kfree(stinger); | ||
183 | return err; | ||
184 | } | ||
185 | |||
186 | input_register_device(&stinger->dev); | ||
187 | |||
188 | printk(KERN_INFO "input: %s on %s\n", stinger_name, serio->phys); | ||
189 | 174 | ||
175 | input_register_device(stinger->dev); | ||
190 | return 0; | 176 | return 0; |
177 | |||
178 | fail: serio_set_drvdata(serio, NULL); | ||
179 | input_free_device(input_dev); | ||
180 | kfree(stinger); | ||
181 | return err; | ||
191 | } | 182 | } |
192 | 183 | ||
193 | /* | 184 | /* |
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index 7431efc4330e..3a7d1bb46472 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c | |||
@@ -63,37 +63,70 @@ MODULE_LICENSE("GPL"); | |||
63 | #define TMDC_ABS_HAT 4 | 63 | #define TMDC_ABS_HAT 4 |
64 | #define TMDC_BTN 16 | 64 | #define TMDC_BTN 16 |
65 | 65 | ||
66 | static unsigned char tmdc_byte_a[16] = { 0, 1, 3, 4, 6, 7 }; | 66 | static const unsigned char tmdc_byte_a[16] = { 0, 1, 3, 4, 6, 7 }; |
67 | static unsigned char tmdc_byte_d[16] = { 2, 5, 8, 9 }; | 67 | static const unsigned char tmdc_byte_d[16] = { 2, 5, 8, 9 }; |
68 | 68 | ||
69 | static signed char tmdc_abs[TMDC_ABS] = | 69 | static const signed char tmdc_abs[TMDC_ABS] = |
70 | { ABS_X, ABS_Y, ABS_RUDDER, ABS_THROTTLE, ABS_RX, ABS_RY, ABS_RZ }; | 70 | { ABS_X, ABS_Y, ABS_RUDDER, ABS_THROTTLE, ABS_RX, ABS_RY, ABS_RZ }; |
71 | static signed char tmdc_abs_hat[TMDC_ABS_HAT] = | 71 | static const signed char tmdc_abs_hat[TMDC_ABS_HAT] = |
72 | { ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y }; | 72 | { ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y }; |
73 | static signed char tmdc_abs_at[TMDC_ABS] = | 73 | static const signed char tmdc_abs_at[TMDC_ABS] = |
74 | { ABS_X, ABS_Y, ABS_RUDDER, -1, ABS_THROTTLE }; | 74 | { ABS_X, ABS_Y, ABS_RUDDER, -1, ABS_THROTTLE }; |
75 | static signed char tmdc_abs_fm[TMDC_ABS] = | 75 | static const signed char tmdc_abs_fm[TMDC_ABS] = |
76 | { ABS_RX, ABS_RY, ABS_X, ABS_Y }; | 76 | { ABS_RX, ABS_RY, ABS_X, ABS_Y }; |
77 | 77 | ||
78 | static short tmdc_btn_pad[TMDC_BTN] = | 78 | static const short tmdc_btn_pad[TMDC_BTN] = |
79 | { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR }; | 79 | { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR }; |
80 | static short tmdc_btn_joy[TMDC_BTN] = | 80 | static const short tmdc_btn_joy[TMDC_BTN] = |
81 | { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE, | 81 | { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE, |
82 | BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; | 82 | BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; |
83 | static short tmdc_btn_fm[TMDC_BTN] = | 83 | static const short tmdc_btn_fm[TMDC_BTN] = |
84 | { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 }; | 84 | { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 }; |
85 | static short tmdc_btn_at[TMDC_BTN] = | 85 | static const short tmdc_btn_at[TMDC_BTN] = |
86 | { BTN_TRIGGER, BTN_THUMB2, BTN_PINKIE, BTN_THUMB, BTN_BASE6, BTN_BASE5, BTN_BASE4, | 86 | { BTN_TRIGGER, BTN_THUMB2, BTN_PINKIE, BTN_THUMB, BTN_BASE6, BTN_BASE5, BTN_BASE4, |
87 | BTN_BASE3, BTN_BASE2, BTN_BASE }; | 87 | BTN_BASE3, BTN_BASE2, BTN_BASE }; |
88 | 88 | ||
89 | static struct { | 89 | static const struct { |
90 | int x; | 90 | int x; |
91 | int y; | 91 | int y; |
92 | } tmdc_hat_to_axis[] = {{ 0, 0}, { 1, 0}, { 0,-1}, {-1, 0}, { 0, 1}}; | 92 | } tmdc_hat_to_axis[] = {{ 0, 0}, { 1, 0}, { 0,-1}, {-1, 0}, { 0, 1}}; |
93 | 93 | ||
94 | static const struct tmdc_model { | ||
95 | unsigned char id; | ||
96 | const char *name; | ||
97 | char abs; | ||
98 | char hats; | ||
99 | char btnc[4]; | ||
100 | char btno[4]; | ||
101 | const signed char *axes; | ||
102 | const short *buttons; | ||
103 | } tmdc_models[] = { | ||
104 | { 1, "ThrustMaster Millenium 3D Inceptor", 6, 2, { 4, 2 }, { 4, 6 }, tmdc_abs, tmdc_btn_joy }, | ||
105 | { 3, "ThrustMaster Rage 3D Gamepad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad }, | ||
106 | { 4, "ThrustMaster Attack Throttle", 5, 2, { 4, 6 }, { 4, 2 }, tmdc_abs_at, tmdc_btn_at }, | ||
107 | { 8, "ThrustMaster FragMaster", 4, 0, { 8, 2 }, { 0, 0 }, tmdc_abs_fm, tmdc_btn_fm }, | ||
108 | { 163, "Thrustmaster Fusion GamePad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad }, | ||
109 | { 0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy } | ||
110 | }; | ||
111 | |||
112 | |||
113 | struct tmdc_port { | ||
114 | struct input_dev *dev; | ||
115 | char name[64]; | ||
116 | char phys[32]; | ||
117 | int mode; | ||
118 | const signed char *abs; | ||
119 | const short *btn; | ||
120 | unsigned char absc; | ||
121 | unsigned char btnc[4]; | ||
122 | unsigned char btno[4]; | ||
123 | }; | ||
124 | |||
94 | struct tmdc { | 125 | struct tmdc { |
95 | struct gameport *gameport; | 126 | struct gameport *gameport; |
96 | struct input_dev dev[2]; | 127 | struct tmdc_port *port[2]; |
128 | #if 0 | ||
129 | struct input_dev *dev[2]; | ||
97 | char name[2][64]; | 130 | char name[2][64]; |
98 | char phys[2][32]; | 131 | char phys[2][32]; |
99 | int mode[2]; | 132 | int mode[2]; |
@@ -102,6 +135,7 @@ struct tmdc { | |||
102 | unsigned char absc[2]; | 135 | unsigned char absc[2]; |
103 | unsigned char btnc[2][4]; | 136 | unsigned char btnc[2][4]; |
104 | unsigned char btno[2][4]; | 137 | unsigned char btno[2][4]; |
138 | #endif | ||
105 | int reads; | 139 | int reads; |
106 | int bads; | 140 | int bads; |
107 | unsigned char exists; | 141 | unsigned char exists; |
@@ -156,6 +190,50 @@ static int tmdc_read_packet(struct gameport *gameport, unsigned char data[2][TMD | |||
156 | return (i[0] == TMDC_MAX_LENGTH) | ((i[1] == TMDC_MAX_LENGTH) << 1); | 190 | return (i[0] == TMDC_MAX_LENGTH) | ((i[1] == TMDC_MAX_LENGTH) << 1); |
157 | } | 191 | } |
158 | 192 | ||
193 | static int tmdc_parse_packet(struct tmdc_port *port, unsigned char *data) | ||
194 | { | ||
195 | int i, k, l; | ||
196 | |||
197 | if (data[TMDC_BYTE_ID] != port->mode) | ||
198 | return -1; | ||
199 | |||
200 | for (i = 0; i < port->absc; i++) { | ||
201 | if (port->abs[i] < 0) | ||
202 | return 0; | ||
203 | |||
204 | input_report_abs(port->dev, port->abs[i], data[tmdc_byte_a[i]]); | ||
205 | } | ||
206 | |||
207 | switch (port->mode) { | ||
208 | |||
209 | case TMDC_MODE_M3DI: | ||
210 | |||
211 | i = tmdc_byte_d[0]; | ||
212 | input_report_abs(port->dev, ABS_HAT0X, ((data[i] >> 3) & 1) - ((data[i] >> 1) & 1)); | ||
213 | input_report_abs(port->dev, ABS_HAT0Y, ((data[i] >> 2) & 1) - ( data[i] & 1)); | ||
214 | break; | ||
215 | |||
216 | case TMDC_MODE_AT: | ||
217 | |||
218 | i = tmdc_byte_a[3]; | ||
219 | input_report_abs(port->dev, ABS_HAT0X, tmdc_hat_to_axis[(data[i] - 141) / 25].x); | ||
220 | input_report_abs(port->dev, ABS_HAT0Y, tmdc_hat_to_axis[(data[i] - 141) / 25].y); | ||
221 | break; | ||
222 | |||
223 | } | ||
224 | |||
225 | for (k = l = 0; k < 4; k++) { | ||
226 | for (i = 0; i < port->btnc[k]; i++) | ||
227 | input_report_key(port->dev, port->btn[i + l], | ||
228 | ((data[tmdc_byte_d[k]] >> (i + port->btno[k])) & 1)); | ||
229 | l += port->btnc[k]; | ||
230 | } | ||
231 | |||
232 | input_sync(port->dev); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | |||
159 | /* | 237 | /* |
160 | * tmdc_poll() reads and analyzes ThrustMaster joystick data. | 238 | * tmdc_poll() reads and analyzes ThrustMaster joystick data. |
161 | */ | 239 | */ |
@@ -164,57 +242,21 @@ static void tmdc_poll(struct gameport *gameport) | |||
164 | { | 242 | { |
165 | unsigned char data[2][TMDC_MAX_LENGTH]; | 243 | unsigned char data[2][TMDC_MAX_LENGTH]; |
166 | struct tmdc *tmdc = gameport_get_drvdata(gameport); | 244 | struct tmdc *tmdc = gameport_get_drvdata(gameport); |
167 | struct input_dev *dev; | ||
168 | unsigned char r, bad = 0; | 245 | unsigned char r, bad = 0; |
169 | int i, j, k, l; | 246 | int i; |
170 | 247 | ||
171 | tmdc->reads++; | 248 | tmdc->reads++; |
172 | 249 | ||
173 | if ((r = tmdc_read_packet(tmdc->gameport, data)) != tmdc->exists) | 250 | if ((r = tmdc_read_packet(tmdc->gameport, data)) != tmdc->exists) |
174 | bad = 1; | 251 | bad = 1; |
175 | else | 252 | else { |
176 | 253 | for (i = 0; i < 2; i++) { | |
177 | for (j = 0; j < 2; j++) | 254 | if (r & (1 << i) & tmdc->exists) { |
178 | if (r & (1 << j) & tmdc->exists) { | ||
179 | |||
180 | if (data[j][TMDC_BYTE_ID] != tmdc->mode[j]) { | ||
181 | bad = 1; | ||
182 | continue; | ||
183 | } | ||
184 | |||
185 | dev = tmdc->dev + j; | ||
186 | |||
187 | for (i = 0; i < tmdc->absc[j]; i++) { | ||
188 | if (tmdc->abs[j][i] < 0) continue; | ||
189 | input_report_abs(dev, tmdc->abs[j][i], data[j][tmdc_byte_a[i]]); | ||
190 | } | ||
191 | |||
192 | switch (tmdc->mode[j]) { | ||
193 | 255 | ||
194 | case TMDC_MODE_M3DI: | 256 | if (tmdc_parse_packet(tmdc->port[i], data[i])) |
195 | 257 | bad = 1; | |
196 | i = tmdc_byte_d[0]; | ||
197 | input_report_abs(dev, ABS_HAT0X, ((data[j][i] >> 3) & 1) - ((data[j][i] >> 1) & 1)); | ||
198 | input_report_abs(dev, ABS_HAT0Y, ((data[j][i] >> 2) & 1) - ( data[j][i] & 1)); | ||
199 | break; | ||
200 | |||
201 | case TMDC_MODE_AT: | ||
202 | |||
203 | i = tmdc_byte_a[3]; | ||
204 | input_report_abs(dev, ABS_HAT0X, tmdc_hat_to_axis[(data[j][i] - 141) / 25].x); | ||
205 | input_report_abs(dev, ABS_HAT0Y, tmdc_hat_to_axis[(data[j][i] - 141) / 25].y); | ||
206 | break; | ||
207 | |||
208 | } | ||
209 | |||
210 | for (k = l = 0; k < 4; k++) { | ||
211 | for (i = 0; i < tmdc->btnc[j][k]; i++) | ||
212 | input_report_key(dev, tmdc->btn[j][i + l], | ||
213 | ((data[j][tmdc_byte_d[k]] >> (i + tmdc->btno[j][k])) & 1)); | ||
214 | l += tmdc->btnc[j][k]; | ||
215 | } | 258 | } |
216 | 259 | } | |
217 | input_sync(dev); | ||
218 | } | 260 | } |
219 | 261 | ||
220 | tmdc->bads += bad; | 262 | tmdc->bads += bad; |
@@ -235,31 +277,89 @@ static void tmdc_close(struct input_dev *dev) | |||
235 | gameport_stop_polling(tmdc->gameport); | 277 | gameport_stop_polling(tmdc->gameport); |
236 | } | 278 | } |
237 | 279 | ||
280 | static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) | ||
281 | { | ||
282 | const struct tmdc_model *model; | ||
283 | struct tmdc_port *port; | ||
284 | struct input_dev *input_dev; | ||
285 | int i, j, b = 0; | ||
286 | |||
287 | tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); | ||
288 | input_dev = input_allocate_device(); | ||
289 | if (!port || !input_dev) { | ||
290 | kfree(port); | ||
291 | input_free_device(input_dev); | ||
292 | return -ENOMEM; | ||
293 | } | ||
294 | |||
295 | port->mode = data[TMDC_BYTE_ID]; | ||
296 | |||
297 | for (model = tmdc_models; model->id && model->id != port->mode; model++) | ||
298 | /* empty */; | ||
299 | |||
300 | port->abs = model->axes; | ||
301 | port->btn = model->buttons; | ||
302 | |||
303 | if (!model->id) { | ||
304 | port->absc = data[TMDC_BYTE_DEF] >> 4; | ||
305 | for (i = 0; i < 4; i++) | ||
306 | port->btnc[i] = i < (data[TMDC_BYTE_DEF] & 0xf) ? 8 : 0; | ||
307 | } else { | ||
308 | port->absc = model->abs; | ||
309 | for (i = 0; i < 4; i++) | ||
310 | port->btnc[i] = model->btnc[i]; | ||
311 | } | ||
312 | |||
313 | for (i = 0; i < 4; i++) | ||
314 | port->btno[i] = model->btno[i]; | ||
315 | |||
316 | snprintf(port->name, sizeof(port->name), model->name, | ||
317 | port->absc, (data[TMDC_BYTE_DEF] & 0xf) << 3, port->mode); | ||
318 | snprintf(port->phys, sizeof(port->phys), "%s/input%d", tmdc->gameport->phys, i); | ||
319 | |||
320 | port->dev = input_dev; | ||
321 | |||
322 | input_dev->name = port->name; | ||
323 | input_dev->phys = port->phys; | ||
324 | input_dev->id.bustype = BUS_GAMEPORT; | ||
325 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER; | ||
326 | input_dev->id.product = model->id; | ||
327 | input_dev->id.version = 0x0100; | ||
328 | input_dev->cdev.dev = &tmdc->gameport->dev; | ||
329 | input_dev->private = tmdc; | ||
330 | |||
331 | input_dev->open = tmdc_open; | ||
332 | input_dev->close = tmdc_close; | ||
333 | |||
334 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
335 | |||
336 | for (i = 0; i < port->absc && i < TMDC_ABS; i++) | ||
337 | if (port->abs[i] >= 0) | ||
338 | input_set_abs_params(input_dev, port->abs[i], 8, 248, 2, 4); | ||
339 | |||
340 | for (i = 0; i < model->hats && i < TMDC_ABS_HAT; i++) | ||
341 | input_set_abs_params(input_dev, tmdc_abs_hat[i], -1, 1, 0, 0); | ||
342 | |||
343 | for (i = 0; i < 4; i++) { | ||
344 | for (j = 0; j < port->btnc[i] && j < TMDC_BTN; j++) | ||
345 | set_bit(port->btn[j + b], input_dev->keybit); | ||
346 | b += port->btnc[i]; | ||
347 | } | ||
348 | |||
349 | input_register_device(port->dev); | ||
350 | |||
351 | return 0; | ||
352 | } | ||
353 | |||
238 | /* | 354 | /* |
239 | * tmdc_probe() probes for ThrustMaster type joysticks. | 355 | * tmdc_probe() probes for ThrustMaster type joysticks. |
240 | */ | 356 | */ |
241 | 357 | ||
242 | static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv) | 358 | static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv) |
243 | { | 359 | { |
244 | static struct models { | ||
245 | unsigned char id; | ||
246 | char *name; | ||
247 | char abs; | ||
248 | char hats; | ||
249 | char btnc[4]; | ||
250 | char btno[4]; | ||
251 | signed char *axes; | ||
252 | short *buttons; | ||
253 | } models[] = { { 1, "ThrustMaster Millenium 3D Inceptor", 6, 2, { 4, 2 }, { 4, 6 }, tmdc_abs, tmdc_btn_joy }, | ||
254 | { 3, "ThrustMaster Rage 3D Gamepad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad }, | ||
255 | { 4, "ThrustMaster Attack Throttle", 5, 2, { 4, 6 }, { 4, 2 }, tmdc_abs_at, tmdc_btn_at }, | ||
256 | { 8, "ThrustMaster FragMaster", 4, 0, { 8, 2 }, { 0, 0 }, tmdc_abs_fm, tmdc_btn_fm }, | ||
257 | { 163, "Thrustmaster Fusion GamePad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad }, | ||
258 | { 0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy }}; | ||
259 | |||
260 | unsigned char data[2][TMDC_MAX_LENGTH]; | 360 | unsigned char data[2][TMDC_MAX_LENGTH]; |
261 | struct tmdc *tmdc; | 361 | struct tmdc *tmdc; |
262 | int i, j, k, l, m; | 362 | int i; |
263 | int err; | 363 | int err; |
264 | 364 | ||
265 | if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) | 365 | if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) |
@@ -281,68 +381,25 @@ static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
281 | gameport_set_poll_handler(gameport, tmdc_poll); | 381 | gameport_set_poll_handler(gameport, tmdc_poll); |
282 | gameport_set_poll_interval(gameport, 20); | 382 | gameport_set_poll_interval(gameport, 20); |
283 | 383 | ||
284 | for (j = 0; j < 2; j++) | 384 | for (i = 0; i < 2; i++) { |
285 | if (tmdc->exists & (1 << j)) { | 385 | if (tmdc->exists & (1 << i)) { |
286 | 386 | ||
287 | tmdc->mode[j] = data[j][TMDC_BYTE_ID]; | 387 | err = tmdc_setup_port(tmdc, i, data[i]); |
288 | 388 | if (err) | |
289 | for (m = 0; models[m].id && models[m].id != tmdc->mode[j]; m++); | 389 | goto fail3; |
290 | |||
291 | tmdc->abs[j] = models[m].axes; | ||
292 | tmdc->btn[j] = models[m].buttons; | ||
293 | |||
294 | if (!models[m].id) { | ||
295 | models[m].abs = data[j][TMDC_BYTE_DEF] >> 4; | ||
296 | for (k = 0; k < 4; k++) | ||
297 | models[m].btnc[k] = k < (data[j][TMDC_BYTE_DEF] & 0xf) ? 8 : 0; | ||
298 | } | ||
299 | |||
300 | tmdc->absc[j] = models[m].abs; | ||
301 | for (k = 0; k < 4; k++) { | ||
302 | tmdc->btnc[j][k] = models[m].btnc[k]; | ||
303 | tmdc->btno[j][k] = models[m].btno[k]; | ||
304 | } | ||
305 | |||
306 | sprintf(tmdc->name[j], models[m].name, models[m].abs, | ||
307 | (data[j][TMDC_BYTE_DEF] & 0xf) << 3, tmdc->mode[j]); | ||
308 | |||
309 | sprintf(tmdc->phys[j], "%s/input%d", gameport->phys, j); | ||
310 | |||
311 | tmdc->dev[j].private = tmdc; | ||
312 | tmdc->dev[j].open = tmdc_open; | ||
313 | tmdc->dev[j].close = tmdc_close; | ||
314 | |||
315 | tmdc->dev[j].name = tmdc->name[j]; | ||
316 | tmdc->dev[j].phys = tmdc->phys[j]; | ||
317 | tmdc->dev[j].id.bustype = BUS_GAMEPORT; | ||
318 | tmdc->dev[j].id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER; | ||
319 | tmdc->dev[j].id.product = models[m].id; | ||
320 | tmdc->dev[j].id.version = 0x0100; | ||
321 | |||
322 | tmdc->dev[j].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
323 | |||
324 | for (i = 0; i < models[m].abs && i < TMDC_ABS; i++) | ||
325 | if (tmdc->abs[j][i] >= 0) | ||
326 | input_set_abs_params(&tmdc->dev[j], tmdc->abs[j][i], 8, 248, 2, 4); | ||
327 | |||
328 | for (i = 0; i < models[m].hats && i < TMDC_ABS_HAT; i++) | ||
329 | input_set_abs_params(&tmdc->dev[j], tmdc_abs_hat[i], -1, 1, 0, 0); | ||
330 | |||
331 | |||
332 | for (k = l = 0; k < 4; k++) { | ||
333 | for (i = 0; i < models[m].btnc[k] && i < TMDC_BTN; i++) | ||
334 | set_bit(tmdc->btn[j][i + l], tmdc->dev[j].keybit); | ||
335 | l += models[m].btnc[k]; | ||
336 | } | ||
337 | |||
338 | input_register_device(tmdc->dev + j); | ||
339 | printk(KERN_INFO "input: %s on %s\n", tmdc->name[j], gameport->phys); | ||
340 | } | 390 | } |
391 | } | ||
341 | 392 | ||
342 | return 0; | 393 | return 0; |
343 | 394 | ||
344 | fail2: gameport_close(gameport); | 395 | fail3: while (--i >= 0) { |
345 | fail1: gameport_set_drvdata(gameport, NULL); | 396 | if (tmdc->port[i]) { |
397 | input_unregister_device(tmdc->port[i]->dev); | ||
398 | kfree(tmdc->port[i]); | ||
399 | } | ||
400 | } | ||
401 | fail2: gameport_close(gameport); | ||
402 | fail1: gameport_set_drvdata(gameport, NULL); | ||
346 | kfree(tmdc); | 403 | kfree(tmdc); |
347 | return err; | 404 | return err; |
348 | } | 405 | } |
@@ -352,9 +409,12 @@ static void tmdc_disconnect(struct gameport *gameport) | |||
352 | struct tmdc *tmdc = gameport_get_drvdata(gameport); | 409 | struct tmdc *tmdc = gameport_get_drvdata(gameport); |
353 | int i; | 410 | int i; |
354 | 411 | ||
355 | for (i = 0; i < 2; i++) | 412 | for (i = 0; i < 2; i++) { |
356 | if (tmdc->exists & (1 << i)) | 413 | if (tmdc->port[i]) { |
357 | input_unregister_device(tmdc->dev + i); | 414 | input_unregister_device(tmdc->port[i]->dev); |
415 | kfree(tmdc->port[i]); | ||
416 | } | ||
417 | } | ||
358 | gameport_close(gameport); | 418 | gameport_close(gameport); |
359 | gameport_set_drvdata(gameport, NULL); | 419 | gameport_set_drvdata(gameport, NULL); |
360 | kfree(tmdc); | 420 | kfree(tmdc); |
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 0c5b9c8297cd..7e9764937d06 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
@@ -42,19 +42,21 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | |||
42 | MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); | 42 | MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); |
43 | MODULE_LICENSE("GPL"); | 43 | MODULE_LICENSE("GPL"); |
44 | 44 | ||
45 | static int tgfx[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 }; | 45 | #define TGFX_MAX_PORTS 3 |
46 | static int tgfx_nargs __initdata = 0; | 46 | #define TGFX_MAX_DEVICES 7 |
47 | module_param_array_named(map, tgfx, int, &tgfx_nargs, 0); | ||
48 | MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>"); | ||
49 | 47 | ||
50 | static int tgfx_2[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 }; | 48 | struct tgfx_config { |
51 | static int tgfx_nargs_2 __initdata = 0; | 49 | int args[TGFX_MAX_DEVICES + 1]; |
52 | module_param_array_named(map2, tgfx_2, int, &tgfx_nargs_2, 0); | 50 | int nargs; |
53 | MODULE_PARM_DESC(map2, "Describes second set of devices"); | 51 | }; |
52 | |||
53 | static struct tgfx_config tgfx[TGFX_MAX_PORTS] __initdata; | ||
54 | 54 | ||
55 | static int tgfx_3[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 }; | 55 | module_param_array_named(map, tgfx[0].args, int, &tgfx[0].nargs, 0); |
56 | static int tgfx_nargs_3 __initdata = 0; | 56 | MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>"); |
57 | module_param_array_named(map3, tgfx_3, int, &tgfx_nargs_3, 0); | 57 | module_param_array_named(map2, tgfx[1].args, int, &tgfx[1].nargs, 0); |
58 | MODULE_PARM_DESC(map2, "Describes second set of devices"); | ||
59 | module_param_array_named(map3, tgfx[2].args, int, &tgfx[2].nargs, 0); | ||
58 | MODULE_PARM_DESC(map3, "Describes third set of devices"); | 60 | MODULE_PARM_DESC(map3, "Describes third set of devices"); |
59 | 61 | ||
60 | __obsolete_setup("tgfx="); | 62 | __obsolete_setup("tgfx="); |
@@ -75,17 +77,17 @@ __obsolete_setup("tgfx_3="); | |||
75 | #define TGFX_TOP2 0x08 | 77 | #define TGFX_TOP2 0x08 |
76 | 78 | ||
77 | static int tgfx_buttons[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2 }; | 79 | static int tgfx_buttons[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2 }; |
78 | static char *tgfx_name = "TurboGraFX Multisystem joystick"; | ||
79 | 80 | ||
80 | static struct tgfx { | 81 | static struct tgfx { |
81 | struct pardevice *pd; | 82 | struct pardevice *pd; |
82 | struct timer_list timer; | 83 | struct timer_list timer; |
83 | struct input_dev dev[7]; | 84 | struct input_dev *dev[TGFX_MAX_DEVICES]; |
84 | char phys[7][32]; | 85 | char name[TGFX_MAX_DEVICES][64]; |
86 | char phys[TGFX_MAX_DEVICES][32]; | ||
85 | int sticks; | 87 | int sticks; |
86 | int used; | 88 | int used; |
87 | struct semaphore sem; | 89 | struct semaphore sem; |
88 | } *tgfx_base[3]; | 90 | } *tgfx_base[TGFX_MAX_PORTS]; |
89 | 91 | ||
90 | /* | 92 | /* |
91 | * tgfx_timer() reads and analyzes TurboGraFX joystick data. | 93 | * tgfx_timer() reads and analyzes TurboGraFX joystick data. |
@@ -100,7 +102,7 @@ static void tgfx_timer(unsigned long private) | |||
100 | for (i = 0; i < 7; i++) | 102 | for (i = 0; i < 7; i++) |
101 | if (tgfx->sticks & (1 << i)) { | 103 | if (tgfx->sticks & (1 << i)) { |
102 | 104 | ||
103 | dev = tgfx->dev + i; | 105 | dev = tgfx->dev[i]; |
104 | 106 | ||
105 | parport_write_data(tgfx->pd->port, ~(1 << i)); | 107 | parport_write_data(tgfx->pd->port, ~(1 << i)); |
106 | data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; | 108 | data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; |
@@ -153,118 +155,165 @@ static void tgfx_close(struct input_dev *dev) | |||
153 | up(&tgfx->sem); | 155 | up(&tgfx->sem); |
154 | } | 156 | } |
155 | 157 | ||
158 | |||
159 | |||
156 | /* | 160 | /* |
157 | * tgfx_probe() probes for tg gamepads. | 161 | * tgfx_probe() probes for tg gamepads. |
158 | */ | 162 | */ |
159 | 163 | ||
160 | static struct tgfx __init *tgfx_probe(int *config, int nargs) | 164 | static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) |
161 | { | 165 | { |
162 | struct tgfx *tgfx; | 166 | struct tgfx *tgfx; |
167 | struct input_dev *input_dev; | ||
163 | struct parport *pp; | 168 | struct parport *pp; |
169 | struct pardevice *pd; | ||
164 | int i, j; | 170 | int i, j; |
171 | int err; | ||
165 | 172 | ||
166 | if (config[0] < 0) | 173 | pp = parport_find_number(parport); |
167 | return NULL; | ||
168 | |||
169 | if (nargs < 2) { | ||
170 | printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n"); | ||
171 | return NULL; | ||
172 | } | ||
173 | |||
174 | pp = parport_find_number(config[0]); | ||
175 | |||
176 | if (!pp) { | 174 | if (!pp) { |
177 | printk(KERN_ERR "turbografx.c: no such parport\n"); | 175 | printk(KERN_ERR "turbografx.c: no such parport\n"); |
178 | return NULL; | 176 | err = -EINVAL; |
177 | goto err_out; | ||
179 | } | 178 | } |
180 | 179 | ||
181 | if (!(tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL))) { | 180 | pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); |
182 | parport_put_port(pp); | 181 | if (!pd) { |
183 | return NULL; | 182 | printk(KERN_ERR "turbografx.c: parport busy already - lp.o loaded?\n"); |
183 | err = -EBUSY; | ||
184 | goto err_put_pp; | ||
184 | } | 185 | } |
185 | 186 | ||
186 | init_MUTEX(&tgfx->sem); | 187 | tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); |
187 | 188 | if (!tgfx) { | |
188 | tgfx->pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | 189 | printk(KERN_ERR "turbografx.c: Not enough memory\n"); |
189 | 190 | err = -ENOMEM; | |
190 | parport_put_port(pp); | 191 | goto err_unreg_pardev; |
191 | |||
192 | if (!tgfx->pd) { | ||
193 | printk(KERN_ERR "turbografx.c: parport busy already - lp.o loaded?\n"); | ||
194 | kfree(tgfx); | ||
195 | return NULL; | ||
196 | } | 192 | } |
197 | 193 | ||
194 | init_MUTEX(&tgfx->sem); | ||
195 | tgfx->pd = pd; | ||
198 | init_timer(&tgfx->timer); | 196 | init_timer(&tgfx->timer); |
199 | tgfx->timer.data = (long) tgfx; | 197 | tgfx->timer.data = (long) tgfx; |
200 | tgfx->timer.function = tgfx_timer; | 198 | tgfx->timer.function = tgfx_timer; |
201 | 199 | ||
202 | tgfx->sticks = 0; | 200 | for (i = 0; i < n_devs; i++) { |
201 | if (n_buttons[i] < 1) | ||
202 | continue; | ||
203 | 203 | ||
204 | for (i = 0; i < nargs - 1; i++) | 204 | if (n_buttons[i] > 6) { |
205 | if (config[i+1] > 0 && config[i+1] < 6) { | 205 | printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); |
206 | 206 | err = -EINVAL; | |
207 | tgfx->sticks |= (1 << i); | 207 | goto err_free_devs; |
208 | } | ||
208 | 209 | ||
209 | tgfx->dev[i].private = tgfx; | 210 | tgfx->dev[i] = input_dev = input_allocate_device(); |
210 | tgfx->dev[i].open = tgfx_open; | 211 | if (!input_dev) { |
211 | tgfx->dev[i].close = tgfx_close; | 212 | printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); |
213 | err = -ENOMEM; | ||
214 | goto err_free_devs; | ||
215 | } | ||
212 | 216 | ||
213 | sprintf(tgfx->phys[i], "%s/input0", tgfx->pd->port->name); | 217 | tgfx->sticks |= (1 << i); |
218 | snprintf(tgfx->name[i], sizeof(tgfx->name[i]), | ||
219 | "TurboGraFX %d-button Multisystem joystick", n_buttons[i]); | ||
220 | snprintf(tgfx->phys[i], sizeof(tgfx->phys[i]), | ||
221 | "%s/input%d", tgfx->pd->port->name, i); | ||
214 | 222 | ||
215 | tgfx->dev[i].name = tgfx_name; | 223 | input_dev->name = tgfx->name[i]; |
216 | tgfx->dev[i].phys = tgfx->phys[i]; | 224 | input_dev->phys = tgfx->phys[i]; |
217 | tgfx->dev[i].id.bustype = BUS_PARPORT; | 225 | input_dev->id.bustype = BUS_PARPORT; |
218 | tgfx->dev[i].id.vendor = 0x0003; | 226 | input_dev->id.vendor = 0x0003; |
219 | tgfx->dev[i].id.product = config[i+1]; | 227 | input_dev->id.product = n_buttons[i]; |
220 | tgfx->dev[i].id.version = 0x0100; | 228 | input_dev->id.version = 0x0100; |
221 | 229 | ||
222 | tgfx->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 230 | input_dev->private = tgfx; |
223 | tgfx->dev[i].absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 231 | input_dev->open = tgfx_open; |
232 | input_dev->close = tgfx_close; | ||
224 | 233 | ||
225 | for (j = 0; j < config[i+1]; j++) | 234 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
226 | set_bit(tgfx_buttons[j], tgfx->dev[i].keybit); | 235 | input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0); |
236 | input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0); | ||
227 | 237 | ||
228 | tgfx->dev[i].absmin[ABS_X] = -1; tgfx->dev[i].absmax[ABS_X] = 1; | 238 | for (j = 0; j < n_buttons[i]; j++) |
229 | tgfx->dev[i].absmin[ABS_Y] = -1; tgfx->dev[i].absmax[ABS_Y] = 1; | 239 | set_bit(tgfx_buttons[j], input_dev->keybit); |
230 | 240 | ||
231 | input_register_device(tgfx->dev + i); | 241 | input_register_device(tgfx->dev[i]); |
232 | printk(KERN_INFO "input: %d-button Multisystem joystick on %s\n", | 242 | } |
233 | config[i+1], tgfx->pd->port->name); | ||
234 | } | ||
235 | 243 | ||
236 | if (!tgfx->sticks) { | 244 | if (!tgfx->sticks) { |
237 | parport_unregister_device(tgfx->pd); | 245 | printk(KERN_ERR "turbografx.c: No valid devices specified\n"); |
238 | kfree(tgfx); | 246 | err = -EINVAL; |
239 | return NULL; | 247 | goto err_free_tgfx; |
240 | } | 248 | } |
241 | 249 | ||
242 | return tgfx; | 250 | return tgfx; |
251 | |||
252 | err_free_devs: | ||
253 | while (--i >= 0) | ||
254 | input_unregister_device(tgfx->dev[i]); | ||
255 | err_free_tgfx: | ||
256 | kfree(tgfx); | ||
257 | err_unreg_pardev: | ||
258 | parport_unregister_device(pd); | ||
259 | err_put_pp: | ||
260 | parport_put_port(pp); | ||
261 | err_out: | ||
262 | return ERR_PTR(err); | ||
263 | } | ||
264 | |||
265 | static void __exit tgfx_remove(struct tgfx *tgfx) | ||
266 | { | ||
267 | int i; | ||
268 | |||
269 | for (i = 0; i < TGFX_MAX_DEVICES; i++) | ||
270 | if (tgfx->dev[i]) | ||
271 | input_unregister_device(tgfx->dev[i]); | ||
272 | parport_unregister_device(tgfx->pd); | ||
273 | kfree(tgfx); | ||
243 | } | 274 | } |
244 | 275 | ||
245 | static int __init tgfx_init(void) | 276 | static int __init tgfx_init(void) |
246 | { | 277 | { |
247 | tgfx_base[0] = tgfx_probe(tgfx, tgfx_nargs); | 278 | int i; |
248 | tgfx_base[1] = tgfx_probe(tgfx_2, tgfx_nargs_2); | 279 | int have_dev = 0; |
249 | tgfx_base[2] = tgfx_probe(tgfx_3, tgfx_nargs_3); | 280 | int err = 0; |
281 | |||
282 | for (i = 0; i < TGFX_MAX_PORTS; i++) { | ||
283 | if (tgfx[i].nargs == 0 || tgfx[i].args[0] < 0) | ||
284 | continue; | ||
285 | |||
286 | if (tgfx[i].nargs < 2) { | ||
287 | printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n"); | ||
288 | err = -EINVAL; | ||
289 | break; | ||
290 | } | ||
291 | |||
292 | tgfx_base[i] = tgfx_probe(tgfx[i].args[0], tgfx[i].args + 1, tgfx[i].nargs - 1); | ||
293 | if (IS_ERR(tgfx_base[i])) { | ||
294 | err = PTR_ERR(tgfx_base[i]); | ||
295 | break; | ||
296 | } | ||
297 | |||
298 | have_dev = 1; | ||
299 | } | ||
250 | 300 | ||
251 | if (tgfx_base[0] || tgfx_base[1] || tgfx_base[2]) | 301 | if (err) { |
252 | return 0; | 302 | while (--i >= 0) |
303 | tgfx_remove(tgfx_base[i]); | ||
304 | return err; | ||
305 | } | ||
253 | 306 | ||
254 | return -ENODEV; | 307 | return have_dev ? 0 : -ENODEV; |
255 | } | 308 | } |
256 | 309 | ||
257 | static void __exit tgfx_exit(void) | 310 | static void __exit tgfx_exit(void) |
258 | { | 311 | { |
259 | int i, j; | 312 | int i; |
260 | 313 | ||
261 | for (i = 0; i < 3; i++) | 314 | for (i = 0; i < TGFX_MAX_PORTS; i++) |
262 | if (tgfx_base[i]) { | 315 | if (tgfx_base[i]) |
263 | for (j = 0; j < 7; j++) | 316 | tgfx_remove(tgfx_base[i]); |
264 | if (tgfx_base[i]->sticks & (1 << j)) | ||
265 | input_unregister_device(tgfx_base[i]->dev + j); | ||
266 | parport_unregister_device(tgfx_base[i]->pd); | ||
267 | } | ||
268 | } | 317 | } |
269 | 318 | ||
270 | module_init(tgfx_init); | 319 | module_init(tgfx_init); |
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index 0379bc166525..cd3a1e742a30 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c | |||
@@ -69,8 +69,6 @@ MODULE_LICENSE("GPL"); | |||
69 | 69 | ||
70 | #define TWIDJOY_MAX_LENGTH 5 | 70 | #define TWIDJOY_MAX_LENGTH 5 |
71 | 71 | ||
72 | static char *twidjoy_name = "Handykey Twiddler"; | ||
73 | |||
74 | static struct twidjoy_button_spec { | 72 | static struct twidjoy_button_spec { |
75 | int bitshift; | 73 | int bitshift; |
76 | int bitmask; | 74 | int bitmask; |
@@ -95,7 +93,7 @@ twidjoy_buttons[] = { | |||
95 | */ | 93 | */ |
96 | 94 | ||
97 | struct twidjoy { | 95 | struct twidjoy { |
98 | struct input_dev dev; | 96 | struct input_dev *dev; |
99 | int idx; | 97 | int idx; |
100 | unsigned char data[TWIDJOY_MAX_LENGTH]; | 98 | unsigned char data[TWIDJOY_MAX_LENGTH]; |
101 | char phys[32]; | 99 | char phys[32]; |
@@ -108,37 +106,33 @@ struct twidjoy { | |||
108 | 106 | ||
109 | static void twidjoy_process_packet(struct twidjoy *twidjoy, struct pt_regs *regs) | 107 | static void twidjoy_process_packet(struct twidjoy *twidjoy, struct pt_regs *regs) |
110 | { | 108 | { |
111 | if (twidjoy->idx == TWIDJOY_MAX_LENGTH) { | 109 | struct input_dev *dev = twidjoy->dev; |
112 | struct input_dev *dev = &twidjoy->dev; | 110 | unsigned char *data = twidjoy->data; |
113 | unsigned char *data = twidjoy->data; | 111 | struct twidjoy_button_spec *bp; |
114 | struct twidjoy_button_spec *bp; | 112 | int button_bits, abs_x, abs_y; |
115 | int button_bits, abs_x, abs_y; | ||
116 | |||
117 | button_bits = ((data[1] & 0x7f) << 7) | (data[0] & 0x7f); | ||
118 | 113 | ||
119 | input_regs(dev, regs); | 114 | button_bits = ((data[1] & 0x7f) << 7) | (data[0] & 0x7f); |
120 | 115 | ||
121 | for (bp = twidjoy_buttons; bp->bitmask; bp++) { | 116 | input_regs(dev, regs); |
122 | int value = (button_bits & (bp->bitmask << bp->bitshift)) >> bp->bitshift; | ||
123 | int i; | ||
124 | 117 | ||
125 | for (i = 0; i < bp->bitmask; i++) | 118 | for (bp = twidjoy_buttons; bp->bitmask; bp++) { |
126 | input_report_key(dev, bp->buttons[i], i+1 == value); | 119 | int value = (button_bits & (bp->bitmask << bp->bitshift)) >> bp->bitshift; |
127 | } | 120 | int i; |
128 | 121 | ||
129 | abs_x = ((data[4] & 0x07) << 5) | ((data[3] & 0x7C) >> 2); | 122 | for (i = 0; i < bp->bitmask; i++) |
130 | if (data[4] & 0x08) abs_x -= 256; | 123 | input_report_key(dev, bp->buttons[i], i+1 == value); |
124 | } | ||
131 | 125 | ||
132 | abs_y = ((data[3] & 0x01) << 7) | ((data[2] & 0x7F) >> 0); | 126 | abs_x = ((data[4] & 0x07) << 5) | ((data[3] & 0x7C) >> 2); |
133 | if (data[3] & 0x02) abs_y -= 256; | 127 | if (data[4] & 0x08) abs_x -= 256; |
134 | 128 | ||
135 | input_report_abs(dev, ABS_X, -abs_x); | 129 | abs_y = ((data[3] & 0x01) << 7) | ((data[2] & 0x7F) >> 0); |
136 | input_report_abs(dev, ABS_Y, +abs_y); | 130 | if (data[3] & 0x02) abs_y -= 256; |
137 | 131 | ||
138 | input_sync(dev); | 132 | input_report_abs(dev, ABS_X, -abs_x); |
139 | } | 133 | input_report_abs(dev, ABS_Y, +abs_y); |
140 | 134 | ||
141 | return; | 135 | input_sync(dev); |
142 | } | 136 | } |
143 | 137 | ||
144 | /* | 138 | /* |
@@ -179,9 +173,9 @@ static void twidjoy_disconnect(struct serio *serio) | |||
179 | { | 173 | { |
180 | struct twidjoy *twidjoy = serio_get_drvdata(serio); | 174 | struct twidjoy *twidjoy = serio_get_drvdata(serio); |
181 | 175 | ||
182 | input_unregister_device(&twidjoy->dev); | ||
183 | serio_close(serio); | 176 | serio_close(serio); |
184 | serio_set_drvdata(serio, NULL); | 177 | serio_set_drvdata(serio, NULL); |
178 | input_unregister_device(twidjoy->dev); | ||
185 | kfree(twidjoy); | 179 | kfree(twidjoy); |
186 | } | 180 | } |
187 | 181 | ||
@@ -195,59 +189,49 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv) | |||
195 | { | 189 | { |
196 | struct twidjoy_button_spec *bp; | 190 | struct twidjoy_button_spec *bp; |
197 | struct twidjoy *twidjoy; | 191 | struct twidjoy *twidjoy; |
192 | struct input_dev *input_dev; | ||
193 | int err = -ENOMEM; | ||
198 | int i; | 194 | int i; |
199 | int err; | ||
200 | |||
201 | if (!(twidjoy = kmalloc(sizeof(struct twidjoy), GFP_KERNEL))) | ||
202 | return -ENOMEM; | ||
203 | 195 | ||
204 | memset(twidjoy, 0, sizeof(struct twidjoy)); | 196 | twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); |
197 | input_dev = input_allocate_device(); | ||
198 | if (!twidjoy || !input_dev) | ||
199 | goto fail; | ||
205 | 200 | ||
201 | twidjoy->dev = input_dev; | ||
206 | sprintf(twidjoy->phys, "%s/input0", serio->phys); | 202 | sprintf(twidjoy->phys, "%s/input0", serio->phys); |
207 | 203 | ||
208 | init_input_dev(&twidjoy->dev); | 204 | input_dev->name = "Handykey Twiddler"; |
209 | twidjoy->dev.name = twidjoy_name; | 205 | input_dev->phys = twidjoy->phys; |
210 | twidjoy->dev.phys = twidjoy->phys; | 206 | input_dev->id.bustype = BUS_RS232; |
211 | twidjoy->dev.id.bustype = BUS_RS232; | 207 | input_dev->id.vendor = SERIO_TWIDJOY; |
212 | twidjoy->dev.id.vendor = SERIO_TWIDJOY; | 208 | input_dev->id.product = 0x0001; |
213 | twidjoy->dev.id.product = 0x0001; | 209 | input_dev->id.version = 0x0100; |
214 | twidjoy->dev.id.version = 0x0100; | 210 | input_dev->cdev.dev = &serio->dev; |
215 | twidjoy->dev.dev = &serio->dev; | 211 | input_dev->private = twidjoy; |
216 | 212 | ||
217 | twidjoy->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 213 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
218 | 214 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | |
219 | for (bp = twidjoy_buttons; bp->bitmask; bp++) { | 215 | input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4); |
216 | input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4); | ||
217 | |||
218 | for (bp = twidjoy_buttons; bp->bitmask; bp++) | ||
220 | for (i = 0; i < bp->bitmask; i++) | 219 | for (i = 0; i < bp->bitmask; i++) |
221 | set_bit(bp->buttons[i], twidjoy->dev.keybit); | 220 | set_bit(bp->buttons[i], input_dev->keybit); |
222 | } | ||
223 | |||
224 | twidjoy->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
225 | |||
226 | for (i = 0; i < 2; i++) { | ||
227 | twidjoy->dev.absmax[ABS_X+i] = 50; | ||
228 | twidjoy->dev.absmin[ABS_X+i] = -50; | ||
229 | |||
230 | /* TODO: arndt 20010708: Are these values appropriate? */ | ||
231 | twidjoy->dev.absfuzz[ABS_X+i] = 4; | ||
232 | twidjoy->dev.absflat[ABS_X+i] = 4; | ||
233 | } | ||
234 | |||
235 | twidjoy->dev.private = twidjoy; | ||
236 | 221 | ||
237 | serio_set_drvdata(serio, twidjoy); | 222 | serio_set_drvdata(serio, twidjoy); |
238 | 223 | ||
239 | err = serio_open(serio, drv); | 224 | err = serio_open(serio, drv); |
240 | if (err) { | 225 | if (err) |
241 | serio_set_drvdata(serio, NULL); | 226 | goto fail; |
242 | kfree(twidjoy); | ||
243 | return err; | ||
244 | } | ||
245 | |||
246 | input_register_device(&twidjoy->dev); | ||
247 | |||
248 | printk(KERN_INFO "input: %s on %s\n", twidjoy_name, serio->phys); | ||
249 | 227 | ||
228 | input_register_device(twidjoy->dev); | ||
250 | return 0; | 229 | return 0; |
230 | |||
231 | fail: serio_set_drvdata(serio, NULL); | ||
232 | input_free_device(input_dev); | ||
233 | kfree(twidjoy); | ||
234 | return err; | ||
251 | } | 235 | } |
252 | 236 | ||
253 | /* | 237 | /* |
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 6976a219504c..99a642d2a1fe 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c | |||
@@ -47,14 +47,13 @@ MODULE_LICENSE("GPL"); | |||
47 | 47 | ||
48 | #define WARRIOR_MAX_LENGTH 16 | 48 | #define WARRIOR_MAX_LENGTH 16 |
49 | static char warrior_lengths[] = { 0, 4, 12, 3, 4, 4, 0, 0 }; | 49 | static char warrior_lengths[] = { 0, 4, 12, 3, 4, 4, 0, 0 }; |
50 | static char *warrior_name = "Logitech WingMan Warrior"; | ||
51 | 50 | ||
52 | /* | 51 | /* |
53 | * Per-Warrior data. | 52 | * Per-Warrior data. |
54 | */ | 53 | */ |
55 | 54 | ||
56 | struct warrior { | 55 | struct warrior { |
57 | struct input_dev dev; | 56 | struct input_dev *dev; |
58 | int idx, len; | 57 | int idx, len; |
59 | unsigned char data[WARRIOR_MAX_LENGTH]; | 58 | unsigned char data[WARRIOR_MAX_LENGTH]; |
60 | char phys[32]; | 59 | char phys[32]; |
@@ -67,7 +66,7 @@ struct warrior { | |||
67 | 66 | ||
68 | static void warrior_process_packet(struct warrior *warrior, struct pt_regs *regs) | 67 | static void warrior_process_packet(struct warrior *warrior, struct pt_regs *regs) |
69 | { | 68 | { |
70 | struct input_dev *dev = &warrior->dev; | 69 | struct input_dev *dev = warrior->dev; |
71 | unsigned char *data = warrior->data; | 70 | unsigned char *data = warrior->data; |
72 | 71 | ||
73 | if (!warrior->idx) return; | 72 | if (!warrior->idx) return; |
@@ -131,9 +130,9 @@ static void warrior_disconnect(struct serio *serio) | |||
131 | { | 130 | { |
132 | struct warrior *warrior = serio_get_drvdata(serio); | 131 | struct warrior *warrior = serio_get_drvdata(serio); |
133 | 132 | ||
134 | input_unregister_device(&warrior->dev); | ||
135 | serio_close(serio); | 133 | serio_close(serio); |
136 | serio_set_drvdata(serio, NULL); | 134 | serio_set_drvdata(serio, NULL); |
135 | input_unregister_device(warrior->dev); | ||
137 | kfree(warrior); | 136 | kfree(warrior); |
138 | } | 137 | } |
139 | 138 | ||
@@ -146,60 +145,48 @@ static void warrior_disconnect(struct serio *serio) | |||
146 | static int warrior_connect(struct serio *serio, struct serio_driver *drv) | 145 | static int warrior_connect(struct serio *serio, struct serio_driver *drv) |
147 | { | 146 | { |
148 | struct warrior *warrior; | 147 | struct warrior *warrior; |
149 | int i; | 148 | struct input_dev *input_dev; |
150 | int err; | 149 | int err = -ENOMEM; |
151 | 150 | ||
152 | if (!(warrior = kmalloc(sizeof(struct warrior), GFP_KERNEL))) | 151 | warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); |
153 | return -ENOMEM; | 152 | input_dev = input_allocate_device(); |
154 | 153 | if (!warrior || !input_dev) | |
155 | memset(warrior, 0, sizeof(struct warrior)); | 154 | goto fail; |
156 | |||
157 | warrior->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); | ||
158 | warrior->dev.keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2); | ||
159 | warrior->dev.relbit[0] = BIT(REL_DIAL); | ||
160 | warrior->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y); | ||
161 | 155 | ||
156 | warrior->dev = input_dev; | ||
162 | sprintf(warrior->phys, "%s/input0", serio->phys); | 157 | sprintf(warrior->phys, "%s/input0", serio->phys); |
163 | 158 | ||
164 | init_input_dev(&warrior->dev); | 159 | input_dev->name = "Logitech WingMan Warrior"; |
165 | warrior->dev.name = warrior_name; | 160 | input_dev->phys = warrior->phys; |
166 | warrior->dev.phys = warrior->phys; | 161 | input_dev->id.bustype = BUS_RS232; |
167 | warrior->dev.id.bustype = BUS_RS232; | 162 | input_dev->id.vendor = SERIO_WARRIOR; |
168 | warrior->dev.id.vendor = SERIO_WARRIOR; | 163 | input_dev->id.product = 0x0001; |
169 | warrior->dev.id.product = 0x0001; | 164 | input_dev->id.version = 0x0100; |
170 | warrior->dev.id.version = 0x0100; | 165 | input_dev->cdev.dev = &serio->dev; |
171 | warrior->dev.dev = &serio->dev; | 166 | input_dev->private = warrior; |
172 | 167 | ||
173 | for (i = 0; i < 2; i++) { | 168 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); |
174 | warrior->dev.absmax[ABS_X+i] = -64; | 169 | input_dev->keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2); |
175 | warrior->dev.absmin[ABS_X+i] = 64; | 170 | input_dev->relbit[0] = BIT(REL_DIAL); |
176 | warrior->dev.absflat[ABS_X+i] = 8; | 171 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 8); |
177 | } | 172 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8); |
178 | 173 | input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0); | |
179 | warrior->dev.absmax[ABS_THROTTLE] = -112; | 174 | input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); |
180 | warrior->dev.absmin[ABS_THROTTLE] = 112; | 175 | input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); |
181 | |||
182 | for (i = 0; i < 2; i++) { | ||
183 | warrior->dev.absmax[ABS_HAT0X+i] = -1; | ||
184 | warrior->dev.absmin[ABS_HAT0X+i] = 1; | ||
185 | } | ||
186 | |||
187 | warrior->dev.private = warrior; | ||
188 | 176 | ||
189 | serio_set_drvdata(serio, warrior); | 177 | serio_set_drvdata(serio, warrior); |
190 | 178 | ||
191 | err = serio_open(serio, drv); | 179 | err = serio_open(serio, drv); |
192 | if (err) { | 180 | if (err) |
193 | serio_set_drvdata(serio, NULL); | 181 | goto fail; |
194 | kfree(warrior); | ||
195 | return err; | ||
196 | } | ||
197 | |||
198 | input_register_device(&warrior->dev); | ||
199 | |||
200 | printk(KERN_INFO "input: Logitech WingMan Warrior on %s\n", serio->phys); | ||
201 | 182 | ||
183 | input_register_device(warrior->dev); | ||
202 | return 0; | 184 | return 0; |
185 | |||
186 | fail: serio_set_drvdata(serio, NULL); | ||
187 | input_free_device(input_dev); | ||
188 | kfree(warrior); | ||
189 | return err; | ||
203 | } | 190 | } |
204 | 191 | ||
205 | /* | 192 | /* |
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index 4e8e8ea214ab..3d63bc1ad322 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c | |||
@@ -155,10 +155,7 @@ static const char *amikbd_messages[8] = { | |||
155 | [7] = KERN_WARNING "amikbd: keyboard interrupt\n" | 155 | [7] = KERN_WARNING "amikbd: keyboard interrupt\n" |
156 | }; | 156 | }; |
157 | 157 | ||
158 | static struct input_dev amikbd_dev; | 158 | static struct input_dev *amikbd_dev; |
159 | |||
160 | static char *amikbd_name = "Amiga keyboard"; | ||
161 | static char *amikbd_phys = "amikbd/input0"; | ||
162 | 159 | ||
163 | static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) | 160 | static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) |
164 | { | 161 | { |
@@ -176,16 +173,16 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) | |||
176 | 173 | ||
177 | scancode = amikbd_keycode[scancode]; | 174 | scancode = amikbd_keycode[scancode]; |
178 | 175 | ||
179 | input_regs(&amikbd_dev, fp); | 176 | input_regs(amikbd_dev, fp); |
180 | 177 | ||
181 | if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */ | 178 | if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */ |
182 | input_report_key(&amikbd_dev, scancode, 1); | 179 | input_report_key(amikbd_dev, scancode, 1); |
183 | input_report_key(&amikbd_dev, scancode, 0); | 180 | input_report_key(amikbd_dev, scancode, 0); |
184 | input_sync(&amikbd_dev); | ||
185 | } else { | 181 | } else { |
186 | input_report_key(&amikbd_dev, scancode, down); | 182 | input_report_key(amikbd_dev, scancode, down); |
187 | input_sync(&amikbd_dev); | ||
188 | } | 183 | } |
184 | |||
185 | input_sync(amikbd_dev); | ||
189 | } else /* scancodes >= 0x78 are error codes */ | 186 | } else /* scancodes >= 0x78 are error codes */ |
190 | printk(amikbd_messages[scancode - 0x78]); | 187 | printk(amikbd_messages[scancode - 0x78]); |
191 | 188 | ||
@@ -202,39 +199,41 @@ static int __init amikbd_init(void) | |||
202 | if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) | 199 | if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) |
203 | return -EBUSY; | 200 | return -EBUSY; |
204 | 201 | ||
205 | init_input_dev(&amikbd_dev); | 202 | amikbd_dev = input_dev_allocate(); |
206 | 203 | if (!amikbd_dev) { | |
207 | amikbd_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 204 | printk(KERN_ERR "amikbd: not enough memory for input device\n"); |
208 | amikbd_dev.keycode = amikbd_keycode; | 205 | release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); |
209 | amikbd_dev.keycodesize = sizeof(unsigned char); | 206 | return -ENOMEM; |
210 | amikbd_dev.keycodemax = ARRAY_SIZE(amikbd_keycode); | 207 | } |
208 | |||
209 | amikbd_dev->name = "Amiga Keyboard"; | ||
210 | amikbd_dev->phys = "amikbd/input0"; | ||
211 | amikbd_dev->id.bustype = BUS_AMIGA; | ||
212 | amikbd_dev->id.vendor = 0x0001; | ||
213 | amikbd_dev->id.product = 0x0001; | ||
214 | amikbd_dev->id.version = 0x0100; | ||
215 | |||
216 | amikbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
217 | amikbd_dev->keycode = amikbd_keycode; | ||
218 | amikbd_dev->keycodesize = sizeof(unsigned char); | ||
219 | amikbd_dev->keycodemax = ARRAY_SIZE(amikbd_keycode); | ||
211 | 220 | ||
212 | for (i = 0; i < 0x78; i++) | 221 | for (i = 0; i < 0x78; i++) |
213 | if (amikbd_keycode[i]) | 222 | if (amikbd_keycode[i]) |
214 | set_bit(amikbd_keycode[i], amikbd_dev.keybit); | 223 | set_bit(amikbd_keycode[i], amikbd_dev->keybit); |
215 | 224 | ||
216 | ciaa.cra &= ~0x41; /* serial data in, turn off TA */ | 225 | ciaa.cra &= ~0x41; /* serial data in, turn off TA */ |
217 | request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); | 226 | request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); |
218 | 227 | ||
219 | amikbd_dev.name = amikbd_name; | 228 | input_register_device(amikbd_dev); |
220 | amikbd_dev.phys = amikbd_phys; | ||
221 | amikbd_dev.id.bustype = BUS_AMIGA; | ||
222 | amikbd_dev.id.vendor = 0x0001; | ||
223 | amikbd_dev.id.product = 0x0001; | ||
224 | amikbd_dev.id.version = 0x0100; | ||
225 | |||
226 | input_register_device(&amikbd_dev); | ||
227 | |||
228 | printk(KERN_INFO "input: %s\n", amikbd_name); | ||
229 | |||
230 | return 0; | 229 | return 0; |
231 | } | 230 | } |
232 | 231 | ||
233 | static void __exit amikbd_exit(void) | 232 | static void __exit amikbd_exit(void) |
234 | { | 233 | { |
235 | input_unregister_device(&amikbd_dev); | ||
236 | free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); | 234 | free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); |
237 | release_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100); | 235 | input_unregister_device(amikbd_dev); |
236 | release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); | ||
238 | } | 237 | } |
239 | 238 | ||
240 | module_init(amikbd_init); | 239 | module_init(amikbd_init); |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 1ad8c2ee7dbf..820c7fd9a604 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -185,12 +185,12 @@ static struct { | |||
185 | 185 | ||
186 | struct atkbd { | 186 | struct atkbd { |
187 | 187 | ||
188 | struct ps2dev ps2dev; | 188 | struct ps2dev ps2dev; |
189 | struct input_dev *dev; | ||
189 | 190 | ||
190 | /* Written only during init */ | 191 | /* Written only during init */ |
191 | char name[64]; | 192 | char name[64]; |
192 | char phys[32]; | 193 | char phys[32]; |
193 | struct input_dev dev; | ||
194 | 194 | ||
195 | unsigned short id; | 195 | unsigned short id; |
196 | unsigned char keycode[512]; | 196 | unsigned char keycode[512]; |
@@ -290,7 +290,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
290 | if (!atkbd->enabled) | 290 | if (!atkbd->enabled) |
291 | goto out; | 291 | goto out; |
292 | 292 | ||
293 | input_event(&atkbd->dev, EV_MSC, MSC_RAW, code); | 293 | input_event(atkbd->dev, EV_MSC, MSC_RAW, code); |
294 | 294 | ||
295 | if (atkbd->translated) { | 295 | if (atkbd->translated) { |
296 | 296 | ||
@@ -326,10 +326,10 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
326 | atkbd->release = 1; | 326 | atkbd->release = 1; |
327 | goto out; | 327 | goto out; |
328 | case ATKBD_RET_HANGUEL: | 328 | case ATKBD_RET_HANGUEL: |
329 | atkbd_report_key(&atkbd->dev, regs, KEY_HANGUEL, 3); | 329 | atkbd_report_key(atkbd->dev, regs, KEY_HANGUEL, 3); |
330 | goto out; | 330 | goto out; |
331 | case ATKBD_RET_HANJA: | 331 | case ATKBD_RET_HANJA: |
332 | atkbd_report_key(&atkbd->dev, regs, KEY_HANJA, 3); | 332 | atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3); |
333 | goto out; | 333 | goto out; |
334 | case ATKBD_RET_ERR: | 334 | case ATKBD_RET_ERR: |
335 | printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); | 335 | printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); |
@@ -345,7 +345,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
345 | } | 345 | } |
346 | 346 | ||
347 | if (atkbd->keycode[code] != ATKBD_KEY_NULL) | 347 | if (atkbd->keycode[code] != ATKBD_KEY_NULL) |
348 | input_event(&atkbd->dev, EV_MSC, MSC_SCAN, code); | 348 | input_event(atkbd->dev, EV_MSC, MSC_SCAN, code); |
349 | 349 | ||
350 | switch (atkbd->keycode[code]) { | 350 | switch (atkbd->keycode[code]) { |
351 | case ATKBD_KEY_NULL: | 351 | case ATKBD_KEY_NULL: |
@@ -365,7 +365,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
365 | "to make it known.\n", | 365 | "to make it known.\n", |
366 | code & 0x80 ? "e0" : "", code & 0x7f); | 366 | code & 0x80 ? "e0" : "", code & 0x7f); |
367 | } | 367 | } |
368 | input_sync(&atkbd->dev); | 368 | input_sync(atkbd->dev); |
369 | break; | 369 | break; |
370 | case ATKBD_SCR_1: | 370 | case ATKBD_SCR_1: |
371 | scroll = 1 - atkbd->release * 2; | 371 | scroll = 1 - atkbd->release * 2; |
@@ -390,7 +390,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
390 | break; | 390 | break; |
391 | default: | 391 | default: |
392 | value = atkbd->release ? 0 : | 392 | value = atkbd->release ? 0 : |
393 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key))); | 393 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev->key))); |
394 | 394 | ||
395 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ | 395 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ |
396 | case 0: | 396 | case 0: |
@@ -398,7 +398,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
398 | break; | 398 | break; |
399 | case 1: | 399 | case 1: |
400 | atkbd->last = code; | 400 | atkbd->last = code; |
401 | atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev.rep[REP_DELAY]) / 2; | 401 | atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev->rep[REP_DELAY]) / 2; |
402 | break; | 402 | break; |
403 | case 2: | 403 | case 2: |
404 | if (!time_after(jiffies, atkbd->time) && atkbd->last == code) | 404 | if (!time_after(jiffies, atkbd->time) && atkbd->last == code) |
@@ -406,16 +406,16 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | 408 | ||
409 | atkbd_report_key(&atkbd->dev, regs, atkbd->keycode[code], value); | 409 | atkbd_report_key(atkbd->dev, regs, atkbd->keycode[code], value); |
410 | } | 410 | } |
411 | 411 | ||
412 | if (atkbd->scroll) { | 412 | if (atkbd->scroll) { |
413 | input_regs(&atkbd->dev, regs); | 413 | input_regs(atkbd->dev, regs); |
414 | if (click != -1) | 414 | if (click != -1) |
415 | input_report_key(&atkbd->dev, BTN_MIDDLE, click); | 415 | input_report_key(atkbd->dev, BTN_MIDDLE, click); |
416 | input_report_rel(&atkbd->dev, REL_WHEEL, scroll); | 416 | input_report_rel(atkbd->dev, REL_WHEEL, scroll); |
417 | input_report_rel(&atkbd->dev, REL_HWHEEL, hscroll); | 417 | input_report_rel(atkbd->dev, REL_HWHEEL, hscroll); |
418 | input_sync(&atkbd->dev); | 418 | input_sync(atkbd->dev); |
419 | } | 419 | } |
420 | 420 | ||
421 | atkbd->release = 0; | 421 | atkbd->release = 0; |
@@ -463,7 +463,6 @@ static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int co | |||
463 | 463 | ||
464 | return 0; | 464 | return 0; |
465 | 465 | ||
466 | |||
467 | case EV_REP: | 466 | case EV_REP: |
468 | 467 | ||
469 | if (atkbd->softrepeat) return 0; | 468 | if (atkbd->softrepeat) return 0; |
@@ -693,7 +692,7 @@ static void atkbd_disconnect(struct serio *serio) | |||
693 | device_remove_file(&serio->dev, &atkbd_attr_softrepeat); | 692 | device_remove_file(&serio->dev, &atkbd_attr_softrepeat); |
694 | device_remove_file(&serio->dev, &atkbd_attr_softraw); | 693 | device_remove_file(&serio->dev, &atkbd_attr_softraw); |
695 | 694 | ||
696 | input_unregister_device(&atkbd->dev); | 695 | input_unregister_device(atkbd->dev); |
697 | serio_close(serio); | 696 | serio_close(serio); |
698 | serio_set_drvdata(serio, NULL); | 697 | serio_set_drvdata(serio, NULL); |
699 | kfree(atkbd); | 698 | kfree(atkbd); |
@@ -701,7 +700,7 @@ static void atkbd_disconnect(struct serio *serio) | |||
701 | 700 | ||
702 | 701 | ||
703 | /* | 702 | /* |
704 | * atkbd_set_device_attrs() initializes keyboard's keycode table | 703 | * atkbd_set_keycode_table() initializes keyboard's keycode table |
705 | * according to the selected scancode set | 704 | * according to the selected scancode set |
706 | */ | 705 | */ |
707 | 706 | ||
@@ -737,53 +736,58 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd) | |||
737 | 736 | ||
738 | static void atkbd_set_device_attrs(struct atkbd *atkbd) | 737 | static void atkbd_set_device_attrs(struct atkbd *atkbd) |
739 | { | 738 | { |
739 | struct input_dev *input_dev = atkbd->dev; | ||
740 | int i; | 740 | int i; |
741 | 741 | ||
742 | memset(&atkbd->dev, 0, sizeof(struct input_dev)); | 742 | if (atkbd->extra) |
743 | sprintf(atkbd->name, "AT Set 2 Extra keyboard"); | ||
744 | else | ||
745 | sprintf(atkbd->name, "AT %s Set %d keyboard", | ||
746 | atkbd->translated ? "Translated" : "Raw", atkbd->set); | ||
743 | 747 | ||
744 | init_input_dev(&atkbd->dev); | 748 | sprintf(atkbd->phys, "%s/input0", atkbd->ps2dev.serio->phys); |
745 | 749 | ||
746 | atkbd->dev.name = atkbd->name; | 750 | input_dev->name = atkbd->name; |
747 | atkbd->dev.phys = atkbd->phys; | 751 | input_dev->phys = atkbd->phys; |
748 | atkbd->dev.id.bustype = BUS_I8042; | 752 | input_dev->id.bustype = BUS_I8042; |
749 | atkbd->dev.id.vendor = 0x0001; | 753 | input_dev->id.vendor = 0x0001; |
750 | atkbd->dev.id.product = atkbd->translated ? 1 : atkbd->set; | 754 | input_dev->id.product = atkbd->translated ? 1 : atkbd->set; |
751 | atkbd->dev.id.version = atkbd->id; | 755 | input_dev->id.version = atkbd->id; |
752 | atkbd->dev.event = atkbd_event; | 756 | input_dev->event = atkbd_event; |
753 | atkbd->dev.private = atkbd; | 757 | input_dev->private = atkbd; |
754 | atkbd->dev.dev = &atkbd->ps2dev.serio->dev; | 758 | input_dev->cdev.dev = &atkbd->ps2dev.serio->dev; |
755 | 759 | ||
756 | atkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); | 760 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); |
757 | 761 | ||
758 | if (atkbd->write) { | 762 | if (atkbd->write) { |
759 | atkbd->dev.evbit[0] |= BIT(EV_LED); | 763 | input_dev->evbit[0] |= BIT(EV_LED); |
760 | atkbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 764 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); |
761 | } | 765 | } |
762 | 766 | ||
763 | if (atkbd->extra) | 767 | if (atkbd->extra) |
764 | atkbd->dev.ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | | 768 | input_dev->ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | |
765 | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC); | 769 | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC); |
766 | 770 | ||
767 | if (!atkbd->softrepeat) { | 771 | if (!atkbd->softrepeat) { |
768 | atkbd->dev.rep[REP_DELAY] = 250; | 772 | input_dev->rep[REP_DELAY] = 250; |
769 | atkbd->dev.rep[REP_PERIOD] = 33; | 773 | input_dev->rep[REP_PERIOD] = 33; |
770 | } | 774 | } |
771 | 775 | ||
772 | atkbd->dev.mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN); | 776 | input_dev->mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN); |
773 | 777 | ||
774 | if (atkbd->scroll) { | 778 | if (atkbd->scroll) { |
775 | atkbd->dev.evbit[0] |= BIT(EV_REL); | 779 | input_dev->evbit[0] |= BIT(EV_REL); |
776 | atkbd->dev.relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL); | 780 | input_dev->relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL); |
777 | set_bit(BTN_MIDDLE, atkbd->dev.keybit); | 781 | set_bit(BTN_MIDDLE, input_dev->keybit); |
778 | } | 782 | } |
779 | 783 | ||
780 | atkbd->dev.keycode = atkbd->keycode; | 784 | input_dev->keycode = atkbd->keycode; |
781 | atkbd->dev.keycodesize = sizeof(unsigned char); | 785 | input_dev->keycodesize = sizeof(unsigned char); |
782 | atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode); | 786 | input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode); |
783 | 787 | ||
784 | for (i = 0; i < 512; i++) | 788 | for (i = 0; i < 512; i++) |
785 | if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) | 789 | if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) |
786 | set_bit(atkbd->keycode[i], atkbd->dev.keybit); | 790 | set_bit(atkbd->keycode[i], input_dev->keybit); |
787 | } | 791 | } |
788 | 792 | ||
789 | /* | 793 | /* |
@@ -796,13 +800,15 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd) | |||
796 | static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | 800 | static int atkbd_connect(struct serio *serio, struct serio_driver *drv) |
797 | { | 801 | { |
798 | struct atkbd *atkbd; | 802 | struct atkbd *atkbd; |
799 | int err; | 803 | struct input_dev *dev; |
800 | 804 | int err = -ENOMEM; | |
801 | if (!(atkbd = kmalloc(sizeof(struct atkbd), GFP_KERNEL))) | ||
802 | return - ENOMEM; | ||
803 | 805 | ||
804 | memset(atkbd, 0, sizeof(struct atkbd)); | 806 | atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); |
807 | dev = input_allocate_device(); | ||
808 | if (!atkbd || !dev) | ||
809 | goto fail; | ||
805 | 810 | ||
811 | atkbd->dev = dev; | ||
806 | ps2_init(&atkbd->ps2dev, serio); | 812 | ps2_init(&atkbd->ps2dev, serio); |
807 | 813 | ||
808 | switch (serio->id.type) { | 814 | switch (serio->id.type) { |
@@ -828,19 +834,15 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
828 | serio_set_drvdata(serio, atkbd); | 834 | serio_set_drvdata(serio, atkbd); |
829 | 835 | ||
830 | err = serio_open(serio, drv); | 836 | err = serio_open(serio, drv); |
831 | if (err) { | 837 | if (err) |
832 | serio_set_drvdata(serio, NULL); | 838 | goto fail; |
833 | kfree(atkbd); | ||
834 | return err; | ||
835 | } | ||
836 | 839 | ||
837 | if (atkbd->write) { | 840 | if (atkbd->write) { |
838 | 841 | ||
839 | if (atkbd_probe(atkbd)) { | 842 | if (atkbd_probe(atkbd)) { |
840 | serio_close(serio); | 843 | serio_close(serio); |
841 | serio_set_drvdata(serio, NULL); | 844 | err = -ENODEV; |
842 | kfree(atkbd); | 845 | goto fail; |
843 | return -ENODEV; | ||
844 | } | 846 | } |
845 | 847 | ||
846 | atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); | 848 | atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); |
@@ -851,19 +853,9 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
851 | atkbd->id = 0xab00; | 853 | atkbd->id = 0xab00; |
852 | } | 854 | } |
853 | 855 | ||
854 | if (atkbd->extra) | ||
855 | sprintf(atkbd->name, "AT Set 2 Extra keyboard"); | ||
856 | else | ||
857 | sprintf(atkbd->name, "AT %s Set %d keyboard", | ||
858 | atkbd->translated ? "Translated" : "Raw", atkbd->set); | ||
859 | |||
860 | sprintf(atkbd->phys, "%s/input0", serio->phys); | ||
861 | |||
862 | atkbd_set_keycode_table(atkbd); | 856 | atkbd_set_keycode_table(atkbd); |
863 | atkbd_set_device_attrs(atkbd); | 857 | atkbd_set_device_attrs(atkbd); |
864 | 858 | ||
865 | input_register_device(&atkbd->dev); | ||
866 | |||
867 | device_create_file(&serio->dev, &atkbd_attr_extra); | 859 | device_create_file(&serio->dev, &atkbd_attr_extra); |
868 | device_create_file(&serio->dev, &atkbd_attr_scroll); | 860 | device_create_file(&serio->dev, &atkbd_attr_scroll); |
869 | device_create_file(&serio->dev, &atkbd_attr_set); | 861 | device_create_file(&serio->dev, &atkbd_attr_set); |
@@ -872,9 +864,14 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
872 | 864 | ||
873 | atkbd_enable(atkbd); | 865 | atkbd_enable(atkbd); |
874 | 866 | ||
875 | printk(KERN_INFO "input: %s on %s\n", atkbd->name, serio->phys); | 867 | input_register_device(atkbd->dev); |
876 | 868 | ||
877 | return 0; | 869 | return 0; |
870 | |||
871 | fail: serio_set_drvdata(serio, NULL); | ||
872 | input_free_device(dev); | ||
873 | kfree(atkbd); | ||
874 | return err; | ||
878 | } | 875 | } |
879 | 876 | ||
880 | /* | 877 | /* |
@@ -896,9 +893,9 @@ static int atkbd_reconnect(struct serio *serio) | |||
896 | atkbd_disable(atkbd); | 893 | atkbd_disable(atkbd); |
897 | 894 | ||
898 | if (atkbd->write) { | 895 | if (atkbd->write) { |
899 | param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0) | 896 | param[0] = (test_bit(LED_SCROLLL, atkbd->dev->led) ? 1 : 0) |
900 | | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0) | 897 | | (test_bit(LED_NUML, atkbd->dev->led) ? 2 : 0) |
901 | | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); | 898 | | (test_bit(LED_CAPSL, atkbd->dev->led) ? 4 : 0); |
902 | 899 | ||
903 | if (atkbd_probe(atkbd)) | 900 | if (atkbd_probe(atkbd)) |
904 | return -1; | 901 | return -1; |
@@ -1008,6 +1005,7 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf) | |||
1008 | 1005 | ||
1009 | static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) | 1006 | static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) |
1010 | { | 1007 | { |
1008 | struct input_dev *new_dev; | ||
1011 | unsigned long value; | 1009 | unsigned long value; |
1012 | char *rest; | 1010 | char *rest; |
1013 | 1011 | ||
@@ -1019,12 +1017,19 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun | |||
1019 | return -EINVAL; | 1017 | return -EINVAL; |
1020 | 1018 | ||
1021 | if (atkbd->extra != value) { | 1019 | if (atkbd->extra != value) { |
1022 | /* unregister device as it's properties will change */ | 1020 | /* |
1023 | input_unregister_device(&atkbd->dev); | 1021 | * Since device's properties will change we need to |
1022 | * unregister old device. But allocate new one first | ||
1023 | * to make sure we have it. | ||
1024 | */ | ||
1025 | if (!(new_dev = input_allocate_device())) | ||
1026 | return -ENOMEM; | ||
1027 | input_unregister_device(atkbd->dev); | ||
1028 | atkbd->dev = new_dev; | ||
1024 | atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); | 1029 | atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); |
1025 | atkbd_activate(atkbd); | 1030 | atkbd_activate(atkbd); |
1026 | atkbd_set_device_attrs(atkbd); | 1031 | atkbd_set_device_attrs(atkbd); |
1027 | input_register_device(&atkbd->dev); | 1032 | input_register_device(atkbd->dev); |
1028 | } | 1033 | } |
1029 | return count; | 1034 | return count; |
1030 | } | 1035 | } |
@@ -1036,6 +1041,7 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf) | |||
1036 | 1041 | ||
1037 | static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) | 1042 | static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) |
1038 | { | 1043 | { |
1044 | struct input_dev *new_dev; | ||
1039 | unsigned long value; | 1045 | unsigned long value; |
1040 | char *rest; | 1046 | char *rest; |
1041 | 1047 | ||
@@ -1044,12 +1050,14 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou | |||
1044 | return -EINVAL; | 1050 | return -EINVAL; |
1045 | 1051 | ||
1046 | if (atkbd->scroll != value) { | 1052 | if (atkbd->scroll != value) { |
1047 | /* unregister device as it's properties will change */ | 1053 | if (!(new_dev = input_allocate_device())) |
1048 | input_unregister_device(&atkbd->dev); | 1054 | return -ENOMEM; |
1055 | input_unregister_device(atkbd->dev); | ||
1056 | atkbd->dev = new_dev; | ||
1049 | atkbd->scroll = value; | 1057 | atkbd->scroll = value; |
1050 | atkbd_set_keycode_table(atkbd); | 1058 | atkbd_set_keycode_table(atkbd); |
1051 | atkbd_set_device_attrs(atkbd); | 1059 | atkbd_set_device_attrs(atkbd); |
1052 | input_register_device(&atkbd->dev); | 1060 | input_register_device(atkbd->dev); |
1053 | } | 1061 | } |
1054 | return count; | 1062 | return count; |
1055 | } | 1063 | } |
@@ -1061,6 +1069,7 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf) | |||
1061 | 1069 | ||
1062 | static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) | 1070 | static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) |
1063 | { | 1071 | { |
1072 | struct input_dev *new_dev; | ||
1064 | unsigned long value; | 1073 | unsigned long value; |
1065 | char *rest; | 1074 | char *rest; |
1066 | 1075 | ||
@@ -1072,13 +1081,15 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) | |||
1072 | return -EINVAL; | 1081 | return -EINVAL; |
1073 | 1082 | ||
1074 | if (atkbd->set != value) { | 1083 | if (atkbd->set != value) { |
1075 | /* unregister device as it's properties will change */ | 1084 | if (!(new_dev = input_allocate_device())) |
1076 | input_unregister_device(&atkbd->dev); | 1085 | return -ENOMEM; |
1086 | input_unregister_device(atkbd->dev); | ||
1087 | atkbd->dev = new_dev; | ||
1077 | atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); | 1088 | atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); |
1078 | atkbd_activate(atkbd); | 1089 | atkbd_activate(atkbd); |
1079 | atkbd_set_keycode_table(atkbd); | 1090 | atkbd_set_keycode_table(atkbd); |
1080 | atkbd_set_device_attrs(atkbd); | 1091 | atkbd_set_device_attrs(atkbd); |
1081 | input_register_device(&atkbd->dev); | 1092 | input_register_device(atkbd->dev); |
1082 | } | 1093 | } |
1083 | return count; | 1094 | return count; |
1084 | } | 1095 | } |
@@ -1090,6 +1101,7 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf) | |||
1090 | 1101 | ||
1091 | static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) | 1102 | static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) |
1092 | { | 1103 | { |
1104 | struct input_dev *new_dev; | ||
1093 | unsigned long value; | 1105 | unsigned long value; |
1094 | char *rest; | 1106 | char *rest; |
1095 | 1107 | ||
@@ -1101,15 +1113,16 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t | |||
1101 | return -EINVAL; | 1113 | return -EINVAL; |
1102 | 1114 | ||
1103 | if (atkbd->softrepeat != value) { | 1115 | if (atkbd->softrepeat != value) { |
1104 | /* unregister device as it's properties will change */ | 1116 | if (!(new_dev = input_allocate_device())) |
1105 | input_unregister_device(&atkbd->dev); | 1117 | return -ENOMEM; |
1118 | input_unregister_device(atkbd->dev); | ||
1119 | atkbd->dev = new_dev; | ||
1106 | atkbd->softrepeat = value; | 1120 | atkbd->softrepeat = value; |
1107 | if (atkbd->softrepeat) | 1121 | if (atkbd->softrepeat) |
1108 | atkbd->softraw = 1; | 1122 | atkbd->softraw = 1; |
1109 | atkbd_set_device_attrs(atkbd); | 1123 | atkbd_set_device_attrs(atkbd); |
1110 | input_register_device(&atkbd->dev); | 1124 | input_register_device(atkbd->dev); |
1111 | } | 1125 | } |
1112 | |||
1113 | return count; | 1126 | return count; |
1114 | } | 1127 | } |
1115 | 1128 | ||
@@ -1121,6 +1134,7 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf) | |||
1121 | 1134 | ||
1122 | static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) | 1135 | static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) |
1123 | { | 1136 | { |
1137 | struct input_dev *new_dev; | ||
1124 | unsigned long value; | 1138 | unsigned long value; |
1125 | char *rest; | 1139 | char *rest; |
1126 | 1140 | ||
@@ -1129,11 +1143,13 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co | |||
1129 | return -EINVAL; | 1143 | return -EINVAL; |
1130 | 1144 | ||
1131 | if (atkbd->softraw != value) { | 1145 | if (atkbd->softraw != value) { |
1132 | /* unregister device as it's properties will change */ | 1146 | if (!(new_dev = input_allocate_device())) |
1133 | input_unregister_device(&atkbd->dev); | 1147 | return -ENOMEM; |
1148 | input_unregister_device(atkbd->dev); | ||
1149 | atkbd->dev = new_dev; | ||
1134 | atkbd->softraw = value; | 1150 | atkbd->softraw = value; |
1135 | atkbd_set_device_attrs(atkbd); | 1151 | atkbd_set_device_attrs(atkbd); |
1136 | input_register_device(&atkbd->dev); | 1152 | input_register_device(atkbd->dev); |
1137 | } | 1153 | } |
1138 | return count; | 1154 | return count; |
1139 | } | 1155 | } |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index cd4b6e795013..3210d298b3bc 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -70,8 +70,7 @@ static unsigned char corgikbd_keycode[NR_SCANCODES] = { | |||
70 | 70 | ||
71 | struct corgikbd { | 71 | struct corgikbd { |
72 | unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; | 72 | unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; |
73 | struct input_dev input; | 73 | struct input_dev *input; |
74 | char phys[32]; | ||
75 | 74 | ||
76 | spinlock_t lock; | 75 | spinlock_t lock; |
77 | struct timer_list timer; | 76 | struct timer_list timer; |
@@ -147,7 +146,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs | |||
147 | spin_lock_irqsave(&corgikbd_data->lock, flags); | 146 | spin_lock_irqsave(&corgikbd_data->lock, flags); |
148 | 147 | ||
149 | if (regs) | 148 | if (regs) |
150 | input_regs(&corgikbd_data->input, regs); | 149 | input_regs(corgikbd_data->input, regs); |
151 | 150 | ||
152 | num_pressed = 0; | 151 | num_pressed = 0; |
153 | for (col = 0; col < KB_COLS; col++) { | 152 | for (col = 0; col < KB_COLS; col++) { |
@@ -169,14 +168,14 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs | |||
169 | scancode = SCANCODE(row, col); | 168 | scancode = SCANCODE(row, col); |
170 | pressed = rowd & KB_ROWMASK(row); | 169 | pressed = rowd & KB_ROWMASK(row); |
171 | 170 | ||
172 | input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); | 171 | input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); |
173 | 172 | ||
174 | if (pressed) | 173 | if (pressed) |
175 | num_pressed++; | 174 | num_pressed++; |
176 | 175 | ||
177 | if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) | 176 | if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) |
178 | && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { | 177 | && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { |
179 | input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); | 178 | input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); |
180 | corgikbd_data->suspend_jiffies=jiffies; | 179 | corgikbd_data->suspend_jiffies=jiffies; |
181 | } | 180 | } |
182 | } | 181 | } |
@@ -185,7 +184,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs | |||
185 | 184 | ||
186 | corgikbd_activate_all(); | 185 | corgikbd_activate_all(); |
187 | 186 | ||
188 | input_sync(&corgikbd_data->input); | 187 | input_sync(corgikbd_data->input); |
189 | 188 | ||
190 | /* if any keys are pressed, enable the timer */ | 189 | /* if any keys are pressed, enable the timer */ |
191 | if (num_pressed) | 190 | if (num_pressed) |
@@ -249,9 +248,9 @@ static void corgikbd_hinge_timer(unsigned long data) | |||
249 | if (hinge_count >= HINGE_STABLE_COUNT) { | 248 | if (hinge_count >= HINGE_STABLE_COUNT) { |
250 | spin_lock_irqsave(&corgikbd_data->lock, flags); | 249 | spin_lock_irqsave(&corgikbd_data->lock, flags); |
251 | 250 | ||
252 | input_report_switch(&corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); | 251 | input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); |
253 | input_report_switch(&corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); | 252 | input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); |
254 | input_sync(&corgikbd_data->input); | 253 | input_sync(corgikbd_data->input); |
255 | 254 | ||
256 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | 255 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); |
257 | } | 256 | } |
@@ -260,24 +259,22 @@ static void corgikbd_hinge_timer(unsigned long data) | |||
260 | } | 259 | } |
261 | 260 | ||
262 | #ifdef CONFIG_PM | 261 | #ifdef CONFIG_PM |
263 | static int corgikbd_suspend(struct device *dev, pm_message_t state, uint32_t level) | 262 | static int corgikbd_suspend(struct device *dev, pm_message_t state) |
264 | { | 263 | { |
265 | if (level == SUSPEND_POWER_DOWN) { | 264 | struct corgikbd *corgikbd = dev_get_drvdata(dev); |
266 | struct corgikbd *corgikbd = dev_get_drvdata(dev); | 265 | corgikbd->suspended = 1; |
267 | corgikbd->suspended = 1; | 266 | |
268 | } | ||
269 | return 0; | 267 | return 0; |
270 | } | 268 | } |
271 | 269 | ||
272 | static int corgikbd_resume(struct device *dev, uint32_t level) | 270 | static int corgikbd_resume(struct device *dev) |
273 | { | 271 | { |
274 | if (level == RESUME_POWER_ON) { | 272 | struct corgikbd *corgikbd = dev_get_drvdata(dev); |
275 | struct corgikbd *corgikbd = dev_get_drvdata(dev); | 273 | |
274 | /* Upon resume, ignore the suspend key for a short while */ | ||
275 | corgikbd->suspend_jiffies=jiffies; | ||
276 | corgikbd->suspended = 0; | ||
276 | 277 | ||
277 | /* Upon resume, ignore the suspend key for a short while */ | ||
278 | corgikbd->suspend_jiffies=jiffies; | ||
279 | corgikbd->suspended = 0; | ||
280 | } | ||
281 | return 0; | 278 | return 0; |
282 | } | 279 | } |
283 | #else | 280 | #else |
@@ -287,16 +284,21 @@ static int corgikbd_resume(struct device *dev, uint32_t level) | |||
287 | 284 | ||
288 | static int __init corgikbd_probe(struct device *dev) | 285 | static int __init corgikbd_probe(struct device *dev) |
289 | { | 286 | { |
290 | int i; | ||
291 | struct corgikbd *corgikbd; | 287 | struct corgikbd *corgikbd; |
288 | struct input_dev *input_dev; | ||
289 | int i; | ||
292 | 290 | ||
293 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); | 291 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); |
294 | if (!corgikbd) | 292 | input_dev = input_allocate_device(); |
293 | if (!corgikbd || !input_dev) { | ||
294 | kfree(corgikbd); | ||
295 | input_free_device(input_dev); | ||
295 | return -ENOMEM; | 296 | return -ENOMEM; |
297 | } | ||
296 | 298 | ||
297 | dev_set_drvdata(dev,corgikbd); | 299 | dev_set_drvdata(dev, corgikbd); |
298 | strcpy(corgikbd->phys, "corgikbd/input0"); | ||
299 | 300 | ||
301 | corgikbd->input = input_dev; | ||
300 | spin_lock_init(&corgikbd->lock); | 302 | spin_lock_init(&corgikbd->lock); |
301 | 303 | ||
302 | /* Init Keyboard rescan timer */ | 304 | /* Init Keyboard rescan timer */ |
@@ -311,28 +313,30 @@ static int __init corgikbd_probe(struct device *dev) | |||
311 | 313 | ||
312 | corgikbd->suspend_jiffies=jiffies; | 314 | corgikbd->suspend_jiffies=jiffies; |
313 | 315 | ||
314 | init_input_dev(&corgikbd->input); | ||
315 | corgikbd->input.private = corgikbd; | ||
316 | corgikbd->input.name = "Corgi Keyboard"; | ||
317 | corgikbd->input.dev = dev; | ||
318 | corgikbd->input.phys = corgikbd->phys; | ||
319 | corgikbd->input.id.bustype = BUS_HOST; | ||
320 | corgikbd->input.id.vendor = 0x0001; | ||
321 | corgikbd->input.id.product = 0x0001; | ||
322 | corgikbd->input.id.version = 0x0100; | ||
323 | corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | ||
324 | corgikbd->input.keycode = corgikbd->keycode; | ||
325 | corgikbd->input.keycodesize = sizeof(unsigned char); | ||
326 | corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode); | ||
327 | |||
328 | memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); | 316 | memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); |
317 | |||
318 | input_dev->name = "Corgi Keyboard"; | ||
319 | input_dev->phys = "corgikbd/input0"; | ||
320 | input_dev->id.bustype = BUS_HOST; | ||
321 | input_dev->id.vendor = 0x0001; | ||
322 | input_dev->id.product = 0x0001; | ||
323 | input_dev->id.version = 0x0100; | ||
324 | input_dev->cdev.dev = dev; | ||
325 | input_dev->private = corgikbd; | ||
326 | |||
327 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | ||
328 | input_dev->keycode = corgikbd->keycode; | ||
329 | input_dev->keycodesize = sizeof(unsigned char); | ||
330 | input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode); | ||
331 | |||
329 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) | 332 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) |
330 | set_bit(corgikbd->keycode[i], corgikbd->input.keybit); | 333 | set_bit(corgikbd->keycode[i], input_dev->keybit); |
331 | clear_bit(0, corgikbd->input.keybit); | 334 | clear_bit(0, input_dev->keybit); |
332 | set_bit(SW_0, corgikbd->input.swbit); | 335 | set_bit(SW_0, input_dev->swbit); |
333 | set_bit(SW_1, corgikbd->input.swbit); | 336 | set_bit(SW_1, input_dev->swbit); |
337 | |||
338 | input_register_device(corgikbd->input); | ||
334 | 339 | ||
335 | input_register_device(&corgikbd->input); | ||
336 | mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); | 340 | mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); |
337 | 341 | ||
338 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | 342 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ |
@@ -349,8 +353,6 @@ static int __init corgikbd_probe(struct device *dev) | |||
349 | for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) | 353 | for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) |
350 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); | 354 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); |
351 | 355 | ||
352 | printk(KERN_INFO "input: Corgi Keyboard Registered\n"); | ||
353 | |||
354 | return 0; | 356 | return 0; |
355 | } | 357 | } |
356 | 358 | ||
@@ -365,7 +367,7 @@ static int corgikbd_remove(struct device *dev) | |||
365 | del_timer_sync(&corgikbd->htimer); | 367 | del_timer_sync(&corgikbd->htimer); |
366 | del_timer_sync(&corgikbd->timer); | 368 | del_timer_sync(&corgikbd->timer); |
367 | 369 | ||
368 | input_unregister_device(&corgikbd->input); | 370 | input_unregister_device(corgikbd->input); |
369 | 371 | ||
370 | kfree(corgikbd); | 372 | kfree(corgikbd); |
371 | 373 | ||
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index ef78bffed5e7..0a90962c38e7 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -204,7 +204,7 @@ static irqreturn_t hil_kbd_interrupt(struct serio *serio, | |||
204 | hil_packet packet; | 204 | hil_packet packet; |
205 | int idx; | 205 | int idx; |
206 | 206 | ||
207 | kbd = (struct hil_kbd *)serio->private; | 207 | kbd = serio_get_drvdata(serio); |
208 | if (kbd == NULL) { | 208 | if (kbd == NULL) { |
209 | BUG(); | 209 | BUG(); |
210 | return IRQ_HANDLED; | 210 | return IRQ_HANDLED; |
@@ -234,7 +234,7 @@ static void hil_kbd_disconnect(struct serio *serio) | |||
234 | { | 234 | { |
235 | struct hil_kbd *kbd; | 235 | struct hil_kbd *kbd; |
236 | 236 | ||
237 | kbd = (struct hil_kbd *)serio->private; | 237 | kbd = serio_get_drvdata(serio); |
238 | if (kbd == NULL) { | 238 | if (kbd == NULL) { |
239 | BUG(); | 239 | BUG(); |
240 | return; | 240 | return; |
@@ -245,20 +245,20 @@ static void hil_kbd_disconnect(struct serio *serio) | |||
245 | kfree(kbd); | 245 | kfree(kbd); |
246 | } | 246 | } |
247 | 247 | ||
248 | static void hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | 248 | static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) |
249 | { | 249 | { |
250 | struct hil_kbd *kbd; | 250 | struct hil_kbd *kbd; |
251 | uint8_t did, *idd; | 251 | uint8_t did, *idd; |
252 | int i; | 252 | int i; |
253 | 253 | ||
254 | if (serio->type != (SERIO_HIL_MLC | SERIO_HIL)) return; | 254 | kbd = kmalloc(sizeof(*kbd), GFP_KERNEL); |
255 | 255 | if (!kbd) | |
256 | if (!(kbd = kmalloc(sizeof(struct hil_kbd), GFP_KERNEL))) return; | 256 | return -ENOMEM; |
257 | memset(kbd, 0, sizeof(struct hil_kbd)); | 257 | memset(kbd, 0, sizeof(struct hil_kbd)); |
258 | 258 | ||
259 | if (serio_open(serio, drv)) goto bail0; | 259 | if (serio_open(serio, drv)) goto bail0; |
260 | 260 | ||
261 | serio->private = kbd; | 261 | serio_set_drvdata(serio, kbd); |
262 | kbd->serio = serio; | 262 | kbd->serio = serio; |
263 | kbd->dev.private = kbd; | 263 | kbd->dev.private = kbd; |
264 | 264 | ||
@@ -342,19 +342,31 @@ static void hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
342 | down(&(kbd->sem)); | 342 | down(&(kbd->sem)); |
343 | up(&(kbd->sem)); | 343 | up(&(kbd->sem)); |
344 | 344 | ||
345 | return; | 345 | return 0; |
346 | bail1: | 346 | bail1: |
347 | serio_close(serio); | 347 | serio_close(serio); |
348 | bail0: | 348 | bail0: |
349 | kfree(kbd); | 349 | kfree(kbd); |
350 | serio_set_drvdata(serio, NULL); | ||
351 | return -EIO; | ||
350 | } | 352 | } |
351 | 353 | ||
354 | static struct serio_device_id hil_kbd_ids[] = { | ||
355 | { | ||
356 | .type = SERIO_HIL_MLC, | ||
357 | .proto = SERIO_HIL, | ||
358 | .id = SERIO_ANY, | ||
359 | .extra = SERIO_ANY, | ||
360 | }, | ||
361 | { 0 } | ||
362 | }; | ||
352 | 363 | ||
353 | struct serio_driver hil_kbd_serio_drv = { | 364 | struct serio_driver hil_kbd_serio_drv = { |
354 | .driver = { | 365 | .driver = { |
355 | .name = "hil_kbd", | 366 | .name = "hil_kbd", |
356 | }, | 367 | }, |
357 | .description = "HP HIL keyboard driver", | 368 | .description = "HP HIL keyboard driver", |
369 | .id_table = hil_kbd_ids, | ||
358 | .connect = hil_kbd_connect, | 370 | .connect = hil_kbd_connect, |
359 | .disconnect = hil_kbd_disconnect, | 371 | .disconnect = hil_kbd_disconnect, |
360 | .interrupt = hil_kbd_interrupt | 372 | .interrupt = hil_kbd_interrupt |
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index eecb77db0847..e95bc052e32a 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
23 | #include <linux/input.h> | 23 | #include <linux/input.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/irq.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/hil.h> | 26 | #include <linux/hil.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | 28 | ||
@@ -278,11 +278,11 @@ static int __init | |||
278 | hil_init_chip(struct parisc_device *dev) | 278 | hil_init_chip(struct parisc_device *dev) |
279 | { | 279 | { |
280 | if (!dev->irq) { | 280 | if (!dev->irq) { |
281 | printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%08lx\n", dev->hpa); | 281 | printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%08lx\n", dev->hpa.start); |
282 | return -ENODEV; | 282 | return -ENODEV; |
283 | } | 283 | } |
284 | 284 | ||
285 | hil_base = dev->hpa; | 285 | hil_base = dev->hpa.start; |
286 | hil_irq = dev->irq; | 286 | hil_irq = dev->irq; |
287 | hil_dev.dev_id = dev; | 287 | hil_dev.dev_id = dev; |
288 | 288 | ||
@@ -299,7 +299,7 @@ static struct parisc_device_id hil_tbl[] = { | |||
299 | MODULE_DEVICE_TABLE(parisc, hil_tbl); | 299 | MODULE_DEVICE_TABLE(parisc, hil_tbl); |
300 | 300 | ||
301 | static struct parisc_driver hil_driver = { | 301 | static struct parisc_driver hil_driver = { |
302 | .name = "HIL", | 302 | .name = "hil", |
303 | .id_table = hil_tbl, | 303 | .id_table = hil_tbl, |
304 | .probe = hil_init_chip, | 304 | .probe = hil_init_chip, |
305 | }; | 305 | }; |
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 098963c7cdd6..7f06780a437f 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c | |||
@@ -102,7 +102,7 @@ static int ctrlclick_volume = 100; /* % */ | |||
102 | module_param (ctrlclick_volume, int, 0); | 102 | module_param (ctrlclick_volume, int, 0); |
103 | MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%"); | 103 | MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%"); |
104 | 104 | ||
105 | static int lk201_compose_is_alt = 0; | 105 | static int lk201_compose_is_alt; |
106 | module_param (lk201_compose_is_alt, int, 0); | 106 | module_param (lk201_compose_is_alt, int, 0); |
107 | MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key " | 107 | MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key " |
108 | "will act as an Alt key"); | 108 | "will act as an Alt key"); |
@@ -274,7 +274,7 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = { | |||
274 | }; | 274 | }; |
275 | 275 | ||
276 | #define CHECK_LED(LED, BITS) do { \ | 276 | #define CHECK_LED(LED, BITS) do { \ |
277 | if (test_bit (LED, lk->dev.led)) \ | 277 | if (test_bit (LED, lk->dev->led)) \ |
278 | leds_on |= BITS; \ | 278 | leds_on |= BITS; \ |
279 | else \ | 279 | else \ |
280 | leds_off |= BITS; \ | 280 | leds_off |= BITS; \ |
@@ -287,7 +287,7 @@ struct lkkbd { | |||
287 | lk_keycode_t keycode[LK_NUM_KEYCODES]; | 287 | lk_keycode_t keycode[LK_NUM_KEYCODES]; |
288 | int ignore_bytes; | 288 | int ignore_bytes; |
289 | unsigned char id[LK_NUM_IGNORE_BYTES]; | 289 | unsigned char id[LK_NUM_IGNORE_BYTES]; |
290 | struct input_dev dev; | 290 | struct input_dev *dev; |
291 | struct serio *serio; | 291 | struct serio *serio; |
292 | struct work_struct tq; | 292 | struct work_struct tq; |
293 | char name[64]; | 293 | char name[64]; |
@@ -423,8 +423,7 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, | |||
423 | DBG (KERN_INFO "Got byte 0x%02x\n", data); | 423 | DBG (KERN_INFO "Got byte 0x%02x\n", data); |
424 | 424 | ||
425 | if (lk->ignore_bytes > 0) { | 425 | if (lk->ignore_bytes > 0) { |
426 | DBG (KERN_INFO "Ignoring a byte on %s\n", | 426 | DBG (KERN_INFO "Ignoring a byte on %s\n", lk->name); |
427 | lk->name); | ||
428 | lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; | 427 | lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; |
429 | 428 | ||
430 | if (lk->ignore_bytes == 0) | 429 | if (lk->ignore_bytes == 0) |
@@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, | |||
435 | 434 | ||
436 | switch (data) { | 435 | switch (data) { |
437 | case LK_ALL_KEYS_UP: | 436 | case LK_ALL_KEYS_UP: |
438 | input_regs (&lk->dev, regs); | 437 | input_regs (lk->dev, regs); |
439 | for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++) | 438 | for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++) |
440 | if (lk->keycode[i] != KEY_RESERVED) | 439 | if (lk->keycode[i] != KEY_RESERVED) |
441 | input_report_key (&lk->dev, lk->keycode[i], 0); | 440 | input_report_key (lk->dev, lk->keycode[i], 0); |
442 | input_sync (&lk->dev); | 441 | input_sync (lk->dev); |
443 | break; | 442 | break; |
444 | case LK_METRONOME: | 443 | case LK_METRONOME: |
445 | DBG (KERN_INFO "Got LK_METRONOME and don't " | 444 | DBG (KERN_INFO "Got %#d and don't " |
446 | "know how to handle...\n"); | 445 | "know how to handle...\n"); |
447 | break; | 446 | break; |
448 | case LK_OUTPUT_ERROR: | 447 | case LK_OUTPUT_ERROR: |
@@ -482,12 +481,12 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, | |||
482 | 481 | ||
483 | default: | 482 | default: |
484 | if (lk->keycode[data] != KEY_RESERVED) { | 483 | if (lk->keycode[data] != KEY_RESERVED) { |
485 | input_regs (&lk->dev, regs); | 484 | input_regs (lk->dev, regs); |
486 | if (!test_bit (lk->keycode[data], lk->dev.key)) | 485 | if (!test_bit (lk->keycode[data], lk->dev->key)) |
487 | input_report_key (&lk->dev, lk->keycode[data], 1); | 486 | input_report_key (lk->dev, lk->keycode[data], 1); |
488 | else | 487 | else |
489 | input_report_key (&lk->dev, lk->keycode[data], 0); | 488 | input_report_key (lk->dev, lk->keycode[data], 0); |
490 | input_sync (&lk->dev); | 489 | input_sync (lk->dev); |
491 | } else | 490 | } else |
492 | printk (KERN_WARNING "%s: Unknown key with " | 491 | printk (KERN_WARNING "%s: Unknown key with " |
493 | "scancode 0x%02x on %s.\n", | 492 | "scancode 0x%02x on %s.\n", |
@@ -605,7 +604,7 @@ lkkbd_reinit (void *data) | |||
605 | lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume)); | 604 | lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume)); |
606 | 605 | ||
607 | /* Enable/disable keyclick (and possibly set volume) */ | 606 | /* Enable/disable keyclick (and possibly set volume) */ |
608 | if (test_bit (SND_CLICK, lk->dev.snd)) { | 607 | if (test_bit (SND_CLICK, lk->dev->snd)) { |
609 | lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK); | 608 | lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK); |
610 | lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume)); | 609 | lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume)); |
611 | lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK); | 610 | lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK); |
@@ -616,7 +615,7 @@ lkkbd_reinit (void *data) | |||
616 | } | 615 | } |
617 | 616 | ||
618 | /* Sound the bell if needed */ | 617 | /* Sound the bell if needed */ |
619 | if (test_bit (SND_BELL, lk->dev.snd)) | 618 | if (test_bit (SND_BELL, lk->dev->snd)) |
620 | lk->serio->write (lk->serio, LK_CMD_SOUND_BELL); | 619 | lk->serio->write (lk->serio, LK_CMD_SOUND_BELL); |
621 | } | 620 | } |
622 | 621 | ||
@@ -627,71 +626,70 @@ static int | |||
627 | lkkbd_connect (struct serio *serio, struct serio_driver *drv) | 626 | lkkbd_connect (struct serio *serio, struct serio_driver *drv) |
628 | { | 627 | { |
629 | struct lkkbd *lk; | 628 | struct lkkbd *lk; |
629 | struct input_dev *input_dev; | ||
630 | int i; | 630 | int i; |
631 | int err; | 631 | int err; |
632 | 632 | ||
633 | if (!(lk = kmalloc (sizeof (struct lkkbd), GFP_KERNEL))) | 633 | lk = kzalloc (sizeof (struct lkkbd), GFP_KERNEL); |
634 | return -ENOMEM; | 634 | input_dev = input_allocate_device (); |
635 | 635 | if (!lk || !input_dev) { | |
636 | memset (lk, 0, sizeof (struct lkkbd)); | 636 | err = -ENOMEM; |
637 | 637 | goto fail; | |
638 | init_input_dev (&lk->dev); | 638 | } |
639 | set_bit (EV_KEY, lk->dev.evbit); | ||
640 | set_bit (EV_LED, lk->dev.evbit); | ||
641 | set_bit (EV_SND, lk->dev.evbit); | ||
642 | set_bit (EV_REP, lk->dev.evbit); | ||
643 | set_bit (LED_CAPSL, lk->dev.ledbit); | ||
644 | set_bit (LED_SLEEP, lk->dev.ledbit); | ||
645 | set_bit (LED_COMPOSE, lk->dev.ledbit); | ||
646 | set_bit (LED_SCROLLL, lk->dev.ledbit); | ||
647 | set_bit (SND_BELL, lk->dev.sndbit); | ||
648 | set_bit (SND_CLICK, lk->dev.sndbit); | ||
649 | 639 | ||
650 | lk->serio = serio; | 640 | lk->serio = serio; |
651 | 641 | lk->dev = input_dev; | |
652 | INIT_WORK (&lk->tq, lkkbd_reinit, lk); | 642 | INIT_WORK (&lk->tq, lkkbd_reinit, lk); |
653 | |||
654 | lk->bell_volume = bell_volume; | 643 | lk->bell_volume = bell_volume; |
655 | lk->keyclick_volume = keyclick_volume; | 644 | lk->keyclick_volume = keyclick_volume; |
656 | lk->ctrlclick_volume = ctrlclick_volume; | 645 | lk->ctrlclick_volume = ctrlclick_volume; |
646 | memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES); | ||
657 | 647 | ||
658 | lk->dev.keycode = lk->keycode; | 648 | strlcpy (lk->name, "DEC LK keyboard", sizeof(lk->name)); |
659 | lk->dev.keycodesize = sizeof (lk_keycode_t); | 649 | snprintf (lk->phys, sizeof(lk->phys), "%s/input0", serio->phys); |
660 | lk->dev.keycodemax = LK_NUM_KEYCODES; | 650 | |
661 | 651 | input_dev->name = lk->name; | |
662 | lk->dev.event = lkkbd_event; | 652 | input_dev->phys = lk->phys; |
663 | lk->dev.private = lk; | 653 | input_dev->id.bustype = BUS_RS232; |
654 | input_dev->id.vendor = SERIO_LKKBD; | ||
655 | input_dev->id.product = 0; | ||
656 | input_dev->id.version = 0x0100; | ||
657 | input_dev->cdev.dev = &serio->dev; | ||
658 | input_dev->event = lkkbd_event; | ||
659 | input_dev->private = lk; | ||
660 | |||
661 | set_bit (EV_KEY, input_dev->evbit); | ||
662 | set_bit (EV_LED, input_dev->evbit); | ||
663 | set_bit (EV_SND, input_dev->evbit); | ||
664 | set_bit (EV_REP, input_dev->evbit); | ||
665 | set_bit (LED_CAPSL, input_dev->ledbit); | ||
666 | set_bit (LED_SLEEP, input_dev->ledbit); | ||
667 | set_bit (LED_COMPOSE, input_dev->ledbit); | ||
668 | set_bit (LED_SCROLLL, input_dev->ledbit); | ||
669 | set_bit (SND_BELL, input_dev->sndbit); | ||
670 | set_bit (SND_CLICK, input_dev->sndbit); | ||
671 | |||
672 | input_dev->keycode = lk->keycode; | ||
673 | input_dev->keycodesize = sizeof (lk_keycode_t); | ||
674 | input_dev->keycodemax = LK_NUM_KEYCODES; | ||
675 | for (i = 0; i < LK_NUM_KEYCODES; i++) | ||
676 | set_bit (lk->keycode[i], input_dev->keybit); | ||
664 | 677 | ||
665 | serio_set_drvdata (serio, lk); | 678 | serio_set_drvdata (serio, lk); |
666 | 679 | ||
667 | err = serio_open (serio, drv); | 680 | err = serio_open (serio, drv); |
668 | if (err) { | 681 | if (err) |
669 | serio_set_drvdata (serio, NULL); | 682 | goto fail; |
670 | kfree (lk); | ||
671 | return err; | ||
672 | } | ||
673 | 683 | ||
674 | sprintf (lk->name, "DEC LK keyboard"); | 684 | input_register_device (lk->dev); |
675 | sprintf (lk->phys, "%s/input0", serio->phys); | ||
676 | |||
677 | memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES); | ||
678 | for (i = 0; i < LK_NUM_KEYCODES; i++) | ||
679 | set_bit (lk->keycode[i], lk->dev.keybit); | ||
680 | |||
681 | lk->dev.name = lk->name; | ||
682 | lk->dev.phys = lk->phys; | ||
683 | lk->dev.id.bustype = BUS_RS232; | ||
684 | lk->dev.id.vendor = SERIO_LKKBD; | ||
685 | lk->dev.id.product = 0; | ||
686 | lk->dev.id.version = 0x0100; | ||
687 | lk->dev.dev = &serio->dev; | ||
688 | |||
689 | input_register_device (&lk->dev); | ||
690 | |||
691 | printk (KERN_INFO "input: %s on %s, initiating reset\n", lk->name, serio->phys); | ||
692 | lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); | 685 | lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); |
693 | 686 | ||
694 | return 0; | 687 | return 0; |
688 | |||
689 | fail: serio_set_drvdata (serio, NULL); | ||
690 | input_free_device (input_dev); | ||
691 | kfree (lk); | ||
692 | return err; | ||
695 | } | 693 | } |
696 | 694 | ||
697 | /* | 695 | /* |
@@ -702,9 +700,11 @@ lkkbd_disconnect (struct serio *serio) | |||
702 | { | 700 | { |
703 | struct lkkbd *lk = serio_get_drvdata (serio); | 701 | struct lkkbd *lk = serio_get_drvdata (serio); |
704 | 702 | ||
705 | input_unregister_device (&lk->dev); | 703 | input_get_device (lk->dev); |
704 | input_unregister_device (lk->dev); | ||
706 | serio_close (serio); | 705 | serio_close (serio); |
707 | serio_set_drvdata (serio, NULL); | 706 | serio_set_drvdata (serio, NULL); |
707 | input_put_device (lk->dev); | ||
708 | kfree (lk); | 708 | kfree (lk); |
709 | } | 709 | } |
710 | 710 | ||
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index eecbde294f1f..cc6aaf9e85be 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c | |||
@@ -37,7 +37,7 @@ static unsigned char dc_kbd_keycode[256] = { | |||
37 | 37 | ||
38 | 38 | ||
39 | struct dc_kbd { | 39 | struct dc_kbd { |
40 | struct input_dev dev; | 40 | struct input_dev *dev; |
41 | unsigned char new[8]; | 41 | unsigned char new[8]; |
42 | unsigned char old[8]; | 42 | unsigned char old[8]; |
43 | }; | 43 | }; |
@@ -46,30 +46,24 @@ struct dc_kbd { | |||
46 | static void dc_scan_kbd(struct dc_kbd *kbd) | 46 | static void dc_scan_kbd(struct dc_kbd *kbd) |
47 | { | 47 | { |
48 | int i; | 48 | int i; |
49 | struct input_dev *dev = &kbd->dev; | 49 | struct input_dev *dev = kbd->dev; |
50 | 50 | ||
51 | for(i=0; i<8; i++) | 51 | for (i = 0; i < 8; i++) |
52 | input_report_key(dev, | 52 | input_report_key(dev, dc_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
53 | dc_kbd_keycode[i+224], | ||
54 | (kbd->new[0]>>i)&1); | ||
55 | 53 | ||
56 | for(i=2; i<8; i++) { | 54 | for (i = 2; i < 8; i++) { |
57 | 55 | ||
58 | if(kbd->old[i]>3&&memscan(kbd->new+2, kbd->old[i], 6)==NULL) { | 56 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == NULL) { |
59 | if(dc_kbd_keycode[kbd->old[i]]) | 57 | if (dc_kbd_keycode[kbd->old[i]]) |
60 | input_report_key(dev, | 58 | input_report_key(dev, dc_kbd_keycode[kbd->old[i]], 0); |
61 | dc_kbd_keycode[kbd->old[i]], | ||
62 | 0); | ||
63 | else | 59 | else |
64 | printk("Unknown key (scancode %#x) released.", | 60 | printk("Unknown key (scancode %#x) released.", |
65 | kbd->old[i]); | 61 | kbd->old[i]); |
66 | } | 62 | } |
67 | 63 | ||
68 | if(kbd->new[i]>3&&memscan(kbd->old+2, kbd->new[i], 6)!=NULL) { | 64 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) != NULL) { |
69 | if(dc_kbd_keycode[kbd->new[i]]) | 65 | if(dc_kbd_keycode[kbd->new[i]]) |
70 | input_report_key(dev, | 66 | input_report_key(dev, dc_kbd_keycode[kbd->new[i]], 1); |
71 | dc_kbd_keycode[kbd->new[i]], | ||
72 | 1); | ||
73 | else | 67 | else |
74 | printk("Unknown key (scancode %#x) pressed.", | 68 | printk("Unknown key (scancode %#x) pressed.", |
75 | kbd->new[i]); | 69 | kbd->new[i]); |
@@ -89,43 +83,39 @@ static void dc_kbd_callback(struct mapleq *mq) | |||
89 | unsigned long *buf = mq->recvbuf; | 83 | unsigned long *buf = mq->recvbuf; |
90 | 84 | ||
91 | if (buf[1] == mapledev->function) { | 85 | if (buf[1] == mapledev->function) { |
92 | memcpy(kbd->new, buf+2, 8); | 86 | memcpy(kbd->new, buf + 2, 8); |
93 | dc_scan_kbd(kbd); | 87 | dc_scan_kbd(kbd); |
94 | } | 88 | } |
95 | } | 89 | } |
96 | 90 | ||
97 | static int dc_kbd_connect(struct maple_device *dev) | 91 | static int dc_kbd_connect(struct maple_device *dev) |
98 | { | 92 | { |
99 | int i; | ||
100 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | ||
101 | struct dc_kbd *kbd; | 93 | struct dc_kbd *kbd; |
94 | struct input_dev *input_dev; | ||
95 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | ||
96 | int i; | ||
102 | 97 | ||
103 | if (!(kbd = kmalloc(sizeof(struct dc_kbd), GFP_KERNEL))) | 98 | dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); |
104 | return -1; | 99 | input_dev = input_allocate_device(); |
105 | memset(kbd, 0, sizeof(struct dc_kbd)); | 100 | if (!kbd || !input_dev) { |
106 | 101 | kfree(kbd); | |
107 | dev->private_data = kbd; | 102 | input_free_device(input_dev); |
108 | 103 | return -ENOMEM; | |
109 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 104 | } |
110 | |||
111 | init_input_dev(&kbd->dev); | ||
112 | |||
113 | for (i=0; i<255; i++) | ||
114 | set_bit(dc_kbd_keycode[i], kbd->dev.keybit); | ||
115 | |||
116 | clear_bit(0, kbd->dev.keybit); | ||
117 | 105 | ||
118 | kbd->dev.private = kbd; | 106 | kbd->dev = input_dev; |
119 | 107 | ||
120 | kbd->dev.name = dev->product_name; | 108 | input_dev->name = dev->product_name; |
121 | kbd->dev.id.bustype = BUS_MAPLE; | 109 | input_dev->id.bustype = BUS_MAPLE; |
110 | input_dev->private = kbd; | ||
111 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
112 | for (i = 0; i < 255; i++) | ||
113 | set_bit(dc_kbd_keycode[i], input_dev->keybit); | ||
114 | clear_bit(0, input_dev->keybit); | ||
122 | 115 | ||
123 | input_register_device(&kbd->dev); | 116 | input_register_device(kbd->dev); |
124 | 117 | ||
125 | maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); | 118 | maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); |
126 | |||
127 | printk(KERN_INFO "input: keyboard(0x%lx): %s\n", data, kbd->dev.name); | ||
128 | |||
129 | return 0; | 119 | return 0; |
130 | } | 120 | } |
131 | 121 | ||
@@ -134,7 +124,7 @@ static void dc_kbd_disconnect(struct maple_device *dev) | |||
134 | { | 124 | { |
135 | struct dc_kbd *kbd = dev->private_data; | 125 | struct dc_kbd *kbd = dev->private_data; |
136 | 126 | ||
137 | input_unregister_device(&kbd->dev); | 127 | input_unregister_device(kbd->dev); |
138 | kfree(kbd); | 128 | kfree(kbd); |
139 | } | 129 | } |
140 | 130 | ||
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 2e8ce1613eec..d10983c521e6 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c | |||
@@ -57,11 +57,9 @@ static unsigned char nkbd_keycode[128] = { | |||
57 | KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0 | 57 | KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0 |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static char *nkbd_name = "Newton Keyboard"; | ||
61 | |||
62 | struct nkbd { | 60 | struct nkbd { |
63 | unsigned char keycode[128]; | 61 | unsigned char keycode[128]; |
64 | struct input_dev dev; | 62 | struct input_dev *dev; |
65 | struct serio *serio; | 63 | struct serio *serio; |
66 | char phys[32]; | 64 | char phys[32]; |
67 | }; | 65 | }; |
@@ -73,13 +71,13 @@ static irqreturn_t nkbd_interrupt(struct serio *serio, | |||
73 | 71 | ||
74 | /* invalid scan codes are probably the init sequence, so we ignore them */ | 72 | /* invalid scan codes are probably the init sequence, so we ignore them */ |
75 | if (nkbd->keycode[data & NKBD_KEY]) { | 73 | if (nkbd->keycode[data & NKBD_KEY]) { |
76 | input_regs(&nkbd->dev, regs); | 74 | input_regs(nkbd->dev, regs); |
77 | input_report_key(&nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS); | 75 | input_report_key(nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS); |
78 | input_sync(&nkbd->dev); | 76 | input_sync(nkbd->dev); |
79 | } | 77 | } |
80 | 78 | ||
81 | else if (data == 0xe7) /* end of init sequence */ | 79 | else if (data == 0xe7) /* end of init sequence */ |
82 | printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys); | 80 | printk(KERN_INFO "input: %s on %s\n", nkbd->dev->name, serio->phys); |
83 | return IRQ_HANDLED; | 81 | return IRQ_HANDLED; |
84 | 82 | ||
85 | } | 83 | } |
@@ -87,62 +85,59 @@ static irqreturn_t nkbd_interrupt(struct serio *serio, | |||
87 | static int nkbd_connect(struct serio *serio, struct serio_driver *drv) | 85 | static int nkbd_connect(struct serio *serio, struct serio_driver *drv) |
88 | { | 86 | { |
89 | struct nkbd *nkbd; | 87 | struct nkbd *nkbd; |
88 | struct input_dev *input_dev; | ||
89 | int err = -ENOMEM; | ||
90 | int i; | 90 | int i; |
91 | int err; | ||
92 | |||
93 | if (!(nkbd = kmalloc(sizeof(struct nkbd), GFP_KERNEL))) | ||
94 | return -ENOMEM; | ||
95 | |||
96 | memset(nkbd, 0, sizeof(struct nkbd)); | ||
97 | 91 | ||
98 | nkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 92 | nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); |
93 | input_dev = input_allocate_device(); | ||
94 | if (!nkbd || !input_dev) | ||
95 | goto fail; | ||
99 | 96 | ||
100 | nkbd->serio = serio; | 97 | nkbd->serio = serio; |
98 | nkbd->dev = input_dev; | ||
99 | sprintf(nkbd->phys, "%s/input0", serio->phys); | ||
100 | memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode)); | ||
101 | 101 | ||
102 | init_input_dev(&nkbd->dev); | 102 | input_dev->name = "Newton Keyboard"; |
103 | nkbd->dev.keycode = nkbd->keycode; | 103 | input_dev->phys = nkbd->phys; |
104 | nkbd->dev.keycodesize = sizeof(unsigned char); | 104 | input_dev->id.bustype = BUS_RS232; |
105 | nkbd->dev.keycodemax = ARRAY_SIZE(nkbd_keycode); | 105 | input_dev->id.vendor = SERIO_NEWTON; |
106 | nkbd->dev.private = nkbd; | 106 | input_dev->id.product = 0x0001; |
107 | input_dev->id.version = 0x0100; | ||
108 | input_dev->cdev.dev = &serio->dev; | ||
109 | input_dev->private = nkbd; | ||
110 | |||
111 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
112 | input_dev->keycode = nkbd->keycode; | ||
113 | input_dev->keycodesize = sizeof(unsigned char); | ||
114 | input_dev->keycodemax = ARRAY_SIZE(nkbd_keycode); | ||
115 | for (i = 0; i < 128; i++) | ||
116 | set_bit(nkbd->keycode[i], input_dev->keybit); | ||
117 | clear_bit(0, input_dev->keybit); | ||
107 | 118 | ||
108 | serio_set_drvdata(serio, nkbd); | 119 | serio_set_drvdata(serio, nkbd); |
109 | 120 | ||
110 | err = serio_open(serio, drv); | 121 | err = serio_open(serio, drv); |
111 | if (err) { | 122 | if (err) |
112 | serio_set_drvdata(serio, NULL); | 123 | goto fail; |
113 | kfree(nkbd); | ||
114 | return err; | ||
115 | } | ||
116 | |||
117 | memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode)); | ||
118 | for (i = 0; i < 128; i++) | ||
119 | set_bit(nkbd->keycode[i], nkbd->dev.keybit); | ||
120 | clear_bit(0, nkbd->dev.keybit); | ||
121 | |||
122 | sprintf(nkbd->phys, "%s/input0", serio->phys); | ||
123 | |||
124 | nkbd->dev.name = nkbd_name; | ||
125 | nkbd->dev.phys = nkbd->phys; | ||
126 | nkbd->dev.id.bustype = BUS_RS232; | ||
127 | nkbd->dev.id.vendor = SERIO_NEWTON; | ||
128 | nkbd->dev.id.product = 0x0001; | ||
129 | nkbd->dev.id.version = 0x0100; | ||
130 | nkbd->dev.dev = &serio->dev; | ||
131 | |||
132 | input_register_device(&nkbd->dev); | ||
133 | |||
134 | printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys); | ||
135 | 124 | ||
125 | input_register_device(nkbd->dev); | ||
136 | return 0; | 126 | return 0; |
127 | |||
128 | fail: serio_set_drvdata(serio, NULL); | ||
129 | input_free_device(input_dev); | ||
130 | kfree(nkbd); | ||
131 | return err; | ||
137 | } | 132 | } |
138 | 133 | ||
139 | static void nkbd_disconnect(struct serio *serio) | 134 | static void nkbd_disconnect(struct serio *serio) |
140 | { | 135 | { |
141 | struct nkbd *nkbd = serio_get_drvdata(serio); | 136 | struct nkbd *nkbd = serio_get_drvdata(serio); |
142 | 137 | ||
143 | input_unregister_device(&nkbd->dev); | ||
144 | serio_close(serio); | 138 | serio_close(serio); |
145 | serio_set_drvdata(serio, NULL); | 139 | serio_set_drvdata(serio, NULL); |
140 | input_unregister_device(nkbd->dev); | ||
146 | kfree(nkbd); | 141 | kfree(nkbd); |
147 | } | 142 | } |
148 | 143 | ||
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 344f46005401..cee9c734a048 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -85,7 +85,7 @@ static int spitz_senses[] = { | |||
85 | 85 | ||
86 | struct spitzkbd { | 86 | struct spitzkbd { |
87 | unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; | 87 | unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; |
88 | struct input_dev input; | 88 | struct input_dev *input; |
89 | char phys[32]; | 89 | char phys[32]; |
90 | 90 | ||
91 | spinlock_t lock; | 91 | spinlock_t lock; |
@@ -187,8 +187,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs | |||
187 | 187 | ||
188 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | 188 | spin_lock_irqsave(&spitzkbd_data->lock, flags); |
189 | 189 | ||
190 | if (regs) | 190 | input_regs(spitzkbd_data->input, regs); |
191 | input_regs(&spitzkbd_data->input, regs); | ||
192 | 191 | ||
193 | num_pressed = 0; | 192 | num_pressed = 0; |
194 | for (col = 0; col < KB_COLS; col++) { | 193 | for (col = 0; col < KB_COLS; col++) { |
@@ -210,7 +209,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs | |||
210 | scancode = SCANCODE(row, col); | 209 | scancode = SCANCODE(row, col); |
211 | pressed = rowd & KB_ROWMASK(row); | 210 | pressed = rowd & KB_ROWMASK(row); |
212 | 211 | ||
213 | input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); | 212 | input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); |
214 | 213 | ||
215 | if (pressed) | 214 | if (pressed) |
216 | num_pressed++; | 215 | num_pressed++; |
@@ -220,15 +219,15 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs | |||
220 | 219 | ||
221 | spitzkbd_activate_all(); | 220 | spitzkbd_activate_all(); |
222 | 221 | ||
223 | input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); | 222 | input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); |
224 | input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey); | 223 | input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey); |
225 | 224 | ||
226 | if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { | 225 | if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { |
227 | input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); | 226 | input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); |
228 | spitzkbd_data->suspend_jiffies = jiffies; | 227 | spitzkbd_data->suspend_jiffies = jiffies; |
229 | } | 228 | } |
230 | 229 | ||
231 | input_sync(&spitzkbd_data->input); | 230 | input_sync(spitzkbd_data->input); |
232 | 231 | ||
233 | /* if any keys are pressed, enable the timer */ | 232 | /* if any keys are pressed, enable the timer */ |
234 | if (num_pressed) | 233 | if (num_pressed) |
@@ -259,6 +258,7 @@ static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *reg | |||
259 | static void spitzkbd_timer_callback(unsigned long data) | 258 | static void spitzkbd_timer_callback(unsigned long data) |
260 | { | 259 | { |
261 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; | 260 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; |
261 | |||
262 | spitzkbd_scankeyboard(spitzkbd_data, NULL); | 262 | spitzkbd_scankeyboard(spitzkbd_data, NULL); |
263 | } | 263 | } |
264 | 264 | ||
@@ -298,9 +298,9 @@ static void spitzkbd_hinge_timer(unsigned long data) | |||
298 | if (hinge_count >= HINGE_STABLE_COUNT) { | 298 | if (hinge_count >= HINGE_STABLE_COUNT) { |
299 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | 299 | spin_lock_irqsave(&spitzkbd_data->lock, flags); |
300 | 300 | ||
301 | input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); | 301 | input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); |
302 | input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); | 302 | input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); |
303 | input_sync(&spitzkbd_data->input); | 303 | input_sync(spitzkbd_data->input); |
304 | 304 | ||
305 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); | 305 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); |
306 | } else { | 306 | } else { |
@@ -309,34 +309,32 @@ static void spitzkbd_hinge_timer(unsigned long data) | |||
309 | } | 309 | } |
310 | 310 | ||
311 | #ifdef CONFIG_PM | 311 | #ifdef CONFIG_PM |
312 | static int spitzkbd_suspend(struct device *dev, pm_message_t state, uint32_t level) | 312 | static int spitzkbd_suspend(struct device *dev, pm_message_t state) |
313 | { | 313 | { |
314 | if (level == SUSPEND_POWER_DOWN) { | 314 | int i; |
315 | int i; | 315 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); |
316 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); | 316 | spitzkbd->suspended = 1; |
317 | spitzkbd->suspended = 1; | 317 | |
318 | 318 | /* Set Strobe lines as inputs - *except* strobe line 0 leave this | |
319 | /* Set Strobe lines as inputs - *except* strobe line 0 leave this | 319 | enabled so we can detect a power button press for resume */ |
320 | enabled so we can detect a power button press for resume */ | 320 | for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++) |
321 | for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++) | 321 | pxa_gpio_mode(spitz_strobes[i] | GPIO_IN); |
322 | pxa_gpio_mode(spitz_strobes[i] | GPIO_IN); | 322 | |
323 | } | ||
324 | return 0; | 323 | return 0; |
325 | } | 324 | } |
326 | 325 | ||
327 | static int spitzkbd_resume(struct device *dev, uint32_t level) | 326 | static int spitzkbd_resume(struct device *dev) |
328 | { | 327 | { |
329 | if (level == RESUME_POWER_ON) { | 328 | int i; |
330 | int i; | 329 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); |
331 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); | ||
332 | 330 | ||
333 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) | 331 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) |
334 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); | 332 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); |
333 | |||
334 | /* Upon resume, ignore the suspend key for a short while */ | ||
335 | spitzkbd->suspend_jiffies = jiffies; | ||
336 | spitzkbd->suspended = 0; | ||
335 | 337 | ||
336 | /* Upon resume, ignore the suspend key for a short while */ | ||
337 | spitzkbd->suspend_jiffies = jiffies; | ||
338 | spitzkbd->suspended = 0; | ||
339 | } | ||
340 | return 0; | 338 | return 0; |
341 | } | 339 | } |
342 | #else | 340 | #else |
@@ -346,14 +344,21 @@ static int spitzkbd_resume(struct device *dev, uint32_t level) | |||
346 | 344 | ||
347 | static int __init spitzkbd_probe(struct device *dev) | 345 | static int __init spitzkbd_probe(struct device *dev) |
348 | { | 346 | { |
349 | int i; | ||
350 | struct spitzkbd *spitzkbd; | 347 | struct spitzkbd *spitzkbd; |
348 | struct input_dev *input_dev; | ||
349 | int i; | ||
351 | 350 | ||
352 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); | 351 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); |
353 | if (!spitzkbd) | 352 | if (!spitzkbd) |
354 | return -ENOMEM; | 353 | return -ENOMEM; |
355 | 354 | ||
356 | dev_set_drvdata(dev,spitzkbd); | 355 | input_dev = input_allocate_device(); |
356 | if (!input_dev) { | ||
357 | kfree(spitzkbd); | ||
358 | return -ENOMEM; | ||
359 | } | ||
360 | |||
361 | dev_set_drvdata(dev, spitzkbd); | ||
357 | strcpy(spitzkbd->phys, "spitzkbd/input0"); | 362 | strcpy(spitzkbd->phys, "spitzkbd/input0"); |
358 | 363 | ||
359 | spin_lock_init(&spitzkbd->lock); | 364 | spin_lock_init(&spitzkbd->lock); |
@@ -368,30 +373,34 @@ static int __init spitzkbd_probe(struct device *dev) | |||
368 | spitzkbd->htimer.function = spitzkbd_hinge_timer; | 373 | spitzkbd->htimer.function = spitzkbd_hinge_timer; |
369 | spitzkbd->htimer.data = (unsigned long) spitzkbd; | 374 | spitzkbd->htimer.data = (unsigned long) spitzkbd; |
370 | 375 | ||
371 | spitzkbd->suspend_jiffies=jiffies; | 376 | spitzkbd->suspend_jiffies = jiffies; |
372 | 377 | ||
373 | init_input_dev(&spitzkbd->input); | 378 | spitzkbd->input = input_dev; |
374 | spitzkbd->input.private = spitzkbd; | 379 | |
375 | spitzkbd->input.name = "Spitz Keyboard"; | 380 | input_dev->private = spitzkbd; |
376 | spitzkbd->input.dev = dev; | 381 | input_dev->name = "Spitz Keyboard"; |
377 | spitzkbd->input.phys = spitzkbd->phys; | 382 | input_dev->phys = spitzkbd->phys; |
378 | spitzkbd->input.id.bustype = BUS_HOST; | 383 | input_dev->cdev.dev = dev; |
379 | spitzkbd->input.id.vendor = 0x0001; | 384 | |
380 | spitzkbd->input.id.product = 0x0001; | 385 | input_dev->id.bustype = BUS_HOST; |
381 | spitzkbd->input.id.version = 0x0100; | 386 | input_dev->id.vendor = 0x0001; |
382 | spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | 387 | input_dev->id.product = 0x0001; |
383 | spitzkbd->input.keycode = spitzkbd->keycode; | 388 | input_dev->id.version = 0x0100; |
384 | spitzkbd->input.keycodesize = sizeof(unsigned char); | 389 | |
385 | spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode); | 390 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); |
391 | input_dev->keycode = spitzkbd->keycode; | ||
392 | input_dev->keycodesize = sizeof(unsigned char); | ||
393 | input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode); | ||
386 | 394 | ||
387 | memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); | 395 | memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); |
388 | for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) | 396 | for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) |
389 | set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit); | 397 | set_bit(spitzkbd->keycode[i], input_dev->keybit); |
390 | clear_bit(0, spitzkbd->input.keybit); | 398 | clear_bit(0, input_dev->keybit); |
391 | set_bit(SW_0, spitzkbd->input.swbit); | 399 | set_bit(SW_0, input_dev->swbit); |
392 | set_bit(SW_1, spitzkbd->input.swbit); | 400 | set_bit(SW_1, input_dev->swbit); |
401 | |||
402 | input_register_device(input_dev); | ||
393 | 403 | ||
394 | input_register_device(&spitzkbd->input); | ||
395 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | 404 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); |
396 | 405 | ||
397 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | 406 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ |
@@ -444,7 +453,7 @@ static int spitzkbd_remove(struct device *dev) | |||
444 | del_timer_sync(&spitzkbd->htimer); | 453 | del_timer_sync(&spitzkbd->htimer); |
445 | del_timer_sync(&spitzkbd->timer); | 454 | del_timer_sync(&spitzkbd->timer); |
446 | 455 | ||
447 | input_unregister_device(&spitzkbd->input); | 456 | input_unregister_device(spitzkbd->input); |
448 | 457 | ||
449 | kfree(spitzkbd); | 458 | kfree(spitzkbd); |
450 | 459 | ||
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 4bae5d89348d..b15b6d8d4f83 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -76,13 +76,14 @@ static unsigned char sunkbd_keycode[128] = { | |||
76 | 76 | ||
77 | struct sunkbd { | 77 | struct sunkbd { |
78 | unsigned char keycode[128]; | 78 | unsigned char keycode[128]; |
79 | struct input_dev dev; | 79 | struct input_dev *dev; |
80 | struct serio *serio; | 80 | struct serio *serio; |
81 | struct work_struct tq; | 81 | struct work_struct tq; |
82 | wait_queue_head_t wait; | 82 | wait_queue_head_t wait; |
83 | char name[64]; | 83 | char name[64]; |
84 | char phys[32]; | 84 | char phys[32]; |
85 | char type; | 85 | char type; |
86 | unsigned char enabled; | ||
86 | volatile s8 reset; | 87 | volatile s8 reset; |
87 | volatile s8 layout; | 88 | volatile s8 layout; |
88 | }; | 89 | }; |
@@ -124,10 +125,13 @@ static irqreturn_t sunkbd_interrupt(struct serio *serio, | |||
124 | break; | 125 | break; |
125 | 126 | ||
126 | default: | 127 | default: |
128 | if (!sunkbd->enabled) | ||
129 | break; | ||
130 | |||
127 | if (sunkbd->keycode[data & SUNKBD_KEY]) { | 131 | if (sunkbd->keycode[data & SUNKBD_KEY]) { |
128 | input_regs(&sunkbd->dev, regs); | 132 | input_regs(sunkbd->dev, regs); |
129 | input_report_key(&sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); | 133 | input_report_key(sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); |
130 | input_sync(&sunkbd->dev); | 134 | input_sync(sunkbd->dev); |
131 | } else { | 135 | } else { |
132 | printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n", | 136 | printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n", |
133 | data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed"); | 137 | data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed"); |
@@ -184,7 +188,7 @@ static int sunkbd_initialize(struct sunkbd *sunkbd) | |||
184 | sunkbd->reset = -2; | 188 | sunkbd->reset = -2; |
185 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET); | 189 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET); |
186 | wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); | 190 | wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); |
187 | if (sunkbd->reset <0) | 191 | if (sunkbd->reset < 0) |
188 | return -1; | 192 | return -1; |
189 | 193 | ||
190 | sunkbd->type = sunkbd->reset; | 194 | sunkbd->type = sunkbd->reset; |
@@ -213,10 +217,17 @@ static void sunkbd_reinit(void *data) | |||
213 | 217 | ||
214 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED); | 218 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED); |
215 | sunkbd->serio->write(sunkbd->serio, | 219 | sunkbd->serio->write(sunkbd->serio, |
216 | (!!test_bit(LED_CAPSL, sunkbd->dev.led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev.led) << 2) | | 220 | (!!test_bit(LED_CAPSL, sunkbd->dev->led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) | |
217 | (!!test_bit(LED_COMPOSE, sunkbd->dev.led) << 1) | !!test_bit(LED_NUML, sunkbd->dev.led)); | 221 | (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | !!test_bit(LED_NUML, sunkbd->dev->led)); |
218 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev.snd)); | 222 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd)); |
219 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev.snd)); | 223 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd)); |
224 | } | ||
225 | |||
226 | static void sunkbd_enable(struct sunkbd *sunkbd, int enable) | ||
227 | { | ||
228 | serio_pause_rx(sunkbd->serio); | ||
229 | sunkbd->enabled = 1; | ||
230 | serio_continue_rx(sunkbd->serio); | ||
220 | } | 231 | } |
221 | 232 | ||
222 | /* | 233 | /* |
@@ -226,70 +237,64 @@ static void sunkbd_reinit(void *data) | |||
226 | static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | 237 | static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) |
227 | { | 238 | { |
228 | struct sunkbd *sunkbd; | 239 | struct sunkbd *sunkbd; |
240 | struct input_dev *input_dev; | ||
241 | int err = -ENOMEM; | ||
229 | int i; | 242 | int i; |
230 | int err; | ||
231 | |||
232 | if (!(sunkbd = kmalloc(sizeof(struct sunkbd), GFP_KERNEL))) | ||
233 | return -ENOMEM; | ||
234 | 243 | ||
235 | memset(sunkbd, 0, sizeof(struct sunkbd)); | 244 | sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); |
236 | 245 | input_dev = input_allocate_device(); | |
237 | init_input_dev(&sunkbd->dev); | 246 | if (!sunkbd || !input_dev) |
238 | init_waitqueue_head(&sunkbd->wait); | 247 | goto fail; |
239 | |||
240 | sunkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP); | ||
241 | sunkbd->dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML); | ||
242 | sunkbd->dev.sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL); | ||
243 | 248 | ||
244 | sunkbd->serio = serio; | 249 | sunkbd->serio = serio; |
245 | 250 | sunkbd->dev = input_dev; | |
251 | init_waitqueue_head(&sunkbd->wait); | ||
246 | INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); | 252 | INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); |
247 | 253 | snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); | |
248 | sunkbd->dev.keycode = sunkbd->keycode; | ||
249 | sunkbd->dev.keycodesize = sizeof(unsigned char); | ||
250 | sunkbd->dev.keycodemax = ARRAY_SIZE(sunkbd_keycode); | ||
251 | |||
252 | sunkbd->dev.event = sunkbd_event; | ||
253 | sunkbd->dev.private = sunkbd; | ||
254 | 254 | ||
255 | serio_set_drvdata(serio, sunkbd); | 255 | serio_set_drvdata(serio, sunkbd); |
256 | 256 | ||
257 | err = serio_open(serio, drv); | 257 | err = serio_open(serio, drv); |
258 | if (err) { | 258 | if (err) |
259 | serio_set_drvdata(serio, NULL); | 259 | goto fail; |
260 | kfree(sunkbd); | ||
261 | return err; | ||
262 | } | ||
263 | 260 | ||
264 | if (sunkbd_initialize(sunkbd) < 0) { | 261 | if (sunkbd_initialize(sunkbd) < 0) { |
265 | serio_close(serio); | 262 | serio_close(serio); |
266 | serio_set_drvdata(serio, NULL); | 263 | goto fail; |
267 | kfree(sunkbd); | ||
268 | return -ENODEV; | ||
269 | } | 264 | } |
270 | 265 | ||
271 | sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type); | 266 | sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type); |
272 | |||
273 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); | 267 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); |
274 | for (i = 0; i < 128; i++) | ||
275 | set_bit(sunkbd->keycode[i], sunkbd->dev.keybit); | ||
276 | clear_bit(0, sunkbd->dev.keybit); | ||
277 | |||
278 | sprintf(sunkbd->phys, "%s/input0", serio->phys); | ||
279 | |||
280 | sunkbd->dev.name = sunkbd->name; | ||
281 | sunkbd->dev.phys = sunkbd->phys; | ||
282 | sunkbd->dev.id.bustype = BUS_RS232; | ||
283 | sunkbd->dev.id.vendor = SERIO_SUNKBD; | ||
284 | sunkbd->dev.id.product = sunkbd->type; | ||
285 | sunkbd->dev.id.version = 0x0100; | ||
286 | sunkbd->dev.dev = &serio->dev; | ||
287 | 268 | ||
288 | input_register_device(&sunkbd->dev); | 269 | input_dev->name = sunkbd->name; |
289 | 270 | input_dev->phys = sunkbd->phys; | |
290 | printk(KERN_INFO "input: %s on %s\n", sunkbd->name, serio->phys); | 271 | input_dev->id.bustype = BUS_RS232; |
272 | input_dev->id.vendor = SERIO_SUNKBD; | ||
273 | input_dev->id.product = sunkbd->type; | ||
274 | input_dev->id.version = 0x0100; | ||
275 | input_dev->cdev.dev = &serio->dev; | ||
276 | input_dev->private = sunkbd; | ||
277 | input_dev->event = sunkbd_event; | ||
278 | |||
279 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP); | ||
280 | input_dev->ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML); | ||
281 | input_dev->sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL); | ||
282 | |||
283 | input_dev->keycode = sunkbd->keycode; | ||
284 | input_dev->keycodesize = sizeof(unsigned char); | ||
285 | input_dev->keycodemax = ARRAY_SIZE(sunkbd_keycode); | ||
286 | for (i = 0; i < 128; i++) | ||
287 | set_bit(sunkbd->keycode[i], input_dev->keybit); | ||
288 | clear_bit(0, input_dev->keybit); | ||
291 | 289 | ||
290 | sunkbd_enable(sunkbd, 1); | ||
291 | input_register_device(sunkbd->dev); | ||
292 | return 0; | 292 | return 0; |
293 | |||
294 | fail: serio_set_drvdata(serio, NULL); | ||
295 | input_free_device(input_dev); | ||
296 | kfree(sunkbd); | ||
297 | return err; | ||
293 | } | 298 | } |
294 | 299 | ||
295 | /* | 300 | /* |
@@ -299,7 +304,9 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
299 | static void sunkbd_disconnect(struct serio *serio) | 304 | static void sunkbd_disconnect(struct serio *serio) |
300 | { | 305 | { |
301 | struct sunkbd *sunkbd = serio_get_drvdata(serio); | 306 | struct sunkbd *sunkbd = serio_get_drvdata(serio); |
302 | input_unregister_device(&sunkbd->dev); | 307 | |
308 | sunkbd_enable(sunkbd, 0); | ||
309 | input_unregister_device(sunkbd->dev); | ||
303 | serio_close(serio); | 310 | serio_close(serio); |
304 | serio_set_drvdata(serio, NULL); | 311 | serio_set_drvdata(serio, NULL); |
305 | kfree(sunkbd); | 312 | kfree(sunkbd); |
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 19eaec7789d1..4135e3e16c51 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c | |||
@@ -56,11 +56,9 @@ static unsigned char xtkbd_keycode[256] = { | |||
56 | 106 | 56 | 106 |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static char *xtkbd_name = "XT Keyboard"; | ||
60 | |||
61 | struct xtkbd { | 59 | struct xtkbd { |
62 | unsigned char keycode[256]; | 60 | unsigned char keycode[256]; |
63 | struct input_dev dev; | 61 | struct input_dev *dev; |
64 | struct serio *serio; | 62 | struct serio *serio; |
65 | char phys[32]; | 63 | char phys[32]; |
66 | }; | 64 | }; |
@@ -77,9 +75,9 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio, | |||
77 | default: | 75 | default: |
78 | 76 | ||
79 | if (xtkbd->keycode[data & XTKBD_KEY]) { | 77 | if (xtkbd->keycode[data & XTKBD_KEY]) { |
80 | input_regs(&xtkbd->dev, regs); | 78 | input_regs(xtkbd->dev, regs); |
81 | input_report_key(&xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); | 79 | input_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); |
82 | input_sync(&xtkbd->dev); | 80 | input_sync(xtkbd->dev); |
83 | } else { | 81 | } else { |
84 | printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n", | 82 | printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n", |
85 | data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed"); | 83 | data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed"); |
@@ -91,62 +89,60 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio, | |||
91 | static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) | 89 | static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) |
92 | { | 90 | { |
93 | struct xtkbd *xtkbd; | 91 | struct xtkbd *xtkbd; |
92 | struct input_dev *input_dev; | ||
93 | int err = -ENOMEM; | ||
94 | int i; | 94 | int i; |
95 | int err; | ||
96 | |||
97 | if (!(xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL))) | ||
98 | return -ENOMEM; | ||
99 | |||
100 | memset(xtkbd, 0, sizeof(struct xtkbd)); | ||
101 | 95 | ||
102 | xtkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 96 | xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); |
97 | input_dev = input_allocate_device(); | ||
98 | if (!xtkbd || !input_dev) | ||
99 | goto fail; | ||
103 | 100 | ||
104 | xtkbd->serio = serio; | 101 | xtkbd->serio = serio; |
102 | xtkbd->dev = input_dev; | ||
103 | sprintf(xtkbd->phys, "%s/input0", serio->phys); | ||
104 | memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode)); | ||
105 | 105 | ||
106 | init_input_dev(&xtkbd->dev); | 106 | input_dev->name = "XT Keyboard"; |
107 | xtkbd->dev.keycode = xtkbd->keycode; | 107 | input_dev->phys = xtkbd->phys; |
108 | xtkbd->dev.keycodesize = sizeof(unsigned char); | 108 | input_dev->id.bustype = BUS_XTKBD; |
109 | xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode); | 109 | input_dev->id.vendor = 0x0001; |
110 | xtkbd->dev.private = xtkbd; | 110 | input_dev->id.product = 0x0001; |
111 | 111 | input_dev->id.version = 0x0100; | |
112 | serio_set_drvdata(serio, xtkbd); | 112 | input_dev->cdev.dev = &serio->dev; |
113 | input_dev->private = xtkbd; | ||
113 | 114 | ||
114 | err = serio_open(serio, drv); | 115 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
115 | if (err) { | 116 | input_dev->keycode = xtkbd->keycode; |
116 | serio_set_drvdata(serio, NULL); | 117 | input_dev->keycodesize = sizeof(unsigned char); |
117 | kfree(xtkbd); | 118 | input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode); |
118 | return err; | ||
119 | } | ||
120 | 119 | ||
121 | memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode)); | ||
122 | for (i = 0; i < 255; i++) | 120 | for (i = 0; i < 255; i++) |
123 | set_bit(xtkbd->keycode[i], xtkbd->dev.keybit); | 121 | set_bit(xtkbd->keycode[i], input_dev->keybit); |
124 | clear_bit(0, xtkbd->dev.keybit); | 122 | clear_bit(0, input_dev->keybit); |
125 | |||
126 | sprintf(xtkbd->phys, "%s/input0", serio->phys); | ||
127 | |||
128 | xtkbd->dev.name = xtkbd_name; | ||
129 | xtkbd->dev.phys = xtkbd->phys; | ||
130 | xtkbd->dev.id.bustype = BUS_XTKBD; | ||
131 | xtkbd->dev.id.vendor = 0x0001; | ||
132 | xtkbd->dev.id.product = 0x0001; | ||
133 | xtkbd->dev.id.version = 0x0100; | ||
134 | xtkbd->dev.dev = &serio->dev; | ||
135 | 123 | ||
136 | input_register_device(&xtkbd->dev); | 124 | serio_set_drvdata(serio, xtkbd); |
137 | 125 | ||
138 | printk(KERN_INFO "input: %s on %s\n", xtkbd_name, serio->phys); | 126 | err = serio_open(serio, drv); |
127 | if (err) | ||
128 | goto fail; | ||
139 | 129 | ||
130 | input_register_device(xtkbd->dev); | ||
140 | return 0; | 131 | return 0; |
132 | |||
133 | fail: serio_set_drvdata(serio, NULL); | ||
134 | input_free_device(input_dev); | ||
135 | kfree(xtkbd); | ||
136 | return err; | ||
141 | } | 137 | } |
142 | 138 | ||
143 | static void xtkbd_disconnect(struct serio *serio) | 139 | static void xtkbd_disconnect(struct serio *serio) |
144 | { | 140 | { |
145 | struct xtkbd *xtkbd = serio_get_drvdata(serio); | 141 | struct xtkbd *xtkbd = serio_get_drvdata(serio); |
146 | 142 | ||
147 | input_unregister_device(&xtkbd->dev); | ||
148 | serio_close(serio); | 143 | serio_close(serio); |
149 | serio_set_drvdata(serio, NULL); | 144 | serio_set_drvdata(serio, NULL); |
145 | input_unregister_device(xtkbd->dev); | ||
150 | kfree(xtkbd); | 146 | kfree(xtkbd); |
151 | } | 147 | } |
152 | 148 | ||
diff --git a/drivers/input/misc/m68kspkr.c b/drivers/input/misc/m68kspkr.c index 64abdd98d482..04489ad7702a 100644 --- a/drivers/input/misc/m68kspkr.c +++ b/drivers/input/misc/m68kspkr.c | |||
@@ -24,9 +24,7 @@ MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>"); | |||
24 | MODULE_DESCRIPTION("m68k beeper driver"); | 24 | MODULE_DESCRIPTION("m68k beeper driver"); |
25 | MODULE_LICENSE("GPL"); | 25 | MODULE_LICENSE("GPL"); |
26 | 26 | ||
27 | static char m68kspkr_name[] = "m68k beeper"; | 27 | static struct input_dev *m68kspkr_dev; |
28 | static char m68kspkr_phys[] = "m68k/generic"; | ||
29 | static struct input_dev m68kspkr_dev; | ||
30 | 28 | ||
31 | static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 29 | static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
32 | { | 30 | { |
@@ -51,32 +49,34 @@ static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int | |||
51 | 49 | ||
52 | static int __init m68kspkr_init(void) | 50 | static int __init m68kspkr_init(void) |
53 | { | 51 | { |
54 | if (!mach_beep){ | 52 | if (!mach_beep) { |
55 | printk("%s: no lowlevel beep support\n", m68kspkr_name); | 53 | printk(KERN_INFO "m68kspkr: no lowlevel beep support\n"); |
56 | return -1; | 54 | return -ENODEV; |
57 | } | 55 | } |
58 | 56 | ||
59 | m68kspkr_dev.evbit[0] = BIT(EV_SND); | 57 | m68kspkr_dev = input_allocate_device(); |
60 | m68kspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 58 | if (!m68kspkr_dev) |
61 | m68kspkr_dev.event = m68kspkr_event; | 59 | return -ENOMEM; |
62 | 60 | ||
63 | m68kspkr_dev.name = m68kspkr_name; | 61 | m68kspkr_dev->name = "m68k beeper"; |
64 | m68kspkr_dev.phys = m68kspkr_phys; | 62 | m68kspkr_dev->phys = "m68k/generic"; |
65 | m68kspkr_dev.id.bustype = BUS_HOST; | 63 | m68kspkr_dev->id.bustype = BUS_HOST; |
66 | m68kspkr_dev.id.vendor = 0x001f; | 64 | m68kspkr_dev->id.vendor = 0x001f; |
67 | m68kspkr_dev.id.product = 0x0001; | 65 | m68kspkr_dev->id.product = 0x0001; |
68 | m68kspkr_dev.id.version = 0x0100; | 66 | m68kspkr_dev->id.version = 0x0100; |
69 | 67 | ||
70 | input_register_device(&m68kspkr_dev); | 68 | m68kspkr_dev->evbit[0] = BIT(EV_SND); |
69 | m68kspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | ||
70 | m68kspkr_dev->event = m68kspkr_event; | ||
71 | 71 | ||
72 | printk(KERN_INFO "input: %s\n", m68kspkr_name); | 72 | input_register_device(m68kspkr_dev); |
73 | 73 | ||
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | static void __exit m68kspkr_exit(void) | 77 | static void __exit m68kspkr_exit(void) |
78 | { | 78 | { |
79 | input_unregister_device(&m68kspkr_dev); | 79 | input_unregister_device(m68kspkr_dev); |
80 | } | 80 | } |
81 | 81 | ||
82 | module_init(m68kspkr_init); | 82 | module_init(m68kspkr_init); |
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c index 3013194f462b..e34633c37fdd 100644 --- a/drivers/input/misc/pcspkr.c +++ b/drivers/input/misc/pcspkr.c | |||
@@ -23,9 +23,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | |||
23 | MODULE_DESCRIPTION("PC Speaker beeper driver"); | 23 | MODULE_DESCRIPTION("PC Speaker beeper driver"); |
24 | MODULE_LICENSE("GPL"); | 24 | MODULE_LICENSE("GPL"); |
25 | 25 | ||
26 | static char pcspkr_name[] = "PC Speaker"; | 26 | static struct input_dev *pcspkr_dev; |
27 | static char pcspkr_phys[] = "isa0061/input0"; | ||
28 | static struct input_dev pcspkr_dev; | ||
29 | 27 | ||
30 | static DEFINE_SPINLOCK(i8253_beep_lock); | 28 | static DEFINE_SPINLOCK(i8253_beep_lock); |
31 | 29 | ||
@@ -68,27 +66,29 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c | |||
68 | 66 | ||
69 | static int __init pcspkr_init(void) | 67 | static int __init pcspkr_init(void) |
70 | { | 68 | { |
71 | pcspkr_dev.evbit[0] = BIT(EV_SND); | 69 | pcspkr_dev = input_allocate_device(); |
72 | pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 70 | if (!pcspkr_dev) |
73 | pcspkr_dev.event = pcspkr_event; | 71 | return -ENOMEM; |
74 | 72 | ||
75 | pcspkr_dev.name = pcspkr_name; | 73 | pcspkr_dev->name = "PC Speaker"; |
76 | pcspkr_dev.phys = pcspkr_phys; | 74 | pcspkr_dev->name = "isa0061/input0"; |
77 | pcspkr_dev.id.bustype = BUS_ISA; | 75 | pcspkr_dev->id.bustype = BUS_ISA; |
78 | pcspkr_dev.id.vendor = 0x001f; | 76 | pcspkr_dev->id.vendor = 0x001f; |
79 | pcspkr_dev.id.product = 0x0001; | 77 | pcspkr_dev->id.product = 0x0001; |
80 | pcspkr_dev.id.version = 0x0100; | 78 | pcspkr_dev->id.version = 0x0100; |
81 | 79 | ||
82 | input_register_device(&pcspkr_dev); | 80 | pcspkr_dev->evbit[0] = BIT(EV_SND); |
81 | pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | ||
82 | pcspkr_dev->event = pcspkr_event; | ||
83 | 83 | ||
84 | printk(KERN_INFO "input: %s\n", pcspkr_name); | 84 | input_register_device(pcspkr_dev); |
85 | 85 | ||
86 | return 0; | 86 | return 0; |
87 | } | 87 | } |
88 | 88 | ||
89 | static void __exit pcspkr_exit(void) | 89 | static void __exit pcspkr_exit(void) |
90 | { | 90 | { |
91 | input_unregister_device(&pcspkr_dev); | 91 | input_unregister_device(pcspkr_dev); |
92 | /* turn off the speaker */ | 92 | /* turn off the speaker */ |
93 | pcspkr_event(NULL, EV_SND, SND_BELL, 0); | 93 | pcspkr_event(NULL, EV_SND, SND_BELL, 0); |
94 | } | 94 | } |
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index cdc3fb3d5f46..5778220a18d2 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c | |||
@@ -17,28 +17,24 @@ | |||
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); | 19 | MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); |
20 | MODULE_DESCRIPTION("PC Speaker beeper driver"); | 20 | MODULE_DESCRIPTION("Sparc Speaker beeper driver"); |
21 | MODULE_LICENSE("GPL"); | 21 | MODULE_LICENSE("GPL"); |
22 | 22 | ||
23 | static unsigned long beep_iobase; | 23 | static unsigned long beep_iobase; |
24 | 24 | static struct input_dev *sparcspkr_dev; | |
25 | static char *sparcspkr_isa_name = "Sparc ISA Speaker"; | ||
26 | static char *sparcspkr_ebus_name = "Sparc EBUS Speaker"; | ||
27 | static char *sparcspkr_phys = "sparc/input0"; | ||
28 | static struct input_dev sparcspkr_dev; | ||
29 | 25 | ||
30 | DEFINE_SPINLOCK(beep_lock); | 26 | DEFINE_SPINLOCK(beep_lock); |
31 | 27 | ||
32 | static void __init init_sparcspkr_struct(void) | 28 | static void __init init_sparcspkr_struct(void) |
33 | { | 29 | { |
34 | sparcspkr_dev.evbit[0] = BIT(EV_SND); | 30 | sparcspkr_dev->evbit[0] = BIT(EV_SND); |
35 | sparcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 31 | sparcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); |
36 | 32 | ||
37 | sparcspkr_dev.phys = sparcspkr_phys; | 33 | sparcspkr_dev->phys = "sparc/input0"; |
38 | sparcspkr_dev.id.bustype = BUS_ISA; | 34 | sparcspkr_dev->id.bustype = BUS_ISA; |
39 | sparcspkr_dev.id.vendor = 0x001f; | 35 | sparcspkr_dev->id.vendor = 0x001f; |
40 | sparcspkr_dev.id.product = 0x0001; | 36 | sparcspkr_dev->id.product = 0x0001; |
41 | sparcspkr_dev.id.version = 0x0100; | 37 | sparcspkr_dev->id.version = 0x0100; |
42 | } | 38 | } |
43 | 39 | ||
44 | static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 40 | static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
@@ -84,14 +80,15 @@ static int __init init_ebus_beep(struct linux_ebus_device *edev) | |||
84 | { | 80 | { |
85 | beep_iobase = edev->resource[0].start; | 81 | beep_iobase = edev->resource[0].start; |
86 | 82 | ||
87 | init_sparcspkr_struct(); | 83 | sparcspkr_dev = input_allocate_device(); |
84 | if (!sparcspkr_dev) | ||
85 | return -ENOMEM; | ||
88 | 86 | ||
89 | sparcspkr_dev.name = sparcspkr_ebus_name; | 87 | sparcspkr_dev->name = "Sparc EBUS Speaker"; |
90 | sparcspkr_dev.event = ebus_spkr_event; | 88 | sparcspkr_dev->event = ebus_spkr_event; |
91 | 89 | ||
92 | input_register_device(&sparcspkr_dev); | 90 | input_register_device(sparcspkr_dev); |
93 | 91 | ||
94 | printk(KERN_INFO "input: %s\n", sparcspkr_ebus_name); | ||
95 | return 0; | 92 | return 0; |
96 | } | 93 | } |
97 | 94 | ||
@@ -137,15 +134,17 @@ static int __init init_isa_beep(struct sparc_isa_device *isa_dev) | |||
137 | { | 134 | { |
138 | beep_iobase = isa_dev->resource.start; | 135 | beep_iobase = isa_dev->resource.start; |
139 | 136 | ||
137 | sparcspkr_dev = input_allocate_device(); | ||
138 | if (!sparcspkr_dev) | ||
139 | return -ENOMEM; | ||
140 | |||
140 | init_sparcspkr_struct(); | 141 | init_sparcspkr_struct(); |
141 | 142 | ||
142 | sparcspkr_dev.name = sparcspkr_isa_name; | 143 | sparcspkr_dev->name = "Sparc ISA Speaker"; |
143 | sparcspkr_dev.event = isa_spkr_event; | 144 | sparcspkr_dev->event = isa_spkr_event; |
144 | sparcspkr_dev.id.bustype = BUS_ISA; | ||
145 | 145 | ||
146 | input_register_device(&sparcspkr_dev); | 146 | input_register_device(&sparcspkr_dev); |
147 | 147 | ||
148 | printk(KERN_INFO "input: %s\n", sparcspkr_isa_name); | ||
149 | return 0; | 148 | return 0; |
150 | } | 149 | } |
151 | #endif | 150 | #endif |
@@ -182,7 +181,7 @@ static int __init sparcspkr_init(void) | |||
182 | 181 | ||
183 | static void __exit sparcspkr_exit(void) | 182 | static void __exit sparcspkr_exit(void) |
184 | { | 183 | { |
185 | input_unregister_device(&sparcspkr_dev); | 184 | input_unregister_device(sparcspkr_dev); |
186 | } | 185 | } |
187 | 186 | ||
188 | module_init(sparcspkr_init); | 187 | module_init(sparcspkr_init); |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index b20783f9748a..4acc7fd4cd0f 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -79,8 +79,8 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) | |||
79 | { | 79 | { |
80 | struct alps_data *priv = psmouse->private; | 80 | struct alps_data *priv = psmouse->private; |
81 | unsigned char *packet = psmouse->packet; | 81 | unsigned char *packet = psmouse->packet; |
82 | struct input_dev *dev = &psmouse->dev; | 82 | struct input_dev *dev = psmouse->dev; |
83 | struct input_dev *dev2 = &priv->dev2; | 83 | struct input_dev *dev2 = priv->dev2; |
84 | int x, y, z, ges, fin, left, right, middle; | 84 | int x, y, z, ges, fin, left, right, middle; |
85 | int back = 0, forward = 0; | 85 | int back = 0, forward = 0; |
86 | 86 | ||
@@ -379,20 +379,24 @@ static int alps_reconnect(struct psmouse *psmouse) | |||
379 | static void alps_disconnect(struct psmouse *psmouse) | 379 | static void alps_disconnect(struct psmouse *psmouse) |
380 | { | 380 | { |
381 | struct alps_data *priv = psmouse->private; | 381 | struct alps_data *priv = psmouse->private; |
382 | |||
382 | psmouse_reset(psmouse); | 383 | psmouse_reset(psmouse); |
383 | input_unregister_device(&priv->dev2); | 384 | input_unregister_device(priv->dev2); |
384 | kfree(priv); | 385 | kfree(priv); |
385 | } | 386 | } |
386 | 387 | ||
387 | int alps_init(struct psmouse *psmouse) | 388 | int alps_init(struct psmouse *psmouse) |
388 | { | 389 | { |
389 | struct alps_data *priv; | 390 | struct alps_data *priv; |
391 | struct input_dev *dev1 = psmouse->dev, *dev2; | ||
390 | int version; | 392 | int version; |
391 | 393 | ||
392 | psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL); | 394 | psmouse->private = priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); |
393 | if (!priv) | 395 | dev2 = input_allocate_device(); |
396 | if (!priv || !dev2) | ||
394 | goto init_fail; | 397 | goto init_fail; |
395 | memset(priv, 0, sizeof(struct alps_data)); | 398 | |
399 | priv->dev2 = dev2; | ||
396 | 400 | ||
397 | if (!(priv->i = alps_get_model(psmouse, &version))) | 401 | if (!(priv->i = alps_get_model(psmouse, &version))) |
398 | goto init_fail; | 402 | goto init_fail; |
@@ -411,41 +415,39 @@ int alps_init(struct psmouse *psmouse) | |||
411 | if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0)) | 415 | if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0)) |
412 | goto init_fail; | 416 | goto init_fail; |
413 | 417 | ||
414 | psmouse->dev.evbit[LONG(EV_KEY)] |= BIT(EV_KEY); | 418 | dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY); |
415 | psmouse->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); | 419 | dev1->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); |
416 | psmouse->dev.keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER); | 420 | dev1->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER); |
417 | psmouse->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 421 | dev1->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
418 | 422 | ||
419 | psmouse->dev.evbit[LONG(EV_ABS)] |= BIT(EV_ABS); | 423 | dev1->evbit[LONG(EV_ABS)] |= BIT(EV_ABS); |
420 | input_set_abs_params(&psmouse->dev, ABS_X, 0, 1023, 0, 0); | 424 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); |
421 | input_set_abs_params(&psmouse->dev, ABS_Y, 0, 767, 0, 0); | 425 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); |
422 | input_set_abs_params(&psmouse->dev, ABS_PRESSURE, 0, 127, 0, 0); | 426 | input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); |
423 | 427 | ||
424 | if (priv->i->flags & ALPS_WHEEL) { | 428 | if (priv->i->flags & ALPS_WHEEL) { |
425 | psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL); | 429 | dev1->evbit[LONG(EV_REL)] |= BIT(EV_REL); |
426 | psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); | 430 | dev1->relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); |
427 | } | 431 | } |
428 | 432 | ||
429 | if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { | 433 | if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { |
430 | psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); | 434 | dev1->keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); |
431 | psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); | 435 | dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); |
432 | } | 436 | } |
433 | 437 | ||
434 | sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys); | 438 | sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys); |
435 | priv->dev2.phys = priv->phys; | 439 | dev2->phys = priv->phys; |
436 | priv->dev2.name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; | 440 | dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; |
437 | priv->dev2.id.bustype = BUS_I8042; | 441 | dev2->id.bustype = BUS_I8042; |
438 | priv->dev2.id.vendor = 0x0002; | 442 | dev2->id.vendor = 0x0002; |
439 | priv->dev2.id.product = PSMOUSE_ALPS; | 443 | dev2->id.product = PSMOUSE_ALPS; |
440 | priv->dev2.id.version = 0x0000; | 444 | dev2->id.version = 0x0000; |
441 | |||
442 | priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
443 | priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); | ||
444 | priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
445 | 445 | ||
446 | input_register_device(&priv->dev2); | 446 | dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
447 | dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); | ||
448 | dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
447 | 449 | ||
448 | printk(KERN_INFO "input: %s on %s\n", priv->dev2.name, psmouse->ps2dev.serio->phys); | 450 | input_register_device(priv->dev2); |
449 | 451 | ||
450 | psmouse->protocol_handler = alps_process_byte; | 452 | psmouse->protocol_handler = alps_process_byte; |
451 | psmouse->disconnect = alps_disconnect; | 453 | psmouse->disconnect = alps_disconnect; |
@@ -455,6 +457,7 @@ int alps_init(struct psmouse *psmouse) | |||
455 | return 0; | 457 | return 0; |
456 | 458 | ||
457 | init_fail: | 459 | init_fail: |
460 | input_free_device(dev2); | ||
458 | kfree(priv); | 461 | kfree(priv); |
459 | return -1; | 462 | return -1; |
460 | } | 463 | } |
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h index aba103dd65b7..e428f8d5d12e 100644 --- a/drivers/input/mouse/alps.h +++ b/drivers/input/mouse/alps.h | |||
@@ -22,7 +22,7 @@ struct alps_model_info { | |||
22 | }; | 22 | }; |
23 | 23 | ||
24 | struct alps_data { | 24 | struct alps_data { |
25 | struct input_dev dev2; /* Relative device */ | 25 | struct input_dev *dev2; /* Relative device */ |
26 | char name[32]; /* Name */ | 26 | char name[32]; /* Name */ |
27 | char phys[32]; /* Phys */ | 27 | char phys[32]; /* Phys */ |
28 | struct alps_model_info *i; /* Info */ | 28 | struct alps_model_info *i; /* Info */ |
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index e994849efb8f..d13d4c8fe3c5 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
@@ -34,10 +34,7 @@ MODULE_DESCRIPTION("Amiga mouse driver"); | |||
34 | MODULE_LICENSE("GPL"); | 34 | MODULE_LICENSE("GPL"); |
35 | 35 | ||
36 | static int amimouse_lastx, amimouse_lasty; | 36 | static int amimouse_lastx, amimouse_lasty; |
37 | static struct input_dev amimouse_dev; | 37 | static struct input_dev *amimouse_dev; |
38 | |||
39 | static char *amimouse_name = "Amiga mouse"; | ||
40 | static char *amimouse_phys = "amimouse/input0"; | ||
41 | 38 | ||
42 | static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp) | 39 | static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp) |
43 | { | 40 | { |
@@ -62,16 +59,16 @@ static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp) | |||
62 | 59 | ||
63 | potgor = custom.potgor; | 60 | potgor = custom.potgor; |
64 | 61 | ||
65 | input_regs(&amimouse_dev, fp); | 62 | input_regs(amimouse_dev, fp); |
66 | 63 | ||
67 | input_report_rel(&amimouse_dev, REL_X, dx); | 64 | input_report_rel(amimouse_dev, REL_X, dx); |
68 | input_report_rel(&amimouse_dev, REL_Y, dy); | 65 | input_report_rel(amimouse_dev, REL_Y, dy); |
69 | 66 | ||
70 | input_report_key(&amimouse_dev, BTN_LEFT, ciaa.pra & 0x40); | 67 | input_report_key(amimouse_dev, BTN_LEFT, ciaa.pra & 0x40); |
71 | input_report_key(&amimouse_dev, BTN_MIDDLE, potgor & 0x0100); | 68 | input_report_key(amimouse_dev, BTN_MIDDLE, potgor & 0x0100); |
72 | input_report_key(&amimouse_dev, BTN_RIGHT, potgor & 0x0400); | 69 | input_report_key(amimouse_dev, BTN_RIGHT, potgor & 0x0400); |
73 | 70 | ||
74 | input_sync(&amimouse_dev); | 71 | input_sync(amimouse_dev); |
75 | 72 | ||
76 | return IRQ_HANDLED; | 73 | return IRQ_HANDLED; |
77 | } | 74 | } |
@@ -103,28 +100,30 @@ static int __init amimouse_init(void) | |||
103 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) | 100 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) |
104 | return -ENODEV; | 101 | return -ENODEV; |
105 | 102 | ||
106 | amimouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 103 | if (!(amimouse_dev = input_allocate_device())) |
107 | amimouse_dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 104 | return -ENOMEM; |
108 | amimouse_dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 105 | |
109 | amimouse_dev.open = amimouse_open; | 106 | amimouse_dev->name = "Amiga mouse"; |
110 | amimouse_dev.close = amimouse_close; | 107 | amimouse_dev->phys = "amimouse/input0"; |
108 | amimouse_dev->id.bustype = BUS_AMIGA; | ||
109 | amimouse_dev->id.vendor = 0x0001; | ||
110 | amimouse_dev->id.product = 0x0002; | ||
111 | amimouse_dev->id.version = 0x0100; | ||
111 | 112 | ||
112 | amimouse_dev.name = amimouse_name; | 113 | amimouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
113 | amimouse_dev.phys = amimouse_phys; | 114 | amimouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
114 | amimouse_dev.id.bustype = BUS_AMIGA; | 115 | amimouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
115 | amimouse_dev.id.vendor = 0x0001; | 116 | amimouse_dev->open = amimouse_open; |
116 | amimouse_dev.id.product = 0x0002; | 117 | amimouse_dev->close = amimouse_close; |
117 | amimouse_dev.id.version = 0x0100; | ||
118 | 118 | ||
119 | input_register_device(&amimouse_dev); | 119 | input_register_device(amimouse_dev); |
120 | 120 | ||
121 | printk(KERN_INFO "input: %s at joy0dat\n", amimouse_name); | ||
122 | return 0; | 121 | return 0; |
123 | } | 122 | } |
124 | 123 | ||
125 | static void __exit amimouse_exit(void) | 124 | static void __exit amimouse_exit(void) |
126 | { | 125 | { |
127 | input_unregister_device(&amimouse_dev); | 126 | input_unregister_device(amimouse_dev); |
128 | } | 127 | } |
129 | 128 | ||
130 | module_init(amimouse_init); | 129 | module_init(amimouse_init); |
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c index bc22849c6c79..c2bf2ed07dc6 100644 --- a/drivers/input/mouse/hil_ptr.c +++ b/drivers/input/mouse/hil_ptr.c | |||
@@ -196,7 +196,7 @@ static irqreturn_t hil_ptr_interrupt(struct serio *serio, | |||
196 | hil_packet packet; | 196 | hil_packet packet; |
197 | int idx; | 197 | int idx; |
198 | 198 | ||
199 | ptr = (struct hil_ptr *)serio->private; | 199 | ptr = serio_get_drvdata(serio); |
200 | if (ptr == NULL) { | 200 | if (ptr == NULL) { |
201 | BUG(); | 201 | BUG(); |
202 | return IRQ_HANDLED; | 202 | return IRQ_HANDLED; |
@@ -227,7 +227,7 @@ static void hil_ptr_disconnect(struct serio *serio) | |||
227 | { | 227 | { |
228 | struct hil_ptr *ptr; | 228 | struct hil_ptr *ptr; |
229 | 229 | ||
230 | ptr = (struct hil_ptr *)serio->private; | 230 | ptr = serio_get_drvdata(serio); |
231 | if (ptr == NULL) { | 231 | if (ptr == NULL) { |
232 | BUG(); | 232 | BUG(); |
233 | return; | 233 | return; |
@@ -238,21 +238,19 @@ static void hil_ptr_disconnect(struct serio *serio) | |||
238 | kfree(ptr); | 238 | kfree(ptr); |
239 | } | 239 | } |
240 | 240 | ||
241 | static void hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | 241 | static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) |
242 | { | 242 | { |
243 | struct hil_ptr *ptr; | 243 | struct hil_ptr *ptr; |
244 | char *txt; | 244 | char *txt; |
245 | unsigned int i, naxsets, btntype; | 245 | unsigned int i, naxsets, btntype; |
246 | uint8_t did, *idd; | 246 | uint8_t did, *idd; |
247 | 247 | ||
248 | if (serio->type != (SERIO_HIL_MLC | SERIO_HIL)) return; | 248 | if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return -ENOMEM; |
249 | |||
250 | if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return; | ||
251 | memset(ptr, 0, sizeof(struct hil_ptr)); | 249 | memset(ptr, 0, sizeof(struct hil_ptr)); |
252 | 250 | ||
253 | if (serio_open(serio, driver)) goto bail0; | 251 | if (serio_open(serio, driver)) goto bail0; |
254 | 252 | ||
255 | serio->private = ptr; | 253 | serio_set_drvdata(serio, ptr); |
256 | ptr->serio = serio; | 254 | ptr->serio = serio; |
257 | ptr->dev.private = ptr; | 255 | ptr->dev.private = ptr; |
258 | 256 | ||
@@ -380,23 +378,34 @@ static void hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | |||
380 | (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", | 378 | (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", |
381 | did); | 379 | did); |
382 | 380 | ||
383 | return; | 381 | return 0; |
384 | bail1: | 382 | bail1: |
385 | serio_close(serio); | 383 | serio_close(serio); |
386 | bail0: | 384 | bail0: |
387 | kfree(ptr); | 385 | kfree(ptr); |
388 | return; | 386 | serio_set_drvdata(serio, NULL); |
387 | return -ENODEV; | ||
389 | } | 388 | } |
390 | 389 | ||
390 | static struct serio_device_id hil_ptr_ids[] = { | ||
391 | { | ||
392 | .type = SERIO_HIL_MLC, | ||
393 | .proto = SERIO_HIL, | ||
394 | .id = SERIO_ANY, | ||
395 | .extra = SERIO_ANY, | ||
396 | }, | ||
397 | { 0 } | ||
398 | }; | ||
391 | 399 | ||
392 | static struct serio_driver hil_ptr_serio_driver = { | 400 | static struct serio_driver hil_ptr_serio_driver = { |
393 | .driver = { | 401 | .driver = { |
394 | .name = "hil_ptr", | 402 | .name = "hil_ptr", |
395 | }, | 403 | }, |
396 | .description = "HP HIL mouse/tablet driver", | 404 | .description = "HP HIL mouse/tablet driver", |
397 | .connect = hil_ptr_connect, | 405 | .id_table = hil_ptr_ids, |
398 | .disconnect = hil_ptr_disconnect, | 406 | .connect = hil_ptr_connect, |
399 | .interrupt = hil_ptr_interrupt | 407 | .disconnect = hil_ptr_disconnect, |
408 | .interrupt = hil_ptr_interrupt | ||
400 | }; | 409 | }; |
401 | 410 | ||
402 | static int __init hil_ptr_init(void) | 411 | static int __init hil_ptr_init(void) |
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c index 1f62c0134010..afc66f56df43 100644 --- a/drivers/input/mouse/inport.c +++ b/drivers/input/mouse/inport.c | |||
@@ -87,40 +87,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); | |||
87 | 87 | ||
88 | __obsolete_setup("inport_irq="); | 88 | __obsolete_setup("inport_irq="); |
89 | 89 | ||
90 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 90 | static struct input_dev *inport_dev; |
91 | |||
92 | static int inport_open(struct input_dev *dev) | ||
93 | { | ||
94 | if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) | ||
95 | return -EBUSY; | ||
96 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | ||
97 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static void inport_close(struct input_dev *dev) | ||
103 | { | ||
104 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | ||
105 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); | ||
106 | free_irq(inport_irq, NULL); | ||
107 | } | ||
108 | |||
109 | static struct input_dev inport_dev = { | ||
110 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, | ||
111 | .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) }, | ||
112 | .relbit = { BIT(REL_X) | BIT(REL_Y) }, | ||
113 | .open = inport_open, | ||
114 | .close = inport_close, | ||
115 | .name = INPORT_NAME, | ||
116 | .phys = "isa023c/input0", | ||
117 | .id = { | ||
118 | .bustype = BUS_ISA, | ||
119 | .vendor = INPORT_VENDOR, | ||
120 | .product = 0x0001, | ||
121 | .version = 0x0100, | ||
122 | }, | ||
123 | }; | ||
124 | 91 | ||
125 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 92 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
126 | { | 93 | { |
@@ -129,31 +96,48 @@ static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
129 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 96 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
130 | outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); | 97 | outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); |
131 | 98 | ||
132 | input_regs(&inport_dev, regs); | 99 | input_regs(inport_dev, regs); |
133 | 100 | ||
134 | outb(INPORT_REG_X, INPORT_CONTROL_PORT); | 101 | outb(INPORT_REG_X, INPORT_CONTROL_PORT); |
135 | input_report_rel(&inport_dev, REL_X, inb(INPORT_DATA_PORT)); | 102 | input_report_rel(inport_dev, REL_X, inb(INPORT_DATA_PORT)); |
136 | 103 | ||
137 | outb(INPORT_REG_Y, INPORT_CONTROL_PORT); | 104 | outb(INPORT_REG_Y, INPORT_CONTROL_PORT); |
138 | input_report_rel(&inport_dev, REL_Y, inb(INPORT_DATA_PORT)); | 105 | input_report_rel(inport_dev, REL_Y, inb(INPORT_DATA_PORT)); |
139 | 106 | ||
140 | outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT); | 107 | outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT); |
141 | buttons = inb(INPORT_DATA_PORT); | 108 | buttons = inb(INPORT_DATA_PORT); |
142 | 109 | ||
143 | input_report_key(&inport_dev, BTN_MIDDLE, buttons & 1); | 110 | input_report_key(inport_dev, BTN_MIDDLE, buttons & 1); |
144 | input_report_key(&inport_dev, BTN_LEFT, buttons & 2); | 111 | input_report_key(inport_dev, BTN_LEFT, buttons & 2); |
145 | input_report_key(&inport_dev, BTN_RIGHT, buttons & 4); | 112 | input_report_key(inport_dev, BTN_RIGHT, buttons & 4); |
146 | 113 | ||
147 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 114 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
148 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); | 115 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); |
149 | 116 | ||
150 | input_sync(&inport_dev); | 117 | input_sync(inport_dev); |
151 | return IRQ_HANDLED; | 118 | return IRQ_HANDLED; |
152 | } | 119 | } |
153 | 120 | ||
121 | static int inport_open(struct input_dev *dev) | ||
122 | { | ||
123 | if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) | ||
124 | return -EBUSY; | ||
125 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | ||
126 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static void inport_close(struct input_dev *dev) | ||
132 | { | ||
133 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | ||
134 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); | ||
135 | free_irq(inport_irq, NULL); | ||
136 | } | ||
137 | |||
154 | static int __init inport_init(void) | 138 | static int __init inport_init(void) |
155 | { | 139 | { |
156 | unsigned char a,b,c; | 140 | unsigned char a, b, c; |
157 | 141 | ||
158 | if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { | 142 | if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { |
159 | printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); | 143 | printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); |
@@ -163,26 +147,44 @@ static int __init inport_init(void) | |||
163 | a = inb(INPORT_SIGNATURE_PORT); | 147 | a = inb(INPORT_SIGNATURE_PORT); |
164 | b = inb(INPORT_SIGNATURE_PORT); | 148 | b = inb(INPORT_SIGNATURE_PORT); |
165 | c = inb(INPORT_SIGNATURE_PORT); | 149 | c = inb(INPORT_SIGNATURE_PORT); |
166 | if (( a == b ) || ( a != c )) { | 150 | if (a == b || a != c) { |
167 | release_region(INPORT_BASE, INPORT_EXTENT); | 151 | release_region(INPORT_BASE, INPORT_EXTENT); |
168 | printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); | 152 | printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); |
169 | return -ENODEV; | 153 | return -ENODEV; |
170 | } | 154 | } |
171 | 155 | ||
156 | if (!(inport_dev = input_allocate_device())) { | ||
157 | printk(KERN_ERR "inport.c: Not enough memory for input device\n"); | ||
158 | release_region(INPORT_BASE, INPORT_EXTENT); | ||
159 | return -ENOMEM; | ||
160 | } | ||
161 | |||
162 | inport_dev->name = INPORT_NAME; | ||
163 | inport_dev->phys = "isa023c/input0"; | ||
164 | inport_dev->id.bustype = BUS_ISA; | ||
165 | inport_dev->id.vendor = INPORT_VENDOR; | ||
166 | inport_dev->id.product = 0x0001; | ||
167 | inport_dev->id.version = 0x0100; | ||
168 | |||
169 | inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
170 | inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
171 | inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
172 | |||
173 | inport_dev->open = inport_open; | ||
174 | inport_dev->close = inport_close; | ||
175 | |||
172 | outb(INPORT_RESET, INPORT_CONTROL_PORT); | 176 | outb(INPORT_RESET, INPORT_CONTROL_PORT); |
173 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 177 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
174 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); | 178 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); |
175 | 179 | ||
176 | input_register_device(&inport_dev); | 180 | input_register_device(inport_dev); |
177 | |||
178 | printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n", INPORT_BASE, inport_irq); | ||
179 | 181 | ||
180 | return 0; | 182 | return 0; |
181 | } | 183 | } |
182 | 184 | ||
183 | static void __exit inport_exit(void) | 185 | static void __exit inport_exit(void) |
184 | { | 186 | { |
185 | input_unregister_device(&inport_dev); | 187 | input_unregister_device(inport_dev); |
186 | release_region(INPORT_BASE, INPORT_EXTENT); | 188 | release_region(INPORT_BASE, INPORT_EXTENT); |
187 | } | 189 | } |
188 | 190 | ||
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c index bd9df9b28325..55991424ac91 100644 --- a/drivers/input/mouse/lifebook.c +++ b/drivers/input/mouse/lifebook.c | |||
@@ -34,7 +34,7 @@ static struct dmi_system_id lifebook_dmi_table[] = { | |||
34 | static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs) | 34 | static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs) |
35 | { | 35 | { |
36 | unsigned char *packet = psmouse->packet; | 36 | unsigned char *packet = psmouse->packet; |
37 | struct input_dev *dev = &psmouse->dev; | 37 | struct input_dev *dev = psmouse->dev; |
38 | 38 | ||
39 | if (psmouse->pktcnt != 3) | 39 | if (psmouse->pktcnt != 3) |
40 | return PSMOUSE_GOOD_DATA; | 40 | return PSMOUSE_GOOD_DATA; |
@@ -113,15 +113,17 @@ int lifebook_detect(struct psmouse *psmouse, int set_properties) | |||
113 | 113 | ||
114 | int lifebook_init(struct psmouse *psmouse) | 114 | int lifebook_init(struct psmouse *psmouse) |
115 | { | 115 | { |
116 | struct input_dev *input_dev = psmouse->dev; | ||
117 | |||
116 | if (lifebook_absolute_mode(psmouse)) | 118 | if (lifebook_absolute_mode(psmouse)) |
117 | return -1; | 119 | return -1; |
118 | 120 | ||
119 | psmouse->dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); | 121 | input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); |
120 | psmouse->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 122 | input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
121 | psmouse->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 123 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
122 | psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 124 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
123 | input_set_abs_params(&psmouse->dev, ABS_X, 0, 1024, 0, 0); | 125 | input_set_abs_params(input_dev, ABS_X, 0, 1024, 0, 0); |
124 | input_set_abs_params(&psmouse->dev, ABS_Y, 0, 1024, 0, 0); | 126 | input_set_abs_params(input_dev, ABS_Y, 0, 1024, 0, 0); |
125 | 127 | ||
126 | psmouse->protocol_handler = lifebook_process_byte; | 128 | psmouse->protocol_handler = lifebook_process_byte; |
127 | psmouse->set_resolution = lifebook_set_resolution; | 129 | psmouse->set_resolution = lifebook_set_resolution; |
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c index 8b5243167227..9c7ce38806d7 100644 --- a/drivers/input/mouse/logibm.c +++ b/drivers/input/mouse/logibm.c | |||
@@ -77,39 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); | |||
77 | 77 | ||
78 | __obsolete_setup("logibm_irq="); | 78 | __obsolete_setup("logibm_irq="); |
79 | 79 | ||
80 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 80 | static struct input_dev *logibm_dev; |
81 | |||
82 | static int logibm_open(struct input_dev *dev) | ||
83 | { | ||
84 | if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { | ||
85 | printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); | ||
86 | return -EBUSY; | ||
87 | } | ||
88 | outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT); | ||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static void logibm_close(struct input_dev *dev) | ||
93 | { | ||
94 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | ||
95 | free_irq(logibm_irq, NULL); | ||
96 | } | ||
97 | |||
98 | static struct input_dev logibm_dev = { | ||
99 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, | ||
100 | .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) }, | ||
101 | .relbit = { BIT(REL_X) | BIT(REL_Y) }, | ||
102 | .open = logibm_open, | ||
103 | .close = logibm_close, | ||
104 | .name = "Logitech bus mouse", | ||
105 | .phys = "isa023c/input0", | ||
106 | .id = { | ||
107 | .bustype = BUS_ISA, | ||
108 | .vendor = 0x0003, | ||
109 | .product = 0x0001, | ||
110 | .version = 0x0100, | ||
111 | }, | ||
112 | }; | ||
113 | 81 | ||
114 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 82 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
115 | { | 83 | { |
@@ -127,18 +95,34 @@ static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
127 | dy |= (buttons & 0xf) << 4; | 95 | dy |= (buttons & 0xf) << 4; |
128 | buttons = ~buttons >> 5; | 96 | buttons = ~buttons >> 5; |
129 | 97 | ||
130 | input_regs(&logibm_dev, regs); | 98 | input_regs(logibm_dev, regs); |
131 | input_report_rel(&logibm_dev, REL_X, dx); | 99 | input_report_rel(logibm_dev, REL_X, dx); |
132 | input_report_rel(&logibm_dev, REL_Y, dy); | 100 | input_report_rel(logibm_dev, REL_Y, dy); |
133 | input_report_key(&logibm_dev, BTN_RIGHT, buttons & 1); | 101 | input_report_key(logibm_dev, BTN_RIGHT, buttons & 1); |
134 | input_report_key(&logibm_dev, BTN_MIDDLE, buttons & 2); | 102 | input_report_key(logibm_dev, BTN_MIDDLE, buttons & 2); |
135 | input_report_key(&logibm_dev, BTN_LEFT, buttons & 4); | 103 | input_report_key(logibm_dev, BTN_LEFT, buttons & 4); |
136 | input_sync(&logibm_dev); | 104 | input_sync(logibm_dev); |
137 | 105 | ||
138 | outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT); | 106 | outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT); |
139 | return IRQ_HANDLED; | 107 | return IRQ_HANDLED; |
140 | } | 108 | } |
141 | 109 | ||
110 | static int logibm_open(struct input_dev *dev) | ||
111 | { | ||
112 | if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { | ||
113 | printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); | ||
114 | return -EBUSY; | ||
115 | } | ||
116 | outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT); | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static void logibm_close(struct input_dev *dev) | ||
121 | { | ||
122 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | ||
123 | free_irq(logibm_irq, NULL); | ||
124 | } | ||
125 | |||
142 | static int __init logibm_init(void) | 126 | static int __init logibm_init(void) |
143 | { | 127 | { |
144 | if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { | 128 | if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { |
@@ -159,16 +143,34 @@ static int __init logibm_init(void) | |||
159 | outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); | 143 | outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); |
160 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | 144 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); |
161 | 145 | ||
162 | input_register_device(&logibm_dev); | 146 | if (!(logibm_dev = input_allocate_device())) { |
147 | printk(KERN_ERR "logibm.c: Not enough memory for input device\n"); | ||
148 | release_region(LOGIBM_BASE, LOGIBM_EXTENT); | ||
149 | return -ENOMEM; | ||
150 | } | ||
151 | |||
152 | logibm_dev->name = "Logitech bus mouse"; | ||
153 | logibm_dev->phys = "isa023c/input0"; | ||
154 | logibm_dev->id.bustype = BUS_ISA; | ||
155 | logibm_dev->id.vendor = 0x0003; | ||
156 | logibm_dev->id.product = 0x0001; | ||
157 | logibm_dev->id.version = 0x0100; | ||
158 | |||
159 | logibm_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
160 | logibm_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
161 | logibm_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
162 | |||
163 | logibm_dev->open = logibm_open; | ||
164 | logibm_dev->close = logibm_close; | ||
163 | 165 | ||
164 | printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq); | 166 | input_register_device(logibm_dev); |
165 | 167 | ||
166 | return 0; | 168 | return 0; |
167 | } | 169 | } |
168 | 170 | ||
169 | static void __exit logibm_exit(void) | 171 | static void __exit logibm_exit(void) |
170 | { | 172 | { |
171 | input_unregister_device(&logibm_dev); | 173 | input_unregister_device(logibm_dev); |
172 | release_region(LOGIBM_BASE, LOGIBM_EXTENT); | 174 | release_region(LOGIBM_BASE, LOGIBM_EXTENT); |
173 | } | 175 | } |
174 | 176 | ||
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 7df96525222e..0f69ff46c1ae 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c | |||
@@ -40,7 +40,7 @@ struct ps2pp_info { | |||
40 | 40 | ||
41 | static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs) | 41 | static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs) |
42 | { | 42 | { |
43 | struct input_dev *dev = &psmouse->dev; | 43 | struct input_dev *dev = psmouse->dev; |
44 | unsigned char *packet = psmouse->packet; | 44 | unsigned char *packet = psmouse->packet; |
45 | 45 | ||
46 | if (psmouse->pktcnt < 3) | 46 | if (psmouse->pktcnt < 3) |
@@ -257,25 +257,27 @@ static struct ps2pp_info *get_model_info(unsigned char model) | |||
257 | static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info, | 257 | static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info, |
258 | int using_ps2pp) | 258 | int using_ps2pp) |
259 | { | 259 | { |
260 | struct input_dev *input_dev = psmouse->dev; | ||
261 | |||
260 | if (model_info->features & PS2PP_SIDE_BTN) | 262 | if (model_info->features & PS2PP_SIDE_BTN) |
261 | set_bit(BTN_SIDE, psmouse->dev.keybit); | 263 | set_bit(BTN_SIDE, input_dev->keybit); |
262 | 264 | ||
263 | if (model_info->features & PS2PP_EXTRA_BTN) | 265 | if (model_info->features & PS2PP_EXTRA_BTN) |
264 | set_bit(BTN_EXTRA, psmouse->dev.keybit); | 266 | set_bit(BTN_EXTRA, input_dev->keybit); |
265 | 267 | ||
266 | if (model_info->features & PS2PP_TASK_BTN) | 268 | if (model_info->features & PS2PP_TASK_BTN) |
267 | set_bit(BTN_TASK, psmouse->dev.keybit); | 269 | set_bit(BTN_TASK, input_dev->keybit); |
268 | 270 | ||
269 | if (model_info->features & PS2PP_NAV_BTN) { | 271 | if (model_info->features & PS2PP_NAV_BTN) { |
270 | set_bit(BTN_FORWARD, psmouse->dev.keybit); | 272 | set_bit(BTN_FORWARD, input_dev->keybit); |
271 | set_bit(BTN_BACK, psmouse->dev.keybit); | 273 | set_bit(BTN_BACK, input_dev->keybit); |
272 | } | 274 | } |
273 | 275 | ||
274 | if (model_info->features & PS2PP_WHEEL) | 276 | if (model_info->features & PS2PP_WHEEL) |
275 | set_bit(REL_WHEEL, psmouse->dev.relbit); | 277 | set_bit(REL_WHEEL, input_dev->relbit); |
276 | 278 | ||
277 | if (model_info->features & PS2PP_HWHEEL) | 279 | if (model_info->features & PS2PP_HWHEEL) |
278 | set_bit(REL_HWHEEL, psmouse->dev.relbit); | 280 | set_bit(REL_HWHEEL, input_dev->relbit); |
279 | 281 | ||
280 | switch (model_info->kind) { | 282 | switch (model_info->kind) { |
281 | case PS2PP_KIND_WHEEL: | 283 | case PS2PP_KIND_WHEEL: |
@@ -387,7 +389,7 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties) | |||
387 | } | 389 | } |
388 | 390 | ||
389 | if (buttons < 3) | 391 | if (buttons < 3) |
390 | clear_bit(BTN_MIDDLE, psmouse->dev.keybit); | 392 | clear_bit(BTN_MIDDLE, psmouse->dev->keybit); |
391 | 393 | ||
392 | if (model_info) | 394 | if (model_info) |
393 | ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); | 395 | ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); |
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c index e90c60cbbf05..b5b34fe4fee8 100644 --- a/drivers/input/mouse/maplemouse.c +++ b/drivers/input/mouse/maplemouse.c | |||
@@ -41,13 +41,12 @@ static int dc_mouse_connect(struct maple_device *dev) | |||
41 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | 41 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); |
42 | struct input_dev *input_dev; | 42 | struct input_dev *input_dev; |
43 | 43 | ||
44 | if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL))) | 44 | dev->private_data = input_dev = input_allocate_device(); |
45 | return -1; | 45 | if (!input_dev) |
46 | return -ENOMEM; | ||
46 | 47 | ||
47 | dev->private_data = input_dev; | 48 | dev->private_data = input_dev; |
48 | 49 | ||
49 | memset(input_dev, 0, sizeof(struct dc_mouse)); | ||
50 | init_input_dev(input_dev); | ||
51 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 50 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
52 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 51 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
53 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); | 52 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); |
@@ -59,8 +58,6 @@ static int dc_mouse_connect(struct maple_device *dev) | |||
59 | 58 | ||
60 | maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); | 59 | maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); |
61 | 60 | ||
62 | printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name); | ||
63 | |||
64 | return 0; | 61 | return 0; |
65 | } | 62 | } |
66 | 63 | ||
@@ -70,7 +67,6 @@ static void dc_mouse_disconnect(struct maple_device *dev) | |||
70 | struct input_dev *input_dev = dev->private_data; | 67 | struct input_dev *input_dev = dev->private_data; |
71 | 68 | ||
72 | input_unregister_device(input_dev); | 69 | input_unregister_device(input_dev); |
73 | kfree(input_dev); | ||
74 | } | 70 | } |
75 | 71 | ||
76 | 72 | ||
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c index 93393d5c0078..d284ea712151 100644 --- a/drivers/input/mouse/pc110pad.c +++ b/drivers/input/mouse/pc110pad.c | |||
@@ -53,13 +53,10 @@ MODULE_LICENSE("GPL"); | |||
53 | static int pc110pad_irq = 10; | 53 | static int pc110pad_irq = 10; |
54 | static int pc110pad_io = 0x15e0; | 54 | static int pc110pad_io = 0x15e0; |
55 | 55 | ||
56 | static struct input_dev pc110pad_dev; | 56 | static struct input_dev *pc110pad_dev; |
57 | static int pc110pad_data[3]; | 57 | static int pc110pad_data[3]; |
58 | static int pc110pad_count; | 58 | static int pc110pad_count; |
59 | 59 | ||
60 | static char *pc110pad_name = "IBM PC110 TouchPad"; | ||
61 | static char *pc110pad_phys = "isa15e0/input0"; | ||
62 | |||
63 | static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) | 60 | static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) |
64 | { | 61 | { |
65 | int value = inb_p(pc110pad_io); | 62 | int value = inb_p(pc110pad_io); |
@@ -74,14 +71,14 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
74 | if (pc110pad_count < 3) | 71 | if (pc110pad_count < 3) |
75 | return IRQ_HANDLED; | 72 | return IRQ_HANDLED; |
76 | 73 | ||
77 | input_regs(&pc110pad_dev, regs); | 74 | input_regs(pc110pad_dev, regs); |
78 | input_report_key(&pc110pad_dev, BTN_TOUCH, | 75 | input_report_key(pc110pad_dev, BTN_TOUCH, |
79 | pc110pad_data[0] & 0x01); | 76 | pc110pad_data[0] & 0x01); |
80 | input_report_abs(&pc110pad_dev, ABS_X, | 77 | input_report_abs(pc110pad_dev, ABS_X, |
81 | pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100)); | 78 | pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100)); |
82 | input_report_abs(&pc110pad_dev, ABS_Y, | 79 | input_report_abs(pc110pad_dev, ABS_Y, |
83 | pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80)); | 80 | pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80)); |
84 | input_sync(&pc110pad_dev); | 81 | input_sync(pc110pad_dev); |
85 | 82 | ||
86 | pc110pad_count = 0; | 83 | pc110pad_count = 0; |
87 | return IRQ_HANDLED; | 84 | return IRQ_HANDLED; |
@@ -94,9 +91,9 @@ static void pc110pad_close(struct input_dev *dev) | |||
94 | 91 | ||
95 | static int pc110pad_open(struct input_dev *dev) | 92 | static int pc110pad_open(struct input_dev *dev) |
96 | { | 93 | { |
97 | pc110pad_interrupt(0,NULL,NULL); | 94 | pc110pad_interrupt(0, NULL, NULL); |
98 | pc110pad_interrupt(0,NULL,NULL); | 95 | pc110pad_interrupt(0, NULL, NULL); |
99 | pc110pad_interrupt(0,NULL,NULL); | 96 | pc110pad_interrupt(0, NULL, NULL); |
100 | outb(PC110PAD_ON, pc110pad_io + 2); | 97 | outb(PC110PAD_ON, pc110pad_io + 2); |
101 | pc110pad_count = 0; | 98 | pc110pad_count = 0; |
102 | 99 | ||
@@ -127,45 +124,46 @@ static int __init pc110pad_init(void) | |||
127 | 124 | ||
128 | outb(PC110PAD_OFF, pc110pad_io + 2); | 125 | outb(PC110PAD_OFF, pc110pad_io + 2); |
129 | 126 | ||
130 | if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) | 127 | if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) { |
131 | { | ||
132 | release_region(pc110pad_io, 4); | 128 | release_region(pc110pad_io, 4); |
133 | printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); | 129 | printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); |
134 | return -EBUSY; | 130 | return -EBUSY; |
135 | } | 131 | } |
136 | 132 | ||
137 | pc110pad_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 133 | if (!(pc110pad_dev = input_allocate_device())) { |
138 | pc110pad_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 134 | free_irq(pc110pad_irq, NULL); |
139 | pc110pad_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 135 | release_region(pc110pad_io, 4); |
136 | printk(KERN_ERR "pc110pad: Not enough memory.\n"); | ||
137 | return -ENOMEM; | ||
138 | } | ||
140 | 139 | ||
141 | pc110pad_dev.absmax[ABS_X] = 0x1ff; | 140 | pc110pad_dev->name = "IBM PC110 TouchPad"; |
142 | pc110pad_dev.absmax[ABS_Y] = 0x0ff; | 141 | pc110pad_dev->phys = "isa15e0/input0"; |
142 | pc110pad_dev->id.bustype = BUS_ISA; | ||
143 | pc110pad_dev->id.vendor = 0x0003; | ||
144 | pc110pad_dev->id.product = 0x0001; | ||
145 | pc110pad_dev->id.version = 0x0100; | ||
143 | 146 | ||
144 | pc110pad_dev.open = pc110pad_open; | 147 | pc110pad_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
145 | pc110pad_dev.close = pc110pad_close; | 148 | pc110pad_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); |
149 | pc110pad_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
146 | 150 | ||
147 | pc110pad_dev.name = pc110pad_name; | 151 | pc110pad_dev->absmax[ABS_X] = 0x1ff; |
148 | pc110pad_dev.phys = pc110pad_phys; | 152 | pc110pad_dev->absmax[ABS_Y] = 0x0ff; |
149 | pc110pad_dev.id.bustype = BUS_ISA; | ||
150 | pc110pad_dev.id.vendor = 0x0003; | ||
151 | pc110pad_dev.id.product = 0x0001; | ||
152 | pc110pad_dev.id.version = 0x0100; | ||
153 | 153 | ||
154 | input_register_device(&pc110pad_dev); | 154 | pc110pad_dev->open = pc110pad_open; |
155 | pc110pad_dev->close = pc110pad_close; | ||
155 | 156 | ||
156 | printk(KERN_INFO "input: %s at %#x irq %d\n", | 157 | input_register_device(pc110pad_dev); |
157 | pc110pad_name, pc110pad_io, pc110pad_irq); | ||
158 | 158 | ||
159 | return 0; | 159 | return 0; |
160 | } | 160 | } |
161 | 161 | ||
162 | static void __exit pc110pad_exit(void) | 162 | static void __exit pc110pad_exit(void) |
163 | { | 163 | { |
164 | input_unregister_device(&pc110pad_dev); | ||
165 | |||
166 | outb(PC110PAD_OFF, pc110pad_io + 2); | 164 | outb(PC110PAD_OFF, pc110pad_io + 2); |
167 | |||
168 | free_irq(pc110pad_irq, NULL); | 165 | free_irq(pc110pad_irq, NULL); |
166 | input_unregister_device(pc110pad_dev); | ||
169 | release_region(pc110pad_io, 4); | 167 | release_region(pc110pad_io, 4); |
170 | } | 168 | } |
171 | 169 | ||
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index af24313ff5bb..6ee9999a2eaa 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -114,7 +114,7 @@ struct psmouse_protocol { | |||
114 | 114 | ||
115 | static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs) | 115 | static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs) |
116 | { | 116 | { |
117 | struct input_dev *dev = &psmouse->dev; | 117 | struct input_dev *dev = psmouse->dev; |
118 | unsigned char *packet = psmouse->packet; | 118 | unsigned char *packet = psmouse->packet; |
119 | 119 | ||
120 | if (psmouse->pktcnt < psmouse->pktsize) | 120 | if (psmouse->pktcnt < psmouse->pktsize) |
@@ -333,12 +333,11 @@ static int genius_detect(struct psmouse *psmouse, int set_properties) | |||
333 | return -1; | 333 | return -1; |
334 | 334 | ||
335 | if (set_properties) { | 335 | if (set_properties) { |
336 | set_bit(BTN_EXTRA, psmouse->dev.keybit); | 336 | set_bit(BTN_EXTRA, psmouse->dev->keybit); |
337 | set_bit(BTN_SIDE, psmouse->dev.keybit); | 337 | set_bit(BTN_SIDE, psmouse->dev->keybit); |
338 | set_bit(REL_WHEEL, psmouse->dev.relbit); | 338 | set_bit(REL_WHEEL, psmouse->dev->relbit); |
339 | 339 | ||
340 | psmouse->vendor = "Genius"; | 340 | psmouse->vendor = "Genius"; |
341 | psmouse->name = "Wheel Mouse"; | ||
342 | psmouse->pktsize = 4; | 341 | psmouse->pktsize = 4; |
343 | } | 342 | } |
344 | 343 | ||
@@ -365,8 +364,8 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties) | |||
365 | return -1; | 364 | return -1; |
366 | 365 | ||
367 | if (set_properties) { | 366 | if (set_properties) { |
368 | set_bit(BTN_MIDDLE, psmouse->dev.keybit); | 367 | set_bit(BTN_MIDDLE, psmouse->dev->keybit); |
369 | set_bit(REL_WHEEL, psmouse->dev.relbit); | 368 | set_bit(REL_WHEEL, psmouse->dev->relbit); |
370 | 369 | ||
371 | if (!psmouse->vendor) psmouse->vendor = "Generic"; | 370 | if (!psmouse->vendor) psmouse->vendor = "Generic"; |
372 | if (!psmouse->name) psmouse->name = "Wheel Mouse"; | 371 | if (!psmouse->name) psmouse->name = "Wheel Mouse"; |
@@ -398,10 +397,10 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties) | |||
398 | return -1; | 397 | return -1; |
399 | 398 | ||
400 | if (set_properties) { | 399 | if (set_properties) { |
401 | set_bit(BTN_MIDDLE, psmouse->dev.keybit); | 400 | set_bit(BTN_MIDDLE, psmouse->dev->keybit); |
402 | set_bit(REL_WHEEL, psmouse->dev.relbit); | 401 | set_bit(REL_WHEEL, psmouse->dev->relbit); |
403 | set_bit(BTN_SIDE, psmouse->dev.keybit); | 402 | set_bit(BTN_SIDE, psmouse->dev->keybit); |
404 | set_bit(BTN_EXTRA, psmouse->dev.keybit); | 403 | set_bit(BTN_EXTRA, psmouse->dev->keybit); |
405 | 404 | ||
406 | if (!psmouse->vendor) psmouse->vendor = "Generic"; | 405 | if (!psmouse->vendor) psmouse->vendor = "Generic"; |
407 | if (!psmouse->name) psmouse->name = "Explorer Mouse"; | 406 | if (!psmouse->name) psmouse->name = "Explorer Mouse"; |
@@ -433,7 +432,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties) | |||
433 | return -1; | 432 | return -1; |
434 | 433 | ||
435 | if (set_properties) { | 434 | if (set_properties) { |
436 | set_bit(BTN_EXTRA, psmouse->dev.keybit); | 435 | set_bit(BTN_EXTRA, psmouse->dev->keybit); |
437 | 436 | ||
438 | psmouse->vendor = "Kensington"; | 437 | psmouse->vendor = "Kensington"; |
439 | psmouse->name = "ThinkingMouse"; | 438 | psmouse->name = "ThinkingMouse"; |
@@ -839,9 +838,9 @@ static void psmouse_disconnect(struct serio *serio) | |||
839 | 838 | ||
840 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); | 839 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); |
841 | 840 | ||
842 | input_unregister_device(&psmouse->dev); | ||
843 | serio_close(serio); | 841 | serio_close(serio); |
844 | serio_set_drvdata(serio, NULL); | 842 | serio_set_drvdata(serio, NULL); |
843 | input_unregister_device(psmouse->dev); | ||
845 | kfree(psmouse); | 844 | kfree(psmouse); |
846 | 845 | ||
847 | if (parent) | 846 | if (parent) |
@@ -852,16 +851,14 @@ static void psmouse_disconnect(struct serio *serio) | |||
852 | 851 | ||
853 | static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) | 852 | static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) |
854 | { | 853 | { |
855 | memset(&psmouse->dev, 0, sizeof(struct input_dev)); | 854 | struct input_dev *input_dev = psmouse->dev; |
856 | 855 | ||
857 | init_input_dev(&psmouse->dev); | 856 | input_dev->private = psmouse; |
857 | input_dev->cdev.dev = &psmouse->ps2dev.serio->dev; | ||
858 | 858 | ||
859 | psmouse->dev.private = psmouse; | 859 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
860 | psmouse->dev.dev = &psmouse->ps2dev.serio->dev; | 860 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
861 | 861 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | |
862 | psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
863 | psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
864 | psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
865 | 862 | ||
866 | psmouse->set_rate = psmouse_set_rate; | 863 | psmouse->set_rate = psmouse_set_rate; |
867 | psmouse->set_resolution = psmouse_set_resolution; | 864 | psmouse->set_resolution = psmouse_set_resolution; |
@@ -883,12 +880,12 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto | |||
883 | sprintf(psmouse->devname, "%s %s %s", | 880 | sprintf(psmouse->devname, "%s %s %s", |
884 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); | 881 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); |
885 | 882 | ||
886 | psmouse->dev.name = psmouse->devname; | 883 | input_dev->name = psmouse->devname; |
887 | psmouse->dev.phys = psmouse->phys; | 884 | input_dev->phys = psmouse->phys; |
888 | psmouse->dev.id.bustype = BUS_I8042; | 885 | input_dev->id.bustype = BUS_I8042; |
889 | psmouse->dev.id.vendor = 0x0002; | 886 | input_dev->id.vendor = 0x0002; |
890 | psmouse->dev.id.product = psmouse->type; | 887 | input_dev->id.product = psmouse->type; |
891 | psmouse->dev.id.version = psmouse->model; | 888 | input_dev->id.version = psmouse->model; |
892 | 889 | ||
893 | return 0; | 890 | return 0; |
894 | } | 891 | } |
@@ -900,7 +897,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto | |||
900 | static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | 897 | static int psmouse_connect(struct serio *serio, struct serio_driver *drv) |
901 | { | 898 | { |
902 | struct psmouse *psmouse, *parent = NULL; | 899 | struct psmouse *psmouse, *parent = NULL; |
903 | int retval; | 900 | struct input_dev *input_dev; |
901 | int retval = -ENOMEM; | ||
904 | 902 | ||
905 | down(&psmouse_sem); | 903 | down(&psmouse_sem); |
906 | 904 | ||
@@ -913,12 +911,13 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
913 | psmouse_deactivate(parent); | 911 | psmouse_deactivate(parent); |
914 | } | 912 | } |
915 | 913 | ||
916 | if (!(psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL))) { | 914 | psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL); |
917 | retval = -ENOMEM; | 915 | input_dev = input_allocate_device(); |
916 | if (!psmouse || !input_dev) | ||
918 | goto out; | 917 | goto out; |
919 | } | ||
920 | 918 | ||
921 | ps2_init(&psmouse->ps2dev, serio); | 919 | ps2_init(&psmouse->ps2dev, serio); |
920 | psmouse->dev = input_dev; | ||
922 | sprintf(psmouse->phys, "%s/input0", serio->phys); | 921 | sprintf(psmouse->phys, "%s/input0", serio->phys); |
923 | 922 | ||
924 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | 923 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); |
@@ -926,16 +925,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
926 | serio_set_drvdata(serio, psmouse); | 925 | serio_set_drvdata(serio, psmouse); |
927 | 926 | ||
928 | retval = serio_open(serio, drv); | 927 | retval = serio_open(serio, drv); |
929 | if (retval) { | 928 | if (retval) |
930 | serio_set_drvdata(serio, NULL); | ||
931 | kfree(psmouse); | ||
932 | goto out; | 929 | goto out; |
933 | } | ||
934 | 930 | ||
935 | if (psmouse_probe(psmouse) < 0) { | 931 | if (psmouse_probe(psmouse) < 0) { |
936 | serio_close(serio); | 932 | serio_close(serio); |
937 | serio_set_drvdata(serio, NULL); | ||
938 | kfree(psmouse); | ||
939 | retval = -ENODEV; | 933 | retval = -ENODEV; |
940 | goto out; | 934 | goto out; |
941 | } | 935 | } |
@@ -947,13 +941,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
947 | 941 | ||
948 | psmouse_switch_protocol(psmouse, NULL); | 942 | psmouse_switch_protocol(psmouse, NULL); |
949 | 943 | ||
950 | input_register_device(&psmouse->dev); | ||
951 | printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); | ||
952 | |||
953 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); | 944 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); |
954 | |||
955 | psmouse_initialize(psmouse); | 945 | psmouse_initialize(psmouse); |
956 | 946 | ||
947 | input_register_device(psmouse->dev); | ||
948 | |||
957 | if (parent && parent->pt_activate) | 949 | if (parent && parent->pt_activate) |
958 | parent->pt_activate(parent); | 950 | parent->pt_activate(parent); |
959 | 951 | ||
@@ -964,6 +956,12 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
964 | retval = 0; | 956 | retval = 0; |
965 | 957 | ||
966 | out: | 958 | out: |
959 | if (retval) { | ||
960 | serio_set_drvdata(serio, NULL); | ||
961 | input_free_device(input_dev); | ||
962 | kfree(psmouse); | ||
963 | } | ||
964 | |||
967 | /* If this is a pass-through port the parent needs to be re-activated */ | 965 | /* If this is a pass-through port the parent needs to be re-activated */ |
968 | if (parent) | 966 | if (parent) |
969 | psmouse_activate(parent); | 967 | psmouse_activate(parent); |
@@ -1161,6 +1159,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1161 | { | 1159 | { |
1162 | struct serio *serio = psmouse->ps2dev.serio; | 1160 | struct serio *serio = psmouse->ps2dev.serio; |
1163 | struct psmouse *parent = NULL; | 1161 | struct psmouse *parent = NULL; |
1162 | struct input_dev *new_dev; | ||
1164 | struct psmouse_protocol *proto; | 1163 | struct psmouse_protocol *proto; |
1165 | int retry = 0; | 1164 | int retry = 0; |
1166 | 1165 | ||
@@ -1170,9 +1169,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1170 | if (psmouse->type == proto->type) | 1169 | if (psmouse->type == proto->type) |
1171 | return count; | 1170 | return count; |
1172 | 1171 | ||
1172 | if (!(new_dev = input_allocate_device())) | ||
1173 | return -ENOMEM; | ||
1174 | |||
1173 | while (serio->child) { | 1175 | while (serio->child) { |
1174 | if (++retry > 3) { | 1176 | if (++retry > 3) { |
1175 | printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); | 1177 | printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); |
1178 | input_free_device(new_dev); | ||
1176 | return -EIO; | 1179 | return -EIO; |
1177 | } | 1180 | } |
1178 | 1181 | ||
@@ -1182,11 +1185,15 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1182 | serio_pin_driver_uninterruptible(serio); | 1185 | serio_pin_driver_uninterruptible(serio); |
1183 | down(&psmouse_sem); | 1186 | down(&psmouse_sem); |
1184 | 1187 | ||
1185 | if (serio->drv != &psmouse_drv) | 1188 | if (serio->drv != &psmouse_drv) { |
1189 | input_free_device(new_dev); | ||
1186 | return -ENODEV; | 1190 | return -ENODEV; |
1191 | } | ||
1187 | 1192 | ||
1188 | if (psmouse->type == proto->type) | 1193 | if (psmouse->type == proto->type) { |
1194 | input_free_device(new_dev); | ||
1189 | return count; /* switched by other thread */ | 1195 | return count; /* switched by other thread */ |
1196 | } | ||
1190 | } | 1197 | } |
1191 | 1198 | ||
1192 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { | 1199 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { |
@@ -1199,8 +1206,9 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1199 | psmouse->disconnect(psmouse); | 1206 | psmouse->disconnect(psmouse); |
1200 | 1207 | ||
1201 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); | 1208 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); |
1202 | input_unregister_device(&psmouse->dev); | 1209 | input_unregister_device(psmouse->dev); |
1203 | 1210 | ||
1211 | psmouse->dev = new_dev; | ||
1204 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | 1212 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); |
1205 | 1213 | ||
1206 | if (psmouse_switch_protocol(psmouse, proto) < 0) { | 1214 | if (psmouse_switch_protocol(psmouse, proto) < 0) { |
@@ -1212,8 +1220,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1212 | psmouse_initialize(psmouse); | 1220 | psmouse_initialize(psmouse); |
1213 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); | 1221 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); |
1214 | 1222 | ||
1215 | input_register_device(&psmouse->dev); | 1223 | input_register_device(psmouse->dev); |
1216 | printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); | ||
1217 | 1224 | ||
1218 | if (parent && parent->pt_activate) | 1225 | if (parent && parent->pt_activate) |
1219 | parent->pt_activate(parent); | 1226 | parent->pt_activate(parent); |
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 45d2bd774f00..7c4192bd1279 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h | |||
@@ -36,7 +36,7 @@ typedef enum { | |||
36 | 36 | ||
37 | struct psmouse { | 37 | struct psmouse { |
38 | void *private; | 38 | void *private; |
39 | struct input_dev dev; | 39 | struct input_dev *dev; |
40 | struct ps2dev ps2dev; | 40 | struct ps2dev ps2dev; |
41 | char *vendor; | 41 | char *vendor; |
42 | char *name; | 42 | char *name; |
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c index 8fe1212b8fd7..09b6ffdb7582 100644 --- a/drivers/input/mouse/rpcmouse.c +++ b/drivers/input/mouse/rpcmouse.c | |||
@@ -34,20 +34,7 @@ MODULE_DESCRIPTION("Acorn RiscPC mouse driver"); | |||
34 | MODULE_LICENSE("GPL"); | 34 | MODULE_LICENSE("GPL"); |
35 | 35 | ||
36 | static short rpcmouse_lastx, rpcmouse_lasty; | 36 | static short rpcmouse_lastx, rpcmouse_lasty; |
37 | 37 | static struct input_dev *rpcmouse_dev; | |
38 | static struct input_dev rpcmouse_dev = { | ||
39 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, | ||
40 | .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) }, | ||
41 | .relbit = { BIT(REL_X) | BIT(REL_Y) }, | ||
42 | .name = "Acorn RiscPC Mouse", | ||
43 | .phys = "rpcmouse/input0", | ||
44 | .id = { | ||
45 | .bustype = BUS_HOST, | ||
46 | .vendor = 0x0005, | ||
47 | .product = 0x0001, | ||
48 | .version = 0x0100, | ||
49 | }, | ||
50 | }; | ||
51 | 38 | ||
52 | static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs) | 39 | static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs) |
53 | { | 40 | { |
@@ -78,29 +65,41 @@ static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
78 | return IRQ_HANDLED; | 65 | return IRQ_HANDLED; |
79 | } | 66 | } |
80 | 67 | ||
68 | |||
81 | static int __init rpcmouse_init(void) | 69 | static int __init rpcmouse_init(void) |
82 | { | 70 | { |
83 | init_input_dev(&rpcmouse_dev); | 71 | if (!(rpcmouse_dev = input_allocate_device())) |
72 | return -ENOMEM; | ||
73 | |||
74 | rpcmouse_dev->name = "Acorn RiscPC Mouse"; | ||
75 | rpcmouse_dev->phys = "rpcmouse/input0"; | ||
76 | rpcmouse_dev->id.bustype = BUS_HOST; | ||
77 | rpcmouse_dev->id.vendor = 0x0005; | ||
78 | rpcmouse_dev->id.product = 0x0001; | ||
79 | rpcmouse_dev->id.version = 0x0100; | ||
80 | |||
81 | rpcmouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
82 | rpcmouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
83 | rpcmouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
84 | 84 | ||
85 | rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX); | 85 | rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX); |
86 | rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY); | 86 | rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY); |
87 | 87 | ||
88 | if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", &rpcmouse_dev)) { | 88 | if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", rpcmouse_dev)) { |
89 | printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n"); | 89 | printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n"); |
90 | return -1; | 90 | input_free_device(rpcmouse_dev); |
91 | return -EBUSY; | ||
91 | } | 92 | } |
92 | 93 | ||
93 | input_register_device(&rpcmouse_dev); | 94 | input_register_device(rpcmouse_dev); |
94 | |||
95 | printk(KERN_INFO "input: Acorn RiscPC mouse\n"); | ||
96 | 95 | ||
97 | return 0; | 96 | return 0; |
98 | } | 97 | } |
99 | 98 | ||
100 | static void __exit rpcmouse_exit(void) | 99 | static void __exit rpcmouse_exit(void) |
101 | { | 100 | { |
102 | input_unregister_device(&rpcmouse_dev); | 101 | free_irq(IRQ_VSYNCPULSE, rpcmouse_dev); |
103 | free_irq(IRQ_VSYNCPULSE, &rpcmouse_dev); | 102 | input_unregister_device(rpcmouse_dev); |
104 | } | 103 | } |
105 | 104 | ||
106 | module_init(rpcmouse_init); | 105 | module_init(rpcmouse_init); |
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index d12b93ae3900..4bf584364d28 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c | |||
@@ -48,7 +48,7 @@ static char *sermouse_protocols[] = { "None", "Mouse Systems Mouse", "Sun Mouse" | |||
48 | "Logitech MZ++ Mouse"}; | 48 | "Logitech MZ++ Mouse"}; |
49 | 49 | ||
50 | struct sermouse { | 50 | struct sermouse { |
51 | struct input_dev dev; | 51 | struct input_dev *dev; |
52 | signed char buf[8]; | 52 | signed char buf[8]; |
53 | unsigned char count; | 53 | unsigned char count; |
54 | unsigned char type; | 54 | unsigned char type; |
@@ -64,7 +64,7 @@ struct sermouse { | |||
64 | 64 | ||
65 | static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs) | 65 | static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs) |
66 | { | 66 | { |
67 | struct input_dev *dev = &sermouse->dev; | 67 | struct input_dev *dev = sermouse->dev; |
68 | signed char *buf = sermouse->buf; | 68 | signed char *buf = sermouse->buf; |
69 | 69 | ||
70 | input_regs(dev, regs); | 70 | input_regs(dev, regs); |
@@ -107,7 +107,7 @@ static void sermouse_process_msc(struct sermouse *sermouse, signed char data, st | |||
107 | 107 | ||
108 | static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs) | 108 | static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs) |
109 | { | 109 | { |
110 | struct input_dev *dev = &sermouse->dev; | 110 | struct input_dev *dev = sermouse->dev; |
111 | signed char *buf = sermouse->buf; | 111 | signed char *buf = sermouse->buf; |
112 | 112 | ||
113 | if (data & 0x40) sermouse->count = 0; | 113 | if (data & 0x40) sermouse->count = 0; |
@@ -230,9 +230,9 @@ static void sermouse_disconnect(struct serio *serio) | |||
230 | { | 230 | { |
231 | struct sermouse *sermouse = serio_get_drvdata(serio); | 231 | struct sermouse *sermouse = serio_get_drvdata(serio); |
232 | 232 | ||
233 | input_unregister_device(&sermouse->dev); | ||
234 | serio_close(serio); | 233 | serio_close(serio); |
235 | serio_set_drvdata(serio, NULL); | 234 | serio_set_drvdata(serio, NULL); |
235 | input_unregister_device(sermouse->dev); | ||
236 | kfree(sermouse); | 236 | kfree(sermouse); |
237 | } | 237 | } |
238 | 238 | ||
@@ -244,56 +244,52 @@ static void sermouse_disconnect(struct serio *serio) | |||
244 | static int sermouse_connect(struct serio *serio, struct serio_driver *drv) | 244 | static int sermouse_connect(struct serio *serio, struct serio_driver *drv) |
245 | { | 245 | { |
246 | struct sermouse *sermouse; | 246 | struct sermouse *sermouse; |
247 | unsigned char c; | 247 | struct input_dev *input_dev; |
248 | int err; | 248 | unsigned char c = serio->id.extra; |
249 | int err = -ENOMEM; | ||
249 | 250 | ||
250 | if (!serio->id.proto || serio->id.proto > SERIO_MZPP) | 251 | sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL); |
251 | return -ENODEV; | 252 | input_dev = input_allocate_device(); |
252 | 253 | if (!sermouse || !input_dev) | |
253 | if (!(sermouse = kmalloc(sizeof(struct sermouse), GFP_KERNEL))) | 254 | goto fail; |
254 | return -ENOMEM; | ||
255 | |||
256 | memset(sermouse, 0, sizeof(struct sermouse)); | ||
257 | |||
258 | init_input_dev(&sermouse->dev); | ||
259 | sermouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
260 | sermouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); | ||
261 | sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
262 | sermouse->dev.private = sermouse; | ||
263 | |||
264 | sermouse->type = serio->id.proto; | ||
265 | c = serio->id.extra; | ||
266 | |||
267 | if (c & 0x01) set_bit(BTN_MIDDLE, sermouse->dev.keybit); | ||
268 | if (c & 0x02) set_bit(BTN_SIDE, sermouse->dev.keybit); | ||
269 | if (c & 0x04) set_bit(BTN_EXTRA, sermouse->dev.keybit); | ||
270 | if (c & 0x10) set_bit(REL_WHEEL, sermouse->dev.relbit); | ||
271 | if (c & 0x20) set_bit(REL_HWHEEL, sermouse->dev.relbit); | ||
272 | 255 | ||
256 | sermouse->dev = input_dev; | ||
273 | sprintf(sermouse->phys, "%s/input0", serio->phys); | 257 | sprintf(sermouse->phys, "%s/input0", serio->phys); |
258 | sermouse->type = serio->id.proto; | ||
274 | 259 | ||
275 | sermouse->dev.name = sermouse_protocols[sermouse->type]; | 260 | input_dev->name = sermouse_protocols[sermouse->type]; |
276 | sermouse->dev.phys = sermouse->phys; | 261 | input_dev->phys = sermouse->phys; |
277 | sermouse->dev.id.bustype = BUS_RS232; | 262 | input_dev->id.bustype = BUS_RS232; |
278 | sermouse->dev.id.vendor = sermouse->type; | 263 | input_dev->id.vendor = sermouse->type; |
279 | sermouse->dev.id.product = c; | 264 | input_dev->id.product = c; |
280 | sermouse->dev.id.version = 0x0100; | 265 | input_dev->id.version = 0x0100; |
281 | sermouse->dev.dev = &serio->dev; | 266 | input_dev->cdev.dev = &serio->dev; |
267 | |||
268 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
269 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); | ||
270 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
271 | input_dev->private = sermouse; | ||
272 | |||
273 | if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit); | ||
274 | if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit); | ||
275 | if (c & 0x04) set_bit(BTN_EXTRA, input_dev->keybit); | ||
276 | if (c & 0x10) set_bit(REL_WHEEL, input_dev->relbit); | ||
277 | if (c & 0x20) set_bit(REL_HWHEEL, input_dev->relbit); | ||
282 | 278 | ||
283 | serio_set_drvdata(serio, sermouse); | 279 | serio_set_drvdata(serio, sermouse); |
284 | 280 | ||
285 | err = serio_open(serio, drv); | 281 | err = serio_open(serio, drv); |
286 | if (err) { | 282 | if (err) |
287 | serio_set_drvdata(serio, NULL); | 283 | goto fail; |
288 | kfree(sermouse); | ||
289 | return err; | ||
290 | } | ||
291 | |||
292 | input_register_device(&sermouse->dev); | ||
293 | 284 | ||
294 | printk(KERN_INFO "input: %s on %s\n", sermouse_protocols[sermouse->type], serio->phys); | 285 | input_register_device(sermouse->dev); |
295 | 286 | ||
296 | return 0; | 287 | return 0; |
288 | |||
289 | fail: serio_set_drvdata(serio, NULL); | ||
290 | input_free_device(input_dev); | ||
291 | kfree(sermouse); | ||
292 | return err; | ||
297 | } | 293 | } |
298 | 294 | ||
299 | static struct serio_device_id sermouse_serio_ids[] = { | 295 | static struct serio_device_id sermouse_serio_ids[] = { |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 029309422409..97cdfd6acaca 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
@@ -342,7 +342,7 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data | |||
342 | */ | 342 | */ |
343 | static void synaptics_process_packet(struct psmouse *psmouse) | 343 | static void synaptics_process_packet(struct psmouse *psmouse) |
344 | { | 344 | { |
345 | struct input_dev *dev = &psmouse->dev; | 345 | struct input_dev *dev = psmouse->dev; |
346 | struct synaptics_data *priv = psmouse->private; | 346 | struct synaptics_data *priv = psmouse->private; |
347 | struct synaptics_hw_state hw; | 347 | struct synaptics_hw_state hw; |
348 | int num_fingers; | 348 | int num_fingers; |
@@ -473,7 +473,7 @@ static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse) | |||
473 | 473 | ||
474 | static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) | 474 | static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) |
475 | { | 475 | { |
476 | struct input_dev *dev = &psmouse->dev; | 476 | struct input_dev *dev = psmouse->dev; |
477 | struct synaptics_data *priv = psmouse->private; | 477 | struct synaptics_data *priv = psmouse->private; |
478 | 478 | ||
479 | input_regs(dev, regs); | 479 | input_regs(dev, regs); |
@@ -645,7 +645,7 @@ int synaptics_init(struct psmouse *psmouse) | |||
645 | SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), | 645 | SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), |
646 | priv->model_id, priv->capabilities, priv->ext_cap); | 646 | priv->model_id, priv->capabilities, priv->ext_cap); |
647 | 647 | ||
648 | set_input_params(&psmouse->dev, priv); | 648 | set_input_params(psmouse->dev, priv); |
649 | 649 | ||
650 | psmouse->protocol_handler = synaptics_process_byte; | 650 | psmouse->protocol_handler = synaptics_process_byte; |
651 | psmouse->set_rate = synaptics_set_rate; | 651 | psmouse->set_rate = synaptics_set_rate; |
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index f024be9b44d2..36e9442a16b2 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c | |||
@@ -112,7 +112,7 @@ MODULE_LICENSE ("GPL"); | |||
112 | 112 | ||
113 | 113 | ||
114 | struct vsxxxaa { | 114 | struct vsxxxaa { |
115 | struct input_dev dev; | 115 | struct input_dev *dev; |
116 | struct serio *serio; | 116 | struct serio *serio; |
117 | #define BUFLEN 15 /* At least 5 is needed for a full tablet packet */ | 117 | #define BUFLEN 15 /* At least 5 is needed for a full tablet packet */ |
118 | unsigned char buf[BUFLEN]; | 118 | unsigned char buf[BUFLEN]; |
@@ -211,7 +211,7 @@ vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t le | |||
211 | static void | 211 | static void |
212 | vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | 212 | vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) |
213 | { | 213 | { |
214 | struct input_dev *dev = &mouse->dev; | 214 | struct input_dev *dev = mouse->dev; |
215 | unsigned char *buf = mouse->buf; | 215 | unsigned char *buf = mouse->buf; |
216 | int left, middle, right; | 216 | int left, middle, right; |
217 | int dx, dy; | 217 | int dx, dy; |
@@ -269,7 +269,7 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | |||
269 | static void | 269 | static void |
270 | vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | 270 | vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) |
271 | { | 271 | { |
272 | struct input_dev *dev = &mouse->dev; | 272 | struct input_dev *dev = mouse->dev; |
273 | unsigned char *buf = mouse->buf; | 273 | unsigned char *buf = mouse->buf; |
274 | int left, middle, right, touch; | 274 | int left, middle, right, touch; |
275 | int x, y; | 275 | int x, y; |
@@ -323,7 +323,7 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | |||
323 | static void | 323 | static void |
324 | vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | 324 | vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs) |
325 | { | 325 | { |
326 | struct input_dev *dev = &mouse->dev; | 326 | struct input_dev *dev = mouse->dev; |
327 | unsigned char *buf = mouse->buf; | 327 | unsigned char *buf = mouse->buf; |
328 | int left, middle, right; | 328 | int left, middle, right; |
329 | unsigned char error; | 329 | unsigned char error; |
@@ -483,9 +483,9 @@ vsxxxaa_disconnect (struct serio *serio) | |||
483 | { | 483 | { |
484 | struct vsxxxaa *mouse = serio_get_drvdata (serio); | 484 | struct vsxxxaa *mouse = serio_get_drvdata (serio); |
485 | 485 | ||
486 | input_unregister_device (&mouse->dev); | ||
487 | serio_close (serio); | 486 | serio_close (serio); |
488 | serio_set_drvdata (serio, NULL); | 487 | serio_set_drvdata (serio, NULL); |
488 | input_unregister_device (mouse->dev); | ||
489 | kfree (mouse); | 489 | kfree (mouse); |
490 | } | 490 | } |
491 | 491 | ||
@@ -493,61 +493,57 @@ static int | |||
493 | vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) | 493 | vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) |
494 | { | 494 | { |
495 | struct vsxxxaa *mouse; | 495 | struct vsxxxaa *mouse; |
496 | int err; | 496 | struct input_dev *input_dev; |
497 | int err = -ENOMEM; | ||
497 | 498 | ||
498 | if (!(mouse = kmalloc (sizeof (struct vsxxxaa), GFP_KERNEL))) | 499 | mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL); |
499 | return -ENOMEM; | 500 | input_dev = input_allocate_device (); |
500 | 501 | if (!mouse || !input_dev) | |
501 | memset (mouse, 0, sizeof (struct vsxxxaa)); | 502 | goto fail; |
502 | |||
503 | init_input_dev (&mouse->dev); | ||
504 | set_bit (EV_KEY, mouse->dev.evbit); /* We have buttons */ | ||
505 | set_bit (EV_REL, mouse->dev.evbit); | ||
506 | set_bit (EV_ABS, mouse->dev.evbit); | ||
507 | set_bit (BTN_LEFT, mouse->dev.keybit); /* We have 3 buttons */ | ||
508 | set_bit (BTN_MIDDLE, mouse->dev.keybit); | ||
509 | set_bit (BTN_RIGHT, mouse->dev.keybit); | ||
510 | set_bit (BTN_TOUCH, mouse->dev.keybit); /* ...and Tablet */ | ||
511 | set_bit (REL_X, mouse->dev.relbit); | ||
512 | set_bit (REL_Y, mouse->dev.relbit); | ||
513 | set_bit (ABS_X, mouse->dev.absbit); | ||
514 | set_bit (ABS_Y, mouse->dev.absbit); | ||
515 | |||
516 | mouse->dev.absmin[ABS_X] = 0; | ||
517 | mouse->dev.absmax[ABS_X] = 1023; | ||
518 | mouse->dev.absmin[ABS_Y] = 0; | ||
519 | mouse->dev.absmax[ABS_Y] = 1023; | ||
520 | |||
521 | mouse->dev.private = mouse; | ||
522 | 503 | ||
504 | mouse->dev = input_dev; | ||
505 | mouse->serio = serio; | ||
523 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); | 506 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); |
524 | sprintf (mouse->phys, "%s/input0", serio->phys); | 507 | sprintf (mouse->phys, "%s/input0", serio->phys); |
525 | mouse->dev.name = mouse->name; | 508 | |
526 | mouse->dev.phys = mouse->phys; | 509 | input_dev->name = mouse->name; |
527 | mouse->dev.id.bustype = BUS_RS232; | 510 | input_dev->phys = mouse->phys; |
528 | mouse->dev.dev = &serio->dev; | 511 | input_dev->id.bustype = BUS_RS232; |
529 | mouse->serio = serio; | 512 | input_dev->cdev.dev = &serio->dev; |
513 | input_dev->private = mouse; | ||
514 | |||
515 | set_bit (EV_KEY, input_dev->evbit); /* We have buttons */ | ||
516 | set_bit (EV_REL, input_dev->evbit); | ||
517 | set_bit (EV_ABS, input_dev->evbit); | ||
518 | set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */ | ||
519 | set_bit (BTN_MIDDLE, input_dev->keybit); | ||
520 | set_bit (BTN_RIGHT, input_dev->keybit); | ||
521 | set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */ | ||
522 | set_bit (REL_X, input_dev->relbit); | ||
523 | set_bit (REL_Y, input_dev->relbit); | ||
524 | input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0); | ||
525 | input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0); | ||
530 | 526 | ||
531 | serio_set_drvdata (serio, mouse); | 527 | serio_set_drvdata (serio, mouse); |
532 | 528 | ||
533 | err = serio_open (serio, drv); | 529 | err = serio_open (serio, drv); |
534 | if (err) { | 530 | if (err) |
535 | serio_set_drvdata (serio, NULL); | 531 | goto fail; |
536 | kfree (mouse); | ||
537 | return err; | ||
538 | } | ||
539 | 532 | ||
540 | /* | 533 | /* |
541 | * Request selftest. Standard packet format and differential | 534 | * Request selftest. Standard packet format and differential |
542 | * mode will be requested after the device ID'ed successfully. | 535 | * mode will be requested after the device ID'ed successfully. |
543 | */ | 536 | */ |
544 | mouse->serio->write (mouse->serio, 'T'); /* Test */ | 537 | serio->write (serio, 'T'); /* Test */ |
545 | |||
546 | input_register_device (&mouse->dev); | ||
547 | 538 | ||
548 | printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys); | 539 | input_register_device (input_dev); |
549 | 540 | ||
550 | return 0; | 541 | return 0; |
542 | |||
543 | fail: serio_set_drvdata (serio, NULL); | ||
544 | input_free_device (input_dev); | ||
545 | kfree (mouse); | ||
546 | return err; | ||
551 | } | 547 | } |
552 | 548 | ||
553 | static struct serio_device_id vsxxaa_serio_ids[] = { | 549 | static struct serio_device_id vsxxaa_serio_ids[] = { |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index c6194a9dd174..2d0af44ac4b9 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * the Free Software Foundation. | 9 | * the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define MOUSEDEV_MINOR_BASE 32 | 12 | #define MOUSEDEV_MINOR_BASE 32 |
13 | #define MOUSEDEV_MINORS 32 | 13 | #define MOUSEDEV_MINORS 32 |
14 | #define MOUSEDEV_MIX 31 | 14 | #define MOUSEDEV_MIX 31 |
15 | 15 | ||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/random.h> | 24 | #include <linux/random.h> |
25 | #include <linux/major.h> | 25 | #include <linux/major.h> |
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/devfs_fs_kernel.h> | ||
28 | #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX | 27 | #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX |
29 | #include <linux/miscdevice.h> | 28 | #include <linux/miscdevice.h> |
30 | #endif | 29 | #endif |
@@ -621,6 +620,7 @@ static struct file_operations mousedev_fops = { | |||
621 | static struct input_handle *mousedev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) | 620 | static struct input_handle *mousedev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
622 | { | 621 | { |
623 | struct mousedev *mousedev; | 622 | struct mousedev *mousedev; |
623 | struct class_device *cdev; | ||
624 | int minor = 0; | 624 | int minor = 0; |
625 | 625 | ||
626 | for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++); | 626 | for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++); |
@@ -649,11 +649,13 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru | |||
649 | 649 | ||
650 | mousedev_table[minor] = mousedev; | 650 | mousedev_table[minor] = mousedev; |
651 | 651 | ||
652 | devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), | 652 | cdev = class_device_create(&input_class, &dev->cdev, |
653 | S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor); | ||
654 | class_device_create(input_class, | ||
655 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), | 653 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), |
656 | dev->dev, "mouse%d", minor); | 654 | dev->cdev.dev, mousedev->name); |
655 | |||
656 | /* temporary symlink to keep userspace happy */ | ||
657 | sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, | ||
658 | mousedev->name); | ||
657 | 659 | ||
658 | return &mousedev->handle; | 660 | return &mousedev->handle; |
659 | } | 661 | } |
@@ -663,9 +665,9 @@ static void mousedev_disconnect(struct input_handle *handle) | |||
663 | struct mousedev *mousedev = handle->private; | 665 | struct mousedev *mousedev = handle->private; |
664 | struct mousedev_list *list; | 666 | struct mousedev_list *list; |
665 | 667 | ||
666 | class_device_destroy(input_class, | 668 | sysfs_remove_link(&input_class.subsys.kset.kobj, mousedev->name); |
669 | class_device_destroy(&input_class, | ||
667 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor)); | 670 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor)); |
668 | devfs_remove("input/mouse%d", mousedev->minor); | ||
669 | mousedev->exist = 0; | 671 | mousedev->exist = 0; |
670 | 672 | ||
671 | if (mousedev->open) { | 673 | if (mousedev->open) { |
@@ -738,9 +740,7 @@ static int __init mousedev_init(void) | |||
738 | mousedev_mix.exist = 1; | 740 | mousedev_mix.exist = 1; |
739 | mousedev_mix.minor = MOUSEDEV_MIX; | 741 | mousedev_mix.minor = MOUSEDEV_MIX; |
740 | 742 | ||
741 | devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), | 743 | class_device_create(&input_class, NULL, |
742 | S_IFCHR|S_IRUGO|S_IWUSR, "input/mice"); | ||
743 | class_device_create(input_class, | ||
744 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice"); | 744 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice"); |
745 | 745 | ||
746 | #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX | 746 | #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX |
@@ -759,8 +759,7 @@ static void __exit mousedev_exit(void) | |||
759 | if (psaux_registered) | 759 | if (psaux_registered) |
760 | misc_deregister(&psaux_mouse); | 760 | misc_deregister(&psaux_mouse); |
761 | #endif | 761 | #endif |
762 | devfs_remove("input/mice"); | 762 | class_device_destroy(&input_class, |
763 | class_device_destroy(input_class, | ||
764 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX)); | 763 | MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX)); |
765 | input_unregister_handler(&mousedev_handler); | 764 | input_unregister_handler(&mousedev_handler); |
766 | } | 765 | } |
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 897e4c12b642..a7b0de0f92b2 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c | |||
@@ -211,9 +211,6 @@ static void gscps2_reset(struct gscps2port *ps2port) | |||
211 | writeb(0xff, addr+GSC_RESET); | 211 | writeb(0xff, addr+GSC_RESET); |
212 | gscps2_flush(ps2port); | 212 | gscps2_flush(ps2port); |
213 | spin_unlock_irqrestore(&ps2port->lock, flags); | 213 | spin_unlock_irqrestore(&ps2port->lock, flags); |
214 | |||
215 | /* enable it */ | ||
216 | gscps2_enable(ps2port, ENABLE); | ||
217 | } | 214 | } |
218 | 215 | ||
219 | static LIST_HEAD(ps2port_list); | 216 | static LIST_HEAD(ps2port_list); |
@@ -307,6 +304,9 @@ static int gscps2_open(struct serio *port) | |||
307 | 304 | ||
308 | gscps2_reset(ps2port); | 305 | gscps2_reset(ps2port); |
309 | 306 | ||
307 | /* enable it */ | ||
308 | gscps2_enable(ps2port, ENABLE); | ||
309 | |||
310 | gscps2_interrupt(0, NULL, NULL); | 310 | gscps2_interrupt(0, NULL, NULL); |
311 | 311 | ||
312 | return 0; | 312 | return 0; |
@@ -331,7 +331,7 @@ static int __init gscps2_probe(struct parisc_device *dev) | |||
331 | { | 331 | { |
332 | struct gscps2port *ps2port; | 332 | struct gscps2port *ps2port; |
333 | struct serio *serio; | 333 | struct serio *serio; |
334 | unsigned long hpa = dev->hpa; | 334 | unsigned long hpa = dev->hpa.start; |
335 | int ret; | 335 | int ret; |
336 | 336 | ||
337 | if (!dev->irq) | 337 | if (!dev->irq) |
@@ -370,8 +370,6 @@ static int __init gscps2_probe(struct parisc_device *dev) | |||
370 | serio->port_data = ps2port; | 370 | serio->port_data = ps2port; |
371 | serio->dev.parent = &dev->dev; | 371 | serio->dev.parent = &dev->dev; |
372 | 372 | ||
373 | list_add_tail(&ps2port->node, &ps2port_list); | ||
374 | |||
375 | ret = -EBUSY; | 373 | ret = -EBUSY; |
376 | if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->port->name, ps2port)) | 374 | if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->port->name, ps2port)) |
377 | goto fail_miserably; | 375 | goto fail_miserably; |
@@ -396,15 +394,16 @@ static int __init gscps2_probe(struct parisc_device *dev) | |||
396 | 394 | ||
397 | serio_register_port(ps2port->port); | 395 | serio_register_port(ps2port->port); |
398 | 396 | ||
397 | list_add_tail(&ps2port->node, &ps2port_list); | ||
398 | |||
399 | return 0; | 399 | return 0; |
400 | 400 | ||
401 | fail: | 401 | fail: |
402 | free_irq(dev->irq, ps2port); | 402 | free_irq(dev->irq, ps2port); |
403 | 403 | ||
404 | fail_miserably: | 404 | fail_miserably: |
405 | list_del(&ps2port->node); | ||
406 | iounmap(ps2port->addr); | 405 | iounmap(ps2port->addr); |
407 | release_mem_region(dev->hpa, GSC_STATUS + 4); | 406 | release_mem_region(dev->hpa.start, GSC_STATUS + 4); |
408 | 407 | ||
409 | fail_nomem: | 408 | fail_nomem: |
410 | kfree(ps2port); | 409 | kfree(ps2port); |
@@ -444,7 +443,7 @@ static struct parisc_device_id gscps2_device_tbl[] = { | |||
444 | }; | 443 | }; |
445 | 444 | ||
446 | static struct parisc_driver parisc_ps2_driver = { | 445 | static struct parisc_driver parisc_ps2_driver = { |
447 | .name = "GSC PS2", | 446 | .name = "gsc_ps2", |
448 | .id_table = gscps2_device_tbl, | 447 | .id_table = gscps2_device_tbl, |
449 | .probe = gscps2_probe, | 448 | .probe = gscps2_probe, |
450 | .remove = gscps2_remove, | 449 | .remove = gscps2_remove, |
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c index c243cb6fdfc4..5704204964a3 100644 --- a/drivers/input/serio/hil_mlc.c +++ b/drivers/input/serio/hil_mlc.c | |||
@@ -801,7 +801,8 @@ static int hil_mlc_serio_open(struct serio *serio) { | |||
801 | struct hil_mlc_serio_map *map; | 801 | struct hil_mlc_serio_map *map; |
802 | struct hil_mlc *mlc; | 802 | struct hil_mlc *mlc; |
803 | 803 | ||
804 | if (serio->private != NULL) return -EBUSY; | 804 | if (serio_get_drvdata(serio) != NULL) |
805 | return -EBUSY; | ||
805 | 806 | ||
806 | map = serio->port_data; | 807 | map = serio->port_data; |
807 | if (map == NULL) { | 808 | if (map == NULL) { |
@@ -832,11 +833,18 @@ static void hil_mlc_serio_close(struct serio *serio) { | |||
832 | return; | 833 | return; |
833 | } | 834 | } |
834 | 835 | ||
835 | serio->private = NULL; | 836 | serio_set_drvdata(serio, NULL); |
836 | serio->drv = NULL; | 837 | serio->drv = NULL; |
837 | /* TODO wake up interruptable */ | 838 | /* TODO wake up interruptable */ |
838 | } | 839 | } |
839 | 840 | ||
841 | static struct serio_device_id hil_mlc_serio_id = { | ||
842 | .type = SERIO_HIL_MLC, | ||
843 | .proto = SERIO_HIL, | ||
844 | .extra = SERIO_ANY, | ||
845 | .id = SERIO_ANY, | ||
846 | }; | ||
847 | |||
840 | int hil_mlc_register(hil_mlc *mlc) { | 848 | int hil_mlc_register(hil_mlc *mlc) { |
841 | int i; | 849 | int i; |
842 | unsigned long flags; | 850 | unsigned long flags; |
@@ -867,7 +875,7 @@ int hil_mlc_register(hil_mlc *mlc) { | |||
867 | mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL); | 875 | mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL); |
868 | mlc->serio[i] = mlc_serio; | 876 | mlc->serio[i] = mlc_serio; |
869 | memset(mlc_serio, 0, sizeof(*mlc_serio)); | 877 | memset(mlc_serio, 0, sizeof(*mlc_serio)); |
870 | mlc_serio->type = SERIO_HIL | SERIO_HIL_MLC; | 878 | mlc_serio->id = hil_mlc_serio_id; |
871 | mlc_serio->write = hil_mlc_serio_write; | 879 | mlc_serio->write = hil_mlc_serio_write; |
872 | mlc_serio->open = hil_mlc_serio_open; | 880 | mlc_serio->open = hil_mlc_serio_open; |
873 | mlc_serio->close = hil_mlc_serio_close; | 881 | mlc_serio->close = hil_mlc_serio_close; |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 7629452dd64b..a10348bb25e9 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -764,7 +764,7 @@ MODULE_DEVICE_TABLE(parisc, hp_sdc_tbl); | |||
764 | static int __init hp_sdc_init_hppa(struct parisc_device *d); | 764 | static int __init hp_sdc_init_hppa(struct parisc_device *d); |
765 | 765 | ||
766 | static struct parisc_driver hp_sdc_driver = { | 766 | static struct parisc_driver hp_sdc_driver = { |
767 | .name = "HP SDC", | 767 | .name = "hp_sdc", |
768 | .id_table = hp_sdc_tbl, | 768 | .id_table = hp_sdc_tbl, |
769 | .probe = hp_sdc_init_hppa, | 769 | .probe = hp_sdc_init_hppa, |
770 | }; | 770 | }; |
@@ -875,9 +875,9 @@ static int __init hp_sdc_init_hppa(struct parisc_device *d) | |||
875 | hp_sdc.dev = d; | 875 | hp_sdc.dev = d; |
876 | hp_sdc.irq = d->irq; | 876 | hp_sdc.irq = d->irq; |
877 | hp_sdc.nmi = d->aux_irq; | 877 | hp_sdc.nmi = d->aux_irq; |
878 | hp_sdc.base_io = d->hpa; | 878 | hp_sdc.base_io = d->hpa.start; |
879 | hp_sdc.data_io = d->hpa + 0x800; | 879 | hp_sdc.data_io = d->hpa.start + 0x800; |
880 | hp_sdc.status_io = d->hpa + 0x801; | 880 | hp_sdc.status_io = d->hpa.start + 0x801; |
881 | 881 | ||
882 | return hp_sdc_init(); | 882 | return hp_sdc_init(); |
883 | } | 883 | } |
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 40d451ce07ff..4bc40f159996 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -911,12 +911,10 @@ static long i8042_panic_blink(long count) | |||
911 | * Here we try to restore the original BIOS settings | 911 | * Here we try to restore the original BIOS settings |
912 | */ | 912 | */ |
913 | 913 | ||
914 | static int i8042_suspend(struct device *dev, pm_message_t state, u32 level) | 914 | static int i8042_suspend(struct device *dev, pm_message_t state) |
915 | { | 915 | { |
916 | if (level == SUSPEND_DISABLE) { | 916 | del_timer_sync(&i8042_timer); |
917 | del_timer_sync(&i8042_timer); | 917 | i8042_controller_reset(); |
918 | i8042_controller_reset(); | ||
919 | } | ||
920 | 918 | ||
921 | return 0; | 919 | return 0; |
922 | } | 920 | } |
@@ -926,13 +924,10 @@ static int i8042_suspend(struct device *dev, pm_message_t state, u32 level) | |||
926 | * Here we try to reset everything back to a state in which suspended | 924 | * Here we try to reset everything back to a state in which suspended |
927 | */ | 925 | */ |
928 | 926 | ||
929 | static int i8042_resume(struct device *dev, u32 level) | 927 | static int i8042_resume(struct device *dev) |
930 | { | 928 | { |
931 | int i; | 929 | int i; |
932 | 930 | ||
933 | if (level != RESUME_ENABLE) | ||
934 | return 0; | ||
935 | |||
936 | if (i8042_ctl_test()) | 931 | if (i8042_ctl_test()) |
937 | return -1; | 932 | return -1; |
938 | 933 | ||
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 4c7fbe550365..0ba3e6562bff 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c | |||
@@ -41,8 +41,7 @@ struct ts_event { | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | struct corgi_ts { | 43 | struct corgi_ts { |
44 | char phys[32]; | 44 | struct input_dev *input; |
45 | struct input_dev input; | ||
46 | struct timer_list timer; | 45 | struct timer_list timer; |
47 | struct ts_event tc; | 46 | struct ts_event tc; |
48 | int pendown; | 47 | int pendown; |
@@ -182,14 +181,12 @@ static void new_data(struct corgi_ts *corgi_ts, struct pt_regs *regs) | |||
182 | if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) | 181 | if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) |
183 | return; | 182 | return; |
184 | 183 | ||
185 | if (regs) | 184 | input_regs(corgi_ts->input, regs); |
186 | input_regs(&corgi_ts->input, regs); | 185 | input_report_abs(corgi_ts->input, ABS_X, corgi_ts->tc.x); |
187 | 186 | input_report_abs(corgi_ts->input, ABS_Y, corgi_ts->tc.y); | |
188 | input_report_abs(&corgi_ts->input, ABS_X, corgi_ts->tc.x); | 187 | input_report_abs(corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure); |
189 | input_report_abs(&corgi_ts->input, ABS_Y, corgi_ts->tc.y); | 188 | input_report_key(corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0)); |
190 | input_report_abs(&corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure); | 189 | input_sync(corgi_ts->input); |
191 | input_report_key(&corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0)); | ||
192 | input_sync(&corgi_ts->input); | ||
193 | } | 190 | } |
194 | 191 | ||
195 | static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) | 192 | static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) |
@@ -234,34 +231,32 @@ static irqreturn_t ts_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
234 | } | 231 | } |
235 | 232 | ||
236 | #ifdef CONFIG_PM | 233 | #ifdef CONFIG_PM |
237 | static int corgits_suspend(struct device *dev, pm_message_t state, uint32_t level) | 234 | static int corgits_suspend(struct device *dev, pm_message_t state) |
238 | { | 235 | { |
239 | if (level == SUSPEND_POWER_DOWN) { | 236 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); |
240 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); | ||
241 | |||
242 | if (corgi_ts->pendown) { | ||
243 | del_timer_sync(&corgi_ts->timer); | ||
244 | corgi_ts->tc.pressure = 0; | ||
245 | new_data(corgi_ts, NULL); | ||
246 | corgi_ts->pendown = 0; | ||
247 | } | ||
248 | corgi_ts->power_mode = PWR_MODE_SUSPEND; | ||
249 | 237 | ||
250 | corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | 238 | if (corgi_ts->pendown) { |
239 | del_timer_sync(&corgi_ts->timer); | ||
240 | corgi_ts->tc.pressure = 0; | ||
241 | new_data(corgi_ts, NULL); | ||
242 | corgi_ts->pendown = 0; | ||
251 | } | 243 | } |
244 | corgi_ts->power_mode = PWR_MODE_SUSPEND; | ||
245 | |||
246 | corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
247 | |||
252 | return 0; | 248 | return 0; |
253 | } | 249 | } |
254 | 250 | ||
255 | static int corgits_resume(struct device *dev, uint32_t level) | 251 | static int corgits_resume(struct device *dev) |
256 | { | 252 | { |
257 | if (level == RESUME_POWER_ON) { | 253 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); |
258 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); | 254 | |
255 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
256 | /* Enable Falling Edge */ | ||
257 | set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); | ||
258 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
259 | 259 | ||
260 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
261 | /* Enable Falling Edge */ | ||
262 | set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); | ||
263 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
264 | } | ||
265 | return 0; | 260 | return 0; |
266 | } | 261 | } |
267 | #else | 262 | #else |
@@ -273,39 +268,44 @@ static int __init corgits_probe(struct device *dev) | |||
273 | { | 268 | { |
274 | struct corgi_ts *corgi_ts; | 269 | struct corgi_ts *corgi_ts; |
275 | struct platform_device *pdev = to_platform_device(dev); | 270 | struct platform_device *pdev = to_platform_device(dev); |
271 | struct input_dev *input_dev; | ||
272 | int err = -ENOMEM; | ||
276 | 273 | ||
277 | if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL))) | 274 | corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL); |
278 | return -ENOMEM; | 275 | input_dev = input_allocate_device(); |
276 | if (!corgi_ts || !input_dev) | ||
277 | goto fail; | ||
279 | 278 | ||
280 | dev_set_drvdata(dev, corgi_ts); | 279 | dev_set_drvdata(dev, corgi_ts); |
281 | 280 | ||
282 | memset(corgi_ts, 0, sizeof(struct corgi_ts)); | ||
283 | |||
284 | corgi_ts->machinfo = dev->platform_data; | 281 | corgi_ts->machinfo = dev->platform_data; |
285 | corgi_ts->irq_gpio = platform_get_irq(pdev, 0); | 282 | corgi_ts->irq_gpio = platform_get_irq(pdev, 0); |
286 | 283 | ||
287 | if (corgi_ts->irq_gpio < 0) { | 284 | if (corgi_ts->irq_gpio < 0) { |
288 | kfree(corgi_ts); | 285 | err = -ENODEV; |
289 | return -ENODEV; | 286 | goto fail; |
290 | } | 287 | } |
291 | 288 | ||
292 | init_input_dev(&corgi_ts->input); | 289 | corgi_ts->input = input_dev; |
293 | corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
294 | corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
295 | input_set_abs_params(&corgi_ts->input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); | ||
296 | input_set_abs_params(&corgi_ts->input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); | ||
297 | input_set_abs_params(&corgi_ts->input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); | ||
298 | 290 | ||
299 | strcpy(corgi_ts->phys, "corgits/input0"); | 291 | init_timer(&corgi_ts->timer); |
292 | corgi_ts->timer.data = (unsigned long) corgi_ts; | ||
293 | corgi_ts->timer.function = corgi_ts_timer; | ||
300 | 294 | ||
301 | corgi_ts->input.private = corgi_ts; | 295 | input_dev->name = "Corgi Touchscreen"; |
302 | corgi_ts->input.name = "Corgi Touchscreen"; | 296 | input_dev->phys = "corgits/input0"; |
303 | corgi_ts->input.dev = dev; | 297 | input_dev->id.bustype = BUS_HOST; |
304 | corgi_ts->input.phys = corgi_ts->phys; | 298 | input_dev->id.vendor = 0x0001; |
305 | corgi_ts->input.id.bustype = BUS_HOST; | 299 | input_dev->id.product = 0x0002; |
306 | corgi_ts->input.id.vendor = 0x0001; | 300 | input_dev->id.version = 0x0100; |
307 | corgi_ts->input.id.product = 0x0002; | 301 | input_dev->cdev.dev = dev; |
308 | corgi_ts->input.id.version = 0x0100; | 302 | input_dev->private = corgi_ts; |
303 | |||
304 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
305 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
306 | input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); | ||
307 | input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); | ||
308 | input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); | ||
309 | 309 | ||
310 | pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN); | 310 | pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN); |
311 | 311 | ||
@@ -319,25 +319,24 @@ static int __init corgits_probe(struct device *dev) | |||
319 | corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | 319 | corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS); |
320 | mdelay(5); | 320 | mdelay(5); |
321 | 321 | ||
322 | init_timer(&corgi_ts->timer); | ||
323 | corgi_ts->timer.data = (unsigned long) corgi_ts; | ||
324 | corgi_ts->timer.function = corgi_ts_timer; | ||
325 | |||
326 | input_register_device(&corgi_ts->input); | ||
327 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
328 | |||
329 | if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { | 322 | if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { |
330 | input_unregister_device(&corgi_ts->input); | 323 | err = -EBUSY; |
331 | kfree(corgi_ts); | 324 | goto fail; |
332 | return -EBUSY; | ||
333 | } | 325 | } |
334 | 326 | ||
327 | input_register_device(corgi_ts->input); | ||
328 | |||
329 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
330 | |||
335 | /* Enable Falling Edge */ | 331 | /* Enable Falling Edge */ |
336 | set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); | 332 | set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); |
337 | 333 | ||
338 | printk(KERN_INFO "input: Corgi Touchscreen Registered\n"); | ||
339 | |||
340 | return 0; | 334 | return 0; |
335 | |||
336 | fail: input_free_device(input_dev); | ||
337 | kfree(corgi_ts); | ||
338 | return err; | ||
339 | |||
341 | } | 340 | } |
342 | 341 | ||
343 | static int corgits_remove(struct device *dev) | 342 | static int corgits_remove(struct device *dev) |
@@ -347,7 +346,7 @@ static int corgits_remove(struct device *dev) | |||
347 | free_irq(corgi_ts->irq_gpio, NULL); | 346 | free_irq(corgi_ts->irq_gpio, NULL); |
348 | del_timer_sync(&corgi_ts->timer); | 347 | del_timer_sync(&corgi_ts->timer); |
349 | corgi_ts->machinfo->put_hsync(); | 348 | corgi_ts->machinfo->put_hsync(); |
350 | input_unregister_device(&corgi_ts->input); | 349 | input_unregister_device(corgi_ts->input); |
351 | kfree(corgi_ts); | 350 | kfree(corgi_ts); |
352 | return 0; | 351 | return 0; |
353 | } | 352 | } |
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 3cdc9cab688d..c86a2eb310fd 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c | |||
@@ -36,14 +36,12 @@ MODULE_LICENSE("GPL"); | |||
36 | 36 | ||
37 | #define ELO_MAX_LENGTH 10 | 37 | #define ELO_MAX_LENGTH 10 |
38 | 38 | ||
39 | static char *elo_name = "Elo Serial TouchScreen"; | ||
40 | |||
41 | /* | 39 | /* |
42 | * Per-touchscreen data. | 40 | * Per-touchscreen data. |
43 | */ | 41 | */ |
44 | 42 | ||
45 | struct elo { | 43 | struct elo { |
46 | struct input_dev dev; | 44 | struct input_dev *dev; |
47 | struct serio *serio; | 45 | struct serio *serio; |
48 | int id; | 46 | int id; |
49 | int idx; | 47 | int idx; |
@@ -54,7 +52,7 @@ struct elo { | |||
54 | 52 | ||
55 | static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs) | 53 | static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs) |
56 | { | 54 | { |
57 | struct input_dev *dev = &elo->dev; | 55 | struct input_dev *dev = elo->dev; |
58 | 56 | ||
59 | elo->csum += elo->data[elo->idx] = data; | 57 | elo->csum += elo->data[elo->idx] = data; |
60 | 58 | ||
@@ -80,7 +78,7 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r | |||
80 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); | 78 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); |
81 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); | 79 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); |
82 | input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]); | 80 | input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]); |
83 | input_report_key(dev, BTN_TOUCH, elo->data[2] & 3); | 81 | input_report_key(dev, BTN_TOUCH, elo->data[8] || elo->data[7]); |
84 | input_sync(dev); | 82 | input_sync(dev); |
85 | } | 83 | } |
86 | elo->idx = 0; | 84 | elo->idx = 0; |
@@ -91,7 +89,7 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r | |||
91 | 89 | ||
92 | static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs) | 90 | static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs) |
93 | { | 91 | { |
94 | struct input_dev *dev = &elo->dev; | 92 | struct input_dev *dev = elo->dev; |
95 | 93 | ||
96 | elo->data[elo->idx] = data; | 94 | elo->data[elo->idx] = data; |
97 | 95 | ||
@@ -129,7 +127,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re | |||
129 | case 5: | 127 | case 5: |
130 | if ((data & 0xf0) == 0) { | 128 | if ((data & 0xf0) == 0) { |
131 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); | 129 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); |
132 | input_report_key(dev, BTN_TOUCH, elo->data[5]); | 130 | input_report_key(dev, BTN_TOUCH, !!elo->data[5]); |
133 | } | 131 | } |
134 | input_sync(dev); | 132 | input_sync(dev); |
135 | elo->idx = 0; | 133 | elo->idx = 0; |
@@ -139,7 +137,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re | |||
139 | 137 | ||
140 | static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs) | 138 | static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs) |
141 | { | 139 | { |
142 | struct input_dev *dev = &elo->dev; | 140 | struct input_dev *dev = elo->dev; |
143 | 141 | ||
144 | elo->data[elo->idx] = data; | 142 | elo->data[elo->idx] = data; |
145 | 143 | ||
@@ -191,7 +189,7 @@ static void elo_disconnect(struct serio *serio) | |||
191 | { | 189 | { |
192 | struct elo* elo = serio_get_drvdata(serio); | 190 | struct elo* elo = serio_get_drvdata(serio); |
193 | 191 | ||
194 | input_unregister_device(&elo->dev); | 192 | input_unregister_device(elo->dev); |
195 | serio_close(serio); | 193 | serio_close(serio); |
196 | serio_set_drvdata(serio, NULL); | 194 | serio_set_drvdata(serio, NULL); |
197 | kfree(elo); | 195 | kfree(elo); |
@@ -206,67 +204,68 @@ static void elo_disconnect(struct serio *serio) | |||
206 | static int elo_connect(struct serio *serio, struct serio_driver *drv) | 204 | static int elo_connect(struct serio *serio, struct serio_driver *drv) |
207 | { | 205 | { |
208 | struct elo *elo; | 206 | struct elo *elo; |
207 | struct input_dev *input_dev; | ||
209 | int err; | 208 | int err; |
210 | 209 | ||
211 | if (!(elo = kmalloc(sizeof(struct elo), GFP_KERNEL))) | 210 | elo = kzalloc(sizeof(struct elo), GFP_KERNEL); |
212 | return -ENOMEM; | 211 | input_dev = input_allocate_device(); |
212 | if (!elo || !input_dev) { | ||
213 | err = -ENOMEM; | ||
214 | goto fail; | ||
215 | } | ||
213 | 216 | ||
214 | memset(elo, 0, sizeof(struct elo)); | 217 | elo->serio = serio; |
218 | elo->id = serio->id.id; | ||
219 | elo->dev = input_dev; | ||
220 | snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys); | ||
215 | 221 | ||
216 | init_input_dev(&elo->dev); | 222 | input_dev->private = elo; |
217 | elo->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 223 | input_dev->name = "Elo Serial TouchScreen"; |
218 | elo->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 224 | input_dev->phys = elo->phys; |
225 | input_dev->id.bustype = BUS_RS232; | ||
226 | input_dev->id.vendor = SERIO_ELO; | ||
227 | input_dev->id.product = elo->id; | ||
228 | input_dev->id.version = 0x0100; | ||
229 | input_dev->cdev.dev = &serio->dev; | ||
219 | 230 | ||
220 | elo->id = serio->id.id; | 231 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
232 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
221 | 233 | ||
222 | switch (elo->id) { | 234 | switch (elo->id) { |
223 | 235 | ||
224 | case 0: /* 10-byte protocol */ | 236 | case 0: /* 10-byte protocol */ |
225 | input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0); | 237 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); |
226 | input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); | 238 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); |
227 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0); | 239 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0); |
228 | break; | 240 | break; |
229 | 241 | ||
230 | case 1: /* 6-byte protocol */ | 242 | case 1: /* 6-byte protocol */ |
231 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0); | 243 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); |
232 | 244 | ||
233 | case 2: /* 4-byte protocol */ | 245 | case 2: /* 4-byte protocol */ |
234 | input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0); | 246 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); |
235 | input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); | 247 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); |
236 | break; | 248 | break; |
237 | 249 | ||
238 | case 3: /* 3-byte protocol */ | 250 | case 3: /* 3-byte protocol */ |
239 | input_set_abs_params(&elo->dev, ABS_X, 0, 255, 0, 0); | 251 | input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); |
240 | input_set_abs_params(&elo->dev, ABS_Y, 0, 255, 0, 0); | 252 | input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); |
241 | break; | 253 | break; |
242 | } | 254 | } |
243 | 255 | ||
244 | elo->serio = serio; | ||
245 | |||
246 | sprintf(elo->phys, "%s/input0", serio->phys); | ||
247 | |||
248 | elo->dev.private = elo; | ||
249 | elo->dev.name = elo_name; | ||
250 | elo->dev.phys = elo->phys; | ||
251 | elo->dev.id.bustype = BUS_RS232; | ||
252 | elo->dev.id.vendor = SERIO_ELO; | ||
253 | elo->dev.id.product = elo->id; | ||
254 | elo->dev.id.version = 0x0100; | ||
255 | |||
256 | serio_set_drvdata(serio, elo); | 256 | serio_set_drvdata(serio, elo); |
257 | 257 | ||
258 | err = serio_open(serio, drv); | 258 | err = serio_open(serio, drv); |
259 | if (err) { | 259 | if (err) |
260 | serio_set_drvdata(serio, NULL); | 260 | goto fail; |
261 | kfree(elo); | ||
262 | return err; | ||
263 | } | ||
264 | |||
265 | input_register_device(&elo->dev); | ||
266 | |||
267 | printk(KERN_INFO "input: %s on %s\n", elo_name, serio->phys); | ||
268 | 261 | ||
262 | input_register_device(elo->dev); | ||
269 | return 0; | 263 | return 0; |
264 | |||
265 | fail: serio_set_drvdata(serio, NULL); | ||
266 | input_free_device(input_dev); | ||
267 | kfree(elo); | ||
268 | return err; | ||
270 | } | 269 | } |
271 | 270 | ||
272 | /* | 271 | /* |
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 53a27e43dd23..466da190ceec 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c | |||
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL"); | |||
48 | 48 | ||
49 | #define GUNZE_MAX_LENGTH 10 | 49 | #define GUNZE_MAX_LENGTH 10 |
50 | 50 | ||
51 | static char *gunze_name = "Gunze AHL-51S TouchScreen"; | ||
52 | |||
53 | /* | 51 | /* |
54 | * Per-touchscreen data. | 52 | * Per-touchscreen data. |
55 | */ | 53 | */ |
56 | 54 | ||
57 | struct gunze { | 55 | struct gunze { |
58 | struct input_dev dev; | 56 | struct input_dev *dev; |
59 | struct serio *serio; | 57 | struct serio *serio; |
60 | int idx; | 58 | int idx; |
61 | unsigned char data[GUNZE_MAX_LENGTH]; | 59 | unsigned char data[GUNZE_MAX_LENGTH]; |
@@ -64,7 +62,7 @@ struct gunze { | |||
64 | 62 | ||
65 | static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs) | 63 | static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs) |
66 | { | 64 | { |
67 | struct input_dev *dev = &gunze->dev; | 65 | struct input_dev *dev = gunze->dev; |
68 | 66 | ||
69 | if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' || | 67 | if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' || |
70 | (gunze->data[0] != 'T' && gunze->data[0] != 'R')) { | 68 | (gunze->data[0] != 'T' && gunze->data[0] != 'R')) { |
@@ -100,11 +98,13 @@ static irqreturn_t gunze_interrupt(struct serio *serio, | |||
100 | 98 | ||
101 | static void gunze_disconnect(struct serio *serio) | 99 | static void gunze_disconnect(struct serio *serio) |
102 | { | 100 | { |
103 | struct gunze* gunze = serio_get_drvdata(serio); | 101 | struct gunze *gunze = serio_get_drvdata(serio); |
104 | 102 | ||
105 | input_unregister_device(&gunze->dev); | 103 | input_get_device(gunze->dev); |
104 | input_unregister_device(gunze->dev); | ||
106 | serio_close(serio); | 105 | serio_close(serio); |
107 | serio_set_drvdata(serio, NULL); | 106 | serio_set_drvdata(serio, NULL); |
107 | input_put_device(gunze->dev); | ||
108 | kfree(gunze); | 108 | kfree(gunze); |
109 | } | 109 | } |
110 | 110 | ||
@@ -117,45 +117,45 @@ static void gunze_disconnect(struct serio *serio) | |||
117 | static int gunze_connect(struct serio *serio, struct serio_driver *drv) | 117 | static int gunze_connect(struct serio *serio, struct serio_driver *drv) |
118 | { | 118 | { |
119 | struct gunze *gunze; | 119 | struct gunze *gunze; |
120 | struct input_dev *input_dev; | ||
120 | int err; | 121 | int err; |
121 | 122 | ||
122 | if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL))) | 123 | gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL); |
123 | return -ENOMEM; | 124 | input_dev = input_allocate_device(); |
124 | 125 | if (!gunze || !input_dev) { | |
125 | memset(gunze, 0, sizeof(struct gunze)); | 126 | err = -ENOMEM; |
126 | 127 | goto fail; | |
127 | init_input_dev(&gunze->dev); | 128 | } |
128 | gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
129 | gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
130 | input_set_abs_params(&gunze->dev, ABS_X, 24, 1000, 0, 0); | ||
131 | input_set_abs_params(&gunze->dev, ABS_Y, 24, 1000, 0, 0); | ||
132 | 129 | ||
133 | gunze->serio = serio; | 130 | gunze->serio = serio; |
134 | 131 | gunze->dev = input_dev; | |
135 | sprintf(gunze->phys, "%s/input0", serio->phys); | 132 | sprintf(gunze->phys, "%s/input0", serio->phys); |
136 | 133 | ||
137 | gunze->dev.private = gunze; | 134 | input_dev->private = gunze; |
138 | gunze->dev.name = gunze_name; | 135 | input_dev->name = "Gunze AHL-51S TouchScreen"; |
139 | gunze->dev.phys = gunze->phys; | 136 | input_dev->phys = gunze->phys; |
140 | gunze->dev.id.bustype = BUS_RS232; | 137 | input_dev->id.bustype = BUS_RS232; |
141 | gunze->dev.id.vendor = SERIO_GUNZE; | 138 | input_dev->id.vendor = SERIO_GUNZE; |
142 | gunze->dev.id.product = 0x0051; | 139 | input_dev->id.product = 0x0051; |
143 | gunze->dev.id.version = 0x0100; | 140 | input_dev->id.version = 0x0100; |
141 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
142 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
143 | input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0); | ||
144 | input_set_abs_params(input_dev, ABS_Y, 24, 1000, 0, 0); | ||
144 | 145 | ||
145 | serio_set_drvdata(serio, gunze); | 146 | serio_set_drvdata(serio, gunze); |
146 | 147 | ||
147 | err = serio_open(serio, drv); | 148 | err = serio_open(serio, drv); |
148 | if (err) { | 149 | if (err) |
149 | serio_set_drvdata(serio, NULL); | 150 | goto fail; |
150 | kfree(gunze); | ||
151 | return err; | ||
152 | } | ||
153 | |||
154 | input_register_device(&gunze->dev); | ||
155 | |||
156 | printk(KERN_INFO "input: %s on %s\n", gunze_name, serio->phys); | ||
157 | 151 | ||
152 | input_register_device(gunze->dev); | ||
158 | return 0; | 153 | return 0; |
154 | |||
155 | fail: serio_set_drvdata(serio, NULL); | ||
156 | input_free_device(input_dev); | ||
157 | kfree(gunze); | ||
158 | return err; | ||
159 | } | 159 | } |
160 | 160 | ||
161 | /* | 161 | /* |
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index bcfa1e36f957..a18d56bdafd9 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/serio.h> | 39 | #include <linux/serio.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/pm.h> | ||
43 | 42 | ||
44 | /* SA1100 serial defines */ | 43 | /* SA1100 serial defines */ |
45 | #include <asm/arch/hardware.h> | 44 | #include <asm/arch/hardware.h> |
@@ -93,16 +92,12 @@ MODULE_LICENSE("GPL"); | |||
93 | #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ | 92 | #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ |
94 | #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ | 93 | #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ |
95 | 94 | ||
96 | static char *h3600_name = "H3600 TouchScreen"; | ||
97 | |||
98 | /* | 95 | /* |
99 | * Per-touchscreen data. | 96 | * Per-touchscreen data. |
100 | */ | 97 | */ |
101 | struct h3600_dev { | 98 | struct h3600_dev { |
102 | struct input_dev dev; | 99 | struct input_dev *dev; |
103 | struct pm_dev *pm_dev; | ||
104 | struct serio *serio; | 100 | struct serio *serio; |
105 | struct pm_dev *pm_dev; | ||
106 | unsigned char event; /* event ID from packet */ | 101 | unsigned char event; /* event ID from packet */ |
107 | unsigned char chksum; | 102 | unsigned char chksum; |
108 | unsigned char len; | 103 | unsigned char len; |
@@ -163,33 +158,6 @@ unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr) | |||
163 | return 0; | 158 | return 0; |
164 | } | 159 | } |
165 | 160 | ||
166 | static int suspended = 0; | ||
167 | static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req, | ||
168 | void *data) | ||
169 | { | ||
170 | struct input_dev *dev = (struct input_dev *) data; | ||
171 | |||
172 | switch (req) { | ||
173 | case PM_SUSPEND: /* enter D1-D3 */ | ||
174 | suspended = 1; | ||
175 | h3600_flite_power(dev, FLITE_PWR_OFF); | ||
176 | break; | ||
177 | case PM_BLANK: | ||
178 | if (!suspended) | ||
179 | h3600_flite_power(dev, FLITE_PWR_OFF); | ||
180 | break; | ||
181 | case PM_RESUME: /* enter D0 */ | ||
182 | /* same as unblank */ | ||
183 | case PM_UNBLANK: | ||
184 | if (suspended) { | ||
185 | //initSerial(); | ||
186 | suspended = 0; | ||
187 | } | ||
188 | h3600_flite_power(dev, FLITE_PWR_ON); | ||
189 | break; | ||
190 | } | ||
191 | return 0; | ||
192 | } | ||
193 | #endif | 161 | #endif |
194 | 162 | ||
195 | /* | 163 | /* |
@@ -199,7 +167,7 @@ static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req, | |||
199 | */ | 167 | */ |
200 | static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | 168 | static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) |
201 | { | 169 | { |
202 | struct input_dev *dev = &ts->dev; | 170 | struct input_dev *dev = ts->dev; |
203 | static int touched = 0; | 171 | static int touched = 0; |
204 | int key, down = 0; | 172 | int key, down = 0; |
205 | 173 | ||
@@ -295,6 +263,7 @@ static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | |||
295 | static int h3600ts_event(struct input_dev *dev, unsigned int type, | 263 | static int h3600ts_event(struct input_dev *dev, unsigned int type, |
296 | unsigned int code, int value) | 264 | unsigned int code, int value) |
297 | { | 265 | { |
266 | #if 0 | ||
298 | struct h3600_dev *ts = dev->private; | 267 | struct h3600_dev *ts = dev->private; |
299 | 268 | ||
300 | switch (type) { | 269 | switch (type) { |
@@ -304,6 +273,8 @@ static int h3600ts_event(struct input_dev *dev, unsigned int type, | |||
304 | } | 273 | } |
305 | } | 274 | } |
306 | return -1; | 275 | return -1; |
276 | #endif | ||
277 | return 0; | ||
307 | } | 278 | } |
308 | 279 | ||
309 | /* | 280 | /* |
@@ -380,14 +351,48 @@ static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data, | |||
380 | static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | 351 | static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) |
381 | { | 352 | { |
382 | struct h3600_dev *ts; | 353 | struct h3600_dev *ts; |
354 | struct input_dev *input_dev; | ||
383 | int err; | 355 | int err; |
384 | 356 | ||
385 | if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL))) | 357 | ts = kzalloc(sizeof(struct h3600_dev), GFP_KERNEL); |
386 | return -ENOMEM; | 358 | input_dev = input_allocate_device(); |
359 | if (!ts || !input_dev) { | ||
360 | err = -ENOMEM; | ||
361 | goto fail1; | ||
362 | } | ||
387 | 363 | ||
388 | memset(ts, 0, sizeof(struct h3600_dev)); | 364 | ts->serio = serio; |
365 | ts->dev = input_dev; | ||
366 | sprintf(ts->phys, "%s/input0", serio->phys); | ||
389 | 367 | ||
390 | init_input_dev(&ts->dev); | 368 | input_dev->name = "H3600 TouchScreen"; |
369 | input_dev->phys = ts->phys; | ||
370 | input_dev->id.bustype = BUS_RS232; | ||
371 | input_dev->id.vendor = SERIO_H3600; | ||
372 | input_dev->id.product = 0x0666; /* FIXME !!! We can ask the hardware */ | ||
373 | input_dev->id.version = 0x0100; | ||
374 | input_dev->cdev.dev = &serio->dev; | ||
375 | input_dev->private = ts; | ||
376 | |||
377 | input_dev->event = h3600ts_event; | ||
378 | |||
379 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR); | ||
380 | input_dev->ledbit[0] = BIT(LED_SLEEP); | ||
381 | input_set_abs_params(input_dev, ABS_X, 60, 985, 0, 0); | ||
382 | input_set_abs_params(input_dev, ABS_Y, 35, 1024, 0, 0); | ||
383 | |||
384 | set_bit(KEY_RECORD, input_dev->keybit); | ||
385 | set_bit(KEY_Q, input_dev->keybit); | ||
386 | set_bit(KEY_PROG1, input_dev->keybit); | ||
387 | set_bit(KEY_PROG2, input_dev->keybit); | ||
388 | set_bit(KEY_PROG3, input_dev->keybit); | ||
389 | set_bit(KEY_UP, input_dev->keybit); | ||
390 | set_bit(KEY_RIGHT, input_dev->keybit); | ||
391 | set_bit(KEY_LEFT, input_dev->keybit); | ||
392 | set_bit(KEY_DOWN, input_dev->keybit); | ||
393 | set_bit(KEY_ENTER, input_dev->keybit); | ||
394 | set_bit(KEY_SUSPEND, input_dev->keybit); | ||
395 | set_bit(BTN_TOUCH, input_dev->keybit); | ||
391 | 396 | ||
392 | /* Device specific stuff */ | 397 | /* Device specific stuff */ |
393 | set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); | 398 | set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); |
@@ -397,73 +402,35 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
397 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 402 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, |
398 | "h3600_action", &ts->dev)) { | 403 | "h3600_action", &ts->dev)) { |
399 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); | 404 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); |
400 | kfree(ts); | 405 | err = -EBUSY; |
401 | return -EBUSY; | 406 | goto fail2; |
402 | } | 407 | } |
403 | 408 | ||
404 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, | 409 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, |
405 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 410 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, |
406 | "h3600_suspend", &ts->dev)) { | 411 | "h3600_suspend", &ts->dev)) { |
407 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); | ||
408 | printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); | 412 | printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); |
409 | kfree(ts); | 413 | err = -EBUSY; |
410 | return -EBUSY; | 414 | goto fail3; |
411 | } | 415 | } |
412 | 416 | ||
413 | /* Now we have things going we setup our input device */ | ||
414 | ts->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR); | ||
415 | ts->dev.ledbit[0] = BIT(LED_SLEEP); | ||
416 | input_set_abs_params(&ts->dev, ABS_X, 60, 985, 0, 0); | ||
417 | input_set_abs_params(&ts->dev, ABS_Y, 35, 1024, 0, 0); | ||
418 | |||
419 | set_bit(KEY_RECORD, ts->dev.keybit); | ||
420 | set_bit(KEY_Q, ts->dev.keybit); | ||
421 | set_bit(KEY_PROG1, ts->dev.keybit); | ||
422 | set_bit(KEY_PROG2, ts->dev.keybit); | ||
423 | set_bit(KEY_PROG3, ts->dev.keybit); | ||
424 | set_bit(KEY_UP, ts->dev.keybit); | ||
425 | set_bit(KEY_RIGHT, ts->dev.keybit); | ||
426 | set_bit(KEY_LEFT, ts->dev.keybit); | ||
427 | set_bit(KEY_DOWN, ts->dev.keybit); | ||
428 | set_bit(KEY_ENTER, ts->dev.keybit); | ||
429 | ts->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); | ||
430 | ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND); | ||
431 | |||
432 | ts->serio = serio; | ||
433 | |||
434 | sprintf(ts->phys, "%s/input0", serio->phys); | ||
435 | |||
436 | ts->dev.event = h3600ts_event; | ||
437 | ts->dev.private = ts; | ||
438 | ts->dev.name = h3600_name; | ||
439 | ts->dev.phys = ts->phys; | ||
440 | ts->dev.id.bustype = BUS_RS232; | ||
441 | ts->dev.id.vendor = SERIO_H3600; | ||
442 | ts->dev.id.product = 0x0666; /* FIXME !!! We can ask the hardware */ | ||
443 | ts->dev.id.version = 0x0100; | ||
444 | |||
445 | serio_set_drvdata(serio, ts); | 417 | serio_set_drvdata(serio, ts); |
446 | 418 | ||
447 | err = serio_open(serio, drv); | 419 | err = serio_open(serio, drv); |
448 | if (err) { | 420 | if (err) |
449 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts); | ||
450 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts); | ||
451 | serio_set_drvdata(serio, NULL); | ||
452 | kfree(ts); | ||
453 | return err; | 421 | return err; |
454 | } | ||
455 | 422 | ||
456 | //h3600_flite_control(1, 25); /* default brightness */ | 423 | //h3600_flite_control(1, 25); /* default brightness */ |
457 | #ifdef CONFIG_PM | 424 | input_register_device(ts->dev); |
458 | ts->pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT, | ||
459 | h3600ts_pm_callback); | ||
460 | printk("registered pm callback\n"); | ||
461 | #endif | ||
462 | input_register_device(&ts->dev); | ||
463 | |||
464 | printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys); | ||
465 | 425 | ||
466 | return 0; | 426 | return 0; |
427 | |||
428 | fail3: free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev); | ||
429 | fail2: free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev); | ||
430 | fail1: serio_set_drvdata(serio, NULL); | ||
431 | input_free_device(input_dev); | ||
432 | kfree(ts); | ||
433 | return err; | ||
467 | } | 434 | } |
468 | 435 | ||
469 | /* | 436 | /* |
@@ -476,9 +443,11 @@ static void h3600ts_disconnect(struct serio *serio) | |||
476 | 443 | ||
477 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); | 444 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); |
478 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); | 445 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); |
479 | input_unregister_device(&ts->dev); | 446 | input_get_device(ts->dev); |
447 | input_unregister_device(ts->dev); | ||
480 | serio_close(serio); | 448 | serio_close(serio); |
481 | serio_set_drvdata(serio, NULL); | 449 | serio_set_drvdata(serio, NULL); |
450 | input_put_device(ts->dev); | ||
482 | kfree(ts); | 451 | kfree(ts); |
483 | } | 452 | } |
484 | 453 | ||
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c index 7e1404441eca..957dd5a1b15e 100644 --- a/drivers/input/touchscreen/hp680_ts_input.c +++ b/drivers/input/touchscreen/hp680_ts_input.c | |||
@@ -21,10 +21,8 @@ | |||
21 | 21 | ||
22 | static void do_softint(void *data); | 22 | static void do_softint(void *data); |
23 | 23 | ||
24 | static struct input_dev hp680_ts_dev; | 24 | static struct input_dev *hp680_ts_dev; |
25 | static DECLARE_WORK(work, do_softint, 0); | 25 | static DECLARE_WORK(work, do_softint, 0); |
26 | static char *hp680_ts_name = "HP Jornada touchscreen"; | ||
27 | static char *hp680_ts_phys = "input0"; | ||
28 | 26 | ||
29 | static void do_softint(void *data) | 27 | static void do_softint(void *data) |
30 | { | 28 | { |
@@ -58,14 +56,14 @@ static void do_softint(void *data) | |||
58 | } | 56 | } |
59 | 57 | ||
60 | if (touched) { | 58 | if (touched) { |
61 | input_report_key(&hp680_ts_dev, BTN_TOUCH, 1); | 59 | input_report_key(hp680_ts_dev, BTN_TOUCH, 1); |
62 | input_report_abs(&hp680_ts_dev, ABS_X, absx); | 60 | input_report_abs(hp680_ts_dev, ABS_X, absx); |
63 | input_report_abs(&hp680_ts_dev, ABS_Y, absy); | 61 | input_report_abs(hp680_ts_dev, ABS_Y, absy); |
64 | } else { | 62 | } else { |
65 | input_report_key(&hp680_ts_dev, BTN_TOUCH, 0); | 63 | input_report_key(hp680_ts_dev, BTN_TOUCH, 0); |
66 | } | 64 | } |
67 | 65 | ||
68 | input_sync(&hp680_ts_dev); | 66 | input_sync(hp680_ts_dev); |
69 | enable_irq(HP680_TS_IRQ); | 67 | enable_irq(HP680_TS_IRQ); |
70 | } | 68 | } |
71 | 69 | ||
@@ -92,27 +90,29 @@ static int __init hp680_ts_init(void) | |||
92 | scpcr |= SCPCR_TS_ENABLE; | 90 | scpcr |= SCPCR_TS_ENABLE; |
93 | ctrl_outw(scpcr, SCPCR); | 91 | ctrl_outw(scpcr, SCPCR); |
94 | 92 | ||
95 | memset(&hp680_ts_dev, 0, sizeof(hp680_ts_dev)); | 93 | hp680_ts_dev = input_allocate_device(); |
96 | init_input_dev(&hp680_ts_dev); | 94 | if (!hp680_ts_dev) |
95 | return -ENOMEM; | ||
97 | 96 | ||
98 | hp680_ts_dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | 97 | hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); |
99 | hp680_ts_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 98 | hp680_ts_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); |
100 | hp680_ts_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 99 | hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
101 | 100 | ||
102 | hp680_ts_dev.absmin[ABS_X] = HP680_TS_ABS_X_MIN; | 101 | hp680_ts_dev->absmin[ABS_X] = HP680_TS_ABS_X_MIN; |
103 | hp680_ts_dev.absmin[ABS_Y] = HP680_TS_ABS_Y_MIN; | 102 | hp680_ts_dev->absmin[ABS_Y] = HP680_TS_ABS_Y_MIN; |
104 | hp680_ts_dev.absmax[ABS_X] = HP680_TS_ABS_X_MAX; | 103 | hp680_ts_dev->absmax[ABS_X] = HP680_TS_ABS_X_MAX; |
105 | hp680_ts_dev.absmax[ABS_Y] = HP680_TS_ABS_Y_MAX; | 104 | hp680_ts_dev->absmax[ABS_Y] = HP680_TS_ABS_Y_MAX; |
106 | 105 | ||
107 | hp680_ts_dev.name = hp680_ts_name; | 106 | hp680_ts_dev->name = "HP Jornada touchscreen"; |
108 | hp680_ts_dev.phys = hp680_ts_phys; | 107 | hp680_ts_dev->phys = "hp680_ts/input0"; |
109 | input_register_device(&hp680_ts_dev); | ||
110 | 108 | ||
111 | if (request_irq | 109 | input_register_device(hp680_ts_dev); |
112 | (HP680_TS_IRQ, hp680_ts_interrupt, SA_INTERRUPT, MODNAME, 0) < 0) { | 110 | |
113 | printk(KERN_ERR "hp680_touchscreen.c : Can't allocate irq %d\n", | 111 | if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt, |
112 | SA_INTERRUPT, MODNAME, 0) < 0) { | ||
113 | printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n", | ||
114 | HP680_TS_IRQ); | 114 | HP680_TS_IRQ); |
115 | input_unregister_device(&hp680_ts_dev); | 115 | input_unregister_device(hp680_ts_dev); |
116 | return -EBUSY; | 116 | return -EBUSY; |
117 | } | 117 | } |
118 | 118 | ||
@@ -124,7 +124,7 @@ static void __exit hp680_ts_exit(void) | |||
124 | free_irq(HP680_TS_IRQ, 0); | 124 | free_irq(HP680_TS_IRQ, 0); |
125 | cancel_delayed_work(&work); | 125 | cancel_delayed_work(&work); |
126 | flush_scheduled_work(); | 126 | flush_scheduled_work(); |
127 | input_unregister_device(&hp680_ts_dev); | 127 | input_unregister_device(hp680_ts_dev); |
128 | } | 128 | } |
129 | 129 | ||
130 | module_init(hp680_ts_init); | 130 | module_init(hp680_ts_init); |
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index afaaebe5225b..4844d250a5eb 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c | |||
@@ -77,7 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ of MK712 touchscreen controller"); | |||
77 | #define MK712_READ_ONE_POINT 0x20 | 77 | #define MK712_READ_ONE_POINT 0x20 |
78 | #define MK712_POWERUP 0x40 | 78 | #define MK712_POWERUP 0x40 |
79 | 79 | ||
80 | static struct input_dev mk712_dev; | 80 | static struct input_dev *mk712_dev; |
81 | static DEFINE_SPINLOCK(mk712_lock); | 81 | static DEFINE_SPINLOCK(mk712_lock); |
82 | 82 | ||
83 | static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 83 | static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
@@ -88,7 +88,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
88 | static unsigned short last_y; | 88 | static unsigned short last_y; |
89 | 89 | ||
90 | spin_lock(&mk712_lock); | 90 | spin_lock(&mk712_lock); |
91 | input_regs(&mk712_dev, regs); | 91 | input_regs(mk712_dev, regs); |
92 | 92 | ||
93 | status = inb(mk712_io + MK712_STATUS); | 93 | status = inb(mk712_io + MK712_STATUS); |
94 | 94 | ||
@@ -100,7 +100,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
100 | if (~status & MK712_STATUS_TOUCH) | 100 | if (~status & MK712_STATUS_TOUCH) |
101 | { | 101 | { |
102 | debounce = 1; | 102 | debounce = 1; |
103 | input_report_key(&mk712_dev, BTN_TOUCH, 0); | 103 | input_report_key(mk712_dev, BTN_TOUCH, 0); |
104 | goto end; | 104 | goto end; |
105 | } | 105 | } |
106 | 106 | ||
@@ -110,15 +110,15 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
110 | goto end; | 110 | goto end; |
111 | } | 111 | } |
112 | 112 | ||
113 | input_report_key(&mk712_dev, BTN_TOUCH, 1); | 113 | input_report_key(mk712_dev, BTN_TOUCH, 1); |
114 | input_report_abs(&mk712_dev, ABS_X, last_x); | 114 | input_report_abs(mk712_dev, ABS_X, last_x); |
115 | input_report_abs(&mk712_dev, ABS_Y, last_y); | 115 | input_report_abs(mk712_dev, ABS_Y, last_y); |
116 | 116 | ||
117 | end: | 117 | end: |
118 | 118 | ||
119 | last_x = inw(mk712_io + MK712_X) & 0x0fff; | 119 | last_x = inw(mk712_io + MK712_X) & 0x0fff; |
120 | last_y = inw(mk712_io + MK712_Y) & 0x0fff; | 120 | last_y = inw(mk712_io + MK712_Y) & 0x0fff; |
121 | input_sync(&mk712_dev); | 121 | input_sync(mk712_dev); |
122 | spin_unlock(&mk712_lock); | 122 | spin_unlock(&mk712_lock); |
123 | return IRQ_HANDLED; | 123 | return IRQ_HANDLED; |
124 | } | 124 | } |
@@ -154,30 +154,11 @@ static void mk712_close(struct input_dev *dev) | |||
154 | spin_unlock_irqrestore(&mk712_lock, flags); | 154 | spin_unlock_irqrestore(&mk712_lock, flags); |
155 | } | 155 | } |
156 | 156 | ||
157 | static struct input_dev mk712_dev = { | ||
158 | .evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, | ||
159 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, | ||
160 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) }, | ||
161 | .open = mk712_open, | ||
162 | .close = mk712_close, | ||
163 | .name = "ICS MicroClock MK712 TouchScreen", | ||
164 | .phys = "isa0260/input0", | ||
165 | .absmin = { [ABS_X] = 0, [ABS_Y] = 0 }, | ||
166 | .absmax = { [ABS_X] = 0xfff, [ABS_Y] = 0xfff }, | ||
167 | .absfuzz = { [ABS_X] = 88, [ABS_Y] = 88 }, | ||
168 | .id = { | ||
169 | .bustype = BUS_ISA, | ||
170 | .vendor = 0x0005, | ||
171 | .product = 0x0001, | ||
172 | .version = 0x0100, | ||
173 | }, | ||
174 | }; | ||
175 | |||
176 | int __init mk712_init(void) | 157 | int __init mk712_init(void) |
177 | { | 158 | { |
159 | int err; | ||
178 | 160 | ||
179 | if(!request_region(mk712_io, 8, "mk712")) | 161 | if (!request_region(mk712_io, 8, "mk712")) { |
180 | { | ||
181 | printk(KERN_WARNING "mk712: unable to get IO region\n"); | 162 | printk(KERN_WARNING "mk712: unable to get IO region\n"); |
182 | return -ENODEV; | 163 | return -ENODEV; |
183 | } | 164 | } |
@@ -188,28 +169,49 @@ int __init mk712_init(void) | |||
188 | (inw(mk712_io + MK712_Y) & 0xf000) || | 169 | (inw(mk712_io + MK712_Y) & 0xf000) || |
189 | (inw(mk712_io + MK712_STATUS) & 0xf333)) { | 170 | (inw(mk712_io + MK712_STATUS) & 0xf333)) { |
190 | printk(KERN_WARNING "mk712: device not present\n"); | 171 | printk(KERN_WARNING "mk712: device not present\n"); |
191 | release_region(mk712_io, 8); | 172 | err = -ENODEV; |
192 | return -ENODEV; | 173 | goto fail; |
193 | } | 174 | } |
194 | 175 | ||
195 | if(request_irq(mk712_irq, mk712_interrupt, 0, "mk712", &mk712_dev)) | 176 | if (!(mk712_dev = input_allocate_device())) { |
196 | { | 177 | printk(KERN_ERR "mk712: not enough memory\n"); |
197 | printk(KERN_WARNING "mk712: unable to get IRQ\n"); | 178 | err = -ENOMEM; |
198 | release_region(mk712_io, 8); | 179 | goto fail; |
199 | return -EBUSY; | ||
200 | } | 180 | } |
201 | 181 | ||
202 | input_register_device(&mk712_dev); | 182 | mk712_dev->name = "ICS MicroClock MK712 TouchScreen"; |
183 | mk712_dev->phys = "isa0260/input0"; | ||
184 | mk712_dev->id.bustype = BUS_ISA; | ||
185 | mk712_dev->id.vendor = 0x0005; | ||
186 | mk712_dev->id.product = 0x0001; | ||
187 | mk712_dev->id.version = 0x0100; | ||
188 | |||
189 | mk712_dev->open = mk712_open; | ||
190 | mk712_dev->close = mk712_close; | ||
203 | 191 | ||
204 | printk(KERN_INFO "input: ICS MicroClock MK712 TouchScreen at %#x irq %d\n", mk712_io, mk712_irq); | 192 | mk712_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
193 | mk712_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
194 | input_set_abs_params(mk712_dev, ABS_X, 0, 0xfff, 88, 0); | ||
195 | input_set_abs_params(mk712_dev, ABS_Y, 0, 0xfff, 88, 0); | ||
205 | 196 | ||
197 | if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) { | ||
198 | printk(KERN_WARNING "mk712: unable to get IRQ\n"); | ||
199 | err = -EBUSY; | ||
200 | goto fail; | ||
201 | } | ||
202 | |||
203 | input_register_device(mk712_dev); | ||
206 | return 0; | 204 | return 0; |
205 | |||
206 | fail: input_free_device(mk712_dev); | ||
207 | release_region(mk712_io, 8); | ||
208 | return err; | ||
207 | } | 209 | } |
208 | 210 | ||
209 | static void __exit mk712_exit(void) | 211 | static void __exit mk712_exit(void) |
210 | { | 212 | { |
211 | input_unregister_device(&mk712_dev); | 213 | input_unregister_device(mk712_dev); |
212 | free_irq(mk712_irq, &mk712_dev); | 214 | free_irq(mk712_irq, mk712_dev); |
213 | release_region(mk712_io, 8); | 215 | release_region(mk712_io, 8); |
214 | } | 216 | } |
215 | 217 | ||
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index aa8ee7842179..1d0d37eeef6e 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c | |||
@@ -51,14 +51,12 @@ MODULE_LICENSE("GPL"); | |||
51 | #define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3]) | 51 | #define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3]) |
52 | #define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0]) | 52 | #define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0]) |
53 | 53 | ||
54 | static char *mtouch_name = "MicroTouch Serial TouchScreen"; | ||
55 | |||
56 | /* | 54 | /* |
57 | * Per-touchscreen data. | 55 | * Per-touchscreen data. |
58 | */ | 56 | */ |
59 | 57 | ||
60 | struct mtouch { | 58 | struct mtouch { |
61 | struct input_dev dev; | 59 | struct input_dev *dev; |
62 | struct serio *serio; | 60 | struct serio *serio; |
63 | int idx; | 61 | int idx; |
64 | unsigned char data[MTOUCH_MAX_LENGTH]; | 62 | unsigned char data[MTOUCH_MAX_LENGTH]; |
@@ -67,7 +65,7 @@ struct mtouch { | |||
67 | 65 | ||
68 | static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs) | 66 | static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs) |
69 | { | 67 | { |
70 | struct input_dev *dev = &mtouch->dev; | 68 | struct input_dev *dev = mtouch->dev; |
71 | 69 | ||
72 | if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) { | 70 | if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) { |
73 | input_regs(dev, regs); | 71 | input_regs(dev, regs); |
@@ -116,9 +114,11 @@ static void mtouch_disconnect(struct serio *serio) | |||
116 | { | 114 | { |
117 | struct mtouch* mtouch = serio_get_drvdata(serio); | 115 | struct mtouch* mtouch = serio_get_drvdata(serio); |
118 | 116 | ||
119 | input_unregister_device(&mtouch->dev); | 117 | input_get_device(mtouch->dev); |
118 | input_unregister_device(mtouch->dev); | ||
120 | serio_close(serio); | 119 | serio_close(serio); |
121 | serio_set_drvdata(serio, NULL); | 120 | serio_set_drvdata(serio, NULL); |
121 | input_put_device(mtouch->dev); | ||
122 | kfree(mtouch); | 122 | kfree(mtouch); |
123 | } | 123 | } |
124 | 124 | ||
@@ -131,46 +131,46 @@ static void mtouch_disconnect(struct serio *serio) | |||
131 | static int mtouch_connect(struct serio *serio, struct serio_driver *drv) | 131 | static int mtouch_connect(struct serio *serio, struct serio_driver *drv) |
132 | { | 132 | { |
133 | struct mtouch *mtouch; | 133 | struct mtouch *mtouch; |
134 | struct input_dev *input_dev; | ||
134 | int err; | 135 | int err; |
135 | 136 | ||
136 | if (!(mtouch = kmalloc(sizeof(*mtouch), GFP_KERNEL))) | 137 | mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL); |
137 | return -ENOMEM; | 138 | input_dev = input_allocate_device(); |
138 | 139 | if (!mtouch || !input_dev) { | |
139 | memset(mtouch, 0, sizeof(*mtouch)); | 140 | err = -ENOMEM; |
140 | 141 | goto fail; | |
141 | init_input_dev(&mtouch->dev); | 142 | } |
142 | mtouch->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
143 | mtouch->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
144 | |||
145 | input_set_abs_params(&mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0); | ||
146 | input_set_abs_params(&mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0); | ||
147 | 143 | ||
148 | mtouch->serio = serio; | 144 | mtouch->serio = serio; |
149 | 145 | mtouch->dev = input_dev; | |
150 | sprintf(mtouch->phys, "%s/input0", serio->phys); | 146 | sprintf(mtouch->phys, "%s/input0", serio->phys); |
151 | 147 | ||
152 | mtouch->dev.private = mtouch; | 148 | input_dev->private = mtouch; |
153 | mtouch->dev.name = mtouch_name; | 149 | input_dev->name = "MicroTouch Serial TouchScreen"; |
154 | mtouch->dev.phys = mtouch->phys; | 150 | input_dev->phys = mtouch->phys; |
155 | mtouch->dev.id.bustype = BUS_RS232; | 151 | input_dev->id.bustype = BUS_RS232; |
156 | mtouch->dev.id.vendor = SERIO_MICROTOUCH; | 152 | input_dev->id.vendor = SERIO_MICROTOUCH; |
157 | mtouch->dev.id.product = 0; | 153 | input_dev->id.product = 0; |
158 | mtouch->dev.id.version = 0x0100; | 154 | input_dev->id.version = 0x0100; |
155 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
156 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
157 | input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0); | ||
158 | input_set_abs_params(mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0); | ||
159 | 159 | ||
160 | serio_set_drvdata(serio, mtouch); | 160 | serio_set_drvdata(serio, mtouch); |
161 | 161 | ||
162 | err = serio_open(serio, drv); | 162 | err = serio_open(serio, drv); |
163 | if (err) { | 163 | if (err) |
164 | serio_set_drvdata(serio, NULL); | 164 | goto fail; |
165 | kfree(mtouch); | ||
166 | return err; | ||
167 | } | ||
168 | |||
169 | input_register_device(&mtouch->dev); | ||
170 | 165 | ||
171 | printk(KERN_INFO "input: %s on %s\n", mtouch->dev.name, serio->phys); | 166 | input_register_device(mtouch->dev); |
172 | 167 | ||
173 | return 0; | 168 | return 0; |
169 | |||
170 | fail: serio_set_drvdata(serio, NULL); | ||
171 | input_free_device(input_dev); | ||
172 | kfree(mtouch); | ||
173 | return err; | ||
174 | } | 174 | } |
175 | 175 | ||
176 | /* | 176 | /* |
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c index 50c63a155156..ca1547929d62 100644 --- a/drivers/input/tsdev.c +++ b/drivers/input/tsdev.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <linux/random.h> | 53 | #include <linux/random.h> |
54 | #include <linux/time.h> | 54 | #include <linux/time.h> |
55 | #include <linux/device.h> | 55 | #include <linux/device.h> |
56 | #include <linux/devfs_fs_kernel.h> | ||
57 | 56 | ||
58 | #ifndef CONFIG_INPUT_TSDEV_SCREEN_X | 57 | #ifndef CONFIG_INPUT_TSDEV_SCREEN_X |
59 | #define CONFIG_INPUT_TSDEV_SCREEN_X 240 | 58 | #define CONFIG_INPUT_TSDEV_SCREEN_X 240 |
@@ -369,6 +368,7 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, | |||
369 | struct input_device_id *id) | 368 | struct input_device_id *id) |
370 | { | 369 | { |
371 | struct tsdev *tsdev; | 370 | struct tsdev *tsdev; |
371 | struct class_device *cdev; | ||
372 | int minor, delta; | 372 | int minor, delta; |
373 | 373 | ||
374 | for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor]; | 374 | for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor]; |
@@ -410,13 +410,13 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, | |||
410 | 410 | ||
411 | tsdev_table[minor] = tsdev; | 411 | tsdev_table[minor] = tsdev; |
412 | 412 | ||
413 | devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), | 413 | cdev = class_device_create(&input_class, &dev->cdev, |
414 | S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor); | ||
415 | devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2), | ||
416 | S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor); | ||
417 | class_device_create(input_class, | ||
418 | MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), | 414 | MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), |
419 | dev->dev, "ts%d", minor); | 415 | dev->cdev.dev, tsdev->name); |
416 | |||
417 | /* temporary symlink to keep userspace happy */ | ||
418 | sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, | ||
419 | tsdev->name); | ||
420 | 420 | ||
421 | return &tsdev->handle; | 421 | return &tsdev->handle; |
422 | } | 422 | } |
@@ -426,10 +426,9 @@ static void tsdev_disconnect(struct input_handle *handle) | |||
426 | struct tsdev *tsdev = handle->private; | 426 | struct tsdev *tsdev = handle->private; |
427 | struct tsdev_list *list; | 427 | struct tsdev_list *list; |
428 | 428 | ||
429 | class_device_destroy(input_class, | 429 | sysfs_remove_link(&input_class.subsys.kset.kobj, tsdev->name); |
430 | class_device_destroy(&input_class, | ||
430 | MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); | 431 | MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); |
431 | devfs_remove("input/ts%d", tsdev->minor); | ||
432 | devfs_remove("input/tsraw%d", tsdev->minor); | ||
433 | tsdev->exist = 0; | 432 | tsdev->exist = 0; |
434 | 433 | ||
435 | if (tsdev->open) { | 434 | if (tsdev->open) { |
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 04fb606b5ddd..11ae0fddea04 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
@@ -1505,7 +1505,7 @@ static int __init capi_init(void) | |||
1505 | return PTR_ERR(capi_class); | 1505 | return PTR_ERR(capi_class); |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | class_device_create(capi_class, MKDEV(capi_major, 0), NULL, "capi"); | 1508 | class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi"); |
1509 | devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR, | 1509 | devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR, |
1510 | "isdn/capi20"); | 1510 | "isdn/capi20"); |
1511 | 1511 | ||
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index c0dc1e3fa58b..d2ead1776c16 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -905,5 +905,5 @@ adbdev_init(void) | |||
905 | adb_dev_class = class_create(THIS_MODULE, "adb"); | 905 | adb_dev_class = class_create(THIS_MODULE, "adb"); |
906 | if (IS_ERR(adb_dev_class)) | 906 | if (IS_ERR(adb_dev_class)) |
907 | return; | 907 | return; |
908 | class_device_create(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb"); | 908 | class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb"); |
909 | } | 909 | } |
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index db654e8bd67e..cdb6d0283195 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c | |||
@@ -206,7 +206,7 @@ u8 adb_to_linux_keycodes[128] = { | |||
206 | }; | 206 | }; |
207 | 207 | ||
208 | struct adbhid { | 208 | struct adbhid { |
209 | struct input_dev input; | 209 | struct input_dev *input; |
210 | int id; | 210 | int id; |
211 | int default_id; | 211 | int default_id; |
212 | int original_handler_id; | 212 | int original_handler_id; |
@@ -291,10 +291,10 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs) | |||
291 | 291 | ||
292 | switch (keycode) { | 292 | switch (keycode) { |
293 | case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */ | 293 | case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */ |
294 | input_regs(&ahid->input, regs); | 294 | input_regs(ahid->input, regs); |
295 | input_report_key(&ahid->input, KEY_CAPSLOCK, 1); | 295 | input_report_key(ahid->input, KEY_CAPSLOCK, 1); |
296 | input_report_key(&ahid->input, KEY_CAPSLOCK, 0); | 296 | input_report_key(ahid->input, KEY_CAPSLOCK, 0); |
297 | input_sync(&ahid->input); | 297 | input_sync(ahid->input); |
298 | return; | 298 | return; |
299 | #ifdef CONFIG_PPC_PMAC | 299 | #ifdef CONFIG_PPC_PMAC |
300 | case ADB_KEY_POWER_OLD: /* Power key on PBook 3400 needs remapping */ | 300 | case ADB_KEY_POWER_OLD: /* Power key on PBook 3400 needs remapping */ |
@@ -347,10 +347,10 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs) | |||
347 | } | 347 | } |
348 | 348 | ||
349 | if (adbhid[id]->keycode[keycode]) { | 349 | if (adbhid[id]->keycode[keycode]) { |
350 | input_regs(&adbhid[id]->input, regs); | 350 | input_regs(adbhid[id]->input, regs); |
351 | input_report_key(&adbhid[id]->input, | 351 | input_report_key(adbhid[id]->input, |
352 | adbhid[id]->keycode[keycode], !up_flag); | 352 | adbhid[id]->keycode[keycode], !up_flag); |
353 | input_sync(&adbhid[id]->input); | 353 | input_sync(adbhid[id]->input); |
354 | } else | 354 | } else |
355 | printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode, | 355 | printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode, |
356 | up_flag ? "released" : "pressed"); | 356 | up_flag ? "released" : "pressed"); |
@@ -441,20 +441,20 @@ adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopo | |||
441 | break; | 441 | break; |
442 | } | 442 | } |
443 | 443 | ||
444 | input_regs(&adbhid[id]->input, regs); | 444 | input_regs(adbhid[id]->input, regs); |
445 | 445 | ||
446 | input_report_key(&adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); | 446 | input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); |
447 | input_report_key(&adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); | 447 | input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); |
448 | 448 | ||
449 | if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD) | 449 | if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD) |
450 | input_report_key(&adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); | 450 | input_report_key(adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); |
451 | 451 | ||
452 | input_report_rel(&adbhid[id]->input, REL_X, | 452 | input_report_rel(adbhid[id]->input, REL_X, |
453 | ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); | 453 | ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); |
454 | input_report_rel(&adbhid[id]->input, REL_Y, | 454 | input_report_rel(adbhid[id]->input, REL_Y, |
455 | ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); | 455 | ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); |
456 | 456 | ||
457 | input_sync(&adbhid[id]->input); | 457 | input_sync(adbhid[id]->input); |
458 | } | 458 | } |
459 | 459 | ||
460 | static void | 460 | static void |
@@ -467,7 +467,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | 469 | ||
470 | input_regs(&adbhid[id]->input, regs); | 470 | input_regs(adbhid[id]->input, regs); |
471 | 471 | ||
472 | switch (adbhid[id]->original_handler_id) { | 472 | switch (adbhid[id]->original_handler_id) { |
473 | default: | 473 | default: |
@@ -477,19 +477,19 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
477 | 477 | ||
478 | switch (data[1] & 0x0f) { | 478 | switch (data[1] & 0x0f) { |
479 | case 0x0: /* microphone */ | 479 | case 0x0: /* microphone */ |
480 | input_report_key(&adbhid[id]->input, KEY_SOUND, down); | 480 | input_report_key(adbhid[id]->input, KEY_SOUND, down); |
481 | break; | 481 | break; |
482 | 482 | ||
483 | case 0x1: /* mute */ | 483 | case 0x1: /* mute */ |
484 | input_report_key(&adbhid[id]->input, KEY_MUTE, down); | 484 | input_report_key(adbhid[id]->input, KEY_MUTE, down); |
485 | break; | 485 | break; |
486 | 486 | ||
487 | case 0x2: /* volume decrease */ | 487 | case 0x2: /* volume decrease */ |
488 | input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, down); | 488 | input_report_key(adbhid[id]->input, KEY_VOLUMEDOWN, down); |
489 | break; | 489 | break; |
490 | 490 | ||
491 | case 0x3: /* volume increase */ | 491 | case 0x3: /* volume increase */ |
492 | input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, down); | 492 | input_report_key(adbhid[id]->input, KEY_VOLUMEUP, down); |
493 | break; | 493 | break; |
494 | 494 | ||
495 | default: | 495 | default: |
@@ -513,19 +513,19 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
513 | 513 | ||
514 | switch (data[1] & 0x0f) { | 514 | switch (data[1] & 0x0f) { |
515 | case 0x8: /* mute */ | 515 | case 0x8: /* mute */ |
516 | input_report_key(&adbhid[id]->input, KEY_MUTE, down); | 516 | input_report_key(adbhid[id]->input, KEY_MUTE, down); |
517 | break; | 517 | break; |
518 | 518 | ||
519 | case 0x7: /* volume decrease */ | 519 | case 0x7: /* volume decrease */ |
520 | input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, down); | 520 | input_report_key(adbhid[id]->input, KEY_VOLUMEDOWN, down); |
521 | break; | 521 | break; |
522 | 522 | ||
523 | case 0x6: /* volume increase */ | 523 | case 0x6: /* volume increase */ |
524 | input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, down); | 524 | input_report_key(adbhid[id]->input, KEY_VOLUMEUP, down); |
525 | break; | 525 | break; |
526 | 526 | ||
527 | case 0xb: /* eject */ | 527 | case 0xb: /* eject */ |
528 | input_report_key(&adbhid[id]->input, KEY_EJECTCD, down); | 528 | input_report_key(adbhid[id]->input, KEY_EJECTCD, down); |
529 | break; | 529 | break; |
530 | 530 | ||
531 | case 0xa: /* brightness decrease */ | 531 | case 0xa: /* brightness decrease */ |
@@ -539,7 +539,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
539 | } | 539 | } |
540 | } | 540 | } |
541 | #endif /* CONFIG_PMAC_BACKLIGHT */ | 541 | #endif /* CONFIG_PMAC_BACKLIGHT */ |
542 | input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSDOWN, down); | 542 | input_report_key(adbhid[id]->input, KEY_BRIGHTNESSDOWN, down); |
543 | break; | 543 | break; |
544 | 544 | ||
545 | case 0x9: /* brightness increase */ | 545 | case 0x9: /* brightness increase */ |
@@ -553,19 +553,19 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
553 | } | 553 | } |
554 | } | 554 | } |
555 | #endif /* CONFIG_PMAC_BACKLIGHT */ | 555 | #endif /* CONFIG_PMAC_BACKLIGHT */ |
556 | input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSUP, down); | 556 | input_report_key(adbhid[id]->input, KEY_BRIGHTNESSUP, down); |
557 | break; | 557 | break; |
558 | 558 | ||
559 | case 0xc: /* videomode switch */ | 559 | case 0xc: /* videomode switch */ |
560 | input_report_key(&adbhid[id]->input, KEY_SWITCHVIDEOMODE, down); | 560 | input_report_key(adbhid[id]->input, KEY_SWITCHVIDEOMODE, down); |
561 | break; | 561 | break; |
562 | 562 | ||
563 | case 0xd: /* keyboard illumination toggle */ | 563 | case 0xd: /* keyboard illumination toggle */ |
564 | input_report_key(&adbhid[id]->input, KEY_KBDILLUMTOGGLE, down); | 564 | input_report_key(adbhid[id]->input, KEY_KBDILLUMTOGGLE, down); |
565 | break; | 565 | break; |
566 | 566 | ||
567 | case 0xe: /* keyboard illumination decrease */ | 567 | case 0xe: /* keyboard illumination decrease */ |
568 | input_report_key(&adbhid[id]->input, KEY_KBDILLUMDOWN, down); | 568 | input_report_key(adbhid[id]->input, KEY_KBDILLUMDOWN, down); |
569 | break; | 569 | break; |
570 | 570 | ||
571 | case 0xf: | 571 | case 0xf: |
@@ -573,7 +573,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
573 | case 0x8f: | 573 | case 0x8f: |
574 | case 0x0f: | 574 | case 0x0f: |
575 | /* keyboard illumination increase */ | 575 | /* keyboard illumination increase */ |
576 | input_report_key(&adbhid[id]->input, KEY_KBDILLUMUP, down); | 576 | input_report_key(adbhid[id]->input, KEY_KBDILLUMUP, down); |
577 | break; | 577 | break; |
578 | 578 | ||
579 | case 0x7f: | 579 | case 0x7f: |
@@ -596,7 +596,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto | |||
596 | break; | 596 | break; |
597 | } | 597 | } |
598 | 598 | ||
599 | input_sync(&adbhid[id]->input); | 599 | input_sync(adbhid[id]->input); |
600 | } | 600 | } |
601 | 601 | ||
602 | static struct adb_request led_request; | 602 | static struct adb_request led_request; |
@@ -683,7 +683,7 @@ adb_message_handler(struct notifier_block *this, unsigned long code, void *x) | |||
683 | int i; | 683 | int i; |
684 | for (i = 1; i < 16; i++) { | 684 | for (i = 1; i < 16; i++) { |
685 | if (adbhid[i]) | 685 | if (adbhid[i]) |
686 | del_timer_sync(&adbhid[i]->input.timer); | 686 | del_timer_sync(&adbhid[i]->input->timer); |
687 | } | 687 | } |
688 | } | 688 | } |
689 | 689 | ||
@@ -699,153 +699,163 @@ adb_message_handler(struct notifier_block *this, unsigned long code, void *x) | |||
699 | return NOTIFY_DONE; | 699 | return NOTIFY_DONE; |
700 | } | 700 | } |
701 | 701 | ||
702 | static void | 702 | static int |
703 | adbhid_input_register(int id, int default_id, int original_handler_id, | 703 | adbhid_input_register(int id, int default_id, int original_handler_id, |
704 | int current_handler_id, int mouse_kind) | 704 | int current_handler_id, int mouse_kind) |
705 | { | 705 | { |
706 | struct adbhid *hid; | ||
707 | struct input_dev *input_dev; | ||
708 | int err; | ||
706 | int i; | 709 | int i; |
707 | 710 | ||
708 | if (adbhid[id]) { | 711 | if (adbhid[id]) { |
709 | printk(KERN_ERR "Trying to reregister ADB HID on ID %d\n", id); | 712 | printk(KERN_ERR "Trying to reregister ADB HID on ID %d\n", id); |
710 | return; | 713 | return -EEXIST; |
711 | } | 714 | } |
712 | 715 | ||
713 | if (!(adbhid[id] = kmalloc(sizeof(struct adbhid), GFP_KERNEL))) | 716 | adbhid[id] = hid = kzalloc(sizeof(struct adbhid), GFP_KERNEL); |
714 | return; | 717 | input_dev = input_allocate_device(); |
715 | 718 | if (!hid || !input_dev) { | |
716 | memset(adbhid[id], 0, sizeof(struct adbhid)); | 719 | err = -ENOMEM; |
717 | sprintf(adbhid[id]->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id); | 720 | goto fail; |
718 | 721 | ||
719 | init_input_dev(&adbhid[id]->input); | 722 | } |
720 | 723 | ||
721 | adbhid[id]->id = default_id; | 724 | sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id); |
722 | adbhid[id]->original_handler_id = original_handler_id; | 725 | |
723 | adbhid[id]->current_handler_id = current_handler_id; | 726 | hid->id = default_id; |
724 | adbhid[id]->mouse_kind = mouse_kind; | 727 | hid->original_handler_id = original_handler_id; |
725 | adbhid[id]->flags = 0; | 728 | hid->current_handler_id = current_handler_id; |
726 | adbhid[id]->input.private = adbhid[id]; | 729 | hid->mouse_kind = mouse_kind; |
727 | adbhid[id]->input.name = adbhid[id]->name; | 730 | hid->flags = 0; |
728 | adbhid[id]->input.phys = adbhid[id]->phys; | 731 | input_dev->private = hid; |
729 | adbhid[id]->input.id.bustype = BUS_ADB; | 732 | input_dev->name = hid->name; |
730 | adbhid[id]->input.id.vendor = 0x0001; | 733 | input_dev->phys = hid->phys; |
731 | adbhid[id]->input.id.product = (id << 12) | (default_id << 8) | original_handler_id; | 734 | input_dev->id.bustype = BUS_ADB; |
732 | adbhid[id]->input.id.version = 0x0100; | 735 | input_dev->id.vendor = 0x0001; |
736 | input_dev->id.product = (id << 12) | (default_id << 8) | original_handler_id; | ||
737 | input_dev->id.version = 0x0100; | ||
733 | 738 | ||
734 | switch (default_id) { | 739 | switch (default_id) { |
735 | case ADB_KEYBOARD: | 740 | case ADB_KEYBOARD: |
736 | if (!(adbhid[id]->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL))) { | 741 | hid->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL); |
737 | kfree(adbhid[id]); | 742 | if (!hid->keycode) { |
738 | return; | 743 | err = -ENOMEM; |
744 | goto fail; | ||
739 | } | 745 | } |
740 | 746 | ||
741 | sprintf(adbhid[id]->name, "ADB keyboard"); | 747 | sprintf(hid->name, "ADB keyboard"); |
742 | 748 | ||
743 | memcpy(adbhid[id]->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes)); | 749 | memcpy(hid->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes)); |
744 | 750 | ||
745 | printk(KERN_INFO "Detected ADB keyboard, type "); | 751 | printk(KERN_INFO "Detected ADB keyboard, type "); |
746 | switch (original_handler_id) { | 752 | switch (original_handler_id) { |
747 | default: | 753 | default: |
748 | printk("<unknown>.\n"); | 754 | printk("<unknown>.\n"); |
749 | adbhid[id]->input.id.version = ADB_KEYBOARD_UNKNOWN; | 755 | input_dev->id.version = ADB_KEYBOARD_UNKNOWN; |
750 | break; | 756 | break; |
751 | 757 | ||
752 | case 0x01: case 0x02: case 0x03: case 0x06: case 0x08: | 758 | case 0x01: case 0x02: case 0x03: case 0x06: case 0x08: |
753 | case 0x0C: case 0x10: case 0x18: case 0x1B: case 0x1C: | 759 | case 0x0C: case 0x10: case 0x18: case 0x1B: case 0x1C: |
754 | case 0xC0: case 0xC3: case 0xC6: | 760 | case 0xC0: case 0xC3: case 0xC6: |
755 | printk("ANSI.\n"); | 761 | printk("ANSI.\n"); |
756 | adbhid[id]->input.id.version = ADB_KEYBOARD_ANSI; | 762 | input_dev->id.version = ADB_KEYBOARD_ANSI; |
757 | break; | 763 | break; |
758 | 764 | ||
759 | case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D: | 765 | case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D: |
760 | case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1: | 766 | case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1: |
761 | case 0xC4: case 0xC7: | 767 | case 0xC4: case 0xC7: |
762 | printk("ISO, swapping keys.\n"); | 768 | printk("ISO, swapping keys.\n"); |
763 | adbhid[id]->input.id.version = ADB_KEYBOARD_ISO; | 769 | input_dev->id.version = ADB_KEYBOARD_ISO; |
764 | i = adbhid[id]->keycode[10]; | 770 | i = hid->keycode[10]; |
765 | adbhid[id]->keycode[10] = adbhid[id]->keycode[50]; | 771 | hid->keycode[10] = hid->keycode[50]; |
766 | adbhid[id]->keycode[50] = i; | 772 | hid->keycode[50] = i; |
767 | break; | 773 | break; |
768 | 774 | ||
769 | case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A: | 775 | case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A: |
770 | case 0x1E: case 0xC2: case 0xC5: case 0xC8: case 0xC9: | 776 | case 0x1E: case 0xC2: case 0xC5: case 0xC8: case 0xC9: |
771 | printk("JIS.\n"); | 777 | printk("JIS.\n"); |
772 | adbhid[id]->input.id.version = ADB_KEYBOARD_JIS; | 778 | input_dev->id.version = ADB_KEYBOARD_JIS; |
773 | break; | 779 | break; |
774 | } | 780 | } |
775 | 781 | ||
776 | for (i = 0; i < 128; i++) | 782 | for (i = 0; i < 128; i++) |
777 | if (adbhid[id]->keycode[i]) | 783 | if (hid->keycode[i]) |
778 | set_bit(adbhid[id]->keycode[i], adbhid[id]->input.keybit); | 784 | set_bit(hid->keycode[i], input_dev->keybit); |
779 | 785 | ||
780 | adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 786 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); |
781 | adbhid[id]->input.ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); | 787 | input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); |
782 | adbhid[id]->input.event = adbhid_kbd_event; | 788 | input_dev->event = adbhid_kbd_event; |
783 | adbhid[id]->input.keycodemax = 127; | 789 | input_dev->keycodemax = 127; |
784 | adbhid[id]->input.keycodesize = 1; | 790 | input_dev->keycodesize = 1; |
785 | break; | 791 | break; |
786 | 792 | ||
787 | case ADB_MOUSE: | 793 | case ADB_MOUSE: |
788 | sprintf(adbhid[id]->name, "ADB mouse"); | 794 | sprintf(hid->name, "ADB mouse"); |
789 | 795 | ||
790 | adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 796 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
791 | adbhid[id]->input.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 797 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
792 | adbhid[id]->input.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 798 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
793 | break; | 799 | break; |
794 | 800 | ||
795 | case ADB_MISC: | 801 | case ADB_MISC: |
796 | switch (original_handler_id) { | 802 | switch (original_handler_id) { |
797 | case 0x02: /* Adjustable keyboard button device */ | 803 | case 0x02: /* Adjustable keyboard button device */ |
798 | sprintf(adbhid[id]->name, "ADB adjustable keyboard buttons"); | 804 | sprintf(hid->name, "ADB adjustable keyboard buttons"); |
799 | adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 805 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
800 | set_bit(KEY_SOUND, adbhid[id]->input.keybit); | 806 | set_bit(KEY_SOUND, input_dev->keybit); |
801 | set_bit(KEY_MUTE, adbhid[id]->input.keybit); | 807 | set_bit(KEY_MUTE, input_dev->keybit); |
802 | set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit); | 808 | set_bit(KEY_VOLUMEUP, input_dev->keybit); |
803 | set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit); | 809 | set_bit(KEY_VOLUMEDOWN, input_dev->keybit); |
804 | break; | 810 | break; |
805 | case 0x1f: /* Powerbook button device */ | 811 | case 0x1f: /* Powerbook button device */ |
806 | sprintf(adbhid[id]->name, "ADB Powerbook buttons"); | 812 | sprintf(hid->name, "ADB Powerbook buttons"); |
807 | adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 813 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
808 | set_bit(KEY_MUTE, adbhid[id]->input.keybit); | 814 | set_bit(KEY_MUTE, input_dev->keybit); |
809 | set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit); | 815 | set_bit(KEY_VOLUMEUP, input_dev->keybit); |
810 | set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit); | 816 | set_bit(KEY_VOLUMEDOWN, input_dev->keybit); |
811 | set_bit(KEY_BRIGHTNESSUP, adbhid[id]->input.keybit); | 817 | set_bit(KEY_BRIGHTNESSUP, input_dev->keybit); |
812 | set_bit(KEY_BRIGHTNESSDOWN, adbhid[id]->input.keybit); | 818 | set_bit(KEY_BRIGHTNESSDOWN, input_dev->keybit); |
813 | set_bit(KEY_EJECTCD, adbhid[id]->input.keybit); | 819 | set_bit(KEY_EJECTCD, input_dev->keybit); |
814 | set_bit(KEY_SWITCHVIDEOMODE, adbhid[id]->input.keybit); | 820 | set_bit(KEY_SWITCHVIDEOMODE, input_dev->keybit); |
815 | set_bit(KEY_KBDILLUMTOGGLE, adbhid[id]->input.keybit); | 821 | set_bit(KEY_KBDILLUMTOGGLE, input_dev->keybit); |
816 | set_bit(KEY_KBDILLUMDOWN, adbhid[id]->input.keybit); | 822 | set_bit(KEY_KBDILLUMDOWN, input_dev->keybit); |
817 | set_bit(KEY_KBDILLUMUP, adbhid[id]->input.keybit); | 823 | set_bit(KEY_KBDILLUMUP, input_dev->keybit); |
818 | break; | 824 | break; |
819 | } | 825 | } |
820 | if (adbhid[id]->name[0]) | 826 | if (hid->name[0]) |
821 | break; | 827 | break; |
822 | /* else fall through */ | 828 | /* else fall through */ |
823 | 829 | ||
824 | default: | 830 | default: |
825 | printk(KERN_INFO "Trying to register unknown ADB device to input layer.\n"); | 831 | printk(KERN_INFO "Trying to register unknown ADB device to input layer.\n"); |
826 | kfree(adbhid[id]); | 832 | err = -ENODEV; |
827 | return; | 833 | goto fail; |
828 | } | 834 | } |
829 | 835 | ||
830 | adbhid[id]->input.keycode = adbhid[id]->keycode; | 836 | input_dev->keycode = hid->keycode; |
831 | |||
832 | input_register_device(&adbhid[id]->input); | ||
833 | 837 | ||
834 | printk(KERN_INFO "input: %s on %s\n", | 838 | input_register_device(input_dev); |
835 | adbhid[id]->name, adbhid[id]->phys); | ||
836 | 839 | ||
837 | if (default_id == ADB_KEYBOARD) { | 840 | if (default_id == ADB_KEYBOARD) { |
838 | /* HACK WARNING!! This should go away as soon there is an utility | 841 | /* HACK WARNING!! This should go away as soon there is an utility |
839 | * to control that for event devices. | 842 | * to control that for event devices. |
840 | */ | 843 | */ |
841 | adbhid[id]->input.rep[REP_DELAY] = 500; /* input layer default: 250 */ | 844 | input_dev->rep[REP_DELAY] = 500; /* input layer default: 250 */ |
842 | adbhid[id]->input.rep[REP_PERIOD] = 66; /* input layer default: 33 */ | 845 | input_dev->rep[REP_PERIOD] = 66; /* input layer default: 33 */ |
843 | } | 846 | } |
847 | |||
848 | return 0; | ||
849 | |||
850 | fail: input_free_device(input_dev); | ||
851 | kfree(hid); | ||
852 | adbhid[id] = NULL; | ||
853 | return err; | ||
844 | } | 854 | } |
845 | 855 | ||
846 | static void adbhid_input_unregister(int id) | 856 | static void adbhid_input_unregister(int id) |
847 | { | 857 | { |
848 | input_unregister_device(&adbhid[id]->input); | 858 | input_unregister_device(adbhid[id]->input); |
849 | if (adbhid[id]->keycode) | 859 | if (adbhid[id]->keycode) |
850 | kfree(adbhid[id]->keycode); | 860 | kfree(adbhid[id]->keycode); |
851 | kfree(adbhid[id]); | 861 | kfree(adbhid[id]); |
@@ -858,7 +868,7 @@ adbhid_input_reregister(int id, int default_id, int org_handler_id, | |||
858 | int cur_handler_id, int mk) | 868 | int cur_handler_id, int mk) |
859 | { | 869 | { |
860 | if (adbhid[id]) { | 870 | if (adbhid[id]) { |
861 | if (adbhid[id]->input.id.product != | 871 | if (adbhid[id]->input->id.product != |
862 | ((id << 12)|(default_id << 8)|org_handler_id)) { | 872 | ((id << 12)|(default_id << 8)|org_handler_id)) { |
863 | adbhid_input_unregister(id); | 873 | adbhid_input_unregister(id); |
864 | adbhid_input_register(id, default_id, org_handler_id, | 874 | adbhid_input_register(id, default_id, org_handler_id, |
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 5ad3a5a9eb7f..a66636116f0b 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c | |||
@@ -16,8 +16,8 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | 17 | ||
18 | 18 | ||
19 | static struct input_dev emumousebtn; | 19 | static struct input_dev *emumousebtn; |
20 | static void emumousebtn_input_register(void); | 20 | static int emumousebtn_input_register(void); |
21 | static int mouse_emulate_buttons = 0; | 21 | static int mouse_emulate_buttons = 0; |
22 | static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ | 22 | static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ |
23 | static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ | 23 | static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ |
@@ -90,10 +90,10 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down) | |||
90 | && (keycode == mouse_button2_keycode | 90 | && (keycode == mouse_button2_keycode |
91 | || keycode == mouse_button3_keycode)) { | 91 | || keycode == mouse_button3_keycode)) { |
92 | if (mouse_emulate_buttons == 1) { | 92 | if (mouse_emulate_buttons == 1) { |
93 | input_report_key(&emumousebtn, | 93 | input_report_key(emumousebtn, |
94 | keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, | 94 | keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, |
95 | down); | 95 | down); |
96 | input_sync(&emumousebtn); | 96 | input_sync(emumousebtn); |
97 | return 1; | 97 | return 1; |
98 | } | 98 | } |
99 | mouse_last_keycode = down ? keycode : 0; | 99 | mouse_last_keycode = down ? keycode : 0; |
@@ -105,30 +105,34 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down) | |||
105 | 105 | ||
106 | EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons); | 106 | EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons); |
107 | 107 | ||
108 | static void emumousebtn_input_register(void) | 108 | static int emumousebtn_input_register(void) |
109 | { | 109 | { |
110 | emumousebtn.name = "Macintosh mouse button emulation"; | 110 | emumousebtn = input_allocate_device(); |
111 | if (!emumousebtn) | ||
112 | return -ENOMEM; | ||
111 | 113 | ||
112 | init_input_dev(&emumousebtn); | 114 | emumousebtn->name = "Macintosh mouse button emulation"; |
115 | emumousebtn->id.bustype = BUS_ADB; | ||
116 | emumousebtn->id.vendor = 0x0001; | ||
117 | emumousebtn->id.product = 0x0001; | ||
118 | emumousebtn->id.version = 0x0100; | ||
113 | 119 | ||
114 | emumousebtn.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 120 | emumousebtn->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
115 | emumousebtn.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 121 | emumousebtn->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
116 | emumousebtn.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 122 | emumousebtn->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
117 | 123 | ||
118 | emumousebtn.id.bustype = BUS_ADB; | 124 | input_register_device(emumousebtn); |
119 | emumousebtn.id.vendor = 0x0001; | ||
120 | emumousebtn.id.product = 0x0001; | ||
121 | emumousebtn.id.version = 0x0100; | ||
122 | 125 | ||
123 | input_register_device(&emumousebtn); | 126 | return 0; |
124 | |||
125 | printk(KERN_INFO "input: Macintosh mouse button emulation\n"); | ||
126 | } | 127 | } |
127 | 128 | ||
128 | int __init mac_hid_init(void) | 129 | int __init mac_hid_init(void) |
129 | { | 130 | { |
131 | int err; | ||
130 | 132 | ||
131 | emumousebtn_input_register(); | 133 | err = emumousebtn_input_register(); |
134 | if (err) | ||
135 | return err; | ||
132 | 136 | ||
133 | #if defined(CONFIG_SYSCTL) | 137 | #if defined(CONFIG_SYSCTL) |
134 | mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); | 138 | mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); |
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c index a0e700d7a4a4..06f4d4686a6c 100644 --- a/drivers/media/common/ir-common.c +++ b/drivers/media/common/ir-common.c | |||
@@ -252,7 +252,6 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir, | |||
252 | if (ir_codes) | 252 | if (ir_codes) |
253 | memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); | 253 | memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); |
254 | 254 | ||
255 | init_input_dev(dev); | ||
256 | dev->keycode = ir->ir_codes; | 255 | dev->keycode = ir->ir_codes; |
257 | dev->keycodesize = sizeof(IR_KEYTAB_TYPE); | 256 | dev->keycodesize = sizeof(IR_KEYTAB_TYPE); |
258 | dev->keycodemax = IR_KEYTAB_SIZE; | 257 | dev->keycodemax = IR_KEYTAB_SIZE; |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 6db0929ef53d..a1607e7d6d6b 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
@@ -137,7 +137,8 @@ struct cinergyt2 { | |||
137 | struct urb *stream_urb [STREAM_URB_COUNT]; | 137 | struct urb *stream_urb [STREAM_URB_COUNT]; |
138 | 138 | ||
139 | #ifdef ENABLE_RC | 139 | #ifdef ENABLE_RC |
140 | struct input_dev rc_input_dev; | 140 | struct input_dev *rc_input_dev; |
141 | char phys[64]; | ||
141 | struct work_struct rc_query_work; | 142 | struct work_struct rc_query_work; |
142 | int rc_input_event; | 143 | int rc_input_event; |
143 | u32 rc_last_code; | 144 | u32 rc_last_code; |
@@ -683,6 +684,7 @@ static struct dvb_device cinergyt2_fe_template = { | |||
683 | }; | 684 | }; |
684 | 685 | ||
685 | #ifdef ENABLE_RC | 686 | #ifdef ENABLE_RC |
687 | |||
686 | static void cinergyt2_query_rc (void *data) | 688 | static void cinergyt2_query_rc (void *data) |
687 | { | 689 | { |
688 | struct cinergyt2 *cinergyt2 = data; | 690 | struct cinergyt2 *cinergyt2 = data; |
@@ -703,7 +705,7 @@ static void cinergyt2_query_rc (void *data) | |||
703 | /* stop key repeat */ | 705 | /* stop key repeat */ |
704 | if (cinergyt2->rc_input_event != KEY_MAX) { | 706 | if (cinergyt2->rc_input_event != KEY_MAX) { |
705 | dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); | 707 | dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); |
706 | input_report_key(&cinergyt2->rc_input_dev, | 708 | input_report_key(cinergyt2->rc_input_dev, |
707 | cinergyt2->rc_input_event, 0); | 709 | cinergyt2->rc_input_event, 0); |
708 | cinergyt2->rc_input_event = KEY_MAX; | 710 | cinergyt2->rc_input_event = KEY_MAX; |
709 | } | 711 | } |
@@ -722,7 +724,7 @@ static void cinergyt2_query_rc (void *data) | |||
722 | /* keyrepeat bit -> just repeat last rc_input_event */ | 724 | /* keyrepeat bit -> just repeat last rc_input_event */ |
723 | } else { | 725 | } else { |
724 | cinergyt2->rc_input_event = KEY_MAX; | 726 | cinergyt2->rc_input_event = KEY_MAX; |
725 | for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) { | 727 | for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3) { |
726 | if (rc_keys[i + 0] == rc_events[n].type && | 728 | if (rc_keys[i + 0] == rc_events[n].type && |
727 | rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { | 729 | rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { |
728 | cinergyt2->rc_input_event = rc_keys[i + 2]; | 730 | cinergyt2->rc_input_event = rc_keys[i + 2]; |
@@ -736,11 +738,11 @@ static void cinergyt2_query_rc (void *data) | |||
736 | cinergyt2->rc_last_code != ~0) { | 738 | cinergyt2->rc_last_code != ~0) { |
737 | /* emit a key-up so the double event is recognized */ | 739 | /* emit a key-up so the double event is recognized */ |
738 | dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); | 740 | dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); |
739 | input_report_key(&cinergyt2->rc_input_dev, | 741 | input_report_key(cinergyt2->rc_input_dev, |
740 | cinergyt2->rc_input_event, 0); | 742 | cinergyt2->rc_input_event, 0); |
741 | } | 743 | } |
742 | dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); | 744 | dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); |
743 | input_report_key(&cinergyt2->rc_input_dev, | 745 | input_report_key(cinergyt2->rc_input_dev, |
744 | cinergyt2->rc_input_event, 1); | 746 | cinergyt2->rc_input_event, 1); |
745 | cinergyt2->rc_last_code = rc_events[n].value; | 747 | cinergyt2->rc_last_code = rc_events[n].value; |
746 | } | 748 | } |
@@ -752,7 +754,59 @@ out: | |||
752 | 754 | ||
753 | up(&cinergyt2->sem); | 755 | up(&cinergyt2->sem); |
754 | } | 756 | } |
755 | #endif | 757 | |
758 | static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) | ||
759 | { | ||
760 | struct input_dev *input_dev; | ||
761 | int i; | ||
762 | |||
763 | cinergyt2->rc_input_dev = input_dev = input_allocate_device(); | ||
764 | if (!input_dev) | ||
765 | return -ENOMEM; | ||
766 | |||
767 | usb_make_path(cinergyt2->udev, cinergyt2->phys, sizeof(cinergyt2->phys)); | ||
768 | strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys)); | ||
769 | cinergyt2->rc_input_event = KEY_MAX; | ||
770 | cinergyt2->rc_last_code = ~0; | ||
771 | INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); | ||
772 | |||
773 | input_dev->name = DRIVER_NAME " remote control"; | ||
774 | input_dev->phys = cinergyt2->phys; | ||
775 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
776 | for (i = 0; ARRAY_SIZE(rc_keys); i += 3) | ||
777 | set_bit(rc_keys[i + 2], input_dev->keybit); | ||
778 | input_dev->keycodesize = 0; | ||
779 | input_dev->keycodemax = 0; | ||
780 | |||
781 | input_register_device(cinergyt2->rc_input_dev); | ||
782 | schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); | ||
783 | } | ||
784 | |||
785 | static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) | ||
786 | { | ||
787 | cancel_delayed_work(&cinergyt2->rc_query_work); | ||
788 | flush_scheduled_work(); | ||
789 | input_unregister_device(cinergyt2->rc_input_dev); | ||
790 | } | ||
791 | |||
792 | static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2) | ||
793 | { | ||
794 | cancel_delayed_work(&cinergyt2->rc_query_work); | ||
795 | } | ||
796 | |||
797 | static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) | ||
798 | { | ||
799 | schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); | ||
800 | } | ||
801 | |||
802 | #else | ||
803 | |||
804 | static inline int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) { return 0; } | ||
805 | static inline void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) { } | ||
806 | static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2) { } | ||
807 | static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { } | ||
808 | |||
809 | #endif /* ENABLE_RC */ | ||
756 | 810 | ||
757 | static void cinergyt2_query (void *data) | 811 | static void cinergyt2_query (void *data) |
758 | { | 812 | { |
@@ -789,9 +843,6 @@ static int cinergyt2_probe (struct usb_interface *intf, | |||
789 | { | 843 | { |
790 | struct cinergyt2 *cinergyt2; | 844 | struct cinergyt2 *cinergyt2; |
791 | int err; | 845 | int err; |
792 | #ifdef ENABLE_RC | ||
793 | int i; | ||
794 | #endif | ||
795 | 846 | ||
796 | if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { | 847 | if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { |
797 | dprintk(1, "out of memory?!?\n"); | 848 | dprintk(1, "out of memory?!?\n"); |
@@ -846,30 +897,17 @@ static int cinergyt2_probe (struct usb_interface *intf, | |||
846 | &cinergyt2_fe_template, cinergyt2, | 897 | &cinergyt2_fe_template, cinergyt2, |
847 | DVB_DEVICE_FRONTEND); | 898 | DVB_DEVICE_FRONTEND); |
848 | 899 | ||
849 | #ifdef ENABLE_RC | 900 | err = cinergyt2_register_rc(cinergyt2); |
850 | cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 901 | if (err) |
851 | cinergyt2->rc_input_dev.keycodesize = 0; | 902 | goto bailout; |
852 | cinergyt2->rc_input_dev.keycodemax = 0; | ||
853 | cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control"; | ||
854 | |||
855 | for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) | ||
856 | set_bit(rc_keys[i + 2], cinergyt2->rc_input_dev.keybit); | ||
857 | |||
858 | input_register_device(&cinergyt2->rc_input_dev); | ||
859 | |||
860 | cinergyt2->rc_input_event = KEY_MAX; | ||
861 | cinergyt2->rc_last_code = ~0; | ||
862 | 903 | ||
863 | INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); | ||
864 | schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); | ||
865 | #endif | ||
866 | return 0; | 904 | return 0; |
867 | 905 | ||
868 | bailout: | 906 | bailout: |
869 | dvb_dmxdev_release(&cinergyt2->dmxdev); | 907 | dvb_dmxdev_release(&cinergyt2->dmxdev); |
870 | dvb_dmx_release(&cinergyt2->demux); | 908 | dvb_dmx_release(&cinergyt2->demux); |
871 | dvb_unregister_adapter (&cinergyt2->adapter); | 909 | dvb_unregister_adapter(&cinergyt2->adapter); |
872 | cinergyt2_free_stream_urbs (cinergyt2); | 910 | cinergyt2_free_stream_urbs(cinergyt2); |
873 | kfree(cinergyt2); | 911 | kfree(cinergyt2); |
874 | return -ENOMEM; | 912 | return -ENOMEM; |
875 | } | 913 | } |
@@ -881,11 +919,7 @@ static void cinergyt2_disconnect (struct usb_interface *intf) | |||
881 | if (down_interruptible(&cinergyt2->sem)) | 919 | if (down_interruptible(&cinergyt2->sem)) |
882 | return; | 920 | return; |
883 | 921 | ||
884 | #ifdef ENABLE_RC | 922 | cinergyt2_unregister_rc(cinergyt2); |
885 | cancel_delayed_work(&cinergyt2->rc_query_work); | ||
886 | flush_scheduled_work(); | ||
887 | input_unregister_device(&cinergyt2->rc_input_dev); | ||
888 | #endif | ||
889 | 923 | ||
890 | cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx); | 924 | cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx); |
891 | dvb_net_release(&cinergyt2->dvbnet); | 925 | dvb_net_release(&cinergyt2->dvbnet); |
@@ -908,9 +942,8 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state) | |||
908 | 942 | ||
909 | if (state.event > PM_EVENT_ON) { | 943 | if (state.event > PM_EVENT_ON) { |
910 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); | 944 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); |
911 | #ifdef ENABLE_RC | 945 | |
912 | cancel_delayed_work(&cinergyt2->rc_query_work); | 946 | cinergyt2_suspend_rc(cinergyt2); |
913 | #endif | ||
914 | cancel_delayed_work(&cinergyt2->query_work); | 947 | cancel_delayed_work(&cinergyt2->query_work); |
915 | if (cinergyt2->streaming) | 948 | if (cinergyt2->streaming) |
916 | cinergyt2_stop_stream_xfer(cinergyt2); | 949 | cinergyt2_stop_stream_xfer(cinergyt2); |
@@ -938,9 +971,8 @@ static int cinergyt2_resume (struct usb_interface *intf) | |||
938 | schedule_delayed_work(&cinergyt2->query_work, HZ/2); | 971 | schedule_delayed_work(&cinergyt2->query_work, HZ/2); |
939 | } | 972 | } |
940 | 973 | ||
941 | #ifdef ENABLE_RC | 974 | cinergyt2_resume_rc(cinergyt2); |
942 | schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); | 975 | |
943 | #endif | ||
944 | up(&cinergyt2->sem); | 976 | up(&cinergyt2->sem); |
945 | return 0; | 977 | return 0; |
946 | } | 978 | } |
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 4b7adca3e286..477b4fa56430 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c | |||
@@ -235,7 +235,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, | |||
235 | S_IFCHR | S_IRUSR | S_IWUSR, | 235 | S_IFCHR | S_IRUSR | S_IWUSR, |
236 | "dvb/adapter%d/%s%d", adap->num, dnames[type], id); | 236 | "dvb/adapter%d/%s%d", adap->num, dnames[type], id); |
237 | 237 | ||
238 | class_device_create(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), | 238 | class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), |
239 | NULL, "dvb%d.%s%d", adap->num, dnames[type], id); | 239 | NULL, "dvb%d.%s%d", adap->num, dnames[type], id); |
240 | 240 | ||
241 | dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", | 241 | dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c index fc7800f1743e..e5c6d9835e06 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c | |||
@@ -39,9 +39,9 @@ static void dvb_usb_read_remote_control(void *data) | |||
39 | d->last_event = event; | 39 | d->last_event = event; |
40 | case REMOTE_KEY_REPEAT: | 40 | case REMOTE_KEY_REPEAT: |
41 | deb_rc("key repeated\n"); | 41 | deb_rc("key repeated\n"); |
42 | input_event(&d->rc_input_dev, EV_KEY, d->last_event, 1); | 42 | input_event(d->rc_input_dev, EV_KEY, event, 1); |
43 | input_event(&d->rc_input_dev, EV_KEY, d->last_event, 0); | 43 | input_event(d->rc_input_dev, EV_KEY, d->last_event, 0); |
44 | input_sync(&d->rc_input_dev); | 44 | input_sync(d->rc_input_dev); |
45 | break; | 45 | break; |
46 | default: | 46 | default: |
47 | break; | 47 | break; |
@@ -53,8 +53,8 @@ static void dvb_usb_read_remote_control(void *data) | |||
53 | deb_rc("NO KEY PRESSED\n"); | 53 | deb_rc("NO KEY PRESSED\n"); |
54 | if (d->last_state != REMOTE_NO_KEY_PRESSED) { | 54 | if (d->last_state != REMOTE_NO_KEY_PRESSED) { |
55 | deb_rc("releasing event %d\n",d->last_event); | 55 | deb_rc("releasing event %d\n",d->last_event); |
56 | input_event(&d->rc_input_dev, EV_KEY, d->last_event, 0); | 56 | input_event(d->rc_input_dev, EV_KEY, d->last_event, 0); |
57 | input_sync(&d->rc_input_dev); | 57 | input_sync(d->rc_input_dev); |
58 | } | 58 | } |
59 | d->last_state = REMOTE_NO_KEY_PRESSED; | 59 | d->last_state = REMOTE_NO_KEY_PRESSED; |
60 | d->last_event = 0; | 60 | d->last_event = 0; |
@@ -63,8 +63,8 @@ static void dvb_usb_read_remote_control(void *data) | |||
63 | deb_rc("KEY PRESSED\n"); | 63 | deb_rc("KEY PRESSED\n"); |
64 | deb_rc("pressing event %d\n",event); | 64 | deb_rc("pressing event %d\n",event); |
65 | 65 | ||
66 | input_event(&d->rc_input_dev, EV_KEY, event, 1); | 66 | input_event(d->rc_input_dev, EV_KEY, event, 1); |
67 | input_sync(&d->rc_input_dev); | 67 | input_sync(d->rc_input_dev); |
68 | 68 | ||
69 | d->last_event = event; | 69 | d->last_event = event; |
70 | d->last_state = REMOTE_KEY_PRESSED; | 70 | d->last_state = REMOTE_KEY_PRESSED; |
@@ -73,8 +73,8 @@ static void dvb_usb_read_remote_control(void *data) | |||
73 | deb_rc("KEY_REPEAT\n"); | 73 | deb_rc("KEY_REPEAT\n"); |
74 | if (d->last_state != REMOTE_NO_KEY_PRESSED) { | 74 | if (d->last_state != REMOTE_NO_KEY_PRESSED) { |
75 | deb_rc("repeating event %d\n",d->last_event); | 75 | deb_rc("repeating event %d\n",d->last_event); |
76 | input_event(&d->rc_input_dev, EV_KEY, d->last_event, 2); | 76 | input_event(d->rc_input_dev, EV_KEY, d->last_event, 2); |
77 | input_sync(&d->rc_input_dev); | 77 | input_sync(d->rc_input_dev); |
78 | d->last_state = REMOTE_KEY_REPEAT; | 78 | d->last_state = REMOTE_KEY_REPEAT; |
79 | } | 79 | } |
80 | default: | 80 | default: |
@@ -89,24 +89,30 @@ schedule: | |||
89 | int dvb_usb_remote_init(struct dvb_usb_device *d) | 89 | int dvb_usb_remote_init(struct dvb_usb_device *d) |
90 | { | 90 | { |
91 | int i; | 91 | int i; |
92 | |||
92 | if (d->props.rc_key_map == NULL || | 93 | if (d->props.rc_key_map == NULL || |
93 | d->props.rc_query == NULL || | 94 | d->props.rc_query == NULL || |
94 | dvb_usb_disable_rc_polling) | 95 | dvb_usb_disable_rc_polling) |
95 | return 0; | 96 | return 0; |
96 | 97 | ||
97 | /* Initialise the remote-control structures.*/ | 98 | usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); |
98 | init_input_dev(&d->rc_input_dev); | 99 | strlcpy(d->rc_phys, "/ir0", sizeof(d->rc_phys)); |
100 | |||
101 | d->rc_input_dev = input_allocate_device(); | ||
102 | if (!d->rc_input_dev) | ||
103 | return -ENOMEM; | ||
99 | 104 | ||
100 | d->rc_input_dev.evbit[0] = BIT(EV_KEY); | 105 | d->rc_input_dev->evbit[0] = BIT(EV_KEY); |
101 | d->rc_input_dev.keycodesize = sizeof(unsigned char); | 106 | d->rc_input_dev->keycodesize = sizeof(unsigned char); |
102 | d->rc_input_dev.keycodemax = KEY_MAX; | 107 | d->rc_input_dev->keycodemax = KEY_MAX; |
103 | d->rc_input_dev.name = "IR-receiver inside an USB DVB receiver"; | 108 | d->rc_input_dev->name = "IR-receiver inside an USB DVB receiver"; |
109 | d->rc_input_dev->phys = d->rc_phys; | ||
104 | 110 | ||
105 | /* set the bits for the keys */ | 111 | /* set the bits for the keys */ |
106 | deb_rc("key map size: %d\n",d->props.rc_key_map_size); | 112 | deb_rc("key map size: %d\n", d->props.rc_key_map_size); |
107 | for (i = 0; i < d->props.rc_key_map_size; i++) { | 113 | for (i = 0; i < d->props.rc_key_map_size; i++) { |
108 | deb_rc("setting bit for event %d item %d\n",d->props.rc_key_map[i].event, i); | 114 | deb_rc("setting bit for event %d item %d\n",d->props.rc_key_map[i].event, i); |
109 | set_bit(d->props.rc_key_map[i].event, d->rc_input_dev.keybit); | 115 | set_bit(d->props.rc_key_map[i].event, d->rc_input_dev->keybit); |
110 | } | 116 | } |
111 | 117 | ||
112 | /* Start the remote-control polling. */ | 118 | /* Start the remote-control polling. */ |
@@ -114,14 +120,14 @@ int dvb_usb_remote_init(struct dvb_usb_device *d) | |||
114 | d->props.rc_interval = 100; /* default */ | 120 | d->props.rc_interval = 100; /* default */ |
115 | 121 | ||
116 | /* setting these two values to non-zero, we have to manage key repeats */ | 122 | /* setting these two values to non-zero, we have to manage key repeats */ |
117 | d->rc_input_dev.rep[REP_PERIOD] = d->props.rc_interval; | 123 | d->rc_input_dev->rep[REP_PERIOD] = d->props.rc_interval; |
118 | d->rc_input_dev.rep[REP_DELAY] = d->props.rc_interval + 150; | 124 | d->rc_input_dev->rep[REP_DELAY] = d->props.rc_interval + 150; |
119 | 125 | ||
120 | input_register_device(&d->rc_input_dev); | 126 | input_register_device(d->rc_input_dev); |
121 | 127 | ||
122 | INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d); | 128 | INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d); |
123 | 129 | ||
124 | info("schedule remote query interval to %d msecs.",d->props.rc_interval); | 130 | info("schedule remote query interval to %d msecs.", d->props.rc_interval); |
125 | schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); | 131 | schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); |
126 | 132 | ||
127 | d->state |= DVB_USB_STATE_REMOTE; | 133 | d->state |= DVB_USB_STATE_REMOTE; |
@@ -134,7 +140,7 @@ int dvb_usb_remote_exit(struct dvb_usb_device *d) | |||
134 | if (d->state & DVB_USB_STATE_REMOTE) { | 140 | if (d->state & DVB_USB_STATE_REMOTE) { |
135 | cancel_delayed_work(&d->rc_query_work); | 141 | cancel_delayed_work(&d->rc_query_work); |
136 | flush_scheduled_work(); | 142 | flush_scheduled_work(); |
137 | input_unregister_device(&d->rc_input_dev); | 143 | input_unregister_device(d->rc_input_dev); |
138 | } | 144 | } |
139 | d->state &= ~DVB_USB_STATE_REMOTE; | 145 | d->state &= ~DVB_USB_STATE_REMOTE; |
140 | return 0; | 146 | return 0; |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 0e4f1035b0dd..b4a1a98006c7 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
@@ -300,7 +300,8 @@ struct dvb_usb_device { | |||
300 | int (*fe_init) (struct dvb_frontend *); | 300 | int (*fe_init) (struct dvb_frontend *); |
301 | 301 | ||
302 | /* remote control */ | 302 | /* remote control */ |
303 | struct input_dev rc_input_dev; | 303 | struct input_dev *rc_input_dev; |
304 | char rc_phys[64]; | ||
304 | struct work_struct rc_query_work; | 305 | struct work_struct rc_query_work; |
305 | u32 last_event; | 306 | u32 last_event; |
306 | int last_state; | 307 | int last_state; |
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index 357a3728ec68..f5e59fc924af 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | static int av_cnt; | 16 | static int av_cnt; |
17 | static struct av7110 *av_list[4]; | 17 | static struct av7110 *av_list[4]; |
18 | static struct input_dev input_dev; | 18 | static struct input_dev *input_dev; |
19 | 19 | ||
20 | static u16 key_map [256] = { | 20 | static u16 key_map [256] = { |
21 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, | 21 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, |
@@ -43,10 +43,10 @@ static u16 key_map [256] = { | |||
43 | 43 | ||
44 | static void av7110_emit_keyup(unsigned long data) | 44 | static void av7110_emit_keyup(unsigned long data) |
45 | { | 45 | { |
46 | if (!data || !test_bit(data, input_dev.key)) | 46 | if (!data || !test_bit(data, input_dev->key)) |
47 | return; | 47 | return; |
48 | 48 | ||
49 | input_event(&input_dev, EV_KEY, data, !!0); | 49 | input_event(input_dev, EV_KEY, data, !!0); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
@@ -112,13 +112,13 @@ static void av7110_emit_key(unsigned long parm) | |||
112 | if (timer_pending(&keyup_timer)) { | 112 | if (timer_pending(&keyup_timer)) { |
113 | del_timer(&keyup_timer); | 113 | del_timer(&keyup_timer); |
114 | if (keyup_timer.data != keycode || new_toggle != old_toggle) { | 114 | if (keyup_timer.data != keycode || new_toggle != old_toggle) { |
115 | input_event(&input_dev, EV_KEY, keyup_timer.data, !!0); | 115 | input_event(input_dev, EV_KEY, keyup_timer.data, !!0); |
116 | input_event(&input_dev, EV_KEY, keycode, !0); | 116 | input_event(input_dev, EV_KEY, keycode, !0); |
117 | } else | 117 | } else |
118 | input_event(&input_dev, EV_KEY, keycode, 2); | 118 | input_event(input_dev, EV_KEY, keycode, 2); |
119 | 119 | ||
120 | } else | 120 | } else |
121 | input_event(&input_dev, EV_KEY, keycode, !0); | 121 | input_event(input_dev, EV_KEY, keycode, !0); |
122 | 122 | ||
123 | keyup_timer.expires = jiffies + UP_TIMEOUT; | 123 | keyup_timer.expires = jiffies + UP_TIMEOUT; |
124 | keyup_timer.data = keycode; | 124 | keyup_timer.data = keycode; |
@@ -132,13 +132,13 @@ static void input_register_keys(void) | |||
132 | { | 132 | { |
133 | int i; | 133 | int i; |
134 | 134 | ||
135 | memset(input_dev.keybit, 0, sizeof(input_dev.keybit)); | 135 | memset(input_dev->keybit, 0, sizeof(input_dev->keybit)); |
136 | 136 | ||
137 | for (i = 0; i < sizeof(key_map) / sizeof(key_map[0]); i++) { | 137 | for (i = 0; i < ARRAY_SIZE(key_map); i++) { |
138 | if (key_map[i] > KEY_MAX) | 138 | if (key_map[i] > KEY_MAX) |
139 | key_map[i] = 0; | 139 | key_map[i] = 0; |
140 | else if (key_map[i] > KEY_RESERVED) | 140 | else if (key_map[i] > KEY_RESERVED) |
141 | set_bit(key_map[i], input_dev.keybit); | 141 | set_bit(key_map[i], input_dev->keybit); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
@@ -216,12 +216,17 @@ int __init av7110_ir_init(struct av7110 *av7110) | |||
216 | init_timer(&keyup_timer); | 216 | init_timer(&keyup_timer); |
217 | keyup_timer.data = 0; | 217 | keyup_timer.data = 0; |
218 | 218 | ||
219 | input_dev.name = "DVB on-card IR receiver"; | 219 | input_dev = input_allocate_device(); |
220 | set_bit(EV_KEY, input_dev.evbit); | 220 | if (!input_dev) |
221 | set_bit(EV_REP, input_dev.evbit); | 221 | return -ENOMEM; |
222 | |||
223 | input_dev->name = "DVB on-card IR receiver"; | ||
224 | |||
225 | set_bit(EV_KEY, input_dev->evbit); | ||
226 | set_bit(EV_REP, input_dev->evbit); | ||
222 | input_register_keys(); | 227 | input_register_keys(); |
223 | input_register_device(&input_dev); | 228 | input_register_device(input_dev); |
224 | input_dev.timer.function = input_repeat_key; | 229 | input_dev->timer.function = input_repeat_key; |
225 | 230 | ||
226 | e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); | 231 | e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); |
227 | if (e) { | 232 | if (e) { |
@@ -256,7 +261,7 @@ void __exit av7110_ir_exit(struct av7110 *av7110) | |||
256 | if (av_cnt == 1) { | 261 | if (av_cnt == 1) { |
257 | del_timer_sync(&keyup_timer); | 262 | del_timer_sync(&keyup_timer); |
258 | remove_proc_entry("av7110_ir", NULL); | 263 | remove_proc_entry("av7110_ir", NULL); |
259 | input_unregister_device(&input_dev); | 264 | input_unregister_device(input_dev); |
260 | } | 265 | } |
261 | 266 | ||
262 | av_cnt--; | 267 | av_cnt--; |
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 2980db3ef22f..51c30ba68140 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
@@ -64,7 +64,7 @@ | |||
64 | 64 | ||
65 | struct budget_ci { | 65 | struct budget_ci { |
66 | struct budget budget; | 66 | struct budget budget; |
67 | struct input_dev input_dev; | 67 | struct input_dev *input_dev; |
68 | struct tasklet_struct msp430_irq_tasklet; | 68 | struct tasklet_struct msp430_irq_tasklet; |
69 | struct tasklet_struct ciintf_irq_tasklet; | 69 | struct tasklet_struct ciintf_irq_tasklet; |
70 | int slot_status; | 70 | int slot_status; |
@@ -145,7 +145,7 @@ static void msp430_ir_debounce(unsigned long data) | |||
145 | static void msp430_ir_interrupt(unsigned long data) | 145 | static void msp430_ir_interrupt(unsigned long data) |
146 | { | 146 | { |
147 | struct budget_ci *budget_ci = (struct budget_ci *) data; | 147 | struct budget_ci *budget_ci = (struct budget_ci *) data; |
148 | struct input_dev *dev = &budget_ci->input_dev; | 148 | struct input_dev *dev = budget_ci->input_dev; |
149 | unsigned int code = | 149 | unsigned int code = |
150 | ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; | 150 | ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; |
151 | 151 | ||
@@ -181,25 +181,27 @@ static void msp430_ir_interrupt(unsigned long data) | |||
181 | static int msp430_ir_init(struct budget_ci *budget_ci) | 181 | static int msp430_ir_init(struct budget_ci *budget_ci) |
182 | { | 182 | { |
183 | struct saa7146_dev *saa = budget_ci->budget.dev; | 183 | struct saa7146_dev *saa = budget_ci->budget.dev; |
184 | struct input_dev *input_dev; | ||
184 | int i; | 185 | int i; |
185 | 186 | ||
186 | memset(&budget_ci->input_dev, 0, sizeof(struct input_dev)); | 187 | budget_ci->input_dev = input_dev = input_allocate_device(); |
188 | if (!input_dev) | ||
189 | return -ENOMEM; | ||
187 | 190 | ||
188 | sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name); | 191 | sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name); |
189 | budget_ci->input_dev.name = budget_ci->ir_dev_name; | ||
190 | 192 | ||
191 | set_bit(EV_KEY, budget_ci->input_dev.evbit); | 193 | input_dev->name = budget_ci->ir_dev_name; |
192 | 194 | ||
193 | for (i = 0; i < sizeof(key_map) / sizeof(*key_map); i++) | 195 | set_bit(EV_KEY, input_dev->evbit); |
196 | for (i = 0; i < ARRAY_SIZE(key_map); i++) | ||
194 | if (key_map[i]) | 197 | if (key_map[i]) |
195 | set_bit(key_map[i], budget_ci->input_dev.keybit); | 198 | set_bit(key_map[i], input_dev->keybit); |
196 | 199 | ||
197 | input_register_device(&budget_ci->input_dev); | 200 | input_register_device(budget_ci->input_dev); |
198 | 201 | ||
199 | budget_ci->input_dev.timer.function = msp430_ir_debounce; | 202 | input_dev->timer.function = msp430_ir_debounce; |
200 | 203 | ||
201 | saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); | 204 | saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); |
202 | |||
203 | saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); | 205 | saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); |
204 | 206 | ||
205 | return 0; | 207 | return 0; |
@@ -208,7 +210,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci) | |||
208 | static void msp430_ir_deinit(struct budget_ci *budget_ci) | 210 | static void msp430_ir_deinit(struct budget_ci *budget_ci) |
209 | { | 211 | { |
210 | struct saa7146_dev *saa = budget_ci->budget.dev; | 212 | struct saa7146_dev *saa = budget_ci->budget.dev; |
211 | struct input_dev *dev = &budget_ci->input_dev; | 213 | struct input_dev *dev = budget_ci->input_dev; |
212 | 214 | ||
213 | saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); | 215 | saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); |
214 | saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); | 216 | saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); |
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 3d08fc83a754..832d179f26fa 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
@@ -152,7 +152,8 @@ struct ttusb_dec { | |||
152 | struct list_head filter_info_list; | 152 | struct list_head filter_info_list; |
153 | spinlock_t filter_info_list_lock; | 153 | spinlock_t filter_info_list_lock; |
154 | 154 | ||
155 | struct input_dev rc_input_dev; | 155 | struct input_dev *rc_input_dev; |
156 | char rc_phys[64]; | ||
156 | 157 | ||
157 | int active; /* Loaded successfully */ | 158 | int active; /* Loaded successfully */ |
158 | }; | 159 | }; |
@@ -235,9 +236,9 @@ static void ttusb_dec_handle_irq( struct urb *urb, struct pt_regs *regs) | |||
235 | * this should/could be added later ... | 236 | * this should/could be added later ... |
236 | * for now lets report each signal as a key down and up*/ | 237 | * for now lets report each signal as a key down and up*/ |
237 | dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]); | 238 | dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]); |
238 | input_report_key(&dec->rc_input_dev,rc_keys[buffer[4]-1],1); | 239 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1); |
239 | input_report_key(&dec->rc_input_dev,rc_keys[buffer[4]-1],0); | 240 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0); |
240 | input_sync(&dec->rc_input_dev); | 241 | input_sync(dec->rc_input_dev); |
241 | } | 242 | } |
242 | 243 | ||
243 | exit: retval = usb_submit_urb(urb, GFP_ATOMIC); | 244 | exit: retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -1181,29 +1182,38 @@ static void ttusb_dec_init_tasklet(struct ttusb_dec *dec) | |||
1181 | (unsigned long)dec); | 1182 | (unsigned long)dec); |
1182 | } | 1183 | } |
1183 | 1184 | ||
1184 | static void ttusb_init_rc( struct ttusb_dec *dec) | 1185 | static int ttusb_init_rc(struct ttusb_dec *dec) |
1185 | { | 1186 | { |
1187 | struct input_dev *input_dev; | ||
1186 | u8 b[] = { 0x00, 0x01 }; | 1188 | u8 b[] = { 0x00, 0x01 }; |
1187 | int i; | 1189 | int i; |
1188 | 1190 | ||
1189 | init_input_dev(&dec->rc_input_dev); | 1191 | usb_make_path(dec->udev, dec->rc_phys, sizeof(dec->rc_phys)); |
1192 | strlcpy(dec->rc_phys, "/input0", sizeof(dec->rc_phys)); | ||
1190 | 1193 | ||
1191 | dec->rc_input_dev.name = "ttusb_dec remote control"; | 1194 | dec->rc_input_dev = input_dev = input_allocate_device(); |
1192 | dec->rc_input_dev.evbit[0] = BIT(EV_KEY); | 1195 | if (!input_dev) |
1193 | dec->rc_input_dev.keycodesize = sizeof(u16); | 1196 | return -ENOMEM; |
1194 | dec->rc_input_dev.keycodemax = 0x1a; | 1197 | |
1195 | dec->rc_input_dev.keycode = rc_keys; | 1198 | input_dev->name = "ttusb_dec remote control"; |
1199 | input_dev->phys = dec->rc_phys; | ||
1200 | input_dev->evbit[0] = BIT(EV_KEY); | ||
1201 | input_dev->keycodesize = sizeof(u16); | ||
1202 | input_dev->keycodemax = 0x1a; | ||
1203 | input_dev->keycode = rc_keys; | ||
1196 | 1204 | ||
1197 | for (i = 0; i < sizeof(rc_keys)/sizeof(rc_keys[0]); i++) | 1205 | for (i = 0; i < ARRAY_SIZE(rc_keys); i++) |
1198 | set_bit(rc_keys[i], dec->rc_input_dev.keybit); | 1206 | set_bit(rc_keys[i], input_dev->keybit); |
1199 | 1207 | ||
1200 | input_register_device(&dec->rc_input_dev); | 1208 | input_register_device(input_dev); |
1201 | 1209 | ||
1202 | if(usb_submit_urb(dec->irq_urb,GFP_KERNEL)) { | 1210 | if (usb_submit_urb(dec->irq_urb, GFP_KERNEL)) |
1203 | printk("%s: usb_submit_urb failed\n",__FUNCTION__); | 1211 | printk("%s: usb_submit_urb failed\n",__FUNCTION__); |
1204 | } | 1212 | |
1205 | /* enable irq pipe */ | 1213 | /* enable irq pipe */ |
1206 | ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); | 1214 | ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); |
1215 | |||
1216 | return 0; | ||
1207 | } | 1217 | } |
1208 | 1218 | ||
1209 | static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) | 1219 | static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) |
@@ -1513,7 +1523,7 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec) | |||
1513 | * As the irq is submitted after the interface is changed, | 1523 | * As the irq is submitted after the interface is changed, |
1514 | * this is the best method i figured out. | 1524 | * this is the best method i figured out. |
1515 | * Any others?*/ | 1525 | * Any others?*/ |
1516 | if(dec->interface == TTUSB_DEC_INTERFACE_IN) | 1526 | if (dec->interface == TTUSB_DEC_INTERFACE_IN) |
1517 | usb_kill_urb(dec->irq_urb); | 1527 | usb_kill_urb(dec->irq_urb); |
1518 | 1528 | ||
1519 | usb_free_urb(dec->irq_urb); | 1529 | usb_free_urb(dec->irq_urb); |
@@ -1521,7 +1531,10 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec) | |||
1521 | usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, | 1531 | usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, |
1522 | dec->irq_buffer, dec->irq_dma_handle); | 1532 | dec->irq_buffer, dec->irq_dma_handle); |
1523 | 1533 | ||
1524 | input_unregister_device(&dec->rc_input_dev); | 1534 | if (dec->rc_input_dev) { |
1535 | input_unregister_device(dec->rc_input_dev); | ||
1536 | dec->rc_input_dev = NULL; | ||
1537 | } | ||
1525 | } | 1538 | } |
1526 | 1539 | ||
1527 | 1540 | ||
@@ -1659,7 +1672,7 @@ static int ttusb_dec_probe(struct usb_interface *intf, | |||
1659 | 1672 | ||
1660 | ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN); | 1673 | ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN); |
1661 | 1674 | ||
1662 | if(enable_rc) | 1675 | if (enable_rc) |
1663 | ttusb_init_rc(dec); | 1676 | ttusb_init_rc(dec); |
1664 | 1677 | ||
1665 | return 0; | 1678 | return 0; |
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index 7a312f79340a..e0e7c7a84bc5 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h | |||
@@ -240,7 +240,7 @@ struct bttv_pll_info { | |||
240 | 240 | ||
241 | /* for gpio-connected remote control */ | 241 | /* for gpio-connected remote control */ |
242 | struct bttv_input { | 242 | struct bttv_input { |
243 | struct input_dev dev; | 243 | struct input_dev *dev; |
244 | struct ir_input_state ir; | 244 | struct ir_input_state ir; |
245 | char name[32]; | 245 | char name[32]; |
246 | char phys[32]; | 246 | char phys[32]; |
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index d81b21d6e05d..c27fe4c36f69 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c | |||
@@ -260,7 +260,7 @@ static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = { | |||
260 | 260 | ||
261 | struct cx88_IR { | 261 | struct cx88_IR { |
262 | struct cx88_core *core; | 262 | struct cx88_core *core; |
263 | struct input_dev input; | 263 | struct input_dev *input; |
264 | struct ir_input_state ir; | 264 | struct ir_input_state ir; |
265 | char name[32]; | 265 | char name[32]; |
266 | char phys[32]; | 266 | char phys[32]; |
@@ -315,23 +315,23 @@ static void cx88_ir_handle_key(struct cx88_IR *ir) | |||
315 | if (ir->mask_keydown) { | 315 | if (ir->mask_keydown) { |
316 | /* bit set on keydown */ | 316 | /* bit set on keydown */ |
317 | if (gpio & ir->mask_keydown) { | 317 | if (gpio & ir->mask_keydown) { |
318 | ir_input_keydown(&ir->input, &ir->ir, data, data); | 318 | ir_input_keydown(ir->input, &ir->ir, data, data); |
319 | } else { | 319 | } else { |
320 | ir_input_nokey(&ir->input, &ir->ir); | 320 | ir_input_nokey(ir->input, &ir->ir); |
321 | } | 321 | } |
322 | 322 | ||
323 | } else if (ir->mask_keyup) { | 323 | } else if (ir->mask_keyup) { |
324 | /* bit cleared on keydown */ | 324 | /* bit cleared on keydown */ |
325 | if (0 == (gpio & ir->mask_keyup)) { | 325 | if (0 == (gpio & ir->mask_keyup)) { |
326 | ir_input_keydown(&ir->input, &ir->ir, data, data); | 326 | ir_input_keydown(ir->input, &ir->ir, data, data); |
327 | } else { | 327 | } else { |
328 | ir_input_nokey(&ir->input, &ir->ir); | 328 | ir_input_nokey(ir->input, &ir->ir); |
329 | } | 329 | } |
330 | 330 | ||
331 | } else { | 331 | } else { |
332 | /* can't distinguish keydown/up :-/ */ | 332 | /* can't distinguish keydown/up :-/ */ |
333 | ir_input_keydown(&ir->input, &ir->ir, data, data); | 333 | ir_input_keydown(ir->input, &ir->ir, data, data); |
334 | ir_input_nokey(&ir->input, &ir->ir); | 334 | ir_input_nokey(ir->input, &ir->ir); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
@@ -357,13 +357,19 @@ static void cx88_ir_work(void *data) | |||
357 | int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | 357 | int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) |
358 | { | 358 | { |
359 | struct cx88_IR *ir; | 359 | struct cx88_IR *ir; |
360 | struct input_dev *input_dev; | ||
360 | IR_KEYTAB_TYPE *ir_codes = NULL; | 361 | IR_KEYTAB_TYPE *ir_codes = NULL; |
361 | int ir_type = IR_TYPE_OTHER; | 362 | int ir_type = IR_TYPE_OTHER; |
362 | 363 | ||
363 | ir = kmalloc(sizeof(*ir), GFP_KERNEL); | 364 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
364 | if (NULL == ir) | 365 | input_dev = input_allocate_device(); |
366 | if (!ir || !input_dev) { | ||
367 | kfree(ir); | ||
368 | input_free_device(input_dev); | ||
365 | return -ENOMEM; | 369 | return -ENOMEM; |
366 | memset(ir, 0, sizeof(*ir)); | 370 | } |
371 | |||
372 | ir->input = input_dev; | ||
367 | 373 | ||
368 | /* detect & configure */ | 374 | /* detect & configure */ |
369 | switch (core->board) { | 375 | switch (core->board) { |
@@ -425,6 +431,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
425 | 431 | ||
426 | if (NULL == ir_codes) { | 432 | if (NULL == ir_codes) { |
427 | kfree(ir); | 433 | kfree(ir); |
434 | input_free_device(input_dev); | ||
428 | return -ENODEV; | 435 | return -ENODEV; |
429 | } | 436 | } |
430 | 437 | ||
@@ -433,19 +440,19 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
433 | cx88_boards[core->board].name); | 440 | cx88_boards[core->board].name); |
434 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); | 441 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); |
435 | 442 | ||
436 | ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); | 443 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
437 | ir->input.name = ir->name; | 444 | input_dev->name = ir->name; |
438 | ir->input.phys = ir->phys; | 445 | input_dev->phys = ir->phys; |
439 | ir->input.id.bustype = BUS_PCI; | 446 | input_dev->id.bustype = BUS_PCI; |
440 | ir->input.id.version = 1; | 447 | input_dev->id.version = 1; |
441 | if (pci->subsystem_vendor) { | 448 | if (pci->subsystem_vendor) { |
442 | ir->input.id.vendor = pci->subsystem_vendor; | 449 | input_dev->id.vendor = pci->subsystem_vendor; |
443 | ir->input.id.product = pci->subsystem_device; | 450 | input_dev->id.product = pci->subsystem_device; |
444 | } else { | 451 | } else { |
445 | ir->input.id.vendor = pci->vendor; | 452 | input_dev->id.vendor = pci->vendor; |
446 | ir->input.id.product = pci->device; | 453 | input_dev->id.product = pci->device; |
447 | } | 454 | } |
448 | ir->input.dev = &pci->dev; | 455 | input_dev->cdev.dev = &pci->dev; |
449 | 456 | ||
450 | /* record handles to ourself */ | 457 | /* record handles to ourself */ |
451 | ir->core = core; | 458 | ir->core = core; |
@@ -465,8 +472,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
465 | } | 472 | } |
466 | 473 | ||
467 | /* all done */ | 474 | /* all done */ |
468 | input_register_device(&ir->input); | 475 | input_register_device(ir->input); |
469 | printk("%s: registered IR remote control\n", core->name); | ||
470 | 476 | ||
471 | return 0; | 477 | return 0; |
472 | } | 478 | } |
@@ -484,7 +490,7 @@ int cx88_ir_fini(struct cx88_core *core) | |||
484 | flush_scheduled_work(); | 490 | flush_scheduled_work(); |
485 | } | 491 | } |
486 | 492 | ||
487 | input_unregister_device(&ir->input); | 493 | input_unregister_device(ir->input); |
488 | kfree(ir); | 494 | kfree(ir); |
489 | 495 | ||
490 | /* done */ | 496 | /* done */ |
@@ -515,7 +521,7 @@ void cx88_ir_irq(struct cx88_core *core) | |||
515 | if (!ir->scount) { | 521 | if (!ir->scount) { |
516 | /* nothing to sample */ | 522 | /* nothing to sample */ |
517 | if (ir->ir.keypressed && time_after(jiffies, ir->release)) | 523 | if (ir->ir.keypressed && time_after(jiffies, ir->release)) |
518 | ir_input_nokey(&ir->input, &ir->ir); | 524 | ir_input_nokey(ir->input, &ir->ir); |
519 | return; | 525 | return; |
520 | } | 526 | } |
521 | 527 | ||
@@ -557,7 +563,7 @@ void cx88_ir_irq(struct cx88_core *core) | |||
557 | 563 | ||
558 | ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); | 564 | ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); |
559 | 565 | ||
560 | ir_input_keydown(&ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); | 566 | ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); |
561 | ir->release = jiffies + msecs_to_jiffies(120); | 567 | ir->release = jiffies + msecs_to_jiffies(120); |
562 | break; | 568 | break; |
563 | case CX88_BOARD_HAUPPAUGE: | 569 | case CX88_BOARD_HAUPPAUGE: |
@@ -566,7 +572,7 @@ void cx88_ir_irq(struct cx88_core *core) | |||
566 | ir_dprintk("biphase decoded: %x\n", ircode); | 572 | ir_dprintk("biphase decoded: %x\n", ircode); |
567 | if ((ircode & 0xfffff000) != 0x3000) | 573 | if ((ircode & 0xfffff000) != 0x3000) |
568 | break; | 574 | break; |
569 | ir_input_keydown(&ir->input, &ir->ir, ircode & 0x3f, ircode); | 575 | ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f, ircode); |
570 | ir->release = jiffies + msecs_to_jiffies(120); | 576 | ir->release = jiffies + msecs_to_jiffies(120); |
571 | break; | 577 | break; |
572 | } | 578 | } |
diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c index cf292da8fdd5..234151e48edc 100644 --- a/drivers/media/video/ir-kbd-gpio.c +++ b/drivers/media/video/ir-kbd-gpio.c | |||
@@ -158,7 +158,7 @@ static IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE] = { | |||
158 | 158 | ||
159 | struct IR { | 159 | struct IR { |
160 | struct bttv_sub_device *sub; | 160 | struct bttv_sub_device *sub; |
161 | struct input_dev input; | 161 | struct input_dev *input; |
162 | struct ir_input_state ir; | 162 | struct ir_input_state ir; |
163 | char name[32]; | 163 | char name[32]; |
164 | char phys[32]; | 164 | char phys[32]; |
@@ -217,23 +217,23 @@ static void ir_handle_key(struct IR *ir) | |||
217 | if (ir->mask_keydown) { | 217 | if (ir->mask_keydown) { |
218 | /* bit set on keydown */ | 218 | /* bit set on keydown */ |
219 | if (gpio & ir->mask_keydown) { | 219 | if (gpio & ir->mask_keydown) { |
220 | ir_input_keydown(&ir->input,&ir->ir,data,data); | 220 | ir_input_keydown(ir->input, &ir->ir, data, data); |
221 | } else { | 221 | } else { |
222 | ir_input_nokey(&ir->input,&ir->ir); | 222 | ir_input_nokey(ir->input, &ir->ir); |
223 | } | 223 | } |
224 | 224 | ||
225 | } else if (ir->mask_keyup) { | 225 | } else if (ir->mask_keyup) { |
226 | /* bit cleared on keydown */ | 226 | /* bit cleared on keydown */ |
227 | if (0 == (gpio & ir->mask_keyup)) { | 227 | if (0 == (gpio & ir->mask_keyup)) { |
228 | ir_input_keydown(&ir->input,&ir->ir,data,data); | 228 | ir_input_keydown(ir->input, &ir->ir, data, data); |
229 | } else { | 229 | } else { |
230 | ir_input_nokey(&ir->input,&ir->ir); | 230 | ir_input_nokey(ir->input, &ir->ir); |
231 | } | 231 | } |
232 | 232 | ||
233 | } else { | 233 | } else { |
234 | /* can't disturgissh keydown/up :-/ */ | 234 | /* can't disturgissh keydown/up :-/ */ |
235 | ir_input_keydown(&ir->input,&ir->ir,data,data); | 235 | ir_input_keydown(ir->input, &ir->ir, data, data); |
236 | ir_input_nokey(&ir->input,&ir->ir); | 236 | ir_input_nokey(ir->input, &ir->ir); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
@@ -268,13 +268,17 @@ static int ir_probe(struct device *dev) | |||
268 | { | 268 | { |
269 | struct bttv_sub_device *sub = to_bttv_sub_dev(dev); | 269 | struct bttv_sub_device *sub = to_bttv_sub_dev(dev); |
270 | struct IR *ir; | 270 | struct IR *ir; |
271 | struct input_dev *input_dev; | ||
271 | IR_KEYTAB_TYPE *ir_codes = NULL; | 272 | IR_KEYTAB_TYPE *ir_codes = NULL; |
272 | int ir_type = IR_TYPE_OTHER; | 273 | int ir_type = IR_TYPE_OTHER; |
273 | 274 | ||
274 | ir = kmalloc(sizeof(*ir),GFP_KERNEL); | 275 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
275 | if (NULL == ir) | 276 | input_dev = input_allocate_device(); |
277 | if (!ir || !input_dev) { | ||
278 | kfree(ir); | ||
279 | input_free_device(input_dev); | ||
276 | return -ENOMEM; | 280 | return -ENOMEM; |
277 | memset(ir,0,sizeof(*ir)); | 281 | } |
278 | 282 | ||
279 | /* detect & configure */ | 283 | /* detect & configure */ |
280 | switch (sub->core->type) { | 284 | switch (sub->core->type) { |
@@ -328,6 +332,7 @@ static int ir_probe(struct device *dev) | |||
328 | } | 332 | } |
329 | if (NULL == ir_codes) { | 333 | if (NULL == ir_codes) { |
330 | kfree(ir); | 334 | kfree(ir); |
335 | input_free_device(input_dev); | ||
331 | return -ENODEV; | 336 | return -ENODEV; |
332 | } | 337 | } |
333 | 338 | ||
@@ -341,19 +346,19 @@ static int ir_probe(struct device *dev) | |||
341 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", | 346 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", |
342 | pci_name(sub->core->pci)); | 347 | pci_name(sub->core->pci)); |
343 | 348 | ||
344 | ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); | 349 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
345 | ir->input.name = ir->name; | 350 | input_dev->name = ir->name; |
346 | ir->input.phys = ir->phys; | 351 | input_dev->phys = ir->phys; |
347 | ir->input.id.bustype = BUS_PCI; | 352 | input_dev->id.bustype = BUS_PCI; |
348 | ir->input.id.version = 1; | 353 | input_dev->id.version = 1; |
349 | if (sub->core->pci->subsystem_vendor) { | 354 | if (sub->core->pci->subsystem_vendor) { |
350 | ir->input.id.vendor = sub->core->pci->subsystem_vendor; | 355 | input_dev->id.vendor = sub->core->pci->subsystem_vendor; |
351 | ir->input.id.product = sub->core->pci->subsystem_device; | 356 | input_dev->id.product = sub->core->pci->subsystem_device; |
352 | } else { | 357 | } else { |
353 | ir->input.id.vendor = sub->core->pci->vendor; | 358 | input_dev->id.vendor = sub->core->pci->vendor; |
354 | ir->input.id.product = sub->core->pci->device; | 359 | input_dev->id.product = sub->core->pci->device; |
355 | } | 360 | } |
356 | ir->input.dev = &sub->core->pci->dev; | 361 | input_dev->cdev.dev = &sub->core->pci->dev; |
357 | 362 | ||
358 | if (ir->polling) { | 363 | if (ir->polling) { |
359 | INIT_WORK(&ir->work, ir_work, ir); | 364 | INIT_WORK(&ir->work, ir_work, ir); |
@@ -364,9 +369,8 @@ static int ir_probe(struct device *dev) | |||
364 | } | 369 | } |
365 | 370 | ||
366 | /* all done */ | 371 | /* all done */ |
367 | dev_set_drvdata(dev,ir); | 372 | dev_set_drvdata(dev, ir); |
368 | input_register_device(&ir->input); | 373 | input_register_device(ir->input); |
369 | printk(DEVNAME ": %s detected at %s\n",ir->input.name,ir->input.phys); | ||
370 | 374 | ||
371 | return 0; | 375 | return 0; |
372 | } | 376 | } |
@@ -380,7 +384,7 @@ static int ir_remove(struct device *dev) | |||
380 | flush_scheduled_work(); | 384 | flush_scheduled_work(); |
381 | } | 385 | } |
382 | 386 | ||
383 | input_unregister_device(&ir->input); | 387 | input_unregister_device(ir->input); |
384 | kfree(ir); | 388 | kfree(ir); |
385 | return 0; | 389 | return 0; |
386 | } | 390 | } |
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 67105b9804a2..9703d3d351f9 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
@@ -121,10 +121,9 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = { | |||
121 | 121 | ||
122 | }; | 122 | }; |
123 | 123 | ||
124 | struct IR; | ||
125 | struct IR { | 124 | struct IR { |
126 | struct i2c_client c; | 125 | struct i2c_client c; |
127 | struct input_dev input; | 126 | struct input_dev *input; |
128 | struct ir_input_state ir; | 127 | struct ir_input_state ir; |
129 | 128 | ||
130 | struct work_struct work; | 129 | struct work_struct work; |
@@ -271,9 +270,9 @@ static void ir_key_poll(struct IR *ir) | |||
271 | } | 270 | } |
272 | 271 | ||
273 | if (0 == rc) { | 272 | if (0 == rc) { |
274 | ir_input_nokey(&ir->input,&ir->ir); | 273 | ir_input_nokey(ir->input, &ir->ir); |
275 | } else { | 274 | } else { |
276 | ir_input_keydown(&ir->input,&ir->ir, ir_key, ir_raw); | 275 | ir_input_keydown(ir->input, &ir->ir, ir_key, ir_raw); |
277 | } | 276 | } |
278 | } | 277 | } |
279 | 278 | ||
@@ -318,11 +317,18 @@ static int ir_attach(struct i2c_adapter *adap, int addr, | |||
318 | char *name; | 317 | char *name; |
319 | int ir_type; | 318 | int ir_type; |
320 | struct IR *ir; | 319 | struct IR *ir; |
320 | struct input_dev *input_dev; | ||
321 | 321 | ||
322 | if (NULL == (ir = kmalloc(sizeof(struct IR),GFP_KERNEL))) | 322 | ir = kzalloc(sizeof(struct IR), GFP_KERNEL); |
323 | input_dev = input_allocate_device(); | ||
324 | if (!ir || !input_dev) { | ||
325 | kfree(ir); | ||
326 | input_free_device(input_dev); | ||
323 | return -ENOMEM; | 327 | return -ENOMEM; |
324 | memset(ir,0,sizeof(*ir)); | 328 | } |
329 | |||
325 | ir->c = client_template; | 330 | ir->c = client_template; |
331 | ir->input = input_dev; | ||
326 | 332 | ||
327 | i2c_set_clientdata(&ir->c, ir); | 333 | i2c_set_clientdata(&ir->c, ir); |
328 | ir->c.adapter = adap; | 334 | ir->c.adapter = adap; |
@@ -375,13 +381,12 @@ static int ir_attach(struct i2c_adapter *adap, int addr, | |||
375 | ir->c.dev.bus_id); | 381 | ir->c.dev.bus_id); |
376 | 382 | ||
377 | /* init + register input device */ | 383 | /* init + register input device */ |
378 | ir_input_init(&ir->input,&ir->ir,ir_type,ir_codes); | 384 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
379 | ir->input.id.bustype = BUS_I2C; | 385 | input_dev->id.bustype = BUS_I2C; |
380 | ir->input.name = ir->c.name; | 386 | input_dev->name = ir->c.name; |
381 | ir->input.phys = ir->phys; | 387 | input_dev->phys = ir->phys; |
382 | input_register_device(&ir->input); | 388 | |
383 | printk(DEVNAME ": %s detected at %s [%s]\n", | 389 | input_register_device(ir->input); |
384 | ir->input.name,ir->input.phys,adap->name); | ||
385 | 390 | ||
386 | /* start polling via eventd */ | 391 | /* start polling via eventd */ |
387 | INIT_WORK(&ir->work, ir_work, ir); | 392 | INIT_WORK(&ir->work, ir_work, ir); |
@@ -402,7 +407,7 @@ static int ir_detach(struct i2c_client *client) | |||
402 | flush_scheduled_work(); | 407 | flush_scheduled_work(); |
403 | 408 | ||
404 | /* unregister devices */ | 409 | /* unregister devices */ |
405 | input_unregister_device(&ir->input); | 410 | input_unregister_device(ir->input); |
406 | i2c_detach_client(&ir->c); | 411 | i2c_detach_client(&ir->c); |
407 | 412 | ||
408 | /* free memory */ | 413 | /* free memory */ |
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index f0d43fc2632f..262890cb20a7 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c | |||
@@ -1420,8 +1420,8 @@ static int msp_detach(struct i2c_client *client); | |||
1420 | static int msp_probe(struct i2c_adapter *adap); | 1420 | static int msp_probe(struct i2c_adapter *adap); |
1421 | static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg); | 1421 | static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg); |
1422 | 1422 | ||
1423 | static int msp_suspend(struct device * dev, pm_message_t state, u32 level); | 1423 | static int msp_suspend(struct device * dev, pm_message_t state); |
1424 | static int msp_resume(struct device * dev, u32 level); | 1424 | static int msp_resume(struct device * dev); |
1425 | 1425 | ||
1426 | static void msp_wake_thread(struct i2c_client *client); | 1426 | static void msp_wake_thread(struct i2c_client *client); |
1427 | 1427 | ||
@@ -1821,7 +1821,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
1821 | return 0; | 1821 | return 0; |
1822 | } | 1822 | } |
1823 | 1823 | ||
1824 | static int msp_suspend(struct device * dev, pm_message_t state, u32 level) | 1824 | static int msp_suspend(struct device * dev, pm_message_t state) |
1825 | { | 1825 | { |
1826 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); | 1826 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); |
1827 | 1827 | ||
@@ -1830,7 +1830,7 @@ static int msp_suspend(struct device * dev, pm_message_t state, u32 level) | |||
1830 | return 0; | 1830 | return 0; |
1831 | } | 1831 | } |
1832 | 1832 | ||
1833 | static int msp_resume(struct device * dev, u32 level) | 1833 | static int msp_resume(struct device * dev) |
1834 | { | 1834 | { |
1835 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); | 1835 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); |
1836 | 1836 | ||
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 1f456c4d76f2..242cb235cf92 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -425,9 +425,9 @@ static int build_key(struct saa7134_dev *dev) | |||
425 | 425 | ||
426 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || | 426 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || |
427 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { | 427 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { |
428 | ir_input_keydown(&ir->dev,&ir->ir,data,data); | 428 | ir_input_keydown(ir->dev, &ir->ir, data, data); |
429 | } else { | 429 | } else { |
430 | ir_input_nokey(&ir->dev,&ir->ir); | 430 | ir_input_nokey(ir->dev, &ir->ir); |
431 | } | 431 | } |
432 | return 0; | 432 | return 0; |
433 | } | 433 | } |
@@ -456,6 +456,7 @@ static void saa7134_input_timer(unsigned long data) | |||
456 | int saa7134_input_init1(struct saa7134_dev *dev) | 456 | int saa7134_input_init1(struct saa7134_dev *dev) |
457 | { | 457 | { |
458 | struct saa7134_ir *ir; | 458 | struct saa7134_ir *ir; |
459 | struct input_dev *input_dev; | ||
459 | IR_KEYTAB_TYPE *ir_codes = NULL; | 460 | IR_KEYTAB_TYPE *ir_codes = NULL; |
460 | u32 mask_keycode = 0; | 461 | u32 mask_keycode = 0; |
461 | u32 mask_keydown = 0; | 462 | u32 mask_keydown = 0; |
@@ -535,10 +536,13 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
535 | return -ENODEV; | 536 | return -ENODEV; |
536 | } | 537 | } |
537 | 538 | ||
538 | ir = kmalloc(sizeof(*ir),GFP_KERNEL); | 539 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
539 | if (NULL == ir) | 540 | input_dev = input_allocate_device(); |
541 | if (!ir || !input_dev) { | ||
542 | kfree(ir); | ||
543 | input_free_device(input_dev); | ||
540 | return -ENOMEM; | 544 | return -ENOMEM; |
541 | memset(ir,0,sizeof(*ir)); | 545 | } |
542 | 546 | ||
543 | /* init hardware-specific stuff */ | 547 | /* init hardware-specific stuff */ |
544 | ir->mask_keycode = mask_keycode; | 548 | ir->mask_keycode = mask_keycode; |
@@ -552,19 +556,19 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
552 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", | 556 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", |
553 | pci_name(dev->pci)); | 557 | pci_name(dev->pci)); |
554 | 558 | ||
555 | ir_input_init(&ir->dev, &ir->ir, ir_type, ir_codes); | 559 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
556 | ir->dev.name = ir->name; | 560 | input_dev->name = ir->name; |
557 | ir->dev.phys = ir->phys; | 561 | input_dev->phys = ir->phys; |
558 | ir->dev.id.bustype = BUS_PCI; | 562 | input_dev->id.bustype = BUS_PCI; |
559 | ir->dev.id.version = 1; | 563 | input_dev->id.version = 1; |
560 | if (dev->pci->subsystem_vendor) { | 564 | if (dev->pci->subsystem_vendor) { |
561 | ir->dev.id.vendor = dev->pci->subsystem_vendor; | 565 | input_dev->id.vendor = dev->pci->subsystem_vendor; |
562 | ir->dev.id.product = dev->pci->subsystem_device; | 566 | input_dev->id.product = dev->pci->subsystem_device; |
563 | } else { | 567 | } else { |
564 | ir->dev.id.vendor = dev->pci->vendor; | 568 | input_dev->id.vendor = dev->pci->vendor; |
565 | ir->dev.id.product = dev->pci->device; | 569 | input_dev->id.product = dev->pci->device; |
566 | } | 570 | } |
567 | ir->dev.dev = &dev->pci->dev; | 571 | input_dev->cdev.dev = &dev->pci->dev; |
568 | 572 | ||
569 | /* all done */ | 573 | /* all done */ |
570 | dev->remote = ir; | 574 | dev->remote = ir; |
@@ -576,8 +580,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
576 | add_timer(&ir->timer); | 580 | add_timer(&ir->timer); |
577 | } | 581 | } |
578 | 582 | ||
579 | input_register_device(&dev->remote->dev); | 583 | input_register_device(ir->dev); |
580 | printk("%s: registered input device for IR\n",dev->name); | ||
581 | return 0; | 584 | return 0; |
582 | } | 585 | } |
583 | 586 | ||
@@ -586,9 +589,9 @@ void saa7134_input_fini(struct saa7134_dev *dev) | |||
586 | if (NULL == dev->remote) | 589 | if (NULL == dev->remote) |
587 | return; | 590 | return; |
588 | 591 | ||
589 | input_unregister_device(&dev->remote->dev); | ||
590 | if (dev->remote->polling) | 592 | if (dev->remote->polling) |
591 | del_timer_sync(&dev->remote->timer); | 593 | del_timer_sync(&dev->remote->timer); |
594 | input_unregister_device(dev->remote->dev); | ||
592 | kfree(dev->remote); | 595 | kfree(dev->remote); |
593 | dev->remote = NULL; | 596 | dev->remote = NULL; |
594 | } | 597 | } |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 3ea09142ec9c..860b89530e2a 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -351,7 +351,7 @@ struct saa7134_oss { | |||
351 | 351 | ||
352 | /* IR input */ | 352 | /* IR input */ |
353 | struct saa7134_ir { | 353 | struct saa7134_ir { |
354 | struct input_dev dev; | 354 | struct input_dev *dev; |
355 | struct ir_input_state ir; | 355 | struct ir_input_state ir; |
356 | char name[32]; | 356 | char name[32]; |
357 | char phys[32]; | 357 | char phys[32]; |
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 0456dda2624d..94053f149ddf 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -784,13 +784,13 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
784 | return 0; | 784 | return 0; |
785 | } | 785 | } |
786 | 786 | ||
787 | static int tda9887_suspend(struct device * dev, pm_message_t state, u32 level) | 787 | static int tda9887_suspend(struct device * dev, pm_message_t state) |
788 | { | 788 | { |
789 | dprintk("tda9887: suspend\n"); | 789 | dprintk("tda9887: suspend\n"); |
790 | return 0; | 790 | return 0; |
791 | } | 791 | } |
792 | 792 | ||
793 | static int tda9887_resume(struct device * dev, u32 level) | 793 | static int tda9887_resume(struct device * dev) |
794 | { | 794 | { |
795 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); | 795 | struct i2c_client *c = container_of(dev, struct i2c_client, dev); |
796 | struct tda9887 *t = i2c_get_clientdata(c); | 796 | struct tda9887 *t = i2c_get_clientdata(c); |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 05572020af4d..ad85bef1c3d5 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -697,7 +697,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
697 | return 0; | 697 | return 0; |
698 | } | 698 | } |
699 | 699 | ||
700 | static int tuner_suspend(struct device *dev, pm_message_t state, u32 level) | 700 | static int tuner_suspend(struct device *dev, pm_message_t state) |
701 | { | 701 | { |
702 | struct i2c_client *c = container_of (dev, struct i2c_client, dev); | 702 | struct i2c_client *c = container_of (dev, struct i2c_client, dev); |
703 | struct tuner *t = i2c_get_clientdata (c); | 703 | struct tuner *t = i2c_get_clientdata (c); |
@@ -707,7 +707,7 @@ static int tuner_suspend(struct device *dev, pm_message_t state, u32 level) | |||
707 | return 0; | 707 | return 0; |
708 | } | 708 | } |
709 | 709 | ||
710 | static int tuner_resume(struct device *dev, u32 level) | 710 | static int tuner_resume(struct device *dev) |
711 | { | 711 | { |
712 | struct i2c_client *c = container_of (dev, struct i2c_client, dev); | 712 | struct i2c_client *c = container_of (dev, struct i2c_client, dev); |
713 | struct tuner *t = i2c_get_clientdata (c); | 713 | struct tuner *t = i2c_get_clientdata (c); |
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h index c5bcfd70f711..9eefedb16211 100644 --- a/drivers/message/i2o/core.h +++ b/drivers/message/i2o/core.h | |||
@@ -36,9 +36,6 @@ extern void __exit i2o_pci_exit(void); | |||
36 | extern void i2o_device_remove(struct i2o_device *); | 36 | extern void i2o_device_remove(struct i2o_device *); |
37 | extern int i2o_device_parse_lct(struct i2o_controller *); | 37 | extern int i2o_device_parse_lct(struct i2o_controller *); |
38 | 38 | ||
39 | extern int i2o_device_init(void); | ||
40 | extern void i2o_device_exit(void); | ||
41 | |||
42 | /* IOP */ | 39 | /* IOP */ |
43 | extern struct i2o_controller *i2o_iop_alloc(void); | 40 | extern struct i2o_controller *i2o_iop_alloc(void); |
44 | extern void i2o_iop_free(struct i2o_controller *); | 41 | extern void i2o_iop_free(struct i2o_controller *); |
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 21f16ba3ac38..d9879965eb50 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c | |||
@@ -45,10 +45,10 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, | |||
45 | writel(type, &msg->body[0]); | 45 | writel(type, &msg->body[0]); |
46 | 46 | ||
47 | return i2o_msg_post_wait(dev->iop, m, 60); | 47 | return i2o_msg_post_wait(dev->iop, m, 60); |
48 | }; | 48 | } |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * i2o_device_claim - claim a device for use by an OSM | 51 | * i2o_device_claim - claim a device for use by an OSM |
52 | * @dev: I2O device to claim | 52 | * @dev: I2O device to claim |
53 | * @drv: I2O driver which wants to claim the device | 53 | * @drv: I2O driver which wants to claim the device |
54 | * | 54 | * |
@@ -73,7 +73,7 @@ int i2o_device_claim(struct i2o_device *dev) | |||
73 | up(&dev->lock); | 73 | up(&dev->lock); |
74 | 74 | ||
75 | return rc; | 75 | return rc; |
76 | }; | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * i2o_device_claim_release - release a device that the OSM is using | 79 | * i2o_device_claim_release - release a device that the OSM is using |
@@ -119,7 +119,8 @@ int i2o_device_claim_release(struct i2o_device *dev) | |||
119 | up(&dev->lock); | 119 | up(&dev->lock); |
120 | 120 | ||
121 | return rc; | 121 | return rc; |
122 | }; | 122 | } |
123 | |||
123 | 124 | ||
124 | /** | 125 | /** |
125 | * i2o_device_release - release the memory for a I2O device | 126 | * i2o_device_release - release the memory for a I2O device |
@@ -135,39 +136,47 @@ static void i2o_device_release(struct device *dev) | |||
135 | pr_debug("i2o: device %s released\n", dev->bus_id); | 136 | pr_debug("i2o: device %s released\n", dev->bus_id); |
136 | 137 | ||
137 | kfree(i2o_dev); | 138 | kfree(i2o_dev); |
138 | }; | 139 | } |
140 | |||
139 | 141 | ||
140 | /** | 142 | /** |
141 | * i2o_device_class_release - Remove I2O device attributes | 143 | * i2o_device_class_show_class_id - Displays class id of I2O device |
142 | * @cd: I2O class device which is added to the I2O device class | 144 | * @cd: class device of which the class id should be displayed |
145 | * @buf: buffer into which the class id should be printed | ||
143 | * | 146 | * |
144 | * Removes attributes from the I2O device again. Also search each device | 147 | * Returns the number of bytes which are printed into the buffer. |
145 | * on the controller for I2O devices which refert to this device as parent | ||
146 | * or user and remove this links also. | ||
147 | */ | 148 | */ |
148 | static void i2o_device_class_release(struct class_device *cd) | 149 | static ssize_t i2o_device_show_class_id(struct device *dev, |
150 | struct device_attribute *attr, | ||
151 | char *buf) | ||
149 | { | 152 | { |
150 | struct i2o_device *i2o_dev, *tmp; | 153 | struct i2o_device *i2o_dev = to_i2o_device(dev); |
151 | struct i2o_controller *c; | ||
152 | 154 | ||
153 | i2o_dev = to_i2o_device(cd->dev); | 155 | sprintf(buf, "0x%03x\n", i2o_dev->lct_data.class_id); |
154 | c = i2o_dev->iop; | 156 | return strlen(buf) + 1; |
157 | } | ||
155 | 158 | ||
156 | sysfs_remove_link(&i2o_dev->device.kobj, "parent"); | 159 | /** |
157 | sysfs_remove_link(&i2o_dev->device.kobj, "user"); | 160 | * i2o_device_class_show_tid - Displays TID of I2O device |
161 | * @cd: class device of which the TID should be displayed | ||
162 | * @buf: buffer into which the class id should be printed | ||
163 | * | ||
164 | * Returns the number of bytes which are printed into the buffer. | ||
165 | */ | ||
166 | static ssize_t i2o_device_show_tid(struct device *dev, | ||
167 | struct device_attribute *attr, | ||
168 | char *buf) | ||
169 | { | ||
170 | struct i2o_device *i2o_dev = to_i2o_device(dev); | ||
158 | 171 | ||
159 | list_for_each_entry(tmp, &c->devices, list) { | 172 | sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid); |
160 | if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) | 173 | return strlen(buf) + 1; |
161 | sysfs_remove_link(&tmp->device.kobj, "parent"); | 174 | } |
162 | if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) | ||
163 | sysfs_remove_link(&tmp->device.kobj, "user"); | ||
164 | } | ||
165 | }; | ||
166 | 175 | ||
167 | /* I2O device class */ | 176 | struct device_attribute i2o_device_attrs[] = { |
168 | static struct class i2o_device_class = { | 177 | __ATTR(class_id, S_IRUGO, i2o_device_show_class_id, NULL), |
169 | .name = "i2o_device", | 178 | __ATTR(tid, S_IRUGO, i2o_device_show_tid, NULL), |
170 | .release = i2o_device_class_release | 179 | __ATTR_NULL |
171 | }; | 180 | }; |
172 | 181 | ||
173 | /** | 182 | /** |
@@ -193,11 +202,69 @@ static struct i2o_device *i2o_device_alloc(void) | |||
193 | 202 | ||
194 | dev->device.bus = &i2o_bus_type; | 203 | dev->device.bus = &i2o_bus_type; |
195 | dev->device.release = &i2o_device_release; | 204 | dev->device.release = &i2o_device_release; |
196 | dev->classdev.class = &i2o_device_class; | ||
197 | dev->classdev.dev = &dev->device; | ||
198 | 205 | ||
199 | return dev; | 206 | return dev; |
200 | }; | 207 | } |
208 | |||
209 | /** | ||
210 | * i2o_setup_sysfs_links - Adds attributes to the I2O device | ||
211 | * @cd: I2O class device which is added to the I2O device class | ||
212 | * | ||
213 | * This function get called when a I2O device is added to the class. It | ||
214 | * creates the attributes for each device and creates user/parent symlink | ||
215 | * if necessary. | ||
216 | * | ||
217 | * Returns 0 on success or negative error code on failure. | ||
218 | */ | ||
219 | static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev) | ||
220 | { | ||
221 | struct i2o_controller *c = i2o_dev->iop; | ||
222 | struct i2o_device *tmp; | ||
223 | |||
224 | /* create user entries for this device */ | ||
225 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); | ||
226 | if (tmp && tmp != i2o_dev) | ||
227 | sysfs_create_link(&i2o_dev->device.kobj, | ||
228 | &tmp->device.kobj, "user"); | ||
229 | |||
230 | /* create user entries refering to this device */ | ||
231 | list_for_each_entry(tmp, &c->devices, list) | ||
232 | if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid && | ||
233 | tmp != i2o_dev) | ||
234 | sysfs_create_link(&tmp->device.kobj, | ||
235 | &i2o_dev->device.kobj, "user"); | ||
236 | |||
237 | /* create parent entries for this device */ | ||
238 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); | ||
239 | if (tmp && tmp != i2o_dev) | ||
240 | sysfs_create_link(&i2o_dev->device.kobj, | ||
241 | &tmp->device.kobj, "parent"); | ||
242 | |||
243 | /* create parent entries refering to this device */ | ||
244 | list_for_each_entry(tmp, &c->devices, list) | ||
245 | if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid && | ||
246 | tmp != i2o_dev) | ||
247 | sysfs_create_link(&tmp->device.kobj, | ||
248 | &i2o_dev->device.kobj, "parent"); | ||
249 | } | ||
250 | |||
251 | static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev) | ||
252 | { | ||
253 | struct i2o_controller *c = i2o_dev->iop; | ||
254 | struct i2o_device *tmp; | ||
255 | |||
256 | sysfs_remove_link(&i2o_dev->device.kobj, "parent"); | ||
257 | sysfs_remove_link(&i2o_dev->device.kobj, "user"); | ||
258 | |||
259 | list_for_each_entry(tmp, &c->devices, list) { | ||
260 | if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) | ||
261 | sysfs_remove_link(&tmp->device.kobj, "parent"); | ||
262 | if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) | ||
263 | sysfs_remove_link(&tmp->device.kobj, "user"); | ||
264 | } | ||
265 | } | ||
266 | |||
267 | |||
201 | 268 | ||
202 | /** | 269 | /** |
203 | * i2o_device_add - allocate a new I2O device and add it to the IOP | 270 | * i2o_device_add - allocate a new I2O device and add it to the IOP |
@@ -222,28 +289,25 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, | |||
222 | } | 289 | } |
223 | 290 | ||
224 | dev->lct_data = *entry; | 291 | dev->lct_data = *entry; |
292 | dev->iop = c; | ||
225 | 293 | ||
226 | snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, | 294 | snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, |
227 | dev->lct_data.tid); | 295 | dev->lct_data.tid); |
228 | 296 | ||
229 | snprintf(dev->classdev.class_id, BUS_ID_SIZE, "%d:%03x", c->unit, | ||
230 | dev->lct_data.tid); | ||
231 | |||
232 | dev->iop = c; | ||
233 | dev->device.parent = &c->device; | 297 | dev->device.parent = &c->device; |
234 | 298 | ||
235 | device_register(&dev->device); | 299 | device_register(&dev->device); |
236 | 300 | ||
237 | list_add_tail(&dev->list, &c->devices); | 301 | list_add_tail(&dev->list, &c->devices); |
238 | 302 | ||
239 | class_device_register(&dev->classdev); | 303 | i2o_setup_sysfs_links(dev); |
240 | 304 | ||
241 | i2o_driver_notify_device_add_all(dev); | 305 | i2o_driver_notify_device_add_all(dev); |
242 | 306 | ||
243 | pr_debug("i2o: device %s added\n", dev->device.bus_id); | 307 | pr_debug("i2o: device %s added\n", dev->device.bus_id); |
244 | 308 | ||
245 | return dev; | 309 | return dev; |
246 | }; | 310 | } |
247 | 311 | ||
248 | /** | 312 | /** |
249 | * i2o_device_remove - remove an I2O device from the I2O core | 313 | * i2o_device_remove - remove an I2O device from the I2O core |
@@ -256,10 +320,10 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, | |||
256 | void i2o_device_remove(struct i2o_device *i2o_dev) | 320 | void i2o_device_remove(struct i2o_device *i2o_dev) |
257 | { | 321 | { |
258 | i2o_driver_notify_device_remove_all(i2o_dev); | 322 | i2o_driver_notify_device_remove_all(i2o_dev); |
259 | class_device_unregister(&i2o_dev->classdev); | 323 | i2o_remove_sysfs_links(i2o_dev); |
260 | list_del(&i2o_dev->list); | 324 | list_del(&i2o_dev->list); |
261 | device_unregister(&i2o_dev->device); | 325 | device_unregister(&i2o_dev->device); |
262 | }; | 326 | } |
263 | 327 | ||
264 | /** | 328 | /** |
265 | * i2o_device_parse_lct - Parse a previously fetched LCT and create devices | 329 | * i2o_device_parse_lct - Parse a previously fetched LCT and create devices |
@@ -337,99 +401,8 @@ int i2o_device_parse_lct(struct i2o_controller *c) | |||
337 | up(&c->lct_lock); | 401 | up(&c->lct_lock); |
338 | 402 | ||
339 | return 0; | 403 | return 0; |
340 | }; | 404 | } |
341 | |||
342 | /** | ||
343 | * i2o_device_class_show_class_id - Displays class id of I2O device | ||
344 | * @cd: class device of which the class id should be displayed | ||
345 | * @buf: buffer into which the class id should be printed | ||
346 | * | ||
347 | * Returns the number of bytes which are printed into the buffer. | ||
348 | */ | ||
349 | static ssize_t i2o_device_class_show_class_id(struct class_device *cd, | ||
350 | char *buf) | ||
351 | { | ||
352 | struct i2o_device *dev = to_i2o_device(cd->dev); | ||
353 | |||
354 | sprintf(buf, "0x%03x\n", dev->lct_data.class_id); | ||
355 | return strlen(buf) + 1; | ||
356 | }; | ||
357 | |||
358 | /** | ||
359 | * i2o_device_class_show_tid - Displays TID of I2O device | ||
360 | * @cd: class device of which the TID should be displayed | ||
361 | * @buf: buffer into which the class id should be printed | ||
362 | * | ||
363 | * Returns the number of bytes which are printed into the buffer. | ||
364 | */ | ||
365 | static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf) | ||
366 | { | ||
367 | struct i2o_device *dev = to_i2o_device(cd->dev); | ||
368 | |||
369 | sprintf(buf, "0x%03x\n", dev->lct_data.tid); | ||
370 | return strlen(buf) + 1; | ||
371 | }; | ||
372 | |||
373 | /* I2O device class attributes */ | ||
374 | static CLASS_DEVICE_ATTR(class_id, S_IRUGO, i2o_device_class_show_class_id, | ||
375 | NULL); | ||
376 | static CLASS_DEVICE_ATTR(tid, S_IRUGO, i2o_device_class_show_tid, NULL); | ||
377 | |||
378 | /** | ||
379 | * i2o_device_class_add - Adds attributes to the I2O device | ||
380 | * @cd: I2O class device which is added to the I2O device class | ||
381 | * | ||
382 | * This function get called when a I2O device is added to the class. It | ||
383 | * creates the attributes for each device and creates user/parent symlink | ||
384 | * if necessary. | ||
385 | * | ||
386 | * Returns 0 on success or negative error code on failure. | ||
387 | */ | ||
388 | static int i2o_device_class_add(struct class_device *cd) | ||
389 | { | ||
390 | struct i2o_device *i2o_dev, *tmp; | ||
391 | struct i2o_controller *c; | ||
392 | |||
393 | i2o_dev = to_i2o_device(cd->dev); | ||
394 | c = i2o_dev->iop; | ||
395 | |||
396 | class_device_create_file(cd, &class_device_attr_class_id); | ||
397 | class_device_create_file(cd, &class_device_attr_tid); | ||
398 | |||
399 | /* create user entries for this device */ | ||
400 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); | ||
401 | if (tmp && (tmp != i2o_dev)) | ||
402 | sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, | ||
403 | "user"); | ||
404 | |||
405 | /* create user entries refering to this device */ | ||
406 | list_for_each_entry(tmp, &c->devices, list) | ||
407 | if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) | ||
408 | && (tmp != i2o_dev)) | ||
409 | sysfs_create_link(&tmp->device.kobj, | ||
410 | &i2o_dev->device.kobj, "user"); | ||
411 | |||
412 | /* create parent entries for this device */ | ||
413 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); | ||
414 | if (tmp && (tmp != i2o_dev)) | ||
415 | sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, | ||
416 | "parent"); | ||
417 | |||
418 | /* create parent entries refering to this device */ | ||
419 | list_for_each_entry(tmp, &c->devices, list) | ||
420 | if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) | ||
421 | && (tmp != i2o_dev)) | ||
422 | sysfs_create_link(&tmp->device.kobj, | ||
423 | &i2o_dev->device.kobj, "parent"); | ||
424 | |||
425 | return 0; | ||
426 | }; | ||
427 | 405 | ||
428 | /* I2O device class interface */ | ||
429 | static struct class_interface i2o_device_class_interface = { | ||
430 | .class = &i2o_device_class, | ||
431 | .add = i2o_device_class_add | ||
432 | }; | ||
433 | 406 | ||
434 | /* | 407 | /* |
435 | * Run time support routines | 408 | * Run time support routines |
@@ -553,11 +526,11 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, | |||
553 | } | 526 | } |
554 | 527 | ||
555 | /* | 528 | /* |
556 | * if oper == I2O_PARAMS_TABLE_GET, get from all rows | 529 | * if oper == I2O_PARAMS_TABLE_GET, get from all rows |
557 | * if fieldcount == -1 return all fields | 530 | * if fieldcount == -1 return all fields |
558 | * ibuf and ibuflen are unused (use NULL, 0) | 531 | * ibuf and ibuflen are unused (use NULL, 0) |
559 | * else return specific fields | 532 | * else return specific fields |
560 | * ibuf contains fieldindexes | 533 | * ibuf contains fieldindexes |
561 | * | 534 | * |
562 | * if oper == I2O_PARAMS_LIST_GET, get from specific rows | 535 | * if oper == I2O_PARAMS_LIST_GET, get from specific rows |
563 | * if fieldcount == -1 return all fields | 536 | * if fieldcount == -1 return all fields |
@@ -602,35 +575,6 @@ int i2o_parm_table_get(struct i2o_device *dev, int oper, int group, | |||
602 | return size; | 575 | return size; |
603 | } | 576 | } |
604 | 577 | ||
605 | /** | ||
606 | * i2o_device_init - Initialize I2O devices | ||
607 | * | ||
608 | * Registers the I2O device class. | ||
609 | * | ||
610 | * Returns 0 on success or negative error code on failure. | ||
611 | */ | ||
612 | int i2o_device_init(void) | ||
613 | { | ||
614 | int rc; | ||
615 | |||
616 | rc = class_register(&i2o_device_class); | ||
617 | if (rc) | ||
618 | return rc; | ||
619 | |||
620 | return class_interface_register(&i2o_device_class_interface); | ||
621 | }; | ||
622 | |||
623 | /** | ||
624 | * i2o_device_exit - I2O devices exit function | ||
625 | * | ||
626 | * Unregisters the I2O device class. | ||
627 | */ | ||
628 | void i2o_device_exit(void) | ||
629 | { | ||
630 | class_interface_register(&i2o_device_class_interface); | ||
631 | class_unregister(&i2o_device_class); | ||
632 | }; | ||
633 | |||
634 | EXPORT_SYMBOL(i2o_device_claim); | 578 | EXPORT_SYMBOL(i2o_device_claim); |
635 | EXPORT_SYMBOL(i2o_device_claim_release); | 579 | EXPORT_SYMBOL(i2o_device_claim_release); |
636 | EXPORT_SYMBOL(i2o_parm_field_get); | 580 | EXPORT_SYMBOL(i2o_parm_field_get); |
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index 739bfdef0c6d..0079a4be0af2 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c | |||
@@ -58,9 +58,12 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv) | |||
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* I2O bus type */ | 60 | /* I2O bus type */ |
61 | extern struct device_attribute i2o_device_attrs[]; | ||
62 | |||
61 | struct bus_type i2o_bus_type = { | 63 | struct bus_type i2o_bus_type = { |
62 | .name = "i2o", | 64 | .name = "i2o", |
63 | .match = i2o_bus_match, | 65 | .match = i2o_bus_match, |
66 | .dev_attrs = i2o_device_attrs, | ||
64 | }; | 67 | }; |
65 | 68 | ||
66 | /** | 69 | /** |
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index 42f8b810d6e5..361da8d1d5e7 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c | |||
@@ -833,6 +833,7 @@ void i2o_iop_remove(struct i2o_controller *c) | |||
833 | list_for_each_entry_safe(dev, tmp, &c->devices, list) | 833 | list_for_each_entry_safe(dev, tmp, &c->devices, list) |
834 | i2o_device_remove(dev); | 834 | i2o_device_remove(dev); |
835 | 835 | ||
836 | class_device_unregister(c->classdev); | ||
836 | device_del(&c->device); | 837 | device_del(&c->device); |
837 | 838 | ||
838 | /* Ask the IOP to switch to RESET state */ | 839 | /* Ask the IOP to switch to RESET state */ |
@@ -1077,9 +1078,7 @@ static void i2o_iop_release(struct device *dev) | |||
1077 | }; | 1078 | }; |
1078 | 1079 | ||
1079 | /* I2O controller class */ | 1080 | /* I2O controller class */ |
1080 | static struct class i2o_controller_class = { | 1081 | static struct class *i2o_controller_class; |
1081 | .name = "i2o_controller", | ||
1082 | }; | ||
1083 | 1082 | ||
1084 | /** | 1083 | /** |
1085 | * i2o_iop_alloc - Allocate and initialize a i2o_controller struct | 1084 | * i2o_iop_alloc - Allocate and initialize a i2o_controller struct |
@@ -1110,14 +1109,10 @@ struct i2o_controller *i2o_iop_alloc(void) | |||
1110 | sprintf(c->name, "iop%d", c->unit); | 1109 | sprintf(c->name, "iop%d", c->unit); |
1111 | 1110 | ||
1112 | device_initialize(&c->device); | 1111 | device_initialize(&c->device); |
1113 | class_device_initialize(&c->classdev); | ||
1114 | 1112 | ||
1115 | c->device.release = &i2o_iop_release; | 1113 | c->device.release = &i2o_iop_release; |
1116 | c->classdev.class = &i2o_controller_class; | ||
1117 | c->classdev.dev = &c->device; | ||
1118 | 1114 | ||
1119 | snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit); | 1115 | snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit); |
1120 | snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit); | ||
1121 | 1116 | ||
1122 | #if BITS_PER_LONG == 64 | 1117 | #if BITS_PER_LONG == 64 |
1123 | spin_lock_init(&c->context_list_lock); | 1118 | spin_lock_init(&c->context_list_lock); |
@@ -1146,7 +1141,9 @@ int i2o_iop_add(struct i2o_controller *c) | |||
1146 | goto iop_reset; | 1141 | goto iop_reset; |
1147 | } | 1142 | } |
1148 | 1143 | ||
1149 | if ((rc = class_device_add(&c->classdev))) { | 1144 | c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0), |
1145 | &c->device, "iop%d", c->unit); | ||
1146 | if (IS_ERR(c->classdev)) { | ||
1150 | osm_err("%s: could not add controller class\n", c->name); | 1147 | osm_err("%s: could not add controller class\n", c->name); |
1151 | goto device_del; | 1148 | goto device_del; |
1152 | } | 1149 | } |
@@ -1184,7 +1181,7 @@ int i2o_iop_add(struct i2o_controller *c) | |||
1184 | return 0; | 1181 | return 0; |
1185 | 1182 | ||
1186 | class_del: | 1183 | class_del: |
1187 | class_device_del(&c->classdev); | 1184 | class_device_unregister(c->classdev); |
1188 | 1185 | ||
1189 | device_del: | 1186 | device_del: |
1190 | device_del(&c->device); | 1187 | device_del(&c->device); |
@@ -1246,13 +1243,10 @@ static int __init i2o_iop_init(void) | |||
1246 | 1243 | ||
1247 | printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); | 1244 | printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); |
1248 | 1245 | ||
1249 | rc = i2o_device_init(); | 1246 | i2o_controller_class = class_create(THIS_MODULE, "i2o_controller"); |
1250 | if (rc) | 1247 | if (IS_ERR(i2o_controller_class)) { |
1251 | goto exit; | ||
1252 | |||
1253 | if ((rc = class_register(&i2o_controller_class))) { | ||
1254 | osm_err("can't register class i2o_controller\n"); | 1248 | osm_err("can't register class i2o_controller\n"); |
1255 | goto device_exit; | 1249 | goto exit; |
1256 | } | 1250 | } |
1257 | 1251 | ||
1258 | if ((rc = i2o_driver_init())) | 1252 | if ((rc = i2o_driver_init())) |
@@ -1273,10 +1267,7 @@ static int __init i2o_iop_init(void) | |||
1273 | i2o_driver_exit(); | 1267 | i2o_driver_exit(); |
1274 | 1268 | ||
1275 | class_exit: | 1269 | class_exit: |
1276 | class_unregister(&i2o_controller_class); | 1270 | class_destroy(i2o_controller_class); |
1277 | |||
1278 | device_exit: | ||
1279 | i2o_device_exit(); | ||
1280 | 1271 | ||
1281 | exit: | 1272 | exit: |
1282 | return rc; | 1273 | return rc; |
@@ -1292,8 +1283,7 @@ static void __exit i2o_iop_exit(void) | |||
1292 | i2o_pci_exit(); | 1283 | i2o_pci_exit(); |
1293 | i2o_exec_exit(); | 1284 | i2o_exec_exit(); |
1294 | i2o_driver_exit(); | 1285 | i2o_driver_exit(); |
1295 | class_unregister(&i2o_controller_class); | 1286 | class_destroy(i2o_controller_class); |
1296 | i2o_device_exit(); | ||
1297 | }; | 1287 | }; |
1298 | 1288 | ||
1299 | module_init(i2o_iop_init); | 1289 | module_init(i2o_iop_init); |
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index e9806fbbe696..720e7a326308 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c | |||
@@ -219,26 +219,24 @@ static int mcp_sa11x0_remove(struct device *dev) | |||
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | 221 | ||
222 | static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state, u32 level) | 222 | static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state) |
223 | { | 223 | { |
224 | struct mcp *mcp = dev_get_drvdata(dev); | 224 | struct mcp *mcp = dev_get_drvdata(dev); |
225 | 225 | ||
226 | if (level == SUSPEND_DISABLE) { | 226 | priv(mcp)->mccr0 = Ser4MCCR0; |
227 | priv(mcp)->mccr0 = Ser4MCCR0; | 227 | priv(mcp)->mccr1 = Ser4MCCR1; |
228 | priv(mcp)->mccr1 = Ser4MCCR1; | 228 | Ser4MCCR0 &= ~MCCR0_MCE; |
229 | Ser4MCCR0 &= ~MCCR0_MCE; | 229 | |
230 | } | ||
231 | return 0; | 230 | return 0; |
232 | } | 231 | } |
233 | 232 | ||
234 | static int mcp_sa11x0_resume(struct device *dev, u32 level) | 233 | static int mcp_sa11x0_resume(struct device *dev) |
235 | { | 234 | { |
236 | struct mcp *mcp = dev_get_drvdata(dev); | 235 | struct mcp *mcp = dev_get_drvdata(dev); |
237 | 236 | ||
238 | if (level == RESUME_RESTORE_STATE) { | 237 | Ser4MCCR1 = priv(mcp)->mccr1; |
239 | Ser4MCCR1 = priv(mcp)->mccr1; | 238 | Ser4MCCR0 = priv(mcp)->mccr0; |
240 | Ser4MCCR0 = priv(mcp)->mccr0; | 239 | |
241 | } | ||
242 | return 0; | 240 | return 0; |
243 | } | 241 | } |
244 | 242 | ||
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c index a260f83bcb02..585cded3d365 100644 --- a/drivers/mfd/ucb1x00-ts.c +++ b/drivers/mfd/ucb1x00-ts.c | |||
@@ -40,7 +40,7 @@ | |||
40 | 40 | ||
41 | 41 | ||
42 | struct ucb1x00_ts { | 42 | struct ucb1x00_ts { |
43 | struct input_dev idev; | 43 | struct input_dev *idev; |
44 | struct ucb1x00 *ucb; | 44 | struct ucb1x00 *ucb; |
45 | 45 | ||
46 | wait_queue_head_t irq_wait; | 46 | wait_queue_head_t irq_wait; |
@@ -56,16 +56,16 @@ static int adcsync; | |||
56 | 56 | ||
57 | static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y) | 57 | static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y) |
58 | { | 58 | { |
59 | input_report_abs(&ts->idev, ABS_X, x); | 59 | input_report_abs(ts->idev, ABS_X, x); |
60 | input_report_abs(&ts->idev, ABS_Y, y); | 60 | input_report_abs(ts->idev, ABS_Y, y); |
61 | input_report_abs(&ts->idev, ABS_PRESSURE, pressure); | 61 | input_report_abs(ts->idev, ABS_PRESSURE, pressure); |
62 | input_sync(&ts->idev); | 62 | input_sync(ts->idev); |
63 | } | 63 | } |
64 | 64 | ||
65 | static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts) | 65 | static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts) |
66 | { | 66 | { |
67 | input_report_abs(&ts->idev, ABS_PRESSURE, 0); | 67 | input_report_abs(ts->idev, ABS_PRESSURE, 0); |
68 | input_sync(&ts->idev); | 68 | input_sync(ts->idev); |
69 | } | 69 | } |
70 | 70 | ||
71 | /* | 71 | /* |
@@ -341,26 +341,30 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev) | |||
341 | { | 341 | { |
342 | struct ucb1x00_ts *ts; | 342 | struct ucb1x00_ts *ts; |
343 | 343 | ||
344 | ts = kmalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL); | 344 | ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL); |
345 | if (!ts) | 345 | if (!ts) |
346 | return -ENOMEM; | 346 | return -ENOMEM; |
347 | 347 | ||
348 | memset(ts, 0, sizeof(struct ucb1x00_ts)); | 348 | ts->idev = input_allocate_device(); |
349 | if (!ts->idev) { | ||
350 | kfree(ts); | ||
351 | return -ENOMEM; | ||
352 | } | ||
349 | 353 | ||
350 | ts->ucb = dev->ucb; | 354 | ts->ucb = dev->ucb; |
351 | ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; | 355 | ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; |
352 | 356 | ||
353 | ts->idev.name = "Touchscreen panel"; | 357 | ts->idev->name = "Touchscreen panel"; |
354 | ts->idev.id.product = ts->ucb->id; | 358 | ts->idev->id.product = ts->ucb->id; |
355 | ts->idev.open = ucb1x00_ts_open; | 359 | ts->idev->open = ucb1x00_ts_open; |
356 | ts->idev.close = ucb1x00_ts_close; | 360 | ts->idev->close = ucb1x00_ts_close; |
357 | 361 | ||
358 | __set_bit(EV_ABS, ts->idev.evbit); | 362 | __set_bit(EV_ABS, ts->idev->evbit); |
359 | __set_bit(ABS_X, ts->idev.absbit); | 363 | __set_bit(ABS_X, ts->idev->absbit); |
360 | __set_bit(ABS_Y, ts->idev.absbit); | 364 | __set_bit(ABS_Y, ts->idev->absbit); |
361 | __set_bit(ABS_PRESSURE, ts->idev.absbit); | 365 | __set_bit(ABS_PRESSURE, ts->idev->absbit); |
362 | 366 | ||
363 | input_register_device(&ts->idev); | 367 | input_register_device(ts->idev); |
364 | 368 | ||
365 | dev->priv = ts; | 369 | dev->priv = ts; |
366 | 370 | ||
@@ -370,7 +374,8 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev) | |||
370 | static void ucb1x00_ts_remove(struct ucb1x00_dev *dev) | 374 | static void ucb1x00_ts_remove(struct ucb1x00_dev *dev) |
371 | { | 375 | { |
372 | struct ucb1x00_ts *ts = dev->priv; | 376 | struct ucb1x00_ts *ts = dev->priv; |
373 | input_unregister_device(&ts->idev); | 377 | |
378 | input_unregister_device(ts->idev); | ||
374 | kfree(ts); | 379 | kfree(ts); |
375 | } | 380 | } |
376 | 381 | ||
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 91c74843dc0d..1e6bdba26756 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <asm/irq.h> | 25 | #include <asm/irq.h> |
26 | #include <asm/scatterlist.h> | 26 | #include <asm/scatterlist.h> |
27 | #include <asm/sizes.h> | ||
27 | #include <asm/hardware/amba.h> | 28 | #include <asm/hardware/amba.h> |
28 | #include <asm/hardware/clock.h> | 29 | #include <asm/hardware/clock.h> |
29 | #include <asm/mach/mmc.h> | 30 | #include <asm/mach/mmc.h> |
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index b53af57074e3..8eba373d42d7 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c | |||
@@ -571,23 +571,23 @@ static int pxamci_remove(struct device *dev) | |||
571 | } | 571 | } |
572 | 572 | ||
573 | #ifdef CONFIG_PM | 573 | #ifdef CONFIG_PM |
574 | static int pxamci_suspend(struct device *dev, pm_message_t state, u32 level) | 574 | static int pxamci_suspend(struct device *dev, pm_message_t state) |
575 | { | 575 | { |
576 | struct mmc_host *mmc = dev_get_drvdata(dev); | 576 | struct mmc_host *mmc = dev_get_drvdata(dev); |
577 | int ret = 0; | 577 | int ret = 0; |
578 | 578 | ||
579 | if (mmc && level == SUSPEND_DISABLE) | 579 | if (mmc) |
580 | ret = mmc_suspend_host(mmc, state); | 580 | ret = mmc_suspend_host(mmc, state); |
581 | 581 | ||
582 | return ret; | 582 | return ret; |
583 | } | 583 | } |
584 | 584 | ||
585 | static int pxamci_resume(struct device *dev, u32 level) | 585 | static int pxamci_resume(struct device *dev) |
586 | { | 586 | { |
587 | struct mmc_host *mmc = dev_get_drvdata(dev); | 587 | struct mmc_host *mmc = dev_get_drvdata(dev); |
588 | int ret = 0; | 588 | int ret = 0; |
589 | 589 | ||
590 | if (mmc && level == RESUME_ENABLE) | 590 | if (mmc) |
591 | ret = mmc_resume_host(mmc); | 591 | ret = mmc_resume_host(mmc); |
592 | 592 | ||
593 | return ret; | 593 | return ret; |
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 3cbca7cbea80..25f7ce7b3bc0 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c | |||
@@ -1955,14 +1955,14 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev) | |||
1955 | */ | 1955 | */ |
1956 | 1956 | ||
1957 | #ifdef CONFIG_PM | 1957 | #ifdef CONFIG_PM |
1958 | static int wbsd_suspend(struct device *dev, pm_message_t state, u32 level) | 1958 | static int wbsd_suspend(struct device *dev, pm_message_t state) |
1959 | { | 1959 | { |
1960 | DBGF("Not yet supported\n"); | 1960 | DBGF("Not yet supported\n"); |
1961 | 1961 | ||
1962 | return 0; | 1962 | return 0; |
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | static int wbsd_resume(struct device *dev, u32 level) | 1965 | static int wbsd_resume(struct device *dev) |
1966 | { | 1966 | { |
1967 | DBGF("Not yet supported\n"); | 1967 | DBGF("Not yet supported\n"); |
1968 | 1968 | ||
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index 8dcaa357b4bb..6a8e0caf9fdc 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/mtd/concat.h> | 22 | #include <linux/mtd/concat.h> |
23 | 23 | ||
24 | #include <asm/hardware.h> | ||
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
25 | #include <asm/sizes.h> | 26 | #include <asm/sizes.h> |
26 | #include <asm/mach/flash.h> | 27 | #include <asm/mach/flash.h> |
@@ -402,21 +403,21 @@ static int __exit sa1100_mtd_remove(struct device *dev) | |||
402 | } | 403 | } |
403 | 404 | ||
404 | #ifdef CONFIG_PM | 405 | #ifdef CONFIG_PM |
405 | static int sa1100_mtd_suspend(struct device *dev, pm_message_t state, u32 level) | 406 | static int sa1100_mtd_suspend(struct device *dev, pm_message_t state) |
406 | { | 407 | { |
407 | struct sa_info *info = dev_get_drvdata(dev); | 408 | struct sa_info *info = dev_get_drvdata(dev); |
408 | int ret = 0; | 409 | int ret = 0; |
409 | 410 | ||
410 | if (info && level == SUSPEND_SAVE_STATE) | 411 | if (info) |
411 | ret = info->mtd->suspend(info->mtd); | 412 | ret = info->mtd->suspend(info->mtd); |
412 | 413 | ||
413 | return ret; | 414 | return ret; |
414 | } | 415 | } |
415 | 416 | ||
416 | static int sa1100_mtd_resume(struct device *dev, u32 level) | 417 | static int sa1100_mtd_resume(struct device *dev) |
417 | { | 418 | { |
418 | struct sa_info *info = dev_get_drvdata(dev); | 419 | struct sa_info *info = dev_get_drvdata(dev); |
419 | if (info && level == RESUME_RESTORE_STATE) | 420 | if (info) |
420 | info->mtd->resume(info->mtd); | 421 | info->mtd->resume(info->mtd); |
421 | return 0; | 422 | return 0; |
422 | } | 423 | } |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 1ed602a0f24c..c534fd5d95cb 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -24,10 +24,10 @@ static void mtd_notify_add(struct mtd_info* mtd) | |||
24 | if (!mtd) | 24 | if (!mtd) |
25 | return; | 25 | return; |
26 | 26 | ||
27 | class_device_create(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), | 27 | class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), |
28 | NULL, "mtd%d", mtd->index); | 28 | NULL, "mtd%d", mtd->index); |
29 | 29 | ||
30 | class_device_create(mtd_class, | 30 | class_device_create(mtd_class, NULL, |
31 | MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), | 31 | MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), |
32 | NULL, "mtd%dro", mtd->index); | 32 | NULL, "mtd%dro", mtd->index); |
33 | } | 33 | } |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 5148d47492a0..fee8c5cf1f3a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -1338,7 +1338,7 @@ config FORCEDETH | |||
1338 | 1338 | ||
1339 | config CS89x0 | 1339 | config CS89x0 |
1340 | tristate "CS89x0 support" | 1340 | tristate "CS89x0 support" |
1341 | depends on (NET_PCI && (ISA || ARCH_IXDP2X01)) || ARCH_PNX0105 | 1341 | depends on (NET_PCI && (ISA || ARCH_IXDP2X01)) || ARCH_PNX0105 || MACH_MP1000 |
1342 | ---help--- | 1342 | ---help--- |
1343 | Support for CS89x0 chipset based Ethernet cards. If you have a | 1343 | Support for CS89x0 chipset based Ethernet cards. If you have a |
1344 | network (Ethernet) card of this type, say Y and read the | 1344 | network (Ethernet) card of this type, say Y and read the |
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index c56d86d371a9..3d50e953faaa 100644 --- a/drivers/net/arm/am79c961a.c +++ b/drivers/net/arm/am79c961a.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include <asm/system.h> | 30 | #include <asm/system.h> |
31 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
32 | #include <asm/hardware.h> | ||
32 | #include <asm/io.h> | 33 | #include <asm/io.h> |
33 | 34 | ||
34 | #define TX_BUFFERS 15 | 35 | #define TX_BUFFERS 15 |
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index a6078ad9b654..bfdae10036ed 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c | |||
@@ -182,6 +182,10 @@ static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0}; | |||
182 | #define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */ | 182 | #define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */ |
183 | static unsigned int netcard_portlist[] __initdata = {CIRRUS_DEFAULT_BASE, 0}; | 183 | static unsigned int netcard_portlist[] __initdata = {CIRRUS_DEFAULT_BASE, 0}; |
184 | static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0}; | 184 | static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0}; |
185 | #elif defined(CONFIG_MACH_MP1000) | ||
186 | #include <asm/arch/mp1000-seprom.h> | ||
187 | static unsigned int netcard_portlist[] __initdata = {MP1000_EIO_BASE+0x300, 0}; | ||
188 | static unsigned int cs8900_irq_map[] = {IRQ_EINT3,0,0,0}; | ||
185 | #else | 189 | #else |
186 | static unsigned int netcard_portlist[] __initdata = | 190 | static unsigned int netcard_portlist[] __initdata = |
187 | { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; | 191 | { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; |
@@ -590,6 +594,10 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) | |||
590 | cnt -= j; | 594 | cnt -= j; |
591 | } | 595 | } |
592 | } else | 596 | } else |
597 | #elif defined(CONFIG_MACH_MP1000) | ||
598 | if (1) { | ||
599 | memcpy(dev->dev_addr, get_eeprom_mac_address(), ETH_ALEN); | ||
600 | } else | ||
593 | #endif | 601 | #endif |
594 | 602 | ||
595 | if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) == | 603 | if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) == |
@@ -649,6 +657,10 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) | |||
649 | if (1) { | 657 | if (1) { |
650 | printk(KERN_NOTICE "cs89x0: No EEPROM on HiCO.SH4\n"); | 658 | printk(KERN_NOTICE "cs89x0: No EEPROM on HiCO.SH4\n"); |
651 | } else | 659 | } else |
660 | #elif defined(CONFIG_MACH_MP1000) | ||
661 | if (1) { | ||
662 | lp->force |= FORCE_RJ45; | ||
663 | } else | ||
652 | #endif | 664 | #endif |
653 | if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0) | 665 | if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0) |
654 | printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n"); | 666 | printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n"); |
@@ -1231,7 +1243,7 @@ net_open(struct net_device *dev) | |||
1231 | else | 1243 | else |
1232 | #endif | 1244 | #endif |
1233 | { | 1245 | { |
1234 | #if !defined(CONFIG_ARCH_IXDP2X01) && !defined(CONFIG_ARCH_PNX0105) | 1246 | #if !defined(CONFIG_ARCH_IXDP2X01) && !defined(CONFIG_ARCH_PNX0105) && !defined(CONFIG_MACH_MP1000) |
1235 | if (((1 << dev->irq) & lp->irq_map) == 0) { | 1247 | if (((1 << dev->irq) & lp->irq_map) == 0) { |
1236 | printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", | 1248 | printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", |
1237 | dev->name, dev->irq, lp->irq_map); | 1249 | dev->name, dev->irq, lp->irq_map); |
diff --git a/drivers/net/cs89x0.h b/drivers/net/cs89x0.h index decea264f121..f19d1ebe0183 100644 --- a/drivers/net/cs89x0.h +++ b/drivers/net/cs89x0.h | |||
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/config.h> | 17 | #include <linux/config.h> |
18 | 18 | ||
19 | #if defined(CONFIG_ARCH_IXDP2X01) || defined(CONFIG_ARCH_PNX0105) | 19 | #if defined(CONFIG_ARCH_IXDP2X01) || defined(CONFIG_ARCH_PNX0105) || defined (CONFIG_MACH_MP1000) |
20 | /* IXDP2401/IXDP2801 uses dword-aligned register addressing */ | 20 | /* IXDP2401/IXDP2801 uses dword-aligned register addressing */ |
21 | #define CS89x0_PORT(reg) ((reg) * 2) | 21 | #define CS89x0_PORT(reg) ((reg) * 2) |
22 | #else | 22 | #else |
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index e54fc10f6846..abce1f730d00 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c | |||
@@ -1140,11 +1140,11 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) | |||
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | static int | 1142 | static int |
1143 | dm9000_drv_suspend(struct device *dev, pm_message_t state, u32 level) | 1143 | dm9000_drv_suspend(struct device *dev, pm_message_t state) |
1144 | { | 1144 | { |
1145 | struct net_device *ndev = dev_get_drvdata(dev); | 1145 | struct net_device *ndev = dev_get_drvdata(dev); |
1146 | 1146 | ||
1147 | if (ndev && level == SUSPEND_DISABLE) { | 1147 | if (ndev) { |
1148 | if (netif_running(ndev)) { | 1148 | if (netif_running(ndev)) { |
1149 | netif_device_detach(ndev); | 1149 | netif_device_detach(ndev); |
1150 | dm9000_shutdown(ndev); | 1150 | dm9000_shutdown(ndev); |
@@ -1154,12 +1154,12 @@ dm9000_drv_suspend(struct device *dev, pm_message_t state, u32 level) | |||
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | static int | 1156 | static int |
1157 | dm9000_drv_resume(struct device *dev, u32 level) | 1157 | dm9000_drv_resume(struct device *dev) |
1158 | { | 1158 | { |
1159 | struct net_device *ndev = dev_get_drvdata(dev); | 1159 | struct net_device *ndev = dev_get_drvdata(dev); |
1160 | board_info_t *db = (board_info_t *) ndev->priv; | 1160 | board_info_t *db = (board_info_t *) ndev->priv; |
1161 | 1161 | ||
1162 | if (ndev && level == RESUME_ENABLE) { | 1162 | if (ndev) { |
1163 | 1163 | ||
1164 | if (netif_running(ndev)) { | 1164 | if (netif_running(ndev)) { |
1165 | dm9000_reset(db); | 1165 | dm9000_reset(db); |
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig index ca5914091d3a..d54156f11e61 100644 --- a/drivers/net/irda/Kconfig +++ b/drivers/net/irda/Kconfig | |||
@@ -400,5 +400,15 @@ config VIA_FIR | |||
400 | To compile it as a module, choose M here: the module will be called | 400 | To compile it as a module, choose M here: the module will be called |
401 | via-ircc. | 401 | via-ircc. |
402 | 402 | ||
403 | config PXA_FICP | ||
404 | tristate "Intel PXA2xx Internal FICP" | ||
405 | depends on ARCH_PXA && IRDA | ||
406 | help | ||
407 | Say Y or M here if you want to build support for the PXA2xx | ||
408 | built-in IRDA interface which can support both SIR and FIR. | ||
409 | This driver relies on platform specific helper routines so | ||
410 | available capabilities may vary from one PXA2xx target to | ||
411 | another. | ||
412 | |||
403 | endmenu | 413 | endmenu |
404 | 414 | ||
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile index 29a8bd812b21..e7a8b7f7f5dd 100644 --- a/drivers/net/irda/Makefile +++ b/drivers/net/irda/Makefile | |||
@@ -18,6 +18,7 @@ obj-$(CONFIG_SMC_IRCC_FIR) += smsc-ircc2.o | |||
18 | obj-$(CONFIG_ALI_FIR) += ali-ircc.o | 18 | obj-$(CONFIG_ALI_FIR) += ali-ircc.o |
19 | obj-$(CONFIG_VLSI_FIR) += vlsi_ir.o | 19 | obj-$(CONFIG_VLSI_FIR) += vlsi_ir.o |
20 | obj-$(CONFIG_VIA_FIR) += via-ircc.o | 20 | obj-$(CONFIG_VIA_FIR) += via-ircc.o |
21 | obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o | ||
21 | # Old dongle drivers for old SIR drivers | 22 | # Old dongle drivers for old SIR drivers |
22 | obj-$(CONFIG_ESI_DONGLE_OLD) += esi.o | 23 | obj-$(CONFIG_ESI_DONGLE_OLD) += esi.o |
23 | obj-$(CONFIG_TEKRAM_DONGLE_OLD) += tekram.o | 24 | obj-$(CONFIG_TEKRAM_DONGLE_OLD) += tekram.o |
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c new file mode 100644 index 000000000000..aef80f5e7c9c --- /dev/null +++ b/drivers/net/irda/pxaficp_ir.c | |||
@@ -0,0 +1,871 @@ | |||
1 | /* | ||
2 | * linux/drivers/net/irda/pxaficp_ir.c | ||
3 | * | ||
4 | * Based on sa1100_ir.c by Russell King | ||
5 | * | ||
6 | * Changes copyright (C) 2003-2005 MontaVista Software, Inc. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * Infra-red driver (SIR/FIR) for the PXA2xx embedded microprocessor | ||
13 | * | ||
14 | */ | ||
15 | #include <linux/config.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/types.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/netdevice.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/rtnetlink.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/dma-mapping.h> | ||
25 | #include <linux/pm.h> | ||
26 | |||
27 | #include <net/irda/irda.h> | ||
28 | #include <net/irda/irmod.h> | ||
29 | #include <net/irda/wrapper.h> | ||
30 | #include <net/irda/irda_device.h> | ||
31 | |||
32 | #include <asm/irq.h> | ||
33 | #include <asm/dma.h> | ||
34 | #include <asm/delay.h> | ||
35 | #include <asm/hardware.h> | ||
36 | #include <asm/arch/irda.h> | ||
37 | #include <asm/arch/pxa-regs.h> | ||
38 | |||
39 | #ifdef CONFIG_MACH_MAINSTONE | ||
40 | #include <asm/arch/mainstone.h> | ||
41 | #endif | ||
42 | |||
43 | #define IrSR_RXPL_NEG_IS_ZERO (1<<4) | ||
44 | #define IrSR_RXPL_POS_IS_ZERO 0x0 | ||
45 | #define IrSR_TXPL_NEG_IS_ZERO (1<<3) | ||
46 | #define IrSR_TXPL_POS_IS_ZERO 0x0 | ||
47 | #define IrSR_XMODE_PULSE_1_6 (1<<2) | ||
48 | #define IrSR_XMODE_PULSE_3_16 0x0 | ||
49 | #define IrSR_RCVEIR_IR_MODE (1<<1) | ||
50 | #define IrSR_RCVEIR_UART_MODE 0x0 | ||
51 | #define IrSR_XMITIR_IR_MODE (1<<0) | ||
52 | #define IrSR_XMITIR_UART_MODE 0x0 | ||
53 | |||
54 | #define IrSR_IR_RECEIVE_ON (\ | ||
55 | IrSR_RXPL_NEG_IS_ZERO | \ | ||
56 | IrSR_TXPL_POS_IS_ZERO | \ | ||
57 | IrSR_XMODE_PULSE_3_16 | \ | ||
58 | IrSR_RCVEIR_IR_MODE | \ | ||
59 | IrSR_XMITIR_UART_MODE) | ||
60 | |||
61 | #define IrSR_IR_TRANSMIT_ON (\ | ||
62 | IrSR_RXPL_NEG_IS_ZERO | \ | ||
63 | IrSR_TXPL_POS_IS_ZERO | \ | ||
64 | IrSR_XMODE_PULSE_3_16 | \ | ||
65 | IrSR_RCVEIR_UART_MODE | \ | ||
66 | IrSR_XMITIR_IR_MODE) | ||
67 | |||
68 | struct pxa_irda { | ||
69 | int speed; | ||
70 | int newspeed; | ||
71 | unsigned long last_oscr; | ||
72 | |||
73 | unsigned char *dma_rx_buff; | ||
74 | unsigned char *dma_tx_buff; | ||
75 | dma_addr_t dma_rx_buff_phy; | ||
76 | dma_addr_t dma_tx_buff_phy; | ||
77 | unsigned int dma_tx_buff_len; | ||
78 | int txdma; | ||
79 | int rxdma; | ||
80 | |||
81 | struct net_device_stats stats; | ||
82 | struct irlap_cb *irlap; | ||
83 | struct qos_info qos; | ||
84 | |||
85 | iobuff_t tx_buff; | ||
86 | iobuff_t rx_buff; | ||
87 | |||
88 | struct device *dev; | ||
89 | struct pxaficp_platform_data *pdata; | ||
90 | }; | ||
91 | |||
92 | |||
93 | #define IS_FIR(si) ((si)->speed >= 4000000) | ||
94 | #define IRDA_FRAME_SIZE_LIMIT 2047 | ||
95 | |||
96 | inline static void pxa_irda_fir_dma_rx_start(struct pxa_irda *si) | ||
97 | { | ||
98 | DCSR(si->rxdma) = DCSR_NODESC; | ||
99 | DSADR(si->rxdma) = __PREG(ICDR); | ||
100 | DTADR(si->rxdma) = si->dma_rx_buff_phy; | ||
101 | DCMD(si->rxdma) = DCMD_INCTRGADDR | DCMD_FLOWSRC | DCMD_WIDTH1 | DCMD_BURST32 | IRDA_FRAME_SIZE_LIMIT; | ||
102 | DCSR(si->rxdma) |= DCSR_RUN; | ||
103 | } | ||
104 | |||
105 | inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda *si) | ||
106 | { | ||
107 | DCSR(si->txdma) = DCSR_NODESC; | ||
108 | DSADR(si->txdma) = si->dma_tx_buff_phy; | ||
109 | DTADR(si->txdma) = __PREG(ICDR); | ||
110 | DCMD(si->txdma) = DCMD_INCSRCADDR | DCMD_FLOWTRG | DCMD_ENDIRQEN | DCMD_WIDTH1 | DCMD_BURST32 | si->dma_tx_buff_len; | ||
111 | DCSR(si->txdma) |= DCSR_RUN; | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * Set the IrDA communications speed. | ||
116 | */ | ||
117 | static int pxa_irda_set_speed(struct pxa_irda *si, int speed) | ||
118 | { | ||
119 | unsigned long flags; | ||
120 | unsigned int divisor; | ||
121 | |||
122 | switch (speed) { | ||
123 | case 9600: case 19200: case 38400: | ||
124 | case 57600: case 115200: | ||
125 | |||
126 | /* refer to PXA250/210 Developer's Manual 10-7 */ | ||
127 | /* BaudRate = 14.7456 MHz / (16*Divisor) */ | ||
128 | divisor = 14745600 / (16 * speed); | ||
129 | |||
130 | local_irq_save(flags); | ||
131 | |||
132 | if (IS_FIR(si)) { | ||
133 | /* stop RX DMA */ | ||
134 | DCSR(si->rxdma) &= ~DCSR_RUN; | ||
135 | /* disable FICP */ | ||
136 | ICCR0 = 0; | ||
137 | pxa_set_cken(CKEN13_FICP, 0); | ||
138 | |||
139 | /* set board transceiver to SIR mode */ | ||
140 | si->pdata->transceiver_mode(si->dev, IR_SIRMODE); | ||
141 | |||
142 | /* configure GPIO46/47 */ | ||
143 | pxa_gpio_mode(GPIO46_STRXD_MD); | ||
144 | pxa_gpio_mode(GPIO47_STTXD_MD); | ||
145 | |||
146 | /* enable the STUART clock */ | ||
147 | pxa_set_cken(CKEN5_STUART, 1); | ||
148 | } | ||
149 | |||
150 | /* disable STUART first */ | ||
151 | STIER = 0; | ||
152 | |||
153 | /* access DLL & DLH */ | ||
154 | STLCR |= LCR_DLAB; | ||
155 | STDLL = divisor & 0xff; | ||
156 | STDLH = divisor >> 8; | ||
157 | STLCR &= ~LCR_DLAB; | ||
158 | |||
159 | si->speed = speed; | ||
160 | STISR = IrSR_IR_RECEIVE_ON | IrSR_XMODE_PULSE_1_6; | ||
161 | STIER = IER_UUE | IER_RLSE | IER_RAVIE | IER_RTIOE; | ||
162 | |||
163 | local_irq_restore(flags); | ||
164 | break; | ||
165 | |||
166 | case 4000000: | ||
167 | local_irq_save(flags); | ||
168 | |||
169 | /* disable STUART */ | ||
170 | STIER = 0; | ||
171 | STISR = 0; | ||
172 | pxa_set_cken(CKEN5_STUART, 0); | ||
173 | |||
174 | /* disable FICP first */ | ||
175 | ICCR0 = 0; | ||
176 | |||
177 | /* set board transceiver to FIR mode */ | ||
178 | si->pdata->transceiver_mode(si->dev, IR_FIRMODE); | ||
179 | |||
180 | /* configure GPIO46/47 */ | ||
181 | pxa_gpio_mode(GPIO46_ICPRXD_MD); | ||
182 | pxa_gpio_mode(GPIO47_ICPTXD_MD); | ||
183 | |||
184 | /* enable the FICP clock */ | ||
185 | pxa_set_cken(CKEN13_FICP, 1); | ||
186 | |||
187 | si->speed = speed; | ||
188 | pxa_irda_fir_dma_rx_start(si); | ||
189 | ICCR0 = ICCR0_ITR | ICCR0_RXE; | ||
190 | |||
191 | local_irq_restore(flags); | ||
192 | break; | ||
193 | |||
194 | default: | ||
195 | return -EINVAL; | ||
196 | } | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | /* SIR interrupt service routine. */ | ||
202 | static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id, struct pt_regs *regs) | ||
203 | { | ||
204 | struct net_device *dev = dev_id; | ||
205 | struct pxa_irda *si = netdev_priv(dev); | ||
206 | int iir, lsr, data; | ||
207 | |||
208 | iir = STIIR; | ||
209 | |||
210 | switch (iir & 0x0F) { | ||
211 | case 0x06: /* Receiver Line Status */ | ||
212 | lsr = STLSR; | ||
213 | while (lsr & LSR_FIFOE) { | ||
214 | data = STRBR; | ||
215 | if (lsr & (LSR_OE | LSR_PE | LSR_FE | LSR_BI)) { | ||
216 | printk(KERN_DEBUG "pxa_ir: sir receiving error\n"); | ||
217 | si->stats.rx_errors++; | ||
218 | if (lsr & LSR_FE) | ||
219 | si->stats.rx_frame_errors++; | ||
220 | if (lsr & LSR_OE) | ||
221 | si->stats.rx_fifo_errors++; | ||
222 | } else { | ||
223 | si->stats.rx_bytes++; | ||
224 | async_unwrap_char(dev, &si->stats, &si->rx_buff, data); | ||
225 | } | ||
226 | lsr = STLSR; | ||
227 | } | ||
228 | dev->last_rx = jiffies; | ||
229 | si->last_oscr = OSCR; | ||
230 | break; | ||
231 | |||
232 | case 0x04: /* Received Data Available */ | ||
233 | /* forth through */ | ||
234 | |||
235 | case 0x0C: /* Character Timeout Indication */ | ||
236 | do { | ||
237 | si->stats.rx_bytes++; | ||
238 | async_unwrap_char(dev, &si->stats, &si->rx_buff, STRBR); | ||
239 | } while (STLSR & LSR_DR); | ||
240 | dev->last_rx = jiffies; | ||
241 | si->last_oscr = OSCR; | ||
242 | break; | ||
243 | |||
244 | case 0x02: /* Transmit FIFO Data Request */ | ||
245 | while ((si->tx_buff.len) && (STLSR & LSR_TDRQ)) { | ||
246 | STTHR = *si->tx_buff.data++; | ||
247 | si->tx_buff.len -= 1; | ||
248 | } | ||
249 | |||
250 | if (si->tx_buff.len == 0) { | ||
251 | si->stats.tx_packets++; | ||
252 | si->stats.tx_bytes += si->tx_buff.data - | ||
253 | si->tx_buff.head; | ||
254 | |||
255 | /* We need to ensure that the transmitter has finished. */ | ||
256 | while ((STLSR & LSR_TEMT) == 0) | ||
257 | cpu_relax(); | ||
258 | si->last_oscr = OSCR; | ||
259 | |||
260 | /* | ||
261 | * Ok, we've finished transmitting. Now enable | ||
262 | * the receiver. Sometimes we get a receive IRQ | ||
263 | * immediately after a transmit... | ||
264 | */ | ||
265 | if (si->newspeed) { | ||
266 | pxa_irda_set_speed(si, si->newspeed); | ||
267 | si->newspeed = 0; | ||
268 | } else { | ||
269 | /* enable IR Receiver, disable IR Transmitter */ | ||
270 | STISR = IrSR_IR_RECEIVE_ON | IrSR_XMODE_PULSE_1_6; | ||
271 | /* enable STUART and receive interrupts */ | ||
272 | STIER = IER_UUE | IER_RLSE | IER_RAVIE | IER_RTIOE; | ||
273 | } | ||
274 | /* I'm hungry! */ | ||
275 | netif_wake_queue(dev); | ||
276 | } | ||
277 | break; | ||
278 | } | ||
279 | |||
280 | return IRQ_HANDLED; | ||
281 | } | ||
282 | |||
283 | /* FIR Receive DMA interrupt handler */ | ||
284 | static void pxa_irda_fir_dma_rx_irq(int channel, void *data, struct pt_regs *regs) | ||
285 | { | ||
286 | int dcsr = DCSR(channel); | ||
287 | |||
288 | DCSR(channel) = dcsr & ~DCSR_RUN; | ||
289 | |||
290 | printk(KERN_DEBUG "pxa_ir: fir rx dma bus error %#x\n", dcsr); | ||
291 | } | ||
292 | |||
293 | /* FIR Transmit DMA interrupt handler */ | ||
294 | static void pxa_irda_fir_dma_tx_irq(int channel, void *data, struct pt_regs *regs) | ||
295 | { | ||
296 | struct net_device *dev = data; | ||
297 | struct pxa_irda *si = netdev_priv(dev); | ||
298 | int dcsr; | ||
299 | |||
300 | dcsr = DCSR(channel); | ||
301 | DCSR(channel) = dcsr & ~DCSR_RUN; | ||
302 | |||
303 | if (dcsr & DCSR_ENDINTR) { | ||
304 | si->stats.tx_packets++; | ||
305 | si->stats.tx_bytes += si->dma_tx_buff_len; | ||
306 | } else { | ||
307 | si->stats.tx_errors++; | ||
308 | } | ||
309 | |||
310 | while (ICSR1 & ICSR1_TBY) | ||
311 | cpu_relax(); | ||
312 | si->last_oscr = OSCR; | ||
313 | |||
314 | /* | ||
315 | * HACK: It looks like the TBY bit is dropped too soon. | ||
316 | * Without this delay things break. | ||
317 | */ | ||
318 | udelay(120); | ||
319 | |||
320 | if (si->newspeed) { | ||
321 | pxa_irda_set_speed(si, si->newspeed); | ||
322 | si->newspeed = 0; | ||
323 | } else { | ||
324 | ICCR0 = 0; | ||
325 | pxa_irda_fir_dma_rx_start(si); | ||
326 | ICCR0 = ICCR0_ITR | ICCR0_RXE; | ||
327 | } | ||
328 | netif_wake_queue(dev); | ||
329 | } | ||
330 | |||
331 | /* EIF(Error in FIFO/End in Frame) handler for FIR */ | ||
332 | static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev) | ||
333 | { | ||
334 | unsigned int len, stat, data; | ||
335 | |||
336 | /* Get the current data position. */ | ||
337 | len = DTADR(si->rxdma) - si->dma_rx_buff_phy; | ||
338 | |||
339 | do { | ||
340 | /* Read Status, and then Data. */ | ||
341 | stat = ICSR1; | ||
342 | rmb(); | ||
343 | data = ICDR; | ||
344 | |||
345 | if (stat & (ICSR1_CRE | ICSR1_ROR)) { | ||
346 | si->stats.rx_errors++; | ||
347 | if (stat & ICSR1_CRE) { | ||
348 | printk(KERN_DEBUG "pxa_ir: fir receive CRC error\n"); | ||
349 | si->stats.rx_crc_errors++; | ||
350 | } | ||
351 | if (stat & ICSR1_ROR) { | ||
352 | printk(KERN_DEBUG "pxa_ir: fir receive overrun\n"); | ||
353 | si->stats.rx_frame_errors++; | ||
354 | } | ||
355 | } else { | ||
356 | si->dma_rx_buff[len++] = data; | ||
357 | } | ||
358 | /* If we hit the end of frame, there's no point in continuing. */ | ||
359 | if (stat & ICSR1_EOF) | ||
360 | break; | ||
361 | } while (ICSR0 & ICSR0_EIF); | ||
362 | |||
363 | if (stat & ICSR1_EOF) { | ||
364 | /* end of frame. */ | ||
365 | struct sk_buff *skb = alloc_skb(len+1,GFP_ATOMIC); | ||
366 | if (!skb) { | ||
367 | printk(KERN_ERR "pxa_ir: fir out of memory for receive skb\n"); | ||
368 | si->stats.rx_dropped++; | ||
369 | return; | ||
370 | } | ||
371 | |||
372 | /* Align IP header to 20 bytes */ | ||
373 | skb_reserve(skb, 1); | ||
374 | memcpy(skb->data, si->dma_rx_buff, len); | ||
375 | skb_put(skb, len); | ||
376 | |||
377 | /* Feed it to IrLAP */ | ||
378 | skb->dev = dev; | ||
379 | skb->mac.raw = skb->data; | ||
380 | skb->protocol = htons(ETH_P_IRDA); | ||
381 | netif_rx(skb); | ||
382 | |||
383 | si->stats.rx_packets++; | ||
384 | si->stats.rx_bytes += len; | ||
385 | |||
386 | dev->last_rx = jiffies; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | /* FIR interrupt handler */ | ||
391 | static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id, struct pt_regs *regs) | ||
392 | { | ||
393 | struct net_device *dev = dev_id; | ||
394 | struct pxa_irda *si = netdev_priv(dev); | ||
395 | int icsr0; | ||
396 | |||
397 | /* stop RX DMA */ | ||
398 | DCSR(si->rxdma) &= ~DCSR_RUN; | ||
399 | si->last_oscr = OSCR; | ||
400 | icsr0 = ICSR0; | ||
401 | |||
402 | if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) { | ||
403 | if (icsr0 & ICSR0_FRE) { | ||
404 | printk(KERN_DEBUG "pxa_ir: fir receive frame error\n"); | ||
405 | si->stats.rx_frame_errors++; | ||
406 | } else { | ||
407 | printk(KERN_DEBUG "pxa_ir: fir receive abort\n"); | ||
408 | si->stats.rx_errors++; | ||
409 | } | ||
410 | ICSR0 = icsr0 & (ICSR0_FRE | ICSR0_RAB); | ||
411 | } | ||
412 | |||
413 | if (icsr0 & ICSR0_EIF) { | ||
414 | /* An error in FIFO occured, or there is a end of frame */ | ||
415 | pxa_irda_fir_irq_eif(si, dev); | ||
416 | } | ||
417 | |||
418 | ICCR0 = 0; | ||
419 | pxa_irda_fir_dma_rx_start(si); | ||
420 | ICCR0 = ICCR0_ITR | ICCR0_RXE; | ||
421 | |||
422 | return IRQ_HANDLED; | ||
423 | } | ||
424 | |||
425 | /* hard_xmit interface of irda device */ | ||
426 | static int pxa_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | ||
427 | { | ||
428 | struct pxa_irda *si = netdev_priv(dev); | ||
429 | int speed = irda_get_next_speed(skb); | ||
430 | |||
431 | /* | ||
432 | * Does this packet contain a request to change the interface | ||
433 | * speed? If so, remember it until we complete the transmission | ||
434 | * of this frame. | ||
435 | */ | ||
436 | if (speed != si->speed && speed != -1) | ||
437 | si->newspeed = speed; | ||
438 | |||
439 | /* | ||
440 | * If this is an empty frame, we can bypass a lot. | ||
441 | */ | ||
442 | if (skb->len == 0) { | ||
443 | if (si->newspeed) { | ||
444 | si->newspeed = 0; | ||
445 | pxa_irda_set_speed(si, speed); | ||
446 | } | ||
447 | dev_kfree_skb(skb); | ||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | netif_stop_queue(dev); | ||
452 | |||
453 | if (!IS_FIR(si)) { | ||
454 | si->tx_buff.data = si->tx_buff.head; | ||
455 | si->tx_buff.len = async_wrap_skb(skb, si->tx_buff.data, si->tx_buff.truesize); | ||
456 | |||
457 | /* Disable STUART interrupts and switch to transmit mode. */ | ||
458 | STIER = 0; | ||
459 | STISR = IrSR_IR_TRANSMIT_ON | IrSR_XMODE_PULSE_1_6; | ||
460 | |||
461 | /* enable STUART and transmit interrupts */ | ||
462 | STIER = IER_UUE | IER_TIE; | ||
463 | } else { | ||
464 | unsigned long mtt = irda_get_mtt(skb); | ||
465 | |||
466 | si->dma_tx_buff_len = skb->len; | ||
467 | memcpy(si->dma_tx_buff, skb->data, skb->len); | ||
468 | |||
469 | if (mtt) | ||
470 | while ((unsigned)(OSCR - si->last_oscr)/4 < mtt) | ||
471 | cpu_relax(); | ||
472 | |||
473 | /* stop RX DMA, disable FICP */ | ||
474 | DCSR(si->rxdma) &= ~DCSR_RUN; | ||
475 | ICCR0 = 0; | ||
476 | |||
477 | pxa_irda_fir_dma_tx_start(si); | ||
478 | ICCR0 = ICCR0_ITR | ICCR0_TXE; | ||
479 | } | ||
480 | |||
481 | dev_kfree_skb(skb); | ||
482 | dev->trans_start = jiffies; | ||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static int pxa_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd) | ||
487 | { | ||
488 | struct if_irda_req *rq = (struct if_irda_req *)ifreq; | ||
489 | struct pxa_irda *si = netdev_priv(dev); | ||
490 | int ret; | ||
491 | |||
492 | switch (cmd) { | ||
493 | case SIOCSBANDWIDTH: | ||
494 | ret = -EPERM; | ||
495 | if (capable(CAP_NET_ADMIN)) { | ||
496 | /* | ||
497 | * We are unable to set the speed if the | ||
498 | * device is not running. | ||
499 | */ | ||
500 | if (netif_running(dev)) { | ||
501 | ret = pxa_irda_set_speed(si, | ||
502 | rq->ifr_baudrate); | ||
503 | } else { | ||
504 | printk(KERN_INFO "pxa_ir: SIOCSBANDWIDTH: !netif_running\n"); | ||
505 | ret = 0; | ||
506 | } | ||
507 | } | ||
508 | break; | ||
509 | |||
510 | case SIOCSMEDIABUSY: | ||
511 | ret = -EPERM; | ||
512 | if (capable(CAP_NET_ADMIN)) { | ||
513 | irda_device_set_media_busy(dev, TRUE); | ||
514 | ret = 0; | ||
515 | } | ||
516 | break; | ||
517 | |||
518 | case SIOCGRECEIVING: | ||
519 | ret = 0; | ||
520 | rq->ifr_receiving = IS_FIR(si) ? 0 | ||
521 | : si->rx_buff.state != OUTSIDE_FRAME; | ||
522 | break; | ||
523 | |||
524 | default: | ||
525 | ret = -EOPNOTSUPP; | ||
526 | break; | ||
527 | } | ||
528 | |||
529 | return ret; | ||
530 | } | ||
531 | |||
532 | static struct net_device_stats *pxa_irda_stats(struct net_device *dev) | ||
533 | { | ||
534 | struct pxa_irda *si = netdev_priv(dev); | ||
535 | return &si->stats; | ||
536 | } | ||
537 | |||
538 | static void pxa_irda_startup(struct pxa_irda *si) | ||
539 | { | ||
540 | /* Disable STUART interrupts */ | ||
541 | STIER = 0; | ||
542 | /* enable STUART interrupt to the processor */ | ||
543 | STMCR = MCR_OUT2; | ||
544 | /* configure SIR frame format: StartBit - Data 7 ... Data 0 - Stop Bit */ | ||
545 | STLCR = LCR_WLS0 | LCR_WLS1; | ||
546 | /* enable FIFO, we use FIFO to improve performance */ | ||
547 | STFCR = FCR_TRFIFOE | FCR_ITL_32; | ||
548 | |||
549 | /* disable FICP */ | ||
550 | ICCR0 = 0; | ||
551 | /* configure FICP ICCR2 */ | ||
552 | ICCR2 = ICCR2_TXP | ICCR2_TRIG_32; | ||
553 | |||
554 | /* configure DMAC */ | ||
555 | DRCMR17 = si->rxdma | DRCMR_MAPVLD; | ||
556 | DRCMR18 = si->txdma | DRCMR_MAPVLD; | ||
557 | |||
558 | /* force SIR reinitialization */ | ||
559 | si->speed = 4000000; | ||
560 | pxa_irda_set_speed(si, 9600); | ||
561 | |||
562 | printk(KERN_DEBUG "pxa_ir: irda startup\n"); | ||
563 | } | ||
564 | |||
565 | static void pxa_irda_shutdown(struct pxa_irda *si) | ||
566 | { | ||
567 | unsigned long flags; | ||
568 | |||
569 | local_irq_save(flags); | ||
570 | |||
571 | /* disable STUART and interrupt */ | ||
572 | STIER = 0; | ||
573 | /* disable STUART SIR mode */ | ||
574 | STISR = 0; | ||
575 | /* disable the STUART clock */ | ||
576 | pxa_set_cken(CKEN5_STUART, 0); | ||
577 | |||
578 | /* disable DMA */ | ||
579 | DCSR(si->txdma) &= ~DCSR_RUN; | ||
580 | DCSR(si->rxdma) &= ~DCSR_RUN; | ||
581 | /* disable FICP */ | ||
582 | ICCR0 = 0; | ||
583 | /* disable the FICP clock */ | ||
584 | pxa_set_cken(CKEN13_FICP, 0); | ||
585 | |||
586 | DRCMR17 = 0; | ||
587 | DRCMR18 = 0; | ||
588 | |||
589 | local_irq_restore(flags); | ||
590 | |||
591 | /* power off board transceiver */ | ||
592 | si->pdata->transceiver_mode(si->dev, IR_OFF); | ||
593 | |||
594 | printk(KERN_DEBUG "pxa_ir: irda shutdown\n"); | ||
595 | } | ||
596 | |||
597 | static int pxa_irda_start(struct net_device *dev) | ||
598 | { | ||
599 | struct pxa_irda *si = netdev_priv(dev); | ||
600 | int err; | ||
601 | |||
602 | si->speed = 9600; | ||
603 | |||
604 | err = request_irq(IRQ_STUART, pxa_irda_sir_irq, 0, dev->name, dev); | ||
605 | if (err) | ||
606 | goto err_irq1; | ||
607 | |||
608 | err = request_irq(IRQ_ICP, pxa_irda_fir_irq, 0, dev->name, dev); | ||
609 | if (err) | ||
610 | goto err_irq2; | ||
611 | |||
612 | /* | ||
613 | * The interrupt must remain disabled for now. | ||
614 | */ | ||
615 | disable_irq(IRQ_STUART); | ||
616 | disable_irq(IRQ_ICP); | ||
617 | |||
618 | err = -EBUSY; | ||
619 | si->rxdma = pxa_request_dma("FICP_RX",DMA_PRIO_LOW, pxa_irda_fir_dma_rx_irq, dev); | ||
620 | if (si->rxdma < 0) | ||
621 | goto err_rx_dma; | ||
622 | |||
623 | si->txdma = pxa_request_dma("FICP_TX",DMA_PRIO_LOW, pxa_irda_fir_dma_tx_irq, dev); | ||
624 | if (si->txdma < 0) | ||
625 | goto err_tx_dma; | ||
626 | |||
627 | err = -ENOMEM; | ||
628 | si->dma_rx_buff = dma_alloc_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, | ||
629 | &si->dma_rx_buff_phy, GFP_KERNEL ); | ||
630 | if (!si->dma_rx_buff) | ||
631 | goto err_dma_rx_buff; | ||
632 | |||
633 | si->dma_tx_buff = dma_alloc_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, | ||
634 | &si->dma_tx_buff_phy, GFP_KERNEL ); | ||
635 | if (!si->dma_tx_buff) | ||
636 | goto err_dma_tx_buff; | ||
637 | |||
638 | /* Setup the serial port for the initial speed. */ | ||
639 | pxa_irda_startup(si); | ||
640 | |||
641 | /* | ||
642 | * Open a new IrLAP layer instance. | ||
643 | */ | ||
644 | si->irlap = irlap_open(dev, &si->qos, "pxa"); | ||
645 | err = -ENOMEM; | ||
646 | if (!si->irlap) | ||
647 | goto err_irlap; | ||
648 | |||
649 | /* | ||
650 | * Now enable the interrupt and start the queue | ||
651 | */ | ||
652 | enable_irq(IRQ_STUART); | ||
653 | enable_irq(IRQ_ICP); | ||
654 | netif_start_queue(dev); | ||
655 | |||
656 | printk(KERN_DEBUG "pxa_ir: irda driver opened\n"); | ||
657 | |||
658 | return 0; | ||
659 | |||
660 | err_irlap: | ||
661 | pxa_irda_shutdown(si); | ||
662 | dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_tx_buff, si->dma_tx_buff_phy); | ||
663 | err_dma_tx_buff: | ||
664 | dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_rx_buff, si->dma_rx_buff_phy); | ||
665 | err_dma_rx_buff: | ||
666 | pxa_free_dma(si->txdma); | ||
667 | err_tx_dma: | ||
668 | pxa_free_dma(si->rxdma); | ||
669 | err_rx_dma: | ||
670 | free_irq(IRQ_ICP, dev); | ||
671 | err_irq2: | ||
672 | free_irq(IRQ_STUART, dev); | ||
673 | err_irq1: | ||
674 | |||
675 | return err; | ||
676 | } | ||
677 | |||
678 | static int pxa_irda_stop(struct net_device *dev) | ||
679 | { | ||
680 | struct pxa_irda *si = netdev_priv(dev); | ||
681 | |||
682 | netif_stop_queue(dev); | ||
683 | |||
684 | pxa_irda_shutdown(si); | ||
685 | |||
686 | /* Stop IrLAP */ | ||
687 | if (si->irlap) { | ||
688 | irlap_close(si->irlap); | ||
689 | si->irlap = NULL; | ||
690 | } | ||
691 | |||
692 | free_irq(IRQ_STUART, dev); | ||
693 | free_irq(IRQ_ICP, dev); | ||
694 | |||
695 | pxa_free_dma(si->rxdma); | ||
696 | pxa_free_dma(si->txdma); | ||
697 | |||
698 | if (si->dma_rx_buff) | ||
699 | dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_tx_buff, si->dma_tx_buff_phy); | ||
700 | if (si->dma_tx_buff) | ||
701 | dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_rx_buff, si->dma_rx_buff_phy); | ||
702 | |||
703 | printk(KERN_DEBUG "pxa_ir: irda driver closed\n"); | ||
704 | return 0; | ||
705 | } | ||
706 | |||
707 | static int pxa_irda_suspend(struct device *_dev, pm_message_t state, u32 level) | ||
708 | { | ||
709 | struct net_device *dev = dev_get_drvdata(_dev); | ||
710 | struct pxa_irda *si; | ||
711 | |||
712 | if (!dev || level != SUSPEND_DISABLE) | ||
713 | return 0; | ||
714 | |||
715 | if (netif_running(dev)) { | ||
716 | si = netdev_priv(dev); | ||
717 | netif_device_detach(dev); | ||
718 | pxa_irda_shutdown(si); | ||
719 | } | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | static int pxa_irda_resume(struct device *_dev, u32 level) | ||
725 | { | ||
726 | struct net_device *dev = dev_get_drvdata(_dev); | ||
727 | struct pxa_irda *si; | ||
728 | |||
729 | if (!dev || level != RESUME_ENABLE) | ||
730 | return 0; | ||
731 | |||
732 | if (netif_running(dev)) { | ||
733 | si = netdev_priv(dev); | ||
734 | pxa_irda_startup(si); | ||
735 | netif_device_attach(dev); | ||
736 | netif_wake_queue(dev); | ||
737 | } | ||
738 | |||
739 | return 0; | ||
740 | } | ||
741 | |||
742 | |||
743 | static int pxa_irda_init_iobuf(iobuff_t *io, int size) | ||
744 | { | ||
745 | io->head = kmalloc(size, GFP_KERNEL | GFP_DMA); | ||
746 | if (io->head != NULL) { | ||
747 | io->truesize = size; | ||
748 | io->in_frame = FALSE; | ||
749 | io->state = OUTSIDE_FRAME; | ||
750 | io->data = io->head; | ||
751 | } | ||
752 | return io->head ? 0 : -ENOMEM; | ||
753 | } | ||
754 | |||
755 | static int pxa_irda_probe(struct device *_dev) | ||
756 | { | ||
757 | struct platform_device *pdev = to_platform_device(_dev); | ||
758 | struct net_device *dev; | ||
759 | struct pxa_irda *si; | ||
760 | unsigned int baudrate_mask; | ||
761 | int err; | ||
762 | |||
763 | if (!pdev->dev.platform_data) | ||
764 | return -ENODEV; | ||
765 | |||
766 | err = request_mem_region(__PREG(STUART), 0x24, "IrDA") ? 0 : -EBUSY; | ||
767 | if (err) | ||
768 | goto err_mem_1; | ||
769 | |||
770 | err = request_mem_region(__PREG(FICP), 0x1c, "IrDA") ? 0 : -EBUSY; | ||
771 | if (err) | ||
772 | goto err_mem_2; | ||
773 | |||
774 | dev = alloc_irdadev(sizeof(struct pxa_irda)); | ||
775 | if (!dev) | ||
776 | goto err_mem_3; | ||
777 | |||
778 | si = netdev_priv(dev); | ||
779 | si->dev = &pdev->dev; | ||
780 | si->pdata = pdev->dev.platform_data; | ||
781 | |||
782 | /* | ||
783 | * Initialise the SIR buffers | ||
784 | */ | ||
785 | err = pxa_irda_init_iobuf(&si->rx_buff, 14384); | ||
786 | if (err) | ||
787 | goto err_mem_4; | ||
788 | err = pxa_irda_init_iobuf(&si->tx_buff, 4000); | ||
789 | if (err) | ||
790 | goto err_mem_5; | ||
791 | |||
792 | dev->hard_start_xmit = pxa_irda_hard_xmit; | ||
793 | dev->open = pxa_irda_start; | ||
794 | dev->stop = pxa_irda_stop; | ||
795 | dev->do_ioctl = pxa_irda_ioctl; | ||
796 | dev->get_stats = pxa_irda_stats; | ||
797 | |||
798 | irda_init_max_qos_capabilies(&si->qos); | ||
799 | |||
800 | baudrate_mask = 0; | ||
801 | if (si->pdata->transceiver_cap & IR_SIRMODE) | ||
802 | baudrate_mask |= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200; | ||
803 | if (si->pdata->transceiver_cap & IR_FIRMODE) | ||
804 | baudrate_mask |= IR_4000000 << 8; | ||
805 | |||
806 | si->qos.baud_rate.bits &= baudrate_mask; | ||
807 | si->qos.min_turn_time.bits = 7; /* 1ms or more */ | ||
808 | |||
809 | irda_qos_bits_to_value(&si->qos); | ||
810 | |||
811 | err = register_netdev(dev); | ||
812 | |||
813 | if (err == 0) | ||
814 | dev_set_drvdata(&pdev->dev, dev); | ||
815 | |||
816 | if (err) { | ||
817 | kfree(si->tx_buff.head); | ||
818 | err_mem_5: | ||
819 | kfree(si->rx_buff.head); | ||
820 | err_mem_4: | ||
821 | free_netdev(dev); | ||
822 | err_mem_3: | ||
823 | release_mem_region(__PREG(FICP), 0x1c); | ||
824 | err_mem_2: | ||
825 | release_mem_region(__PREG(STUART), 0x24); | ||
826 | } | ||
827 | err_mem_1: | ||
828 | return err; | ||
829 | } | ||
830 | |||
831 | static int pxa_irda_remove(struct device *_dev) | ||
832 | { | ||
833 | struct net_device *dev = dev_get_drvdata(_dev); | ||
834 | |||
835 | if (dev) { | ||
836 | struct pxa_irda *si = netdev_priv(dev); | ||
837 | unregister_netdev(dev); | ||
838 | kfree(si->tx_buff.head); | ||
839 | kfree(si->rx_buff.head); | ||
840 | free_netdev(dev); | ||
841 | } | ||
842 | |||
843 | release_mem_region(__PREG(STUART), 0x24); | ||
844 | release_mem_region(__PREG(FICP), 0x1c); | ||
845 | |||
846 | return 0; | ||
847 | } | ||
848 | |||
849 | static struct device_driver pxa_ir_driver = { | ||
850 | .name = "pxa2xx-ir", | ||
851 | .bus = &platform_bus_type, | ||
852 | .probe = pxa_irda_probe, | ||
853 | .remove = pxa_irda_remove, | ||
854 | .suspend = pxa_irda_suspend, | ||
855 | .resume = pxa_irda_resume, | ||
856 | }; | ||
857 | |||
858 | static int __init pxa_irda_init(void) | ||
859 | { | ||
860 | return driver_register(&pxa_ir_driver); | ||
861 | } | ||
862 | |||
863 | static void __exit pxa_irda_exit(void) | ||
864 | { | ||
865 | driver_unregister(&pxa_ir_driver); | ||
866 | } | ||
867 | |||
868 | module_init(pxa_irda_init); | ||
869 | module_exit(pxa_irda_exit); | ||
870 | |||
871 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c index 8d34ac60d906..06883309916d 100644 --- a/drivers/net/irda/sa1100_ir.c +++ b/drivers/net/irda/sa1100_ir.c | |||
@@ -291,12 +291,12 @@ static void sa1100_irda_shutdown(struct sa1100_irda *si) | |||
291 | /* | 291 | /* |
292 | * Suspend the IrDA interface. | 292 | * Suspend the IrDA interface. |
293 | */ | 293 | */ |
294 | static int sa1100_irda_suspend(struct device *_dev, pm_message_t state, u32 level) | 294 | static int sa1100_irda_suspend(struct device *_dev, pm_message_t state) |
295 | { | 295 | { |
296 | struct net_device *dev = dev_get_drvdata(_dev); | 296 | struct net_device *dev = dev_get_drvdata(_dev); |
297 | struct sa1100_irda *si; | 297 | struct sa1100_irda *si; |
298 | 298 | ||
299 | if (!dev || level != SUSPEND_DISABLE) | 299 | if (!dev) |
300 | return 0; | 300 | return 0; |
301 | 301 | ||
302 | si = dev->priv; | 302 | si = dev->priv; |
@@ -316,12 +316,12 @@ static int sa1100_irda_suspend(struct device *_dev, pm_message_t state, u32 leve | |||
316 | /* | 316 | /* |
317 | * Resume the IrDA interface. | 317 | * Resume the IrDA interface. |
318 | */ | 318 | */ |
319 | static int sa1100_irda_resume(struct device *_dev, u32 level) | 319 | static int sa1100_irda_resume(struct device *_dev) |
320 | { | 320 | { |
321 | struct net_device *dev = dev_get_drvdata(_dev); | 321 | struct net_device *dev = dev_get_drvdata(_dev); |
322 | struct sa1100_irda *si; | 322 | struct sa1100_irda *si; |
323 | 323 | ||
324 | if (!dev || level != RESUME_ENABLE) | 324 | if (!dev) |
325 | return 0; | 325 | return 0; |
326 | 326 | ||
327 | si = dev->priv; | 327 | si = dev->priv; |
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index dd89bda1f131..bbac720cca63 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c | |||
@@ -213,8 +213,8 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base); | |||
213 | 213 | ||
214 | /* Power Management */ | 214 | /* Power Management */ |
215 | 215 | ||
216 | static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level); | 216 | static int smsc_ircc_suspend(struct device *dev, pm_message_t state); |
217 | static int smsc_ircc_resume(struct device *dev, u32 level); | 217 | static int smsc_ircc_resume(struct device *dev); |
218 | 218 | ||
219 | static struct device_driver smsc_ircc_driver = { | 219 | static struct device_driver smsc_ircc_driver = { |
220 | .name = SMSC_IRCC2_DRIVER_NAME, | 220 | .name = SMSC_IRCC2_DRIVER_NAME, |
@@ -1646,13 +1646,13 @@ static int smsc_ircc_net_close(struct net_device *dev) | |||
1646 | return 0; | 1646 | return 0; |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level) | 1649 | static int smsc_ircc_suspend(struct device *dev, pm_message_t state) |
1650 | { | 1650 | { |
1651 | struct smsc_ircc_cb *self = dev_get_drvdata(dev); | 1651 | struct smsc_ircc_cb *self = dev_get_drvdata(dev); |
1652 | 1652 | ||
1653 | IRDA_MESSAGE("%s, Suspending\n", driver_name); | 1653 | IRDA_MESSAGE("%s, Suspending\n", driver_name); |
1654 | 1654 | ||
1655 | if (level == SUSPEND_DISABLE && !self->io.suspended) { | 1655 | if (!self->io.suspended) { |
1656 | smsc_ircc_net_close(self->netdev); | 1656 | smsc_ircc_net_close(self->netdev); |
1657 | self->io.suspended = 1; | 1657 | self->io.suspended = 1; |
1658 | } | 1658 | } |
@@ -1660,11 +1660,11 @@ static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level) | |||
1660 | return 0; | 1660 | return 0; |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | static int smsc_ircc_resume(struct device *dev, u32 level) | 1663 | static int smsc_ircc_resume(struct device *dev) |
1664 | { | 1664 | { |
1665 | struct smsc_ircc_cb *self = dev_get_drvdata(dev); | 1665 | struct smsc_ircc_cb *self = dev_get_drvdata(dev); |
1666 | 1666 | ||
1667 | if (level == RESUME_ENABLE && self->io.suspended) { | 1667 | if (self->io.suspended) { |
1668 | 1668 | ||
1669 | smsc_ircc_net_open(self->netdev); | 1669 | smsc_ircc_net_open(self->netdev); |
1670 | self->io.suspended = 0; | 1670 | self->io.suspended = 0; |
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c index 41bad07ac1ac..f7b7238d8352 100644 --- a/drivers/net/lasi_82596.c +++ b/drivers/net/lasi_82596.c | |||
@@ -415,6 +415,10 @@ static int rx_ring_size = RX_RING_SIZE; | |||
415 | static int ticks_limit = 100; | 415 | static int ticks_limit = 100; |
416 | static int max_cmd_backlog = TX_RING_SIZE-1; | 416 | static int max_cmd_backlog = TX_RING_SIZE-1; |
417 | 417 | ||
418 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
419 | static void i596_poll_controller(struct net_device *dev); | ||
420 | #endif | ||
421 | |||
418 | 422 | ||
419 | static inline void CA(struct net_device *dev) | 423 | static inline void CA(struct net_device *dev) |
420 | { | 424 | { |
@@ -636,11 +640,11 @@ static int init_i596_mem(struct net_device *dev) | |||
636 | 640 | ||
637 | disable_irq(dev->irq); /* disable IRQs from LAN */ | 641 | disable_irq(dev->irq); /* disable IRQs from LAN */ |
638 | DEB(DEB_INIT, | 642 | DEB(DEB_INIT, |
639 | printk("RESET 82596 port: %p (with IRQ %d disabled)\n", | 643 | printk("RESET 82596 port: %lx (with IRQ %d disabled)\n", |
640 | (void*)(dev->base_addr + PA_I82596_RESET), | 644 | (dev->base_addr + PA_I82596_RESET), |
641 | dev->irq)); | 645 | dev->irq)); |
642 | 646 | ||
643 | gsc_writel(0, (void*)(dev->base_addr + PA_I82596_RESET)); /* Hard Reset */ | 647 | gsc_writel(0, (dev->base_addr + PA_I82596_RESET)); /* Hard Reset */ |
644 | udelay(100); /* Wait 100us - seems to help */ | 648 | udelay(100); /* Wait 100us - seems to help */ |
645 | 649 | ||
646 | /* change the scp address */ | 650 | /* change the scp address */ |
@@ -1209,6 +1213,9 @@ static int __devinit i82596_probe(struct net_device *dev, | |||
1209 | dev->set_multicast_list = set_multicast_list; | 1213 | dev->set_multicast_list = set_multicast_list; |
1210 | dev->tx_timeout = i596_tx_timeout; | 1214 | dev->tx_timeout = i596_tx_timeout; |
1211 | dev->watchdog_timeo = TX_TIMEOUT; | 1215 | dev->watchdog_timeo = TX_TIMEOUT; |
1216 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1217 | dev->poll_controller = i596_poll_controller; | ||
1218 | #endif | ||
1212 | 1219 | ||
1213 | dev->priv = (void *)(dev->mem_start); | 1220 | dev->priv = (void *)(dev->mem_start); |
1214 | 1221 | ||
@@ -1242,6 +1249,14 @@ static int __devinit i82596_probe(struct net_device *dev, | |||
1242 | return 0; | 1249 | return 0; |
1243 | } | 1250 | } |
1244 | 1251 | ||
1252 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1253 | static void i596_poll_controller(struct net_device *dev) | ||
1254 | { | ||
1255 | disable_irq(dev->irq); | ||
1256 | i596_interrupt(dev->irq, dev, NULL); | ||
1257 | enable_irq(dev->irq); | ||
1258 | } | ||
1259 | #endif | ||
1245 | 1260 | ||
1246 | static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 1261 | static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
1247 | { | 1262 | { |
@@ -1528,17 +1543,18 @@ lan_init_chip(struct parisc_device *dev) | |||
1528 | 1543 | ||
1529 | if (!dev->irq) { | 1544 | if (!dev->irq) { |
1530 | printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n", | 1545 | printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n", |
1531 | __FILE__, dev->hpa); | 1546 | __FILE__, dev->hpa.start); |
1532 | return -ENODEV; | 1547 | return -ENODEV; |
1533 | } | 1548 | } |
1534 | 1549 | ||
1535 | printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n", dev->hpa, dev->irq); | 1550 | printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n", dev->hpa.start, |
1551 | dev->irq); | ||
1536 | 1552 | ||
1537 | netdevice = alloc_etherdev(0); | 1553 | netdevice = alloc_etherdev(0); |
1538 | if (!netdevice) | 1554 | if (!netdevice) |
1539 | return -ENOMEM; | 1555 | return -ENOMEM; |
1540 | 1556 | ||
1541 | netdevice->base_addr = dev->hpa; | 1557 | netdevice->base_addr = dev->hpa.start; |
1542 | netdevice->irq = dev->irq; | 1558 | netdevice->irq = dev->irq; |
1543 | 1559 | ||
1544 | retval = i82596_probe(netdevice, &dev->dev); | 1560 | retval = i82596_probe(netdevice, &dev->dev); |
@@ -1566,7 +1582,7 @@ static struct parisc_device_id lan_tbl[] = { | |||
1566 | MODULE_DEVICE_TABLE(parisc, lan_tbl); | 1582 | MODULE_DEVICE_TABLE(parisc, lan_tbl); |
1567 | 1583 | ||
1568 | static struct parisc_driver lan_driver = { | 1584 | static struct parisc_driver lan_driver = { |
1569 | .name = "Apricot", | 1585 | .name = "lasi_82596", |
1570 | .id_table = lan_tbl, | 1586 | .id_table = lan_tbl, |
1571 | .probe = lan_init_chip, | 1587 | .probe = lan_init_chip, |
1572 | }; | 1588 | }; |
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 90630672703d..ad93b0da87f0 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
@@ -133,13 +133,9 @@ static int mdio_bus_suspend(struct device * dev, pm_message_t state) | |||
133 | int ret = 0; | 133 | int ret = 0; |
134 | struct device_driver *drv = dev->driver; | 134 | struct device_driver *drv = dev->driver; |
135 | 135 | ||
136 | if (drv && drv->suspend) { | 136 | if (drv && drv->suspend) |
137 | ret = drv->suspend(dev, state, SUSPEND_DISABLE); | 137 | ret = drv->suspend(dev, state); |
138 | if (ret == 0) | 138 | |
139 | ret = drv->suspend(dev, state, SUSPEND_SAVE_STATE); | ||
140 | if (ret == 0) | ||
141 | ret = drv->suspend(dev, state, SUSPEND_POWER_DOWN); | ||
142 | } | ||
143 | return ret; | 139 | return ret; |
144 | } | 140 | } |
145 | 141 | ||
@@ -148,13 +144,9 @@ static int mdio_bus_resume(struct device * dev) | |||
148 | int ret = 0; | 144 | int ret = 0; |
149 | struct device_driver *drv = dev->driver; | 145 | struct device_driver *drv = dev->driver; |
150 | 146 | ||
151 | if (drv && drv->resume) { | 147 | if (drv && drv->resume) |
152 | ret = drv->resume(dev, RESUME_POWER_ON); | 148 | ret = drv->resume(dev); |
153 | if (ret == 0) | 149 | |
154 | ret = drv->resume(dev, RESUME_RESTORE_STATE); | ||
155 | if (ret == 0) | ||
156 | ret = drv->resume(dev, RESUME_ENABLE); | ||
157 | } | ||
158 | return ret; | 150 | return ret; |
159 | } | 151 | } |
160 | 152 | ||
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 0df7e92b0bf8..d3c9958b00d0 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -863,7 +863,7 @@ static int __init ppp_init(void) | |||
863 | err = PTR_ERR(ppp_class); | 863 | err = PTR_ERR(ppp_class); |
864 | goto out_chrdev; | 864 | goto out_chrdev; |
865 | } | 865 | } |
866 | class_device_create(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); | 866 | class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); |
867 | err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0), | 867 | err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0), |
868 | S_IFCHR|S_IRUSR|S_IWUSR, "ppp"); | 868 | S_IFCHR|S_IRUSR|S_IWUSR, "ppp"); |
869 | if (err) | 869 | if (err) |
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index 1438fdd20826..0ddaa611cc61 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
@@ -2291,11 +2291,11 @@ static int smc_drv_remove(struct device *dev) | |||
2291 | return 0; | 2291 | return 0; |
2292 | } | 2292 | } |
2293 | 2293 | ||
2294 | static int smc_drv_suspend(struct device *dev, pm_message_t state, u32 level) | 2294 | static int smc_drv_suspend(struct device *dev, pm_message_t state) |
2295 | { | 2295 | { |
2296 | struct net_device *ndev = dev_get_drvdata(dev); | 2296 | struct net_device *ndev = dev_get_drvdata(dev); |
2297 | 2297 | ||
2298 | if (ndev && level == SUSPEND_DISABLE) { | 2298 | if (ndev) { |
2299 | if (netif_running(ndev)) { | 2299 | if (netif_running(ndev)) { |
2300 | netif_device_detach(ndev); | 2300 | netif_device_detach(ndev); |
2301 | smc_shutdown(ndev); | 2301 | smc_shutdown(ndev); |
@@ -2305,12 +2305,12 @@ static int smc_drv_suspend(struct device *dev, pm_message_t state, u32 level) | |||
2305 | return 0; | 2305 | return 0; |
2306 | } | 2306 | } |
2307 | 2307 | ||
2308 | static int smc_drv_resume(struct device *dev, u32 level) | 2308 | static int smc_drv_resume(struct device *dev) |
2309 | { | 2309 | { |
2310 | struct platform_device *pdev = to_platform_device(dev); | 2310 | struct platform_device *pdev = to_platform_device(dev); |
2311 | struct net_device *ndev = dev_get_drvdata(dev); | 2311 | struct net_device *ndev = dev_get_drvdata(dev); |
2312 | 2312 | ||
2313 | if (ndev && level == RESUME_ENABLE) { | 2313 | if (ndev) { |
2314 | struct smc_local *lp = netdev_priv(ndev); | 2314 | struct smc_local *lp = netdev_priv(ndev); |
2315 | smc_enable_device(pdev); | 2315 | smc_enable_device(pdev); |
2316 | if (netif_running(ndev)) { | 2316 | if (netif_running(ndev)) { |
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index ae9e897c255e..e392ee8b37a1 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -400,7 +400,7 @@ static int __init cosa_init(void) | |||
400 | goto out_chrdev; | 400 | goto out_chrdev; |
401 | } | 401 | } |
402 | for (i=0; i<nr_cards; i++) { | 402 | for (i=0; i<nr_cards; i++) { |
403 | class_device_create(cosa_class, MKDEV(cosa_major, i), | 403 | class_device_create(cosa_class, NULL, MKDEV(cosa_major, i), |
404 | NULL, "cosa%d", i); | 404 | NULL, "cosa%d", i); |
405 | err = devfs_mk_cdev(MKDEV(cosa_major, i), | 405 | err = devfs_mk_cdev(MKDEV(cosa_major, i), |
406 | S_IFCHR|S_IRUSR|S_IWUSR, | 406 | S_IFCHR|S_IRUSR|S_IWUSR, |
diff --git a/drivers/parisc/asp.c b/drivers/parisc/asp.c index 388609967133..558420bc9f88 100644 --- a/drivers/parisc/asp.c +++ b/drivers/parisc/asp.c | |||
@@ -77,12 +77,12 @@ asp_init_chip(struct parisc_device *dev) | |||
77 | struct gsc_irq gsc_irq; | 77 | struct gsc_irq gsc_irq; |
78 | int ret; | 78 | int ret; |
79 | 79 | ||
80 | asp.version = gsc_readb(dev->hpa + ASP_VER_OFFSET) & 0xf; | 80 | asp.version = gsc_readb(dev->hpa.start + ASP_VER_OFFSET) & 0xf; |
81 | asp.name = (asp.version == 1) ? "Asp" : "Cutoff"; | 81 | asp.name = (asp.version == 1) ? "Asp" : "Cutoff"; |
82 | asp.hpa = ASP_INTERRUPT_ADDR; | 82 | asp.hpa = ASP_INTERRUPT_ADDR; |
83 | 83 | ||
84 | printk(KERN_INFO "%s version %d at 0x%lx found.\n", | 84 | printk(KERN_INFO "%s version %d at 0x%lx found.\n", |
85 | asp.name, asp.version, dev->hpa); | 85 | asp.name, asp.version, dev->hpa.start); |
86 | 86 | ||
87 | /* the IRQ ASP should use */ | 87 | /* the IRQ ASP should use */ |
88 | ret = -EBUSY; | 88 | ret = -EBUSY; |
@@ -126,7 +126,7 @@ static struct parisc_device_id asp_tbl[] = { | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | struct parisc_driver asp_driver = { | 128 | struct parisc_driver asp_driver = { |
129 | .name = "Asp", | 129 | .name = "asp", |
130 | .id_table = asp_tbl, | 130 | .id_table = asp_tbl, |
131 | .probe = asp_init_chip, | 131 | .probe = asp_init_chip, |
132 | }; | 132 | }; |
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index a3bd91a61827..9e0229f7e25f 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c | |||
@@ -100,9 +100,9 @@ | |||
100 | #define DBG_RUN_SG(x...) | 100 | #define DBG_RUN_SG(x...) |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #define CCIO_INLINE /* inline */ | 103 | #define CCIO_INLINE inline |
104 | #define WRITE_U32(value, addr) gsc_writel(value, (u32 *)(addr)) | 104 | #define WRITE_U32(value, addr) __raw_writel(value, addr) |
105 | #define READ_U32(addr) gsc_readl((u32 *)(addr)) | 105 | #define READ_U32(addr) __raw_readl(addr) |
106 | 106 | ||
107 | #define U2_IOA_RUNWAY 0x580 | 107 | #define U2_IOA_RUNWAY 0x580 |
108 | #define U2_BC_GSC 0x501 | 108 | #define U2_BC_GSC 0x501 |
@@ -115,28 +115,28 @@ | |||
115 | 115 | ||
116 | struct ioa_registers { | 116 | struct ioa_registers { |
117 | /* Runway Supervisory Set */ | 117 | /* Runway Supervisory Set */ |
118 | volatile int32_t unused1[12]; | 118 | int32_t unused1[12]; |
119 | volatile uint32_t io_command; /* Offset 12 */ | 119 | uint32_t io_command; /* Offset 12 */ |
120 | volatile uint32_t io_status; /* Offset 13 */ | 120 | uint32_t io_status; /* Offset 13 */ |
121 | volatile uint32_t io_control; /* Offset 14 */ | 121 | uint32_t io_control; /* Offset 14 */ |
122 | volatile int32_t unused2[1]; | 122 | int32_t unused2[1]; |
123 | 123 | ||
124 | /* Runway Auxiliary Register Set */ | 124 | /* Runway Auxiliary Register Set */ |
125 | volatile uint32_t io_err_resp; /* Offset 0 */ | 125 | uint32_t io_err_resp; /* Offset 0 */ |
126 | volatile uint32_t io_err_info; /* Offset 1 */ | 126 | uint32_t io_err_info; /* Offset 1 */ |
127 | volatile uint32_t io_err_req; /* Offset 2 */ | 127 | uint32_t io_err_req; /* Offset 2 */ |
128 | volatile uint32_t io_err_resp_hi; /* Offset 3 */ | 128 | uint32_t io_err_resp_hi; /* Offset 3 */ |
129 | volatile uint32_t io_tlb_entry_m; /* Offset 4 */ | 129 | uint32_t io_tlb_entry_m; /* Offset 4 */ |
130 | volatile uint32_t io_tlb_entry_l; /* Offset 5 */ | 130 | uint32_t io_tlb_entry_l; /* Offset 5 */ |
131 | volatile uint32_t unused3[1]; | 131 | uint32_t unused3[1]; |
132 | volatile uint32_t io_pdir_base; /* Offset 7 */ | 132 | uint32_t io_pdir_base; /* Offset 7 */ |
133 | volatile uint32_t io_io_low_hv; /* Offset 8 */ | 133 | uint32_t io_io_low_hv; /* Offset 8 */ |
134 | volatile uint32_t io_io_high_hv; /* Offset 9 */ | 134 | uint32_t io_io_high_hv; /* Offset 9 */ |
135 | volatile uint32_t unused4[1]; | 135 | uint32_t unused4[1]; |
136 | volatile uint32_t io_chain_id_mask; /* Offset 11 */ | 136 | uint32_t io_chain_id_mask; /* Offset 11 */ |
137 | volatile uint32_t unused5[2]; | 137 | uint32_t unused5[2]; |
138 | volatile uint32_t io_io_low; /* Offset 14 */ | 138 | uint32_t io_io_low; /* Offset 14 */ |
139 | volatile uint32_t io_io_high; /* Offset 15 */ | 139 | uint32_t io_io_high; /* Offset 15 */ |
140 | }; | 140 | }; |
141 | 141 | ||
142 | /* | 142 | /* |
@@ -226,7 +226,7 @@ struct ioa_registers { | |||
226 | */ | 226 | */ |
227 | 227 | ||
228 | struct ioc { | 228 | struct ioc { |
229 | struct ioa_registers *ioc_hpa; /* I/O MMU base address */ | 229 | struct ioa_registers __iomem *ioc_regs; /* I/O MMU base address */ |
230 | u8 *res_map; /* resource map, bit == pdir entry */ | 230 | u8 *res_map; /* resource map, bit == pdir entry */ |
231 | u64 *pdir_base; /* physical base address */ | 231 | u64 *pdir_base; /* physical base address */ |
232 | u32 pdir_size; /* bytes, function of IOV Space size */ | 232 | u32 pdir_size; /* bytes, function of IOV Space size */ |
@@ -595,7 +595,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, | |||
595 | ** Grab virtual index [0:11] | 595 | ** Grab virtual index [0:11] |
596 | ** Deposit virt_idx bits into I/O PDIR word | 596 | ** Deposit virt_idx bits into I/O PDIR word |
597 | */ | 597 | */ |
598 | asm volatile ("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba)); | 598 | asm volatile ("lci %%r0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba)); |
599 | asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci)); | 599 | asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci)); |
600 | asm volatile ("depw %1,15,12,%0" : "+r" (pa) : "r" (ci)); | 600 | asm volatile ("depw %1,15,12,%0" : "+r" (pa) : "r" (ci)); |
601 | 601 | ||
@@ -613,7 +613,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, | |||
613 | ** the real mode coherence index generation of U2, the PDIR entry | 613 | ** the real mode coherence index generation of U2, the PDIR entry |
614 | ** must be flushed to memory to retain coherence." | 614 | ** must be flushed to memory to retain coherence." |
615 | */ | 615 | */ |
616 | asm volatile("fdc 0(%0)" : : "r" (pdir_ptr)); | 616 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr)); |
617 | asm volatile("sync"); | 617 | asm volatile("sync"); |
618 | } | 618 | } |
619 | 619 | ||
@@ -636,7 +636,7 @@ ccio_clear_io_tlb(struct ioc *ioc, dma_addr_t iovp, size_t byte_cnt) | |||
636 | byte_cnt += chain_size; | 636 | byte_cnt += chain_size; |
637 | 637 | ||
638 | while(byte_cnt > chain_size) { | 638 | while(byte_cnt > chain_size) { |
639 | WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_hpa->io_command); | 639 | WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_regs->io_command); |
640 | iovp += chain_size; | 640 | iovp += chain_size; |
641 | byte_cnt -= chain_size; | 641 | byte_cnt -= chain_size; |
642 | } | 642 | } |
@@ -684,7 +684,7 @@ ccio_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) | |||
684 | ** Hopefully someone figures out how to patch (NOP) the | 684 | ** Hopefully someone figures out how to patch (NOP) the |
685 | ** FDC/SYNC out at boot time. | 685 | ** FDC/SYNC out at boot time. |
686 | */ | 686 | */ |
687 | asm volatile("fdc 0(%0)" : : "r" (pdir_ptr[7])); | 687 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr[7])); |
688 | 688 | ||
689 | iovp += IOVP_SIZE; | 689 | iovp += IOVP_SIZE; |
690 | byte_cnt -= IOVP_SIZE; | 690 | byte_cnt -= IOVP_SIZE; |
@@ -1251,7 +1251,7 @@ static struct parisc_device_id ccio_tbl[] = { | |||
1251 | static int ccio_probe(struct parisc_device *dev); | 1251 | static int ccio_probe(struct parisc_device *dev); |
1252 | 1252 | ||
1253 | static struct parisc_driver ccio_driver = { | 1253 | static struct parisc_driver ccio_driver = { |
1254 | .name = "U2:Uturn", | 1254 | .name = "ccio", |
1255 | .id_table = ccio_tbl, | 1255 | .id_table = ccio_tbl, |
1256 | .probe = ccio_probe, | 1256 | .probe = ccio_probe, |
1257 | }; | 1257 | }; |
@@ -1314,14 +1314,13 @@ ccio_ioc_init(struct ioc *ioc) | |||
1314 | 1314 | ||
1315 | ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); | 1315 | ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); |
1316 | 1316 | ||
1317 | BUG_ON(ioc->pdir_size >= 4 * 1024 * 1024); /* max pdir size < 4MB */ | 1317 | BUG_ON(ioc->pdir_size > 8 * 1024 * 1024); /* max pdir size <= 8MB */ |
1318 | 1318 | ||
1319 | /* Verify it's a power of two */ | 1319 | /* Verify it's a power of two */ |
1320 | BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); | 1320 | BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); |
1321 | 1321 | ||
1322 | DBG_INIT("%s() hpa 0x%lx mem %luMB IOV %dMB (%d bits)\n", | 1322 | DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n", |
1323 | __FUNCTION__, | 1323 | __FUNCTION__, ioc->ioc_regs, |
1324 | ioc->ioc_hpa, | ||
1325 | (unsigned long) num_physpages >> (20 - PAGE_SHIFT), | 1324 | (unsigned long) num_physpages >> (20 - PAGE_SHIFT), |
1326 | iova_space_size>>20, | 1325 | iova_space_size>>20, |
1327 | iov_order + PAGE_SHIFT); | 1326 | iov_order + PAGE_SHIFT); |
@@ -1329,13 +1328,12 @@ ccio_ioc_init(struct ioc *ioc) | |||
1329 | ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, | 1328 | ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, |
1330 | get_order(ioc->pdir_size)); | 1329 | get_order(ioc->pdir_size)); |
1331 | if(NULL == ioc->pdir_base) { | 1330 | if(NULL == ioc->pdir_base) { |
1332 | panic("%s:%s() could not allocate I/O Page Table\n", __FILE__, | 1331 | panic("%s() could not allocate I/O Page Table\n", __FUNCTION__); |
1333 | __FUNCTION__); | ||
1334 | } | 1332 | } |
1335 | memset(ioc->pdir_base, 0, ioc->pdir_size); | 1333 | memset(ioc->pdir_base, 0, ioc->pdir_size); |
1336 | 1334 | ||
1337 | BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base); | 1335 | BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base); |
1338 | DBG_INIT(" base %p", ioc->pdir_base); | 1336 | DBG_INIT(" base %p\n", ioc->pdir_base); |
1339 | 1337 | ||
1340 | /* resource map size dictated by pdir_size */ | 1338 | /* resource map size dictated by pdir_size */ |
1341 | ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; | 1339 | ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; |
@@ -1344,8 +1342,7 @@ ccio_ioc_init(struct ioc *ioc) | |||
1344 | ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, | 1342 | ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, |
1345 | get_order(ioc->res_size)); | 1343 | get_order(ioc->res_size)); |
1346 | if(NULL == ioc->res_map) { | 1344 | if(NULL == ioc->res_map) { |
1347 | panic("%s:%s() could not allocate resource map\n", __FILE__, | 1345 | panic("%s() could not allocate resource map\n", __FUNCTION__); |
1348 | __FUNCTION__); | ||
1349 | } | 1346 | } |
1350 | memset(ioc->res_map, 0, ioc->res_size); | 1347 | memset(ioc->res_map, 0, ioc->res_size); |
1351 | 1348 | ||
@@ -1366,44 +1363,58 @@ ccio_ioc_init(struct ioc *ioc) | |||
1366 | ** Initialize IOA hardware | 1363 | ** Initialize IOA hardware |
1367 | */ | 1364 | */ |
1368 | WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift, | 1365 | WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift, |
1369 | &ioc->ioc_hpa->io_chain_id_mask); | 1366 | &ioc->ioc_regs->io_chain_id_mask); |
1370 | 1367 | ||
1371 | WRITE_U32(virt_to_phys(ioc->pdir_base), | 1368 | WRITE_U32(virt_to_phys(ioc->pdir_base), |
1372 | &ioc->ioc_hpa->io_pdir_base); | 1369 | &ioc->ioc_regs->io_pdir_base); |
1373 | 1370 | ||
1374 | /* | 1371 | /* |
1375 | ** Go to "Virtual Mode" | 1372 | ** Go to "Virtual Mode" |
1376 | */ | 1373 | */ |
1377 | WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_hpa->io_control); | 1374 | WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_regs->io_control); |
1378 | 1375 | ||
1379 | /* | 1376 | /* |
1380 | ** Initialize all I/O TLB entries to 0 (Valid bit off). | 1377 | ** Initialize all I/O TLB entries to 0 (Valid bit off). |
1381 | */ | 1378 | */ |
1382 | WRITE_U32(0, &ioc->ioc_hpa->io_tlb_entry_m); | 1379 | WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_m); |
1383 | WRITE_U32(0, &ioc->ioc_hpa->io_tlb_entry_l); | 1380 | WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_l); |
1384 | 1381 | ||
1385 | for(i = 1 << CCIO_CHAINID_SHIFT; i ; i--) { | 1382 | for(i = 1 << CCIO_CHAINID_SHIFT; i ; i--) { |
1386 | WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)), | 1383 | WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)), |
1387 | &ioc->ioc_hpa->io_command); | 1384 | &ioc->ioc_regs->io_command); |
1388 | } | 1385 | } |
1389 | } | 1386 | } |
1390 | 1387 | ||
1391 | static void | 1388 | static void |
1392 | ccio_init_resource(struct resource *res, char *name, unsigned long ioaddr) | 1389 | ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr) |
1393 | { | 1390 | { |
1394 | int result; | 1391 | int result; |
1395 | 1392 | ||
1396 | res->parent = NULL; | 1393 | res->parent = NULL; |
1397 | res->flags = IORESOURCE_MEM; | 1394 | res->flags = IORESOURCE_MEM; |
1398 | res->start = (unsigned long)(signed) __raw_readl(ioaddr) << 16; | 1395 | /* |
1399 | res->end = (unsigned long)(signed) (__raw_readl(ioaddr + 4) << 16) - 1; | 1396 | * bracing ((signed) ...) are required for 64bit kernel because |
1397 | * we only want to sign extend the lower 16 bits of the register. | ||
1398 | * The upper 16-bits of range registers are hardcoded to 0xffff. | ||
1399 | */ | ||
1400 | res->start = (unsigned long)((signed) READ_U32(ioaddr) << 16); | ||
1401 | res->end = (unsigned long)((signed) (READ_U32(ioaddr + 4) << 16) - 1); | ||
1400 | res->name = name; | 1402 | res->name = name; |
1403 | /* | ||
1404 | * Check if this MMIO range is disable | ||
1405 | */ | ||
1401 | if (res->end + 1 == res->start) | 1406 | if (res->end + 1 == res->start) |
1402 | return; | 1407 | return; |
1403 | result = request_resource(&iomem_resource, res); | 1408 | |
1409 | /* On some platforms (e.g. K-Class), we have already registered | ||
1410 | * resources for devices reported by firmware. Some are children | ||
1411 | * of ccio. | ||
1412 | * "insert" ccio ranges in the mmio hierarchy (/proc/iomem). | ||
1413 | */ | ||
1414 | result = insert_resource(&iomem_resource, res); | ||
1404 | if (result < 0) { | 1415 | if (result < 0) { |
1405 | printk(KERN_ERR "%s: failed to claim CCIO bus address space (%08lx,%08lx)\n", | 1416 | printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n", |
1406 | __FILE__, res->start, res->end); | 1417 | __FUNCTION__, res->start, res->end); |
1407 | } | 1418 | } |
1408 | } | 1419 | } |
1409 | 1420 | ||
@@ -1414,9 +1425,8 @@ static void __init ccio_init_resources(struct ioc *ioc) | |||
1414 | 1425 | ||
1415 | sprintf(name, "GSC Bus [%d/]", ioc->hw_path); | 1426 | sprintf(name, "GSC Bus [%d/]", ioc->hw_path); |
1416 | 1427 | ||
1417 | ccio_init_resource(res, name, (unsigned long)&ioc->ioc_hpa->io_io_low); | 1428 | ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); |
1418 | ccio_init_resource(res + 1, name, | 1429 | ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); |
1419 | (unsigned long)&ioc->ioc_hpa->io_io_low_hv); | ||
1420 | } | 1430 | } |
1421 | 1431 | ||
1422 | static int new_ioc_area(struct resource *res, unsigned long size, | 1432 | static int new_ioc_area(struct resource *res, unsigned long size, |
@@ -1427,7 +1437,12 @@ static int new_ioc_area(struct resource *res, unsigned long size, | |||
1427 | 1437 | ||
1428 | res->start = (max - size + 1) &~ (align - 1); | 1438 | res->start = (max - size + 1) &~ (align - 1); |
1429 | res->end = res->start + size; | 1439 | res->end = res->start + size; |
1430 | if (!request_resource(&iomem_resource, res)) | 1440 | |
1441 | /* We might be trying to expand the MMIO range to include | ||
1442 | * a child device that has already registered it's MMIO space. | ||
1443 | * Use "insert" instead of request_resource(). | ||
1444 | */ | ||
1445 | if (!insert_resource(&iomem_resource, res)) | ||
1431 | return 0; | 1446 | return 0; |
1432 | 1447 | ||
1433 | return new_ioc_area(res, size, min, max - size, align); | 1448 | return new_ioc_area(res, size, min, max - size, align); |
@@ -1486,15 +1501,15 @@ int ccio_allocate_resource(const struct parisc_device *dev, | |||
1486 | 1501 | ||
1487 | if (!expand_ioc_area(parent, size, min, max, align)) { | 1502 | if (!expand_ioc_area(parent, size, min, max, align)) { |
1488 | __raw_writel(((parent->start)>>16) | 0xffff0000, | 1503 | __raw_writel(((parent->start)>>16) | 0xffff0000, |
1489 | (unsigned long)&(ioc->ioc_hpa->io_io_low)); | 1504 | &ioc->ioc_regs->io_io_low); |
1490 | __raw_writel(((parent->end)>>16) | 0xffff0000, | 1505 | __raw_writel(((parent->end)>>16) | 0xffff0000, |
1491 | (unsigned long)&(ioc->ioc_hpa->io_io_high)); | 1506 | &ioc->ioc_regs->io_io_high); |
1492 | } else if (!expand_ioc_area(parent + 1, size, min, max, align)) { | 1507 | } else if (!expand_ioc_area(parent + 1, size, min, max, align)) { |
1493 | parent++; | 1508 | parent++; |
1494 | __raw_writel(((parent->start)>>16) | 0xffff0000, | 1509 | __raw_writel(((parent->start)>>16) | 0xffff0000, |
1495 | (unsigned long)&(ioc->ioc_hpa->io_io_low_hv)); | 1510 | &ioc->ioc_regs->io_io_low_hv); |
1496 | __raw_writel(((parent->end)>>16) | 0xffff0000, | 1511 | __raw_writel(((parent->end)>>16) | 0xffff0000, |
1497 | (unsigned long)&(ioc->ioc_hpa->io_io_high_hv)); | 1512 | &ioc->ioc_regs->io_io_high_hv); |
1498 | } else { | 1513 | } else { |
1499 | return -EBUSY; | 1514 | return -EBUSY; |
1500 | } | 1515 | } |
@@ -1521,7 +1536,12 @@ int ccio_request_resource(const struct parisc_device *dev, | |||
1521 | return -EBUSY; | 1536 | return -EBUSY; |
1522 | } | 1537 | } |
1523 | 1538 | ||
1524 | return request_resource(parent, res); | 1539 | /* "transparent" bus bridges need to register MMIO resources |
1540 | * firmware assigned them. e.g. children of hppb.c (e.g. K-class) | ||
1541 | * registered their resources in the PDC "bus walk" (See | ||
1542 | * arch/parisc/kernel/inventory.c). | ||
1543 | */ | ||
1544 | return insert_resource(parent, res); | ||
1525 | } | 1545 | } |
1526 | 1546 | ||
1527 | /** | 1547 | /** |
@@ -1546,7 +1566,7 @@ static int ccio_probe(struct parisc_device *dev) | |||
1546 | 1566 | ||
1547 | ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn"; | 1567 | ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn"; |
1548 | 1568 | ||
1549 | printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, dev->hpa); | 1569 | printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, dev->hpa.start); |
1550 | 1570 | ||
1551 | for (i = 0; i < ioc_count; i++) { | 1571 | for (i = 0; i < ioc_count; i++) { |
1552 | ioc_p = &(*ioc_p)->next; | 1572 | ioc_p = &(*ioc_p)->next; |
@@ -1554,7 +1574,7 @@ static int ccio_probe(struct parisc_device *dev) | |||
1554 | *ioc_p = ioc; | 1574 | *ioc_p = ioc; |
1555 | 1575 | ||
1556 | ioc->hw_path = dev->hw_path; | 1576 | ioc->hw_path = dev->hw_path; |
1557 | ioc->ioc_hpa = (struct ioa_registers *)dev->hpa; | 1577 | ioc->ioc_regs = ioremap(dev->hpa.start, 4096); |
1558 | ccio_ioc_init(ioc); | 1578 | ccio_ioc_init(ioc); |
1559 | ccio_init_resources(ioc); | 1579 | ccio_init_resources(ioc); |
1560 | hppa_dma_ops = &ccio_ops; | 1580 | hppa_dma_ops = &ccio_ops; |
diff --git a/drivers/parisc/ccio-rm-dma.c b/drivers/parisc/ccio-rm-dma.c index 57e6385976e2..356b8357bccc 100644 --- a/drivers/parisc/ccio-rm-dma.c +++ b/drivers/parisc/ccio-rm-dma.c | |||
@@ -167,7 +167,7 @@ ccio_probe(struct parisc_device *dev) | |||
167 | { | 167 | { |
168 | printk(KERN_INFO "%s found %s at 0x%lx\n", MODULE_NAME, | 168 | printk(KERN_INFO "%s found %s at 0x%lx\n", MODULE_NAME, |
169 | dev->id.hversion == U2_BC_GSC ? "U2" : "UTurn", | 169 | dev->id.hversion == U2_BC_GSC ? "U2" : "UTurn", |
170 | dev->hpa); | 170 | dev->hpa.start); |
171 | 171 | ||
172 | /* | 172 | /* |
173 | ** FIXME - should check U2 registers to verify it's really running | 173 | ** FIXME - should check U2 registers to verify it's really running |
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 2f2dbef2c3b7..5ab75334c579 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c | |||
@@ -178,6 +178,8 @@ static int dino_cfg_read(struct pci_bus *bus, unsigned int devfn, int where, | |||
178 | void __iomem *base_addr = d->hba.base_addr; | 178 | void __iomem *base_addr = d->hba.base_addr; |
179 | unsigned long flags; | 179 | unsigned long flags; |
180 | 180 | ||
181 | DBG("%s: %p, %d, %d, %d\n", __FUNCTION__, base_addr, devfn, where, | ||
182 | size); | ||
181 | spin_lock_irqsave(&d->dinosaur_pen, flags); | 183 | spin_lock_irqsave(&d->dinosaur_pen, flags); |
182 | 184 | ||
183 | /* tell HW which CFG address */ | 185 | /* tell HW which CFG address */ |
@@ -211,6 +213,8 @@ static int dino_cfg_write(struct pci_bus *bus, unsigned int devfn, int where, | |||
211 | void __iomem *base_addr = d->hba.base_addr; | 213 | void __iomem *base_addr = d->hba.base_addr; |
212 | unsigned long flags; | 214 | unsigned long flags; |
213 | 215 | ||
216 | DBG("%s: %p, %d, %d, %d\n", __FUNCTION__, base_addr, devfn, where, | ||
217 | size); | ||
214 | spin_lock_irqsave(&d->dinosaur_pen, flags); | 218 | spin_lock_irqsave(&d->dinosaur_pen, flags); |
215 | 219 | ||
216 | /* avoid address stepping feature */ | 220 | /* avoid address stepping feature */ |
@@ -295,7 +299,7 @@ static void dino_disable_irq(unsigned int irq) | |||
295 | struct dino_device *dino_dev = irq_desc[irq].handler_data; | 299 | struct dino_device *dino_dev = irq_desc[irq].handler_data; |
296 | int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq); | 300 | int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq); |
297 | 301 | ||
298 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, irq_dev, irq); | 302 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq); |
299 | 303 | ||
300 | /* Clear the matching bit in the IMR register */ | 304 | /* Clear the matching bit in the IMR register */ |
301 | dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); | 305 | dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); |
@@ -308,7 +312,7 @@ static void dino_enable_irq(unsigned int irq) | |||
308 | int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq); | 312 | int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq); |
309 | u32 tmp; | 313 | u32 tmp; |
310 | 314 | ||
311 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, irq_dev, irq); | 315 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq); |
312 | 316 | ||
313 | /* | 317 | /* |
314 | ** clear pending IRQ bits | 318 | ** clear pending IRQ bits |
@@ -490,7 +494,7 @@ dino_card_setup(struct pci_bus *bus, void __iomem *base_addr) | |||
490 | if (res->start == F_EXTEND(0xf0000000UL | (i * _8MB))) | 494 | if (res->start == F_EXTEND(0xf0000000UL | (i * _8MB))) |
491 | break; | 495 | break; |
492 | } | 496 | } |
493 | DBG("DINO GSC WRITE i=%d, start=%lx, dino addr = %lx\n", | 497 | DBG("DINO GSC WRITE i=%d, start=%lx, dino addr = %p\n", |
494 | i, res->start, base_addr + DINO_IO_ADDR_EN); | 498 | i, res->start, base_addr + DINO_IO_ADDR_EN); |
495 | __raw_writel(1 << i, base_addr + DINO_IO_ADDR_EN); | 499 | __raw_writel(1 << i, base_addr + DINO_IO_ADDR_EN); |
496 | } | 500 | } |
@@ -683,6 +687,14 @@ static void __init | |||
683 | dino_card_init(struct dino_device *dino_dev) | 687 | dino_card_init(struct dino_device *dino_dev) |
684 | { | 688 | { |
685 | u32 brdg_feat = 0x00784e05; | 689 | u32 brdg_feat = 0x00784e05; |
690 | unsigned long status; | ||
691 | |||
692 | status = __raw_readl(dino_dev->hba.base_addr+DINO_IO_STATUS); | ||
693 | if (status & 0x0000ff80) { | ||
694 | __raw_writel(0x00000005, | ||
695 | dino_dev->hba.base_addr+DINO_IO_COMMAND); | ||
696 | udelay(1); | ||
697 | } | ||
686 | 698 | ||
687 | __raw_writel(0x00000000, dino_dev->hba.base_addr+DINO_GMASK); | 699 | __raw_writel(0x00000000, dino_dev->hba.base_addr+DINO_GMASK); |
688 | __raw_writel(0x00000001, dino_dev->hba.base_addr+DINO_IO_FBB_EN); | 700 | __raw_writel(0x00000001, dino_dev->hba.base_addr+DINO_IO_FBB_EN); |
@@ -902,15 +914,15 @@ void ccio_cujo20_fixup(struct parisc_device *dev, u32 iovp); | |||
902 | ** If so, initialize the chip appropriately (card-mode vs bridge mode). | 914 | ** If so, initialize the chip appropriately (card-mode vs bridge mode). |
903 | ** Much of the initialization is common though. | 915 | ** Much of the initialization is common though. |
904 | */ | 916 | */ |
905 | static int __init | 917 | static int __init dino_probe(struct parisc_device *dev) |
906 | dino_driver_callback(struct parisc_device *dev) | ||
907 | { | 918 | { |
908 | struct dino_device *dino_dev; // Dino specific control struct | 919 | struct dino_device *dino_dev; // Dino specific control struct |
909 | const char *version = "unknown"; | 920 | const char *version = "unknown"; |
910 | char *name; | 921 | char *name; |
911 | int is_cujo = 0; | 922 | int is_cujo = 0; |
912 | struct pci_bus *bus; | 923 | struct pci_bus *bus; |
913 | 924 | unsigned long hpa = dev->hpa.start; | |
925 | |||
914 | name = "Dino"; | 926 | name = "Dino"; |
915 | if (is_card_dino(&dev->id)) { | 927 | if (is_card_dino(&dev->id)) { |
916 | version = "3.x (card mode)"; | 928 | version = "3.x (card mode)"; |
@@ -928,11 +940,11 @@ dino_driver_callback(struct parisc_device *dev) | |||
928 | } | 940 | } |
929 | } | 941 | } |
930 | 942 | ||
931 | printk("%s version %s found at 0x%lx\n", name, version, dev->hpa); | 943 | printk("%s version %s found at 0x%lx\n", name, version, hpa); |
932 | 944 | ||
933 | if (!request_mem_region(dev->hpa, PAGE_SIZE, name)) { | 945 | if (!request_mem_region(hpa, PAGE_SIZE, name)) { |
934 | printk(KERN_ERR "DINO: Hey! Someone took my MMIO space (0x%ld)!\n", | 946 | printk(KERN_ERR "DINO: Hey! Someone took my MMIO space (0x%ld)!\n", |
935 | dev->hpa); | 947 | hpa); |
936 | return 1; | 948 | return 1; |
937 | } | 949 | } |
938 | 950 | ||
@@ -940,12 +952,12 @@ dino_driver_callback(struct parisc_device *dev) | |||
940 | if (is_cujo && dev->id.hversion_rev == 1) { | 952 | if (is_cujo && dev->id.hversion_rev == 1) { |
941 | #ifdef CONFIG_IOMMU_CCIO | 953 | #ifdef CONFIG_IOMMU_CCIO |
942 | printk(KERN_WARNING "Enabling Cujo 2.0 bug workaround\n"); | 954 | printk(KERN_WARNING "Enabling Cujo 2.0 bug workaround\n"); |
943 | if (dev->hpa == (unsigned long)CUJO_RAVEN_ADDR) { | 955 | if (hpa == (unsigned long)CUJO_RAVEN_ADDR) { |
944 | ccio_cujo20_fixup(dev, CUJO_RAVEN_BADPAGE); | 956 | ccio_cujo20_fixup(dev, CUJO_RAVEN_BADPAGE); |
945 | } else if (dev->hpa == (unsigned long)CUJO_FIREHAWK_ADDR) { | 957 | } else if (hpa == (unsigned long)CUJO_FIREHAWK_ADDR) { |
946 | ccio_cujo20_fixup(dev, CUJO_FIREHAWK_BADPAGE); | 958 | ccio_cujo20_fixup(dev, CUJO_FIREHAWK_BADPAGE); |
947 | } else { | 959 | } else { |
948 | printk("Don't recognise Cujo at address 0x%lx, not enabling workaround\n", dev->hpa); | 960 | printk("Don't recognise Cujo at address 0x%lx, not enabling workaround\n", hpa); |
949 | } | 961 | } |
950 | #endif | 962 | #endif |
951 | } else if (!is_cujo && !is_card_dino(&dev->id) && | 963 | } else if (!is_cujo && !is_card_dino(&dev->id) && |
@@ -970,7 +982,7 @@ dino_driver_callback(struct parisc_device *dev) | |||
970 | memset(dino_dev, 0, sizeof(struct dino_device)); | 982 | memset(dino_dev, 0, sizeof(struct dino_device)); |
971 | 983 | ||
972 | dino_dev->hba.dev = dev; | 984 | dino_dev->hba.dev = dev; |
973 | dino_dev->hba.base_addr = ioremap(dev->hpa, 4096); /* faster access */ | 985 | dino_dev->hba.base_addr = ioremap(hpa, 4096); |
974 | dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ | 986 | dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ |
975 | spin_lock_init(&dino_dev->dinosaur_pen); | 987 | spin_lock_init(&dino_dev->dinosaur_pen); |
976 | dino_dev->hba.iommu = ccio_get_iommu(dev); | 988 | dino_dev->hba.iommu = ccio_get_iommu(dev); |
@@ -1027,9 +1039,9 @@ static struct parisc_device_id dino_tbl[] = { | |||
1027 | }; | 1039 | }; |
1028 | 1040 | ||
1029 | static struct parisc_driver dino_driver = { | 1041 | static struct parisc_driver dino_driver = { |
1030 | .name = "Dino", | 1042 | .name = "dino", |
1031 | .id_table = dino_tbl, | 1043 | .id_table = dino_tbl, |
1032 | .probe = dino_driver_callback, | 1044 | .probe = dino_probe, |
1033 | }; | 1045 | }; |
1034 | 1046 | ||
1035 | /* | 1047 | /* |
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c index 043d47aea75b..6362bf99eff6 100644 --- a/drivers/parisc/eisa.c +++ b/drivers/parisc/eisa.c | |||
@@ -315,7 +315,7 @@ static int __devinit eisa_probe(struct parisc_device *dev) | |||
315 | char *name = is_mongoose(dev) ? "Mongoose" : "Wax"; | 315 | char *name = is_mongoose(dev) ? "Mongoose" : "Wax"; |
316 | 316 | ||
317 | printk(KERN_INFO "%s EISA Adapter found at 0x%08lx\n", | 317 | printk(KERN_INFO "%s EISA Adapter found at 0x%08lx\n", |
318 | name, dev->hpa); | 318 | name, dev->hpa.start); |
319 | 319 | ||
320 | eisa_dev.hba.dev = dev; | 320 | eisa_dev.hba.dev = dev; |
321 | eisa_dev.hba.iommu = ccio_get_iommu(dev); | 321 | eisa_dev.hba.iommu = ccio_get_iommu(dev); |
@@ -397,7 +397,7 @@ static struct parisc_device_id eisa_tbl[] = { | |||
397 | MODULE_DEVICE_TABLE(parisc, eisa_tbl); | 397 | MODULE_DEVICE_TABLE(parisc, eisa_tbl); |
398 | 398 | ||
399 | static struct parisc_driver eisa_driver = { | 399 | static struct parisc_driver eisa_driver = { |
400 | .name = "EISA Bus Adapter", | 400 | .name = "eisa_ba", |
401 | .id_table = eisa_tbl, | 401 | .id_table = eisa_tbl, |
402 | .probe = eisa_probe, | 402 | .probe = eisa_probe, |
403 | }; | 403 | }; |
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c index af5e02526a18..16d40f95978d 100644 --- a/drivers/parisc/gsc.c +++ b/drivers/parisc/gsc.c | |||
@@ -183,12 +183,20 @@ void gsc_asic_assign_irq(struct gsc_asic *asic, int local_irq, int *irqp) | |||
183 | *irqp = irq; | 183 | *irqp = irq; |
184 | } | 184 | } |
185 | 185 | ||
186 | static struct device *next_device(struct klist_iter *i) | ||
187 | { | ||
188 | struct klist_node * n = klist_next(i); | ||
189 | return n ? container_of(n, struct device, knode_parent) : NULL; | ||
190 | } | ||
191 | |||
186 | void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, | 192 | void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, |
187 | void (*choose_irq)(struct parisc_device *, void *)) | 193 | void (*choose_irq)(struct parisc_device *, void *)) |
188 | { | 194 | { |
189 | struct device *dev; | 195 | struct device *dev; |
196 | struct klist_iter i; | ||
190 | 197 | ||
191 | list_for_each_entry(dev, &parent->dev.children, node) { | 198 | klist_iter_init(&parent->dev.klist_children, &i); |
199 | while ((dev = next_device(&i))) { | ||
192 | struct parisc_device *padev = to_parisc_device(dev); | 200 | struct parisc_device *padev = to_parisc_device(dev); |
193 | 201 | ||
194 | /* work-around for 715/64 and others which have parent | 202 | /* work-around for 715/64 and others which have parent |
@@ -197,6 +205,7 @@ void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, | |||
197 | return gsc_fixup_irqs(padev, ctrl, choose_irq); | 205 | return gsc_fixup_irqs(padev, ctrl, choose_irq); |
198 | choose_irq(padev, ctrl); | 206 | choose_irq(padev, ctrl); |
199 | } | 207 | } |
208 | klist_iter_exit(&i); | ||
200 | } | 209 | } |
201 | 210 | ||
202 | int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic) | 211 | int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic) |
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c index e869c6020370..5edf93f80757 100644 --- a/drivers/parisc/hppb.c +++ b/drivers/parisc/hppb.c | |||
@@ -68,14 +68,14 @@ static int hppb_probe(struct parisc_device *dev) | |||
68 | memset(card->next, '\0', sizeof(struct hppb_card)); | 68 | memset(card->next, '\0', sizeof(struct hppb_card)); |
69 | card = card->next; | 69 | card = card->next; |
70 | } | 70 | } |
71 | printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa); | 71 | printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start); |
72 | 72 | ||
73 | card->hpa = dev->hpa; | 73 | card->hpa = dev->hpa.start; |
74 | card->mmio_region.name = "HP-PB Bus"; | 74 | card->mmio_region.name = "HP-PB Bus"; |
75 | card->mmio_region.flags = IORESOURCE_MEM; | 75 | card->mmio_region.flags = IORESOURCE_MEM; |
76 | 76 | ||
77 | card->mmio_region.start = __raw_readl(dev->hpa + IO_IO_LOW); | 77 | card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW); |
78 | card->mmio_region.end = __raw_readl(dev->hpa + IO_IO_HIGH) - 1; | 78 | card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1; |
79 | 79 | ||
80 | status = ccio_request_resource(dev, &card->mmio_region); | 80 | status = ccio_request_resource(dev, &card->mmio_region); |
81 | if(status < 0) { | 81 | if(status < 0) { |
@@ -93,7 +93,7 @@ static struct parisc_device_id hppb_tbl[] = { | |||
93 | }; | 93 | }; |
94 | 94 | ||
95 | static struct parisc_driver hppb_driver = { | 95 | static struct parisc_driver hppb_driver = { |
96 | .name = "Gecko Boa", | 96 | .name = "gecko_boa", |
97 | .id_table = hppb_tbl, | 97 | .id_table = hppb_tbl, |
98 | .probe = hppb_probe, | 98 | .probe = hppb_probe, |
99 | }; | 99 | }; |
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 7a57c1b8373f..a39fbfef789a 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c | |||
@@ -244,7 +244,7 @@ static struct irt_entry *iosapic_alloc_irt(int num_entries) | |||
244 | * 4-byte alignment on 32-bit kernels | 244 | * 4-byte alignment on 32-bit kernels |
245 | */ | 245 | */ |
246 | a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL); | 246 | a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL); |
247 | a = (a + 7) & ~7; | 247 | a = (a + 7UL) & ~7UL; |
248 | return (struct irt_entry *)a; | 248 | return (struct irt_entry *)a; |
249 | } | 249 | } |
250 | 250 | ||
diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c index cb84a4e84a2f..a8c20396ffbe 100644 --- a/drivers/parisc/lasi.c +++ b/drivers/parisc/lasi.c | |||
@@ -175,7 +175,7 @@ lasi_init_chip(struct parisc_device *dev) | |||
175 | return -ENOMEM; | 175 | return -ENOMEM; |
176 | 176 | ||
177 | lasi->name = "Lasi"; | 177 | lasi->name = "Lasi"; |
178 | lasi->hpa = dev->hpa; | 178 | lasi->hpa = dev->hpa.start; |
179 | 179 | ||
180 | /* Check the 4-bit (yes, only 4) version register */ | 180 | /* Check the 4-bit (yes, only 4) version register */ |
181 | lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf; | 181 | lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf; |
@@ -233,7 +233,7 @@ static struct parisc_device_id lasi_tbl[] = { | |||
233 | }; | 233 | }; |
234 | 234 | ||
235 | struct parisc_driver lasi_driver = { | 235 | struct parisc_driver lasi_driver = { |
236 | .name = "Lasi", | 236 | .name = "lasi", |
237 | .id_table = lasi_tbl, | 237 | .id_table = lasi_tbl, |
238 | .probe = lasi_init_chip, | 238 | .probe = lasi_init_chip, |
239 | }; | 239 | }; |
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index 7fdd80b7eb47..5e495dcbc58a 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c | |||
@@ -1288,7 +1288,7 @@ lba_legacy_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev) | |||
1288 | ** Adjust "window" for this rope. | 1288 | ** Adjust "window" for this rope. |
1289 | */ | 1289 | */ |
1290 | rsize /= ROPES_PER_IOC; | 1290 | rsize /= ROPES_PER_IOC; |
1291 | r->start += (rsize + 1) * LBA_NUM(pa_dev->hpa); | 1291 | r->start += (rsize + 1) * LBA_NUM(pa_dev->hpa.start); |
1292 | r->end = r->start + rsize; | 1292 | r->end = r->start + rsize; |
1293 | } else { | 1293 | } else { |
1294 | r->end = r->start = 0; /* Not enabled. */ | 1294 | r->end = r->start = 0; /* Not enabled. */ |
@@ -1458,7 +1458,7 @@ lba_driver_probe(struct parisc_device *dev) | |||
1458 | u32 func_class; | 1458 | u32 func_class; |
1459 | void *tmp_obj; | 1459 | void *tmp_obj; |
1460 | char *version; | 1460 | char *version; |
1461 | void __iomem *addr = ioremap(dev->hpa, 4096); | 1461 | void __iomem *addr = ioremap(dev->hpa.start, 4096); |
1462 | 1462 | ||
1463 | /* Read HW Rev First */ | 1463 | /* Read HW Rev First */ |
1464 | func_class = READ_REG32(addr + LBA_FCLASS); | 1464 | func_class = READ_REG32(addr + LBA_FCLASS); |
@@ -1476,7 +1476,7 @@ lba_driver_probe(struct parisc_device *dev) | |||
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n", | 1478 | printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n", |
1479 | MODULE_NAME, version, func_class & 0xf, dev->hpa); | 1479 | MODULE_NAME, version, func_class & 0xf, dev->hpa.start); |
1480 | 1480 | ||
1481 | if (func_class < 2) { | 1481 | if (func_class < 2) { |
1482 | printk(KERN_WARNING "Can't support LBA older than " | 1482 | printk(KERN_WARNING "Can't support LBA older than " |
@@ -1503,17 +1503,17 @@ lba_driver_probe(struct parisc_device *dev) | |||
1503 | * but for the mask for func_class. | 1503 | * but for the mask for func_class. |
1504 | */ | 1504 | */ |
1505 | printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n", | 1505 | printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n", |
1506 | MODULE_NAME, version, func_class & 0xff, dev->hpa); | 1506 | MODULE_NAME, version, func_class & 0xff, dev->hpa.start); |
1507 | cfg_ops = &mercury_cfg_ops; | 1507 | cfg_ops = &mercury_cfg_ops; |
1508 | } else { | 1508 | } else { |
1509 | printk(KERN_ERR "Unknown LBA found at 0x%lx\n", dev->hpa); | 1509 | printk(KERN_ERR "Unknown LBA found at 0x%lx\n", dev->hpa.start); |
1510 | return -ENODEV; | 1510 | return -ENODEV; |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | /* | 1513 | /* |
1514 | ** Tell I/O SAPIC driver we have a IRQ handler/region. | 1514 | ** Tell I/O SAPIC driver we have a IRQ handler/region. |
1515 | */ | 1515 | */ |
1516 | tmp_obj = iosapic_register(dev->hpa + LBA_IOSAPIC_BASE); | 1516 | tmp_obj = iosapic_register(dev->hpa.start + LBA_IOSAPIC_BASE); |
1517 | 1517 | ||
1518 | /* NOTE: PCI devices (e.g. 103c:1005 graphics card) which don't | 1518 | /* NOTE: PCI devices (e.g. 103c:1005 graphics card) which don't |
1519 | ** have an IRT entry will get NULL back from iosapic code. | 1519 | ** have an IRT entry will get NULL back from iosapic code. |
@@ -1635,7 +1635,7 @@ void __init lba_init(void) | |||
1635 | */ | 1635 | */ |
1636 | void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask) | 1636 | void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask) |
1637 | { | 1637 | { |
1638 | void __iomem * base_addr = ioremap(lba->hpa, 4096); | 1638 | void __iomem * base_addr = ioremap(lba->hpa.start, 4096); |
1639 | 1639 | ||
1640 | imask <<= 2; /* adjust for hints - 2 more bits */ | 1640 | imask <<= 2; /* adjust for hints - 2 more bits */ |
1641 | 1641 | ||
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 286902298e33..95bd07b8b61b 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -18,6 +18,9 @@ | |||
18 | * Changes: | 18 | * Changes: |
19 | * - Audit copy_from_user in led_proc_write. | 19 | * - Audit copy_from_user in led_proc_write. |
20 | * Daniele Bellucci <bellucda@tiscali.it> | 20 | * Daniele Bellucci <bellucda@tiscali.it> |
21 | * - Switch from using a tasklet to a work queue, so the led_LCD_driver | ||
22 | * can sleep. | ||
23 | * David Pye <dmp@davidmpye.dyndns.org> | ||
21 | */ | 24 | */ |
22 | 25 | ||
23 | #include <linux/config.h> | 26 | #include <linux/config.h> |
@@ -37,6 +40,7 @@ | |||
37 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
38 | #include <linux/ctype.h> | 41 | #include <linux/ctype.h> |
39 | #include <linux/blkdev.h> | 42 | #include <linux/blkdev.h> |
43 | #include <linux/workqueue.h> | ||
40 | #include <linux/rcupdate.h> | 44 | #include <linux/rcupdate.h> |
41 | #include <asm/io.h> | 45 | #include <asm/io.h> |
42 | #include <asm/processor.h> | 46 | #include <asm/processor.h> |
@@ -47,25 +51,30 @@ | |||
47 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
48 | 52 | ||
49 | /* The control of the LEDs and LCDs on PARISC-machines have to be done | 53 | /* The control of the LEDs and LCDs on PARISC-machines have to be done |
50 | completely in software. The necessary calculations are done in a tasklet | 54 | completely in software. The necessary calculations are done in a work queue |
51 | which is scheduled at every timer interrupt and since the calculations | 55 | task which is scheduled regularly, and since the calculations may consume a |
52 | may consume relatively much CPU-time some of the calculations can be | 56 | relatively large amount of CPU time, some of the calculations can be |
53 | turned off with the following variables (controlled via procfs) */ | 57 | turned off with the following variables (controlled via procfs) */ |
54 | 58 | ||
55 | static int led_type = -1; | 59 | static int led_type = -1; |
56 | static int led_heartbeat = 1; | 60 | static unsigned char lastleds; /* LED state from most recent update */ |
57 | static int led_diskio = 1; | 61 | static unsigned int led_heartbeat = 1; |
58 | static int led_lanrxtx = 1; | 62 | static unsigned int led_diskio = 1; |
63 | static unsigned int led_lanrxtx = 1; | ||
59 | static char lcd_text[32]; | 64 | static char lcd_text[32]; |
60 | static char lcd_text_default[32]; | 65 | static char lcd_text_default[32]; |
61 | 66 | ||
67 | |||
68 | static struct workqueue_struct *led_wq; | ||
69 | static void led_work_func(void *); | ||
70 | static DECLARE_WORK(led_task, led_work_func, NULL); | ||
71 | |||
62 | #if 0 | 72 | #if 0 |
63 | #define DPRINTK(x) printk x | 73 | #define DPRINTK(x) printk x |
64 | #else | 74 | #else |
65 | #define DPRINTK(x) | 75 | #define DPRINTK(x) |
66 | #endif | 76 | #endif |
67 | 77 | ||
68 | |||
69 | struct lcd_block { | 78 | struct lcd_block { |
70 | unsigned char command; /* stores the command byte */ | 79 | unsigned char command; /* stores the command byte */ |
71 | unsigned char on; /* value for turning LED on */ | 80 | unsigned char on; /* value for turning LED on */ |
@@ -116,12 +125,27 @@ lcd_info __attribute__((aligned(8))) = | |||
116 | #define LCD_DATA_REG lcd_info.lcd_data_reg_addr | 125 | #define LCD_DATA_REG lcd_info.lcd_data_reg_addr |
117 | #define LED_DATA_REG lcd_info.lcd_cmd_reg_addr /* LASI & ASP only */ | 126 | #define LED_DATA_REG lcd_info.lcd_cmd_reg_addr /* LASI & ASP only */ |
118 | 127 | ||
128 | #define LED_HASLCD 1 | ||
129 | #define LED_NOLCD 0 | ||
130 | |||
131 | /* The workqueue must be created at init-time */ | ||
132 | static int start_task(void) | ||
133 | { | ||
134 | /* Display the default text now */ | ||
135 | if (led_type == LED_HASLCD) lcd_print( lcd_text_default ); | ||
136 | |||
137 | /* Create the work queue and queue the LED task */ | ||
138 | led_wq = create_singlethread_workqueue("led_wq"); | ||
139 | queue_work(led_wq, &led_task); | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | device_initcall(start_task); | ||
119 | 145 | ||
120 | /* ptr to LCD/LED-specific function */ | 146 | /* ptr to LCD/LED-specific function */ |
121 | static void (*led_func_ptr) (unsigned char); | 147 | static void (*led_func_ptr) (unsigned char); |
122 | 148 | ||
123 | #define LED_HASLCD 1 | ||
124 | #define LED_NOLCD 0 | ||
125 | #ifdef CONFIG_PROC_FS | 149 | #ifdef CONFIG_PROC_FS |
126 | static int led_proc_read(char *page, char **start, off_t off, int count, | 150 | static int led_proc_read(char *page, char **start, off_t off, int count, |
127 | int *eof, void *data) | 151 | int *eof, void *data) |
@@ -286,52 +310,35 @@ static void led_LASI_driver(unsigned char leds) | |||
286 | /* | 310 | /* |
287 | ** | 311 | ** |
288 | ** led_LCD_driver() | 312 | ** led_LCD_driver() |
289 | ** | ||
290 | ** The logic of the LCD driver is, that we write at every scheduled call | ||
291 | ** only to one of LCD_CMD_REG _or_ LCD_DATA_REG - registers. | ||
292 | ** That way we don't need to let this tasklet busywait for min_cmd_delay | ||
293 | ** milliseconds. | ||
294 | ** | ||
295 | ** TODO: check the value of "min_cmd_delay" against the value of HZ. | ||
296 | ** | 313 | ** |
297 | */ | 314 | */ |
298 | static void led_LCD_driver(unsigned char leds) | 315 | static void led_LCD_driver(unsigned char leds) |
299 | { | 316 | { |
300 | static int last_index; /* 0:heartbeat, 1:disk, 2:lan_in, 3:lan_out */ | 317 | static int i; |
301 | static int last_was_cmd;/* 0: CMD was written last, 1: DATA was last */ | 318 | static unsigned char mask[4] = { LED_HEARTBEAT, LED_DISK_IO, |
302 | struct lcd_block *block_ptr; | 319 | LED_LAN_RCV, LED_LAN_TX }; |
303 | int value; | ||
304 | |||
305 | switch (last_index) { | ||
306 | case 0: block_ptr = &lcd_info.heartbeat; | ||
307 | value = leds & LED_HEARTBEAT; | ||
308 | break; | ||
309 | case 1: block_ptr = &lcd_info.disk_io; | ||
310 | value = leds & LED_DISK_IO; | ||
311 | break; | ||
312 | case 2: block_ptr = &lcd_info.lan_rcv; | ||
313 | value = leds & LED_LAN_RCV; | ||
314 | break; | ||
315 | case 3: block_ptr = &lcd_info.lan_tx; | ||
316 | value = leds & LED_LAN_TX; | ||
317 | break; | ||
318 | default: /* should never happen: */ | ||
319 | return; | ||
320 | } | ||
321 | |||
322 | if (last_was_cmd) { | ||
323 | /* write the value to the LCD data port */ | ||
324 | gsc_writeb( value ? block_ptr->on : block_ptr->off, LCD_DATA_REG ); | ||
325 | } else { | ||
326 | /* write the command-byte to the LCD command register */ | ||
327 | gsc_writeb( block_ptr->command, LCD_CMD_REG ); | ||
328 | } | ||
329 | 320 | ||
330 | /* now update the vars for the next interrupt iteration */ | 321 | static struct lcd_block * blockp[4] = { |
331 | if (++last_was_cmd == 2) { /* switch between cmd & data */ | 322 | &lcd_info.heartbeat, |
332 | last_was_cmd = 0; | 323 | &lcd_info.disk_io, |
333 | if (++last_index == 4) | 324 | &lcd_info.lan_rcv, |
334 | last_index = 0; /* switch back to heartbeat index */ | 325 | &lcd_info.lan_tx |
326 | }; | ||
327 | |||
328 | /* Convert min_cmd_delay to milliseconds */ | ||
329 | unsigned int msec_cmd_delay = 1 + (lcd_info.min_cmd_delay / 1000); | ||
330 | |||
331 | for (i=0; i<4; ++i) | ||
332 | { | ||
333 | if ((leds & mask[i]) != (lastleds & mask[i])) | ||
334 | { | ||
335 | gsc_writeb( blockp[i]->command, LCD_CMD_REG ); | ||
336 | msleep(msec_cmd_delay); | ||
337 | |||
338 | gsc_writeb( leds & mask[i] ? blockp[i]->on : | ||
339 | blockp[i]->off, LCD_DATA_REG ); | ||
340 | msleep(msec_cmd_delay); | ||
341 | } | ||
335 | } | 342 | } |
336 | } | 343 | } |
337 | 344 | ||
@@ -356,7 +363,7 @@ static __inline__ int led_get_net_activity(void) | |||
356 | 363 | ||
357 | rx_total = tx_total = 0; | 364 | rx_total = tx_total = 0; |
358 | 365 | ||
359 | /* we are running as tasklet, so locking dev_base | 366 | /* we are running as a workqueue task, so locking dev_base |
360 | * for reading should be OK */ | 367 | * for reading should be OK */ |
361 | read_lock(&dev_base_lock); | 368 | read_lock(&dev_base_lock); |
362 | rcu_read_lock(); | 369 | rcu_read_lock(); |
@@ -405,7 +412,7 @@ static __inline__ int led_get_diskio_activity(void) | |||
405 | static unsigned long last_pgpgin, last_pgpgout; | 412 | static unsigned long last_pgpgin, last_pgpgout; |
406 | struct page_state pgstat; | 413 | struct page_state pgstat; |
407 | int changed; | 414 | int changed; |
408 | 415 | ||
409 | get_full_page_state(&pgstat); /* get no of sectors in & out */ | 416 | get_full_page_state(&pgstat); /* get no of sectors in & out */ |
410 | 417 | ||
411 | /* Just use a very simple calculation here. Do not care about overflow, | 418 | /* Just use a very simple calculation here. Do not care about overflow, |
@@ -413,86 +420,70 @@ static __inline__ int led_get_diskio_activity(void) | |||
413 | changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout); | 420 | changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout); |
414 | last_pgpgin = pgstat.pgpgin; | 421 | last_pgpgin = pgstat.pgpgin; |
415 | last_pgpgout = pgstat.pgpgout; | 422 | last_pgpgout = pgstat.pgpgout; |
416 | 423 | ||
417 | return (changed ? LED_DISK_IO : 0); | 424 | return (changed ? LED_DISK_IO : 0); |
418 | } | 425 | } |
419 | 426 | ||
420 | 427 | ||
421 | 428 | ||
422 | /* | 429 | /* |
423 | ** led_tasklet_func() | 430 | ** led_work_func() |
424 | ** | 431 | ** |
425 | ** is scheduled at every timer interrupt from time.c and | 432 | ** manages when and which chassis LCD/LED gets updated |
426 | ** updates the chassis LCD/LED | ||
427 | 433 | ||
428 | TODO: | 434 | TODO: |
429 | - display load average (older machines like 715/64 have 4 "free" LED's for that) | 435 | - display load average (older machines like 715/64 have 4 "free" LED's for that) |
430 | - optimizations | 436 | - optimizations |
431 | */ | 437 | */ |
432 | 438 | ||
433 | #define HEARTBEAT_LEN (HZ*6/100) | 439 | #define HEARTBEAT_LEN (HZ*10/100) |
434 | #define HEARTBEAT_2ND_RANGE_START (HZ*22/100) | 440 | #define HEARTBEAT_2ND_RANGE_START (HZ*28/100) |
435 | #define HEARTBEAT_2ND_RANGE_END (HEARTBEAT_2ND_RANGE_START + HEARTBEAT_LEN) | 441 | #define HEARTBEAT_2ND_RANGE_END (HEARTBEAT_2ND_RANGE_START + HEARTBEAT_LEN) |
436 | 442 | ||
437 | #define NORMALIZED_COUNT(count) (count/(HZ/100)) | 443 | #define LED_UPDATE_INTERVAL (1 + (HZ*19/1000)) |
438 | 444 | ||
439 | static void led_tasklet_func(unsigned long unused) | 445 | static void led_work_func (void *unused) |
440 | { | 446 | { |
441 | static unsigned char lastleds; | 447 | static unsigned long last_jiffies; |
442 | unsigned char currentleds; /* stores current value of the LEDs */ | ||
443 | static unsigned long count; /* static incremented value, not wrapped */ | ||
444 | static unsigned long count_HZ; /* counter in range 0..HZ */ | 448 | static unsigned long count_HZ; /* counter in range 0..HZ */ |
449 | unsigned char currentleds = 0; /* stores current value of the LEDs */ | ||
445 | 450 | ||
446 | /* exit if not initialized */ | 451 | /* exit if not initialized */ |
447 | if (!led_func_ptr) | 452 | if (!led_func_ptr) |
448 | return; | 453 | return; |
449 | 454 | ||
450 | /* increment the local counters */ | 455 | /* increment the heartbeat timekeeper */ |
451 | ++count; | 456 | count_HZ += jiffies - last_jiffies; |
452 | if (++count_HZ == HZ) | 457 | last_jiffies = jiffies; |
458 | if (count_HZ >= HZ) | ||
453 | count_HZ = 0; | 459 | count_HZ = 0; |
454 | 460 | ||
455 | currentleds = lastleds; | 461 | if (likely(led_heartbeat)) |
456 | |||
457 | if (led_heartbeat) | ||
458 | { | ||
459 | /* flash heartbeat-LED like a real heart (2 x short then a long delay) */ | ||
460 | if (count_HZ<HEARTBEAT_LEN || | ||
461 | (count_HZ>=HEARTBEAT_2ND_RANGE_START && count_HZ<HEARTBEAT_2ND_RANGE_END)) | ||
462 | currentleds |= LED_HEARTBEAT; | ||
463 | else | ||
464 | currentleds &= ~LED_HEARTBEAT; | ||
465 | } | ||
466 | |||
467 | /* look for network activity and flash LEDs respectively */ | ||
468 | if (led_lanrxtx && ((NORMALIZED_COUNT(count)+(8/2)) & 7) == 0) | ||
469 | { | 462 | { |
470 | currentleds &= ~(LED_LAN_RCV | LED_LAN_TX); | 463 | /* flash heartbeat-LED like a real heart |
471 | currentleds |= led_get_net_activity(); | 464 | * (2 x short then a long delay) |
465 | */ | ||
466 | if (count_HZ < HEARTBEAT_LEN || | ||
467 | (count_HZ >= HEARTBEAT_2ND_RANGE_START && | ||
468 | count_HZ < HEARTBEAT_2ND_RANGE_END)) | ||
469 | currentleds |= LED_HEARTBEAT; | ||
472 | } | 470 | } |
473 | 471 | ||
474 | /* avoid to calculate diskio-stats at same irq as netio-stats */ | 472 | if (likely(led_lanrxtx)) currentleds |= led_get_net_activity(); |
475 | if (led_diskio && (NORMALIZED_COUNT(count) & 7) == 0) | 473 | if (likely(led_diskio)) currentleds |= led_get_diskio_activity(); |
476 | { | ||
477 | currentleds &= ~LED_DISK_IO; | ||
478 | currentleds |= led_get_diskio_activity(); | ||
479 | } | ||
480 | 474 | ||
481 | /* blink all LEDs twice a second if we got an Oops (HPMC) */ | 475 | /* blink all LEDs twice a second if we got an Oops (HPMC) */ |
482 | if (oops_in_progress) { | 476 | if (unlikely(oops_in_progress)) |
483 | currentleds = (count_HZ<=(HZ/2)) ? 0 : 0xff; | 477 | currentleds = (count_HZ<=(HZ/2)) ? 0 : 0xff; |
484 | } | ||
485 | |||
486 | /* update the LCD/LEDs */ | ||
487 | if (currentleds != lastleds) { | ||
488 | led_func_ptr(currentleds); | ||
489 | lastleds = currentleds; | ||
490 | } | ||
491 | } | ||
492 | 478 | ||
493 | /* main led tasklet struct (scheduled from time.c) */ | 479 | if (currentleds != lastleds) |
494 | DECLARE_TASKLET_DISABLED(led_tasklet, led_tasklet_func, 0); | 480 | { |
481 | led_func_ptr(currentleds); /* Update the LCD/LEDs */ | ||
482 | lastleds = currentleds; | ||
483 | } | ||
495 | 484 | ||
485 | queue_delayed_work(led_wq, &led_task, LED_UPDATE_INTERVAL); | ||
486 | } | ||
496 | 487 | ||
497 | /* | 488 | /* |
498 | ** led_halt() | 489 | ** led_halt() |
@@ -522,9 +513,13 @@ static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) | |||
522 | default: return NOTIFY_DONE; | 513 | default: return NOTIFY_DONE; |
523 | } | 514 | } |
524 | 515 | ||
525 | /* completely stop the LED/LCD tasklet */ | 516 | /* Cancel the work item and delete the queue */ |
526 | tasklet_disable(&led_tasklet); | 517 | if (led_wq) { |
527 | 518 | cancel_rearming_delayed_workqueue(led_wq, &led_task); | |
519 | destroy_workqueue(led_wq); | ||
520 | led_wq = NULL; | ||
521 | } | ||
522 | |||
528 | if (lcd_info.model == DISPLAY_MODEL_LCD) | 523 | if (lcd_info.model == DISPLAY_MODEL_LCD) |
529 | lcd_print(txt); | 524 | lcd_print(txt); |
530 | else | 525 | else |
@@ -559,7 +554,6 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d | |||
559 | printk(KERN_INFO "LCD display at %lx,%lx registered\n", | 554 | printk(KERN_INFO "LCD display at %lx,%lx registered\n", |
560 | LCD_CMD_REG , LCD_DATA_REG); | 555 | LCD_CMD_REG , LCD_DATA_REG); |
561 | led_func_ptr = led_LCD_driver; | 556 | led_func_ptr = led_LCD_driver; |
562 | lcd_print( lcd_text_default ); | ||
563 | led_type = LED_HASLCD; | 557 | led_type = LED_HASLCD; |
564 | break; | 558 | break; |
565 | 559 | ||
@@ -589,9 +583,11 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d | |||
589 | initialized++; | 583 | initialized++; |
590 | register_reboot_notifier(&led_notifier); | 584 | register_reboot_notifier(&led_notifier); |
591 | 585 | ||
592 | /* start the led tasklet for the first time */ | 586 | /* Ensure the work is queued */ |
593 | tasklet_enable(&led_tasklet); | 587 | if (led_wq) { |
594 | 588 | queue_work(led_wq, &led_task); | |
589 | } | ||
590 | |||
595 | return 0; | 591 | return 0; |
596 | } | 592 | } |
597 | 593 | ||
@@ -626,8 +622,8 @@ void __init register_led_regions(void) | |||
626 | ** lcd_print() | 622 | ** lcd_print() |
627 | ** | 623 | ** |
628 | ** Displays the given string on the LCD-Display of newer machines. | 624 | ** Displays the given string on the LCD-Display of newer machines. |
629 | ** lcd_print() disables the timer-based led tasklet during its | 625 | ** lcd_print() disables/enables the timer-based led work queue to |
630 | ** execution and enables it afterwards again. | 626 | ** avoid a race condition while writing the CMD/DATA register pair. |
631 | ** | 627 | ** |
632 | */ | 628 | */ |
633 | int lcd_print( char *str ) | 629 | int lcd_print( char *str ) |
@@ -637,12 +633,13 @@ int lcd_print( char *str ) | |||
637 | if (!led_func_ptr || lcd_info.model != DISPLAY_MODEL_LCD) | 633 | if (!led_func_ptr || lcd_info.model != DISPLAY_MODEL_LCD) |
638 | return 0; | 634 | return 0; |
639 | 635 | ||
640 | /* temporarily disable the led tasklet */ | 636 | /* temporarily disable the led work task */ |
641 | tasklet_disable(&led_tasklet); | 637 | if (led_wq) |
638 | cancel_rearming_delayed_workqueue(led_wq, &led_task); | ||
642 | 639 | ||
643 | /* copy display string to buffer for procfs */ | 640 | /* copy display string to buffer for procfs */ |
644 | strlcpy(lcd_text, str, sizeof(lcd_text)); | 641 | strlcpy(lcd_text, str, sizeof(lcd_text)); |
645 | 642 | ||
646 | /* Set LCD Cursor to 1st character */ | 643 | /* Set LCD Cursor to 1st character */ |
647 | gsc_writeb(lcd_info.reset_cmd1, LCD_CMD_REG); | 644 | gsc_writeb(lcd_info.reset_cmd1, LCD_CMD_REG); |
648 | udelay(lcd_info.min_cmd_delay); | 645 | udelay(lcd_info.min_cmd_delay); |
@@ -656,8 +653,10 @@ int lcd_print( char *str ) | |||
656 | udelay(lcd_info.min_cmd_delay); | 653 | udelay(lcd_info.min_cmd_delay); |
657 | } | 654 | } |
658 | 655 | ||
659 | /* re-enable the led tasklet */ | 656 | /* re-queue the work */ |
660 | tasklet_enable(&led_tasklet); | 657 | if (led_wq) { |
658 | queue_work(led_wq, &led_task); | ||
659 | } | ||
661 | 660 | ||
662 | return lcd_info.lcd_width; | 661 | return lcd_info.lcd_width; |
663 | } | 662 | } |
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index 67c8f3b44848..273a74179720 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c | |||
@@ -536,7 +536,7 @@ pdcs_info_read(struct subsystem *entry, char *buf) | |||
536 | 536 | ||
537 | out += sprintf(out, "Memory tested: "); | 537 | out += sprintf(out, "Memory tested: "); |
538 | if ((result & 0x0F) < 0x0E) | 538 | if ((result & 0x0F) < 0x0E) |
539 | out += sprintf(out, "%.3f MB", 0.256*(1<<(result & 0x0F))); | 539 | out += sprintf(out, "%d kB", (1<<(result & 0x0F))*256); |
540 | else | 540 | else |
541 | out += sprintf(out, "All"); | 541 | out += sprintf(out, "All"); |
542 | out += sprintf(out, "\n"); | 542 | out += sprintf(out, "\n"); |
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c index bd8b3e5a5cd7..c85653f315aa 100644 --- a/drivers/parisc/sba_iommu.c +++ b/drivers/parisc/sba_iommu.c | |||
@@ -91,8 +91,8 @@ extern struct proc_dir_entry * proc_mckinley_root; | |||
91 | #define DBG_RES(x...) | 91 | #define DBG_RES(x...) |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | #if defined(__LP64__) && !defined(CONFIG_PDC_NARROW) | 94 | #if defined(CONFIG_64BIT) |
95 | /* "low end" PA8800 machines use ZX1 chipset */ | 95 | /* "low end" PA8800 machines use ZX1 chipset: PAT PDC and only run 64-bit */ |
96 | #define ZX1_SUPPORT | 96 | #define ZX1_SUPPORT |
97 | #endif | 97 | #endif |
98 | 98 | ||
@@ -231,7 +231,7 @@ struct ioc { | |||
231 | spinlock_t res_lock; | 231 | spinlock_t res_lock; |
232 | unsigned int res_bitshift; /* from the LEFT! */ | 232 | unsigned int res_bitshift; /* from the LEFT! */ |
233 | unsigned int res_size; /* size of resource map in bytes */ | 233 | unsigned int res_size; /* size of resource map in bytes */ |
234 | #if SBA_HINT_SUPPORT | 234 | #ifdef SBA_HINT_SUPPORT |
235 | /* FIXME : DMA HINTs not used */ | 235 | /* FIXME : DMA HINTs not used */ |
236 | unsigned long hint_mask_pdir; /* bits used for DMA hints */ | 236 | unsigned long hint_mask_pdir; /* bits used for DMA hints */ |
237 | unsigned int hint_shift_pdir; | 237 | unsigned int hint_shift_pdir; |
@@ -294,7 +294,7 @@ static unsigned long piranha_bad_128k = 0; | |||
294 | /* Looks nice and keeps the compiler happy */ | 294 | /* Looks nice and keeps the compiler happy */ |
295 | #define SBA_DEV(d) ((struct sba_device *) (d)) | 295 | #define SBA_DEV(d) ((struct sba_device *) (d)) |
296 | 296 | ||
297 | #if SBA_AGP_SUPPORT | 297 | #ifdef SBA_AGP_SUPPORT |
298 | static int reserve_sba_gart = 1; | 298 | static int reserve_sba_gart = 1; |
299 | #endif | 299 | #endif |
300 | 300 | ||
@@ -314,7 +314,7 @@ static int reserve_sba_gart = 1; | |||
314 | #define WRITE_REG32(val, addr) __raw_writel(cpu_to_le32(val), addr) | 314 | #define WRITE_REG32(val, addr) __raw_writel(cpu_to_le32(val), addr) |
315 | #define WRITE_REG64(val, addr) __raw_writeq(cpu_to_le64(val), addr) | 315 | #define WRITE_REG64(val, addr) __raw_writeq(cpu_to_le64(val), addr) |
316 | 316 | ||
317 | #ifdef __LP64__ | 317 | #ifdef CONFIG_64BIT |
318 | #define READ_REG(addr) READ_REG64(addr) | 318 | #define READ_REG(addr) READ_REG64(addr) |
319 | #define WRITE_REG(value, addr) WRITE_REG64(value, addr) | 319 | #define WRITE_REG(value, addr) WRITE_REG64(value, addr) |
320 | #else | 320 | #else |
@@ -324,7 +324,7 @@ static int reserve_sba_gart = 1; | |||
324 | 324 | ||
325 | #ifdef DEBUG_SBA_INIT | 325 | #ifdef DEBUG_SBA_INIT |
326 | 326 | ||
327 | /* NOTE: When __LP64__ isn't defined, READ_REG64() is two 32-bit reads */ | 327 | /* NOTE: When CONFIG_64BIT isn't defined, READ_REG64() is two 32-bit reads */ |
328 | 328 | ||
329 | /** | 329 | /** |
330 | * sba_dump_ranges - debugging only - print ranges assigned to this IOA | 330 | * sba_dump_ranges - debugging only - print ranges assigned to this IOA |
@@ -364,7 +364,7 @@ static void sba_dump_tlb(void __iomem *hpa) | |||
364 | #else | 364 | #else |
365 | #define sba_dump_ranges(x) | 365 | #define sba_dump_ranges(x) |
366 | #define sba_dump_tlb(x) | 366 | #define sba_dump_tlb(x) |
367 | #endif | 367 | #endif /* DEBUG_SBA_INIT */ |
368 | 368 | ||
369 | 369 | ||
370 | #ifdef ASSERT_PDIR_SANITY | 370 | #ifdef ASSERT_PDIR_SANITY |
@@ -674,7 +674,7 @@ sba_free_range(struct ioc *ioc, dma_addr_t iova, size_t size) | |||
674 | * | 674 | * |
675 | ***************************************************************/ | 675 | ***************************************************************/ |
676 | 676 | ||
677 | #if SBA_HINT_SUPPORT | 677 | #ifdef SBA_HINT_SUPPORT |
678 | #define SBA_DMA_HINT(ioc, val) ((val) << (ioc)->hint_shift_pdir) | 678 | #define SBA_DMA_HINT(ioc, val) ((val) << (ioc)->hint_shift_pdir) |
679 | #endif | 679 | #endif |
680 | 680 | ||
@@ -743,9 +743,8 @@ sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, | |||
743 | * (bit #61, big endian), we have to flush and sync every time | 743 | * (bit #61, big endian), we have to flush and sync every time |
744 | * IO-PDIR is changed in Ike/Astro. | 744 | * IO-PDIR is changed in Ike/Astro. |
745 | */ | 745 | */ |
746 | if (ioc_needs_fdc) { | 746 | if (ioc_needs_fdc) |
747 | asm volatile("fdc 0(%%sr1,%0)\n\tsync" : : "r" (pdir_ptr)); | 747 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr)); |
748 | } | ||
749 | } | 748 | } |
750 | 749 | ||
751 | 750 | ||
@@ -769,42 +768,57 @@ static SBA_INLINE void | |||
769 | sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) | 768 | sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) |
770 | { | 769 | { |
771 | u32 iovp = (u32) SBA_IOVP(ioc,iova); | 770 | u32 iovp = (u32) SBA_IOVP(ioc,iova); |
772 | 771 | u64 *pdir_ptr = &ioc->pdir_base[PDIR_INDEX(iovp)]; | |
773 | /* Even though this is a big-endian machine, the entries | ||
774 | ** in the iopdir are little endian. That's why we clear the byte | ||
775 | ** at +7 instead of at +0. | ||
776 | */ | ||
777 | int off = PDIR_INDEX(iovp)*sizeof(u64)+7; | ||
778 | 772 | ||
779 | #ifdef ASSERT_PDIR_SANITY | 773 | #ifdef ASSERT_PDIR_SANITY |
780 | /* Assert first pdir entry is set */ | 774 | /* Assert first pdir entry is set. |
781 | if (0x80 != (((u8 *) ioc->pdir_base)[off])) { | 775 | ** |
776 | ** Even though this is a big-endian machine, the entries | ||
777 | ** in the iopdir are little endian. That's why we look at | ||
778 | ** the byte at +7 instead of at +0. | ||
779 | */ | ||
780 | if (0x80 != (((u8 *) pdir_ptr)[7])) { | ||
782 | sba_dump_pdir_entry(ioc,"sba_mark_invalid()", PDIR_INDEX(iovp)); | 781 | sba_dump_pdir_entry(ioc,"sba_mark_invalid()", PDIR_INDEX(iovp)); |
783 | } | 782 | } |
784 | #endif | 783 | #endif |
785 | 784 | ||
786 | if (byte_cnt <= IOVP_SIZE) | 785 | if (byte_cnt > IOVP_SIZE) |
787 | { | 786 | { |
788 | iovp |= IOVP_SHIFT; /* set "size" field for PCOM */ | 787 | #if 0 |
788 | unsigned long entries_per_cacheline = ioc_needs_fdc ? | ||
789 | L1_CACHE_ALIGN(((unsigned long) pdir_ptr)) | ||
790 | - (unsigned long) pdir_ptr; | ||
791 | : 262144; | ||
792 | #endif | ||
789 | 793 | ||
790 | /* | 794 | /* set "size" field for PCOM */ |
791 | ** clear I/O PDIR entry "valid" bit | 795 | iovp |= get_order(byte_cnt) + PAGE_SHIFT; |
792 | ** Do NOT clear the rest - save it for debugging. | ||
793 | ** We should only clear bits that have previously | ||
794 | ** been enabled. | ||
795 | */ | ||
796 | ((u8 *)(ioc->pdir_base))[off] = 0; | ||
797 | } else { | ||
798 | u32 t = get_order(byte_cnt) + PAGE_SHIFT; | ||
799 | 796 | ||
800 | iovp |= t; | ||
801 | do { | 797 | do { |
802 | /* clear I/O Pdir entry "valid" bit first */ | 798 | /* clear I/O Pdir entry "valid" bit first */ |
803 | ((u8 *)(ioc->pdir_base))[off] = 0; | 799 | ((u8 *) pdir_ptr)[7] = 0; |
804 | off += sizeof(u64); | 800 | if (ioc_needs_fdc) { |
801 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr)); | ||
802 | #if 0 | ||
803 | entries_per_cacheline = L1_CACHE_SHIFT - 3; | ||
804 | #endif | ||
805 | } | ||
806 | pdir_ptr++; | ||
805 | byte_cnt -= IOVP_SIZE; | 807 | byte_cnt -= IOVP_SIZE; |
806 | } while (byte_cnt > 0); | 808 | } while (byte_cnt > IOVP_SIZE); |
807 | } | 809 | } else |
810 | iovp |= IOVP_SHIFT; /* set "size" field for PCOM */ | ||
811 | |||
812 | /* | ||
813 | ** clear I/O PDIR entry "valid" bit. | ||
814 | ** We have to R/M/W the cacheline regardless how much of the | ||
815 | ** pdir entry that we clobber. | ||
816 | ** The rest of the entry would be useful for debugging if we | ||
817 | ** could dump core on HPMC. | ||
818 | */ | ||
819 | ((u8 *) pdir_ptr)[7] = 0; | ||
820 | if (ioc_needs_fdc) | ||
821 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr)); | ||
808 | 822 | ||
809 | WRITE_REG( SBA_IOVA(ioc, iovp, 0, 0), ioc->ioc_hpa+IOC_PCOM); | 823 | WRITE_REG( SBA_IOVA(ioc, iovp, 0, 0), ioc->ioc_hpa+IOC_PCOM); |
810 | } | 824 | } |
@@ -819,18 +833,29 @@ sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) | |||
819 | static int sba_dma_supported( struct device *dev, u64 mask) | 833 | static int sba_dma_supported( struct device *dev, u64 mask) |
820 | { | 834 | { |
821 | struct ioc *ioc; | 835 | struct ioc *ioc; |
836 | |||
822 | if (dev == NULL) { | 837 | if (dev == NULL) { |
823 | printk(KERN_ERR MODULE_NAME ": EISA/ISA/et al not supported\n"); | 838 | printk(KERN_ERR MODULE_NAME ": EISA/ISA/et al not supported\n"); |
824 | BUG(); | 839 | BUG(); |
825 | return(0); | 840 | return(0); |
826 | } | 841 | } |
827 | 842 | ||
828 | ioc = GET_IOC(dev); | 843 | /* Documentation/DMA-mapping.txt tells drivers to try 64-bit first, |
844 | * then fall back to 32-bit if that fails. | ||
845 | * We are just "encouraging" 32-bit DMA masks here since we can | ||
846 | * never allow IOMMU bypass unless we add special support for ZX1. | ||
847 | */ | ||
848 | if (mask > ~0U) | ||
849 | return 0; | ||
829 | 850 | ||
830 | /* check if mask is > than the largest IO Virt Address */ | 851 | ioc = GET_IOC(dev); |
831 | 852 | ||
832 | return((int) (mask >= (ioc->ibase + | 853 | /* |
833 | (ioc->pdir_size / sizeof(u64) * IOVP_SIZE) ))); | 854 | * check if mask is >= than the current max IO Virt Address |
855 | * The max IO Virt address will *always* < 30 bits. | ||
856 | */ | ||
857 | return((int)(mask >= (ioc->ibase - 1 + | ||
858 | (ioc->pdir_size / sizeof(u64) * IOVP_SIZE) ))); | ||
834 | } | 859 | } |
835 | 860 | ||
836 | 861 | ||
@@ -898,11 +923,17 @@ sba_map_single(struct device *dev, void *addr, size_t size, | |||
898 | size -= IOVP_SIZE; | 923 | size -= IOVP_SIZE; |
899 | pdir_start++; | 924 | pdir_start++; |
900 | } | 925 | } |
901 | /* form complete address */ | 926 | |
927 | /* force FDC ops in io_pdir_entry() to be visible to IOMMU */ | ||
928 | if (ioc_needs_fdc) | ||
929 | asm volatile("sync" : : ); | ||
930 | |||
902 | #ifdef ASSERT_PDIR_SANITY | 931 | #ifdef ASSERT_PDIR_SANITY |
903 | sba_check_pdir(ioc,"Check after sba_map_single()"); | 932 | sba_check_pdir(ioc,"Check after sba_map_single()"); |
904 | #endif | 933 | #endif |
905 | spin_unlock_irqrestore(&ioc->res_lock, flags); | 934 | spin_unlock_irqrestore(&ioc->res_lock, flags); |
935 | |||
936 | /* form complete address */ | ||
906 | return SBA_IOVA(ioc, iovp, offset, DEFAULT_DMA_HINT_REG); | 937 | return SBA_IOVA(ioc, iovp, offset, DEFAULT_DMA_HINT_REG); |
907 | } | 938 | } |
908 | 939 | ||
@@ -958,12 +989,19 @@ sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, | |||
958 | d--; | 989 | d--; |
959 | } | 990 | } |
960 | ioc->saved_cnt = 0; | 991 | ioc->saved_cnt = 0; |
992 | |||
961 | READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ | 993 | READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ |
962 | } | 994 | } |
963 | #else /* DELAYED_RESOURCE_CNT == 0 */ | 995 | #else /* DELAYED_RESOURCE_CNT == 0 */ |
964 | sba_free_range(ioc, iova, size); | 996 | sba_free_range(ioc, iova, size); |
997 | |||
998 | /* If fdc's were issued, force fdc's to be visible now */ | ||
999 | if (ioc_needs_fdc) | ||
1000 | asm volatile("sync" : : ); | ||
1001 | |||
965 | READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ | 1002 | READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ |
966 | #endif /* DELAYED_RESOURCE_CNT == 0 */ | 1003 | #endif /* DELAYED_RESOURCE_CNT == 0 */ |
1004 | |||
967 | spin_unlock_irqrestore(&ioc->res_lock, flags); | 1005 | spin_unlock_irqrestore(&ioc->res_lock, flags); |
968 | 1006 | ||
969 | /* XXX REVISIT for 2.5 Linux - need syncdma for zero-copy support. | 1007 | /* XXX REVISIT for 2.5 Linux - need syncdma for zero-copy support. |
@@ -1106,6 +1144,10 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
1106 | */ | 1144 | */ |
1107 | filled = iommu_fill_pdir(ioc, sglist, nents, 0, sba_io_pdir_entry); | 1145 | filled = iommu_fill_pdir(ioc, sglist, nents, 0, sba_io_pdir_entry); |
1108 | 1146 | ||
1147 | /* force FDC ops in io_pdir_entry() to be visible to IOMMU */ | ||
1148 | if (ioc_needs_fdc) | ||
1149 | asm volatile("sync" : : ); | ||
1150 | |||
1109 | #ifdef ASSERT_PDIR_SANITY | 1151 | #ifdef ASSERT_PDIR_SANITY |
1110 | if (sba_check_pdir(ioc,"Check after sba_map_sg()")) | 1152 | if (sba_check_pdir(ioc,"Check after sba_map_sg()")) |
1111 | { | 1153 | { |
@@ -1234,8 +1276,10 @@ sba_alloc_pdir(unsigned int pdir_size) | |||
1234 | unsigned long pdir_order = get_order(pdir_size); | 1276 | unsigned long pdir_order = get_order(pdir_size); |
1235 | 1277 | ||
1236 | pdir_base = __get_free_pages(GFP_KERNEL, pdir_order); | 1278 | pdir_base = __get_free_pages(GFP_KERNEL, pdir_order); |
1237 | if (NULL == (void *) pdir_base) | 1279 | if (NULL == (void *) pdir_base) { |
1238 | panic("sba_ioc_init() could not allocate I/O Page Table\n"); | 1280 | panic("%s() could not allocate I/O Page Table\n", |
1281 | __FUNCTION__); | ||
1282 | } | ||
1239 | 1283 | ||
1240 | /* If this is not PA8700 (PCX-W2) | 1284 | /* If this is not PA8700 (PCX-W2) |
1241 | ** OR newer than ver 2.2 | 1285 | ** OR newer than ver 2.2 |
@@ -1322,19 +1366,29 @@ sba_alloc_pdir(unsigned int pdir_size) | |||
1322 | return (void *) pdir_base; | 1366 | return (void *) pdir_base; |
1323 | } | 1367 | } |
1324 | 1368 | ||
1369 | static struct device *next_device(struct klist_iter *i) | ||
1370 | { | ||
1371 | struct klist_node * n = klist_next(i); | ||
1372 | return n ? container_of(n, struct device, knode_parent) : NULL; | ||
1373 | } | ||
1374 | |||
1325 | /* setup Mercury or Elroy IBASE/IMASK registers. */ | 1375 | /* setup Mercury or Elroy IBASE/IMASK registers. */ |
1326 | static void setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | 1376 | static void |
1377 | setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | ||
1327 | { | 1378 | { |
1328 | /* lba_set_iregs() is in drivers/parisc/lba_pci.c */ | 1379 | /* lba_set_iregs() is in drivers/parisc/lba_pci.c */ |
1329 | extern void lba_set_iregs(struct parisc_device *, u32, u32); | 1380 | extern void lba_set_iregs(struct parisc_device *, u32, u32); |
1330 | struct device *dev; | 1381 | struct device *dev; |
1382 | struct klist_iter i; | ||
1331 | 1383 | ||
1332 | list_for_each_entry(dev, &sba->dev.children, node) { | 1384 | klist_iter_init(&sba->dev.klist_children, &i); |
1385 | while ((dev = next_device(&i))) { | ||
1333 | struct parisc_device *lba = to_parisc_device(dev); | 1386 | struct parisc_device *lba = to_parisc_device(dev); |
1334 | int rope_num = (lba->hpa >> 13) & 0xf; | 1387 | int rope_num = (lba->hpa.start >> 13) & 0xf; |
1335 | if (rope_num >> 3 == ioc_num) | 1388 | if (rope_num >> 3 == ioc_num) |
1336 | lba_set_iregs(lba, ioc->ibase, ioc->imask); | 1389 | lba_set_iregs(lba, ioc->ibase, ioc->imask); |
1337 | } | 1390 | } |
1391 | klist_iter_exit(&i); | ||
1338 | } | 1392 | } |
1339 | 1393 | ||
1340 | static void | 1394 | static void |
@@ -1343,7 +1397,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1343 | u32 iova_space_mask; | 1397 | u32 iova_space_mask; |
1344 | u32 iova_space_size; | 1398 | u32 iova_space_size; |
1345 | int iov_order, tcnfg; | 1399 | int iov_order, tcnfg; |
1346 | #if SBA_AGP_SUPPORT | 1400 | #ifdef SBA_AGP_SUPPORT |
1347 | int agp_found = 0; | 1401 | int agp_found = 0; |
1348 | #endif | 1402 | #endif |
1349 | /* | 1403 | /* |
@@ -1380,7 +1434,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1380 | DBG_INIT("%s() pdir %p size %x\n", | 1434 | DBG_INIT("%s() pdir %p size %x\n", |
1381 | __FUNCTION__, ioc->pdir_base, ioc->pdir_size); | 1435 | __FUNCTION__, ioc->pdir_base, ioc->pdir_size); |
1382 | 1436 | ||
1383 | #if SBA_HINT_SUPPORT | 1437 | #ifdef SBA_HINT_SUPPORT |
1384 | ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; | 1438 | ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; |
1385 | ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); | 1439 | ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); |
1386 | 1440 | ||
@@ -1404,7 +1458,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1404 | 1458 | ||
1405 | WRITE_REG(ioc->imask, ioc->ioc_hpa + IOC_IMASK); | 1459 | WRITE_REG(ioc->imask, ioc->ioc_hpa + IOC_IMASK); |
1406 | 1460 | ||
1407 | #ifdef __LP64__ | 1461 | #ifdef CONFIG_64BIT |
1408 | /* | 1462 | /* |
1409 | ** Setting the upper bits makes checking for bypass addresses | 1463 | ** Setting the upper bits makes checking for bypass addresses |
1410 | ** a little faster later on. | 1464 | ** a little faster later on. |
@@ -1437,7 +1491,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1437 | */ | 1491 | */ |
1438 | WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM); | 1492 | WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM); |
1439 | 1493 | ||
1440 | #if SBA_AGP_SUPPORT | 1494 | #ifdef SBA_AGP_SUPPORT |
1441 | /* | 1495 | /* |
1442 | ** If an AGP device is present, only use half of the IOV space | 1496 | ** If an AGP device is present, only use half of the IOV space |
1443 | ** for PCI DMA. Unfortunately we can't know ahead of time | 1497 | ** for PCI DMA. Unfortunately we can't know ahead of time |
@@ -1489,11 +1543,9 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1489 | if (iova_space_size < (1 << (20 - PAGE_SHIFT))) { | 1543 | if (iova_space_size < (1 << (20 - PAGE_SHIFT))) { |
1490 | iova_space_size = 1 << (20 - PAGE_SHIFT); | 1544 | iova_space_size = 1 << (20 - PAGE_SHIFT); |
1491 | } | 1545 | } |
1492 | #ifdef __LP64__ | ||
1493 | else if (iova_space_size > (1 << (30 - PAGE_SHIFT))) { | 1546 | else if (iova_space_size > (1 << (30 - PAGE_SHIFT))) { |
1494 | iova_space_size = 1 << (30 - PAGE_SHIFT); | 1547 | iova_space_size = 1 << (30 - PAGE_SHIFT); |
1495 | } | 1548 | } |
1496 | #endif | ||
1497 | 1549 | ||
1498 | /* | 1550 | /* |
1499 | ** iova space must be log2() in size. | 1551 | ** iova space must be log2() in size. |
@@ -1519,7 +1571,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1519 | DBG_INIT("%s() pdir %p size %x\n", | 1571 | DBG_INIT("%s() pdir %p size %x\n", |
1520 | __FUNCTION__, ioc->pdir_base, pdir_size); | 1572 | __FUNCTION__, ioc->pdir_base, pdir_size); |
1521 | 1573 | ||
1522 | #if SBA_HINT_SUPPORT | 1574 | #ifdef SBA_HINT_SUPPORT |
1523 | /* FIXME : DMA HINTs not used */ | 1575 | /* FIXME : DMA HINTs not used */ |
1524 | ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; | 1576 | ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; |
1525 | ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); | 1577 | ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); |
@@ -1590,7 +1642,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num) | |||
1590 | 1642 | ||
1591 | static void __iomem *ioc_remap(struct sba_device *sba_dev, int offset) | 1643 | static void __iomem *ioc_remap(struct sba_device *sba_dev, int offset) |
1592 | { | 1644 | { |
1593 | return ioremap(sba_dev->dev->hpa + offset, SBA_FUNC_SIZE); | 1645 | return ioremap(sba_dev->dev->hpa.start + offset, SBA_FUNC_SIZE); |
1594 | } | 1646 | } |
1595 | 1647 | ||
1596 | static void sba_hw_init(struct sba_device *sba_dev) | 1648 | static void sba_hw_init(struct sba_device *sba_dev) |
@@ -1968,7 +2020,7 @@ sba_driver_callback(struct parisc_device *dev) | |||
1968 | u32 func_class; | 2020 | u32 func_class; |
1969 | int i; | 2021 | int i; |
1970 | char *version; | 2022 | char *version; |
1971 | void __iomem *sba_addr = ioremap(dev->hpa, SBA_FUNC_SIZE); | 2023 | void __iomem *sba_addr = ioremap(dev->hpa.start, SBA_FUNC_SIZE); |
1972 | 2024 | ||
1973 | sba_dump_ranges(sba_addr); | 2025 | sba_dump_ranges(sba_addr); |
1974 | 2026 | ||
@@ -2010,7 +2062,7 @@ sba_driver_callback(struct parisc_device *dev) | |||
2010 | } | 2062 | } |
2011 | 2063 | ||
2012 | printk(KERN_INFO "%s found %s at 0x%lx\n", | 2064 | printk(KERN_INFO "%s found %s at 0x%lx\n", |
2013 | MODULE_NAME, version, dev->hpa); | 2065 | MODULE_NAME, version, dev->hpa.start); |
2014 | 2066 | ||
2015 | sba_dev = kmalloc(sizeof(struct sba_device), GFP_KERNEL); | 2067 | sba_dev = kmalloc(sizeof(struct sba_device), GFP_KERNEL); |
2016 | if (!sba_dev) { | 2068 | if (!sba_dev) { |
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c index e0efed796b92..bab3bcabcb6e 100644 --- a/drivers/parisc/superio.c +++ b/drivers/parisc/superio.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * (C) Copyright 2000 Alex deVries <alex@onefishtwo.ca> | 11 | * (C) Copyright 2000 Alex deVries <alex@onefishtwo.ca> |
12 | * (C) Copyright 2001 John Marvin <jsm fc hp com> | 12 | * (C) Copyright 2001 John Marvin <jsm fc hp com> |
13 | * (C) Copyright 2003 Grant Grundler <grundler parisc-linux org> | 13 | * (C) Copyright 2003 Grant Grundler <grundler parisc-linux org> |
14 | * (C) Copyright 2005 Kyle McMartin <kyle@parisc-linux.org> | ||
14 | * | 15 | * |
15 | * This program is free software; you can redistribute it and/or | 16 | * This program is free software; you can redistribute it and/or |
16 | * modify it under the terms of the GNU General Public License as | 17 | * modify it under the terms of the GNU General Public License as |
@@ -405,6 +406,7 @@ static void __devinit superio_serial_init(void) | |||
405 | 406 | ||
406 | serial[0].iobase = sio_dev.sp1_base; | 407 | serial[0].iobase = sio_dev.sp1_base; |
407 | serial[0].irq = SP1_IRQ; | 408 | serial[0].irq = SP1_IRQ; |
409 | spin_lock_init(&serial[0].lock); | ||
408 | 410 | ||
409 | retval = early_serial_setup(&serial[0]); | 411 | retval = early_serial_setup(&serial[0]); |
410 | if (retval < 0) { | 412 | if (retval < 0) { |
@@ -414,6 +416,7 @@ static void __devinit superio_serial_init(void) | |||
414 | 416 | ||
415 | serial[1].iobase = sio_dev.sp2_base; | 417 | serial[1].iobase = sio_dev.sp2_base; |
416 | serial[1].irq = SP2_IRQ; | 418 | serial[1].irq = SP2_IRQ; |
419 | spin_lock_init(&serial[1].lock); | ||
417 | retval = early_serial_setup(&serial[1]); | 420 | retval = early_serial_setup(&serial[1]); |
418 | 421 | ||
419 | if (retval < 0) | 422 | if (retval < 0) |
diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c index e547d7d024d8..17dce2adf7fe 100644 --- a/drivers/parisc/wax.c +++ b/drivers/parisc/wax.c | |||
@@ -81,7 +81,7 @@ wax_init_chip(struct parisc_device *dev) | |||
81 | return -ENOMEM; | 81 | return -ENOMEM; |
82 | 82 | ||
83 | wax->name = "wax"; | 83 | wax->name = "wax"; |
84 | wax->hpa = dev->hpa; | 84 | wax->hpa = dev->hpa.start; |
85 | 85 | ||
86 | wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */ | 86 | wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */ |
87 | printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa); | 87 | printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa); |
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c index 02d72acd1c89..fde29a75f888 100644 --- a/drivers/parport/parport_gsc.c +++ b/drivers/parport/parport_gsc.c | |||
@@ -359,11 +359,12 @@ static int __devinit parport_init_chip(struct parisc_device *dev) | |||
359 | unsigned long port; | 359 | unsigned long port; |
360 | 360 | ||
361 | if (!dev->irq) { | 361 | if (!dev->irq) { |
362 | printk("IRQ not found for parallel device at 0x%lx\n", dev->hpa); | 362 | printk(KERN_WARNING "IRQ not found for parallel device at 0x%lx\n", |
363 | dev->hpa.start); | ||
363 | return -ENODEV; | 364 | return -ENODEV; |
364 | } | 365 | } |
365 | 366 | ||
366 | port = dev->hpa + PARPORT_GSC_OFFSET; | 367 | port = dev->hpa.start + PARPORT_GSC_OFFSET; |
367 | 368 | ||
368 | /* some older machines with ASP-chip don't support | 369 | /* some older machines with ASP-chip don't support |
369 | * the enhanced parport modes. | 370 | * the enhanced parport modes. |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 393e0cee91a9..14f05d22bb70 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -61,7 +61,7 @@ static int pcie_port_remove_service(struct device *dev) | |||
61 | 61 | ||
62 | static void pcie_port_shutdown_service(struct device *dev) {} | 62 | static void pcie_port_shutdown_service(struct device *dev) {} |
63 | 63 | ||
64 | static int pcie_port_suspend_service(struct device *dev, pm_message_t state, u32 level) | 64 | static int pcie_port_suspend_service(struct device *dev, pm_message_t state) |
65 | { | 65 | { |
66 | struct pcie_device *pciedev; | 66 | struct pcie_device *pciedev; |
67 | struct pcie_port_service_driver *driver; | 67 | struct pcie_port_service_driver *driver; |
@@ -76,7 +76,7 @@ static int pcie_port_suspend_service(struct device *dev, pm_message_t state, u32 | |||
76 | return 0; | 76 | return 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | static int pcie_port_resume_service(struct device *dev, u32 level) | 79 | static int pcie_port_resume_service(struct device *dev) |
80 | { | 80 | { |
81 | struct pcie_device *pciedev; | 81 | struct pcie_device *pciedev; |
82 | struct pcie_port_service_driver *driver; | 82 | struct pcie_port_service_driver *driver; |
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index 470ef756252e..d90a634cebf5 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c | |||
@@ -519,30 +519,13 @@ static int au1x00_drv_pcmcia_probe(struct device *dev) | |||
519 | } | 519 | } |
520 | 520 | ||
521 | 521 | ||
522 | static int au1x00_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level) | ||
523 | { | ||
524 | int ret = 0; | ||
525 | if (level == SUSPEND_SAVE_STATE) | ||
526 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
527 | return ret; | ||
528 | } | ||
529 | |||
530 | static int au1x00_drv_pcmcia_resume(struct device *dev, u32 level) | ||
531 | { | ||
532 | int ret = 0; | ||
533 | if (level == RESUME_RESTORE_STATE) | ||
534 | ret = pcmcia_socket_dev_resume(dev); | ||
535 | return ret; | ||
536 | } | ||
537 | |||
538 | |||
539 | static struct device_driver au1x00_pcmcia_driver = { | 522 | static struct device_driver au1x00_pcmcia_driver = { |
540 | .probe = au1x00_drv_pcmcia_probe, | 523 | .probe = au1x00_drv_pcmcia_probe, |
541 | .remove = au1x00_drv_pcmcia_remove, | 524 | .remove = au1x00_drv_pcmcia_remove, |
542 | .name = "au1x00-pcmcia", | 525 | .name = "au1x00-pcmcia", |
543 | .bus = &platform_bus_type, | 526 | .bus = &platform_bus_type, |
544 | .suspend = au1x00_drv_pcmcia_suspend, | 527 | .suspend = pcmcia_socket_dev_suspend, |
545 | .resume = au1x00_drv_pcmcia_resume | 528 | .resume = pcmcia_socket_dev_resume, |
546 | }; | 529 | }; |
547 | 530 | ||
548 | static struct platform_device au1x00_device = { | 531 | static struct platform_device au1x00_device = { |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 080608c7381a..39d096b52926 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -1157,7 +1157,8 @@ static struct pcmcia_callback pcmcia_bus_callback = { | |||
1157 | .requery = pcmcia_bus_rescan, | 1157 | .requery = pcmcia_bus_rescan, |
1158 | }; | 1158 | }; |
1159 | 1159 | ||
1160 | static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) | 1160 | static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev, |
1161 | struct class_interface *class_intf) | ||
1161 | { | 1162 | { |
1162 | struct pcmcia_socket *socket = class_get_devdata(class_dev); | 1163 | struct pcmcia_socket *socket = class_get_devdata(class_dev); |
1163 | int ret; | 1164 | int ret; |
@@ -1192,7 +1193,8 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) | |||
1192 | return 0; | 1193 | return 0; |
1193 | } | 1194 | } |
1194 | 1195 | ||
1195 | static void pcmcia_bus_remove_socket(struct class_device *class_dev) | 1196 | static void pcmcia_bus_remove_socket(struct class_device *class_dev, |
1197 | struct class_interface *class_intf) | ||
1196 | { | 1198 | { |
1197 | struct pcmcia_socket *socket = class_get_devdata(class_dev); | 1199 | struct pcmcia_socket *socket = class_get_devdata(class_dev); |
1198 | 1200 | ||
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c index 316f8bcc878b..b57a0b98b4d6 100644 --- a/drivers/pcmcia/hd64465_ss.c +++ b/drivers/pcmcia/hd64465_ss.c | |||
@@ -844,27 +844,11 @@ static void hs_exit_socket(hs_socket_t *sp) | |||
844 | local_irq_restore(flags); | 844 | local_irq_restore(flags); |
845 | } | 845 | } |
846 | 846 | ||
847 | static int hd64465_suspend(struct device *dev, pm_message_t state, u32 level) | ||
848 | { | ||
849 | int ret = 0; | ||
850 | if (level == SUSPEND_SAVE_STATE) | ||
851 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
852 | return ret; | ||
853 | } | ||
854 | |||
855 | static int hd64465_resume(struct device *dev, u32 level) | ||
856 | { | ||
857 | int ret = 0; | ||
858 | if (level == RESUME_RESTORE_STATE) | ||
859 | ret = pcmcia_socket_dev_resume(dev); | ||
860 | return ret; | ||
861 | } | ||
862 | |||
863 | static struct device_driver hd64465_driver = { | 847 | static struct device_driver hd64465_driver = { |
864 | .name = "hd64465-pcmcia", | 848 | .name = "hd64465-pcmcia", |
865 | .bus = &platform_bus_type, | 849 | .bus = &platform_bus_type, |
866 | .suspend = hd64465_suspend, | 850 | .suspend = pcmcia_socket_dev_suspend, |
867 | .resume = hd64465_resume, | 851 | .resume = pcmcia_socket_dev_resume, |
868 | }; | 852 | }; |
869 | 853 | ||
870 | static struct platform_device hd64465_device = { | 854 | static struct platform_device hd64465_device = { |
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index a713015e8228..4a41f67d185d 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c | |||
@@ -1332,27 +1332,11 @@ static struct pccard_operations pcic_operations = { | |||
1332 | 1332 | ||
1333 | /*====================================================================*/ | 1333 | /*====================================================================*/ |
1334 | 1334 | ||
1335 | static int i82365_suspend(struct device *dev, pm_message_t state, u32 level) | ||
1336 | { | ||
1337 | int ret = 0; | ||
1338 | if (level == SUSPEND_SAVE_STATE) | ||
1339 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
1340 | return ret; | ||
1341 | } | ||
1342 | |||
1343 | static int i82365_resume(struct device *dev, u32 level) | ||
1344 | { | ||
1345 | int ret = 0; | ||
1346 | if (level == RESUME_RESTORE_STATE) | ||
1347 | ret = pcmcia_socket_dev_resume(dev); | ||
1348 | return ret; | ||
1349 | } | ||
1350 | |||
1351 | static struct device_driver i82365_driver = { | 1335 | static struct device_driver i82365_driver = { |
1352 | .name = "i82365", | 1336 | .name = "i82365", |
1353 | .bus = &platform_bus_type, | 1337 | .bus = &platform_bus_type, |
1354 | .suspend = i82365_suspend, | 1338 | .suspend = pcmcia_socket_dev_suspend, |
1355 | .resume = i82365_resume, | 1339 | .resume = pcmcia_socket_dev_resume, |
1356 | }; | 1340 | }; |
1357 | 1341 | ||
1358 | static struct platform_device i82365_device = { | 1342 | static struct platform_device i82365_device = { |
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index 65f3ee3d4d3c..c6ed70ea4812 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c | |||
@@ -731,28 +731,11 @@ static struct pccard_operations pcc_operations = { | |||
731 | 731 | ||
732 | /*====================================================================*/ | 732 | /*====================================================================*/ |
733 | 733 | ||
734 | static int m32r_pcc_suspend(struct device *dev, pm_message_t state, u32 level) | ||
735 | { | ||
736 | int ret = 0; | ||
737 | if (level == SUSPEND_SAVE_STATE) | ||
738 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
739 | return ret; | ||
740 | } | ||
741 | |||
742 | static int m32r_pcc_resume(struct device *dev, u32 level) | ||
743 | { | ||
744 | int ret = 0; | ||
745 | if (level == RESUME_RESTORE_STATE) | ||
746 | ret = pcmcia_socket_dev_resume(dev); | ||
747 | return ret; | ||
748 | } | ||
749 | |||
750 | |||
751 | static struct device_driver pcc_driver = { | 734 | static struct device_driver pcc_driver = { |
752 | .name = "cfc", | 735 | .name = "cfc", |
753 | .bus = &platform_bus_type, | 736 | .bus = &platform_bus_type, |
754 | .suspend = m32r_pcc_suspend, | 737 | .suspend = pcmcia_socket_dev_suspend, |
755 | .resume = m32r_pcc_resume, | 738 | .resume = pcmcia_socket_dev_resume, |
756 | }; | 739 | }; |
757 | 740 | ||
758 | static struct platform_device pcc_device = { | 741 | static struct platform_device pcc_device = { |
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c index 7b14d7efd68c..3397ff28de6a 100644 --- a/drivers/pcmcia/m32r_pcc.c +++ b/drivers/pcmcia/m32r_pcc.c | |||
@@ -695,28 +695,11 @@ static struct pccard_operations pcc_operations = { | |||
695 | 695 | ||
696 | /*====================================================================*/ | 696 | /*====================================================================*/ |
697 | 697 | ||
698 | static int m32r_pcc_suspend(struct device *dev, pm_message_t state, u32 level) | ||
699 | { | ||
700 | int ret = 0; | ||
701 | if (level == SUSPEND_SAVE_STATE) | ||
702 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
703 | return ret; | ||
704 | } | ||
705 | |||
706 | static int m32r_pcc_resume(struct device *dev, u32 level) | ||
707 | { | ||
708 | int ret = 0; | ||
709 | if (level == RESUME_RESTORE_STATE) | ||
710 | ret = pcmcia_socket_dev_resume(dev); | ||
711 | return ret; | ||
712 | } | ||
713 | |||
714 | |||
715 | static struct device_driver pcc_driver = { | 698 | static struct device_driver pcc_driver = { |
716 | .name = "pcc", | 699 | .name = "pcc", |
717 | .bus = &platform_bus_type, | 700 | .bus = &platform_bus_type, |
718 | .suspend = m32r_pcc_suspend, | 701 | .suspend = pcmcia_socket_dev_suspend, |
719 | .resume = m32r_pcc_resume, | 702 | .resume = pcmcia_socket_dev_resume, |
720 | }; | 703 | }; |
721 | 704 | ||
722 | static struct platform_device pcc_device = { | 705 | static struct platform_device pcc_device = { |
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index 94be9e51654e..2558c3cc91ec 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c | |||
@@ -329,27 +329,13 @@ static int __devexit omap_cf_remove(struct device *dev) | |||
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | 331 | ||
332 | static int omap_cf_suspend(struct device *dev, pm_message_t mesg, u32 level) | ||
333 | { | ||
334 | if (level != SUSPEND_SAVE_STATE) | ||
335 | return 0; | ||
336 | return pcmcia_socket_dev_suspend(dev, mesg); | ||
337 | } | ||
338 | |||
339 | static int omap_cf_resume(struct device *dev, u32 level) | ||
340 | { | ||
341 | if (level != RESUME_RESTORE_STATE) | ||
342 | return 0; | ||
343 | return pcmcia_socket_dev_resume(dev); | ||
344 | } | ||
345 | |||
346 | static struct device_driver omap_cf_driver = { | 332 | static struct device_driver omap_cf_driver = { |
347 | .name = (char *) driver_name, | 333 | .name = (char *) driver_name, |
348 | .bus = &platform_bus_type, | 334 | .bus = &platform_bus_type, |
349 | .probe = omap_cf_probe, | 335 | .probe = omap_cf_probe, |
350 | .remove = __devexit_p(omap_cf_remove), | 336 | .remove = __devexit_p(omap_cf_remove), |
351 | .suspend = omap_cf_suspend, | 337 | .suspend = pcmcia_socket_dev_suspend, |
352 | .resume = omap_cf_resume, | 338 | .resume = pcmcia_socket_dev_resume, |
353 | }; | 339 | }; |
354 | 340 | ||
355 | static int __init omap_cf_init(void) | 341 | static int __init omap_cf_init(void) |
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 325c992f7d8f..c2a12d53f6c7 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -205,32 +205,20 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev) | |||
205 | } | 205 | } |
206 | EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); | 206 | EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); |
207 | 207 | ||
208 | static int pxa2xx_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level) | 208 | static int pxa2xx_drv_pcmcia_resume(struct device *dev) |
209 | { | 209 | { |
210 | int ret = 0; | 210 | struct pcmcia_low_level *ops = dev->platform_data; |
211 | if (level == SUSPEND_SAVE_STATE) | 211 | int nr = ops ? ops->nr : 0; |
212 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
213 | return ret; | ||
214 | } | ||
215 | 212 | ||
216 | static int pxa2xx_drv_pcmcia_resume(struct device *dev, u32 level) | 213 | MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0); |
217 | { | 214 | |
218 | int ret = 0; | 215 | return pcmcia_socket_dev_resume(dev); |
219 | if (level == RESUME_RESTORE_STATE) | ||
220 | { | ||
221 | struct pcmcia_low_level *ops = dev->platform_data; | ||
222 | int nr = ops ? ops->nr : 0; | ||
223 | |||
224 | MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0); | ||
225 | ret = pcmcia_socket_dev_resume(dev); | ||
226 | } | ||
227 | return ret; | ||
228 | } | 216 | } |
229 | 217 | ||
230 | static struct device_driver pxa2xx_pcmcia_driver = { | 218 | static struct device_driver pxa2xx_pcmcia_driver = { |
231 | .probe = pxa2xx_drv_pcmcia_probe, | 219 | .probe = pxa2xx_drv_pcmcia_probe, |
232 | .remove = soc_common_drv_pcmcia_remove, | 220 | .remove = soc_common_drv_pcmcia_remove, |
233 | .suspend = pxa2xx_drv_pcmcia_suspend, | 221 | .suspend = pcmcia_socket_dev_suspend, |
234 | .resume = pxa2xx_drv_pcmcia_resume, | 222 | .resume = pxa2xx_drv_pcmcia_resume, |
235 | .name = "pxa2xx-pcmcia", | 223 | .name = "pxa2xx-pcmcia", |
236 | .bus = &platform_bus_type, | 224 | .bus = &platform_bus_type, |
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index f9a5c70284b5..fc87e7e2b6b8 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -994,7 +994,8 @@ static struct class_device_attribute *pccard_rsrc_attributes[] = { | |||
994 | NULL, | 994 | NULL, |
995 | }; | 995 | }; |
996 | 996 | ||
997 | static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev) | 997 | static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev, |
998 | struct class_interface *class_intf) | ||
998 | { | 999 | { |
999 | struct pcmcia_socket *s = class_get_devdata(class_dev); | 1000 | struct pcmcia_socket *s = class_get_devdata(class_dev); |
1000 | struct class_device_attribute **attr; | 1001 | struct class_device_attribute **attr; |
@@ -1011,7 +1012,8 @@ static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev) | |||
1011 | return ret; | 1012 | return ret; |
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev) | 1015 | static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev, |
1016 | struct class_interface *class_intf) | ||
1015 | { | 1017 | { |
1016 | struct pcmcia_socket *s = class_get_devdata(class_dev); | 1018 | struct pcmcia_socket *s = class_get_devdata(class_dev); |
1017 | struct class_device_attribute **attr; | 1019 | struct class_device_attribute **attr; |
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c index d4ed508b38be..b768fa81f043 100644 --- a/drivers/pcmcia/sa1100_generic.c +++ b/drivers/pcmcia/sa1100_generic.c | |||
@@ -74,29 +74,13 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev) | |||
74 | return ret; | 74 | return ret; |
75 | } | 75 | } |
76 | 76 | ||
77 | static int sa11x0_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level) | ||
78 | { | ||
79 | int ret = 0; | ||
80 | if (level == SUSPEND_SAVE_STATE) | ||
81 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static int sa11x0_drv_pcmcia_resume(struct device *dev, u32 level) | ||
86 | { | ||
87 | int ret = 0; | ||
88 | if (level == RESUME_RESTORE_STATE) | ||
89 | ret = pcmcia_socket_dev_resume(dev); | ||
90 | return ret; | ||
91 | } | ||
92 | |||
93 | static struct device_driver sa11x0_pcmcia_driver = { | 77 | static struct device_driver sa11x0_pcmcia_driver = { |
94 | .probe = sa11x0_drv_pcmcia_probe, | 78 | .probe = sa11x0_drv_pcmcia_probe, |
95 | .remove = soc_common_drv_pcmcia_remove, | 79 | .remove = soc_common_drv_pcmcia_remove, |
96 | .name = "sa11x0-pcmcia", | 80 | .name = "sa11x0-pcmcia", |
97 | .bus = &platform_bus_type, | 81 | .bus = &platform_bus_type, |
98 | .suspend = sa11x0_drv_pcmcia_suspend, | 82 | .suspend = pcmcia_socket_dev_suspend, |
99 | .resume = sa11x0_drv_pcmcia_resume, | 83 | .resume = pcmcia_socket_dev_resume, |
100 | }; | 84 | }; |
101 | 85 | ||
102 | /* sa11x0_pcmcia_init() | 86 | /* sa11x0_pcmcia_init() |
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c index bb90a1448a53..81ded52c8959 100644 --- a/drivers/pcmcia/sa1111_generic.c +++ b/drivers/pcmcia/sa1111_generic.c | |||
@@ -122,7 +122,7 @@ void sa1111_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | |||
122 | 122 | ||
123 | static int pcmcia_probe(struct sa1111_dev *dev) | 123 | static int pcmcia_probe(struct sa1111_dev *dev) |
124 | { | 124 | { |
125 | char *base; | 125 | void __iomem *base; |
126 | 126 | ||
127 | if (!request_mem_region(dev->res.start, 512, | 127 | if (!request_mem_region(dev->res.start, 512, |
128 | SA1111_DRIVER_NAME(dev))) | 128 | SA1111_DRIVER_NAME(dev))) |
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 1040a6c1a8a4..4a3150a7854c 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c | |||
@@ -341,7 +341,8 @@ static struct bin_attribute pccard_cis_attr = { | |||
341 | .write = pccard_store_cis, | 341 | .write = pccard_store_cis, |
342 | }; | 342 | }; |
343 | 343 | ||
344 | static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) | 344 | static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev, |
345 | struct class_interface *class_intf) | ||
345 | { | 346 | { |
346 | struct class_device_attribute **attr; | 347 | struct class_device_attribute **attr; |
347 | int ret = 0; | 348 | int ret = 0; |
@@ -357,7 +358,8 @@ static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) | |||
357 | return ret; | 358 | return ret; |
358 | } | 359 | } |
359 | 360 | ||
360 | static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev) | 361 | static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev, |
362 | struct class_interface *class_intf) | ||
361 | { | 363 | { |
362 | struct class_device_attribute **attr; | 364 | struct class_device_attribute **attr; |
363 | 365 | ||
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c index d5a61eae6119..f158b67f6610 100644 --- a/drivers/pcmcia/tcic.c +++ b/drivers/pcmcia/tcic.c | |||
@@ -372,27 +372,11 @@ static int __init get_tcic_id(void) | |||
372 | 372 | ||
373 | /*====================================================================*/ | 373 | /*====================================================================*/ |
374 | 374 | ||
375 | static int tcic_drv_suspend(struct device *dev, pm_message_t state, u32 level) | ||
376 | { | ||
377 | int ret = 0; | ||
378 | if (level == SUSPEND_SAVE_STATE) | ||
379 | ret = pcmcia_socket_dev_suspend(dev, state); | ||
380 | return ret; | ||
381 | } | ||
382 | |||
383 | static int tcic_drv_resume(struct device *dev, u32 level) | ||
384 | { | ||
385 | int ret = 0; | ||
386 | if (level == RESUME_RESTORE_STATE) | ||
387 | ret = pcmcia_socket_dev_resume(dev); | ||
388 | return ret; | ||
389 | } | ||
390 | |||
391 | static struct device_driver tcic_driver = { | 375 | static struct device_driver tcic_driver = { |
392 | .name = "tcic-pcmcia", | 376 | .name = "tcic-pcmcia", |
393 | .bus = &platform_bus_type, | 377 | .bus = &platform_bus_type, |
394 | .suspend = tcic_drv_suspend, | 378 | .suspend = pcmcia_socket_dev_suspend, |
395 | .resume = tcic_drv_resume, | 379 | .resume = pcmcia_socket_dev_resume, |
396 | }; | 380 | }; |
397 | 381 | ||
398 | static struct platform_device tcic_device = { | 382 | static struct platform_device tcic_device = { |
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c index 17bb2da6752b..3d2dca675e02 100644 --- a/drivers/pcmcia/vrc4171_card.c +++ b/drivers/pcmcia/vrc4171_card.c | |||
@@ -774,31 +774,11 @@ static int __devinit vrc4171_card_setup(char *options) | |||
774 | 774 | ||
775 | __setup("vrc4171_card=", vrc4171_card_setup); | 775 | __setup("vrc4171_card=", vrc4171_card_setup); |
776 | 776 | ||
777 | static int vrc4171_card_suspend(struct device *dev, pm_message_t state, u32 level) | ||
778 | { | ||
779 | int retval = 0; | ||
780 | |||
781 | if (level == SUSPEND_SAVE_STATE) | ||
782 | retval = pcmcia_socket_dev_suspend(dev, state); | ||
783 | |||
784 | return retval; | ||
785 | } | ||
786 | |||
787 | static int vrc4171_card_resume(struct device *dev, u32 level) | ||
788 | { | ||
789 | int retval = 0; | ||
790 | |||
791 | if (level == RESUME_RESTORE_STATE) | ||
792 | retval = pcmcia_socket_dev_resume(dev); | ||
793 | |||
794 | return retval; | ||
795 | } | ||
796 | |||
797 | static struct device_driver vrc4171_card_driver = { | 777 | static struct device_driver vrc4171_card_driver = { |
798 | .name = vrc4171_card_name, | 778 | .name = vrc4171_card_name, |
799 | .bus = &platform_bus_type, | 779 | .bus = &platform_bus_type, |
800 | .suspend = vrc4171_card_suspend, | 780 | .suspend = pcmcia_socket_dev_suspend, |
801 | .resume = vrc4171_card_resume, | 781 | .resume = pcmcia_socket_dev_resume, |
802 | }; | 782 | }; |
803 | 783 | ||
804 | static int __devinit vrc4171_card_init(void) | 784 | static int __devinit vrc4171_card_init(void) |
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index db9f952f9e3c..ec6ab65f0872 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -151,6 +151,40 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) | |||
151 | readb(socket->base + 0x800 + reg + 1); | 151 | readb(socket->base + 0x800 + reg + 1); |
152 | } | 152 | } |
153 | 153 | ||
154 | static ssize_t show_yenta_registers(struct device *yentadev, struct device_attribute *attr, char *buf) | ||
155 | { | ||
156 | struct pci_dev *dev = to_pci_dev(yentadev); | ||
157 | struct yenta_socket *socket = pci_get_drvdata(dev); | ||
158 | int offset = 0, i; | ||
159 | |||
160 | offset = snprintf(buf, PAGE_SIZE, "CB registers:"); | ||
161 | for (i = 0; i < 0x24; i += 4) { | ||
162 | unsigned val; | ||
163 | if (!(i & 15)) | ||
164 | offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i); | ||
165 | val = cb_readl(socket, i); | ||
166 | offset += snprintf(buf + offset, PAGE_SIZE - offset, " %08x", val); | ||
167 | } | ||
168 | |||
169 | offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n\nExCA registers:"); | ||
170 | for (i = 0; i < 0x45; i++) { | ||
171 | unsigned char val; | ||
172 | if (!(i & 7)) { | ||
173 | if (i & 8) { | ||
174 | memcpy(buf + offset, " -", 2); | ||
175 | offset += 2; | ||
176 | } else | ||
177 | offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i); | ||
178 | } | ||
179 | val = exca_readb(socket, i); | ||
180 | offset += snprintf(buf + offset, PAGE_SIZE - offset, " %02x", val); | ||
181 | } | ||
182 | buf[offset++] = '\n'; | ||
183 | return offset; | ||
184 | } | ||
185 | |||
186 | static DEVICE_ATTR(yenta_registers, S_IRUSR, show_yenta_registers, NULL); | ||
187 | |||
154 | /* | 188 | /* |
155 | * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend | 189 | * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend |
156 | * on what kind of card is inserted.. | 190 | * on what kind of card is inserted.. |
@@ -765,6 +799,9 @@ static void yenta_close(struct pci_dev *dev) | |||
765 | { | 799 | { |
766 | struct yenta_socket *sock = pci_get_drvdata(dev); | 800 | struct yenta_socket *sock = pci_get_drvdata(dev); |
767 | 801 | ||
802 | /* Remove the register attributes */ | ||
803 | device_remove_file(&dev->dev, &dev_attr_yenta_registers); | ||
804 | |||
768 | /* we don't want a dying socket registered */ | 805 | /* we don't want a dying socket registered */ |
769 | pcmcia_unregister_socket(&sock->socket); | 806 | pcmcia_unregister_socket(&sock->socket); |
770 | 807 | ||
@@ -1138,8 +1175,11 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1138 | 1175 | ||
1139 | /* Register it with the pcmcia layer.. */ | 1176 | /* Register it with the pcmcia layer.. */ |
1140 | ret = pcmcia_register_socket(&socket->socket); | 1177 | ret = pcmcia_register_socket(&socket->socket); |
1141 | if (ret == 0) | 1178 | if (ret == 0) { |
1179 | /* Add the yenta register attributes */ | ||
1180 | device_create_file(&dev->dev, &dev_attr_yenta_registers); | ||
1142 | goto out; | 1181 | goto out; |
1182 | } | ||
1143 | 1183 | ||
1144 | unmap: | 1184 | unmap: |
1145 | iounmap(socket->base); | 1185 | iounmap(socket->base); |
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c index ed0cb1f15b4c..fcaee447d6fe 100644 --- a/drivers/s390/char/tape_class.c +++ b/drivers/s390/char/tape_class.c | |||
@@ -72,6 +72,7 @@ struct tape_class_device *register_tape_dev( | |||
72 | 72 | ||
73 | tcd->class_device = class_device_create( | 73 | tcd->class_device = class_device_create( |
74 | tape_class, | 74 | tape_class, |
75 | NULL, | ||
75 | tcd->char_device->dev, | 76 | tcd->char_device->dev, |
76 | device, | 77 | device, |
77 | "%s", tcd->device_name | 78 | "%s", tcd->device_name |
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c index 491f00c032e8..a107fec4457a 100644 --- a/drivers/s390/char/vmlogrdr.c +++ b/drivers/s390/char/vmlogrdr.c | |||
@@ -787,6 +787,7 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) { | |||
787 | return ret; | 787 | return ret; |
788 | } | 788 | } |
789 | priv->class_device = class_device_create( | 789 | priv->class_device = class_device_create( |
790 | NULL, | ||
790 | vmlogrdr_class, | 791 | vmlogrdr_class, |
791 | MKDEV(vmlogrdr_major, priv->minor_num), | 792 | MKDEV(vmlogrdr_major, priv->minor_num), |
792 | dev, | 793 | dev, |
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index da6e51c7fe69..540147cb51ce 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -936,7 +936,7 @@ static int ch_probe(struct device *dev) | |||
936 | if (init) | 936 | if (init) |
937 | ch_init_elem(ch); | 937 | ch_init_elem(ch); |
938 | 938 | ||
939 | class_device_create(ch_sysfs_class, | 939 | class_device_create(ch_sysfs_class, NULL, |
940 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), | 940 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), |
941 | dev, "s%s", ch->name); | 941 | dev, "s%s", ch->name); |
942 | 942 | ||
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c index 4cbb6187cc44..459a4daebece 100644 --- a/drivers/scsi/lasi700.c +++ b/drivers/scsi/lasi700.c | |||
@@ -98,7 +98,7 @@ MODULE_DEVICE_TABLE(parisc, lasi700_ids); | |||
98 | static int __init | 98 | static int __init |
99 | lasi700_probe(struct parisc_device *dev) | 99 | lasi700_probe(struct parisc_device *dev) |
100 | { | 100 | { |
101 | unsigned long base = dev->hpa + LASI_SCSI_CORE_OFFSET; | 101 | unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET; |
102 | struct NCR_700_Host_Parameters *hostdata; | 102 | struct NCR_700_Host_Parameters *hostdata; |
103 | struct Scsi_Host *host; | 103 | struct Scsi_Host *host; |
104 | 104 | ||
@@ -125,8 +125,6 @@ lasi700_probe(struct parisc_device *dev) | |||
125 | hostdata->dmode_extra = DMODE_FC2; | 125 | hostdata->dmode_extra = DMODE_FC2; |
126 | } | 126 | } |
127 | 127 | ||
128 | NCR_700_set_mem_mapped(hostdata); | ||
129 | |||
130 | host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev); | 128 | host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev); |
131 | if (!host) | 129 | if (!host) |
132 | goto out_kfree; | 130 | goto out_kfree; |
@@ -168,7 +166,7 @@ lasi700_driver_remove(struct parisc_device *dev) | |||
168 | } | 166 | } |
169 | 167 | ||
170 | static struct parisc_driver lasi700_driver = { | 168 | static struct parisc_driver lasi700_driver = { |
171 | .name = "Lasi SCSI", | 169 | .name = "lasi_scsi", |
172 | .id_table = lasi700_ids, | 170 | .id_table = lasi700_ids, |
173 | .probe = lasi700_probe, | 171 | .probe = lasi700_probe, |
174 | .remove = __devexit_p(lasi700_driver_remove), | 172 | .remove = __devexit_p(lasi700_driver_remove), |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index a68c0341dc82..69058510f43a 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -40,14 +40,56 @@ | |||
40 | #include "scsi.h" | 40 | #include "scsi.h" |
41 | #include <scsi/scsi_host.h> | 41 | #include <scsi/scsi_host.h> |
42 | #include <linux/libata.h> | 42 | #include <linux/libata.h> |
43 | #include <linux/hdreg.h> | ||
43 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
44 | 45 | ||
45 | #include "libata.h" | 46 | #include "libata.h" |
46 | 47 | ||
48 | #define SECTOR_SIZE 512 | ||
49 | |||
47 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); | 50 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); |
48 | static struct ata_device * | 51 | static struct ata_device * |
49 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); | 52 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); |
50 | 53 | ||
54 | #define RW_RECOVERY_MPAGE 0x1 | ||
55 | #define RW_RECOVERY_MPAGE_LEN 12 | ||
56 | #define CACHE_MPAGE 0x8 | ||
57 | #define CACHE_MPAGE_LEN 20 | ||
58 | #define CONTROL_MPAGE 0xa | ||
59 | #define CONTROL_MPAGE_LEN 12 | ||
60 | #define ALL_MPAGES 0x3f | ||
61 | #define ALL_SUB_MPAGES 0xff | ||
62 | |||
63 | |||
64 | static const u8 def_rw_recovery_mpage[] = { | ||
65 | RW_RECOVERY_MPAGE, | ||
66 | RW_RECOVERY_MPAGE_LEN - 2, | ||
67 | (1 << 7) | /* AWRE, sat-r06 say it shall be 0 */ | ||
68 | (1 << 6), /* ARRE (auto read reallocation) */ | ||
69 | 0, /* read retry count */ | ||
70 | 0, 0, 0, 0, | ||
71 | 0, /* write retry count */ | ||
72 | 0, 0, 0 | ||
73 | }; | ||
74 | |||
75 | static const u8 def_cache_mpage[CACHE_MPAGE_LEN] = { | ||
76 | CACHE_MPAGE, | ||
77 | CACHE_MPAGE_LEN - 2, | ||
78 | 0, /* contains WCE, needs to be 0 for logic */ | ||
79 | 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
80 | 0, /* contains DRA, needs to be 0 for logic */ | ||
81 | 0, 0, 0, 0, 0, 0, 0 | ||
82 | }; | ||
83 | |||
84 | static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = { | ||
85 | CONTROL_MPAGE, | ||
86 | CONTROL_MPAGE_LEN - 2, | ||
87 | 2, /* DSENSE=0, GLTSD=1 */ | ||
88 | 0, /* [QAM+QERR may be 1, see 05-359r1] */ | ||
89 | 0, 0, 0, 0, 0xff, 0xff, | ||
90 | 0, 30 /* extended self test time, see 05-359r1 */ | ||
91 | }; | ||
92 | |||
51 | 93 | ||
52 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, | 94 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, |
53 | void (*done)(struct scsi_cmnd *)) | 95 | void (*done)(struct scsi_cmnd *)) |
@@ -86,6 +128,150 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev, | |||
86 | return 0; | 128 | return 0; |
87 | } | 129 | } |
88 | 130 | ||
131 | /** | ||
132 | * ata_cmd_ioctl - Handler for HDIO_DRIVE_CMD ioctl | ||
133 | * @dev: Device to whom we are issuing command | ||
134 | * @arg: User provided data for issuing command | ||
135 | * | ||
136 | * LOCKING: | ||
137 | * Defined by the SCSI layer. We don't really care. | ||
138 | * | ||
139 | * RETURNS: | ||
140 | * Zero on success, negative errno on error. | ||
141 | */ | ||
142 | |||
143 | int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | ||
144 | { | ||
145 | int rc = 0; | ||
146 | u8 scsi_cmd[MAX_COMMAND_SIZE]; | ||
147 | u8 args[4], *argbuf = NULL; | ||
148 | int argsize = 0; | ||
149 | struct scsi_request *sreq; | ||
150 | |||
151 | if (NULL == (void *)arg) | ||
152 | return -EINVAL; | ||
153 | |||
154 | if (copy_from_user(args, arg, sizeof(args))) | ||
155 | return -EFAULT; | ||
156 | |||
157 | sreq = scsi_allocate_request(scsidev, GFP_KERNEL); | ||
158 | if (!sreq) | ||
159 | return -EINTR; | ||
160 | |||
161 | memset(scsi_cmd, 0, sizeof(scsi_cmd)); | ||
162 | |||
163 | if (args[3]) { | ||
164 | argsize = SECTOR_SIZE * args[3]; | ||
165 | argbuf = kmalloc(argsize, GFP_KERNEL); | ||
166 | if (argbuf == NULL) { | ||
167 | rc = -ENOMEM; | ||
168 | goto error; | ||
169 | } | ||
170 | |||
171 | scsi_cmd[1] = (4 << 1); /* PIO Data-in */ | ||
172 | scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, | ||
173 | block count in sector count field */ | ||
174 | sreq->sr_data_direction = DMA_FROM_DEVICE; | ||
175 | } else { | ||
176 | scsi_cmd[1] = (3 << 1); /* Non-data */ | ||
177 | /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ | ||
178 | sreq->sr_data_direction = DMA_NONE; | ||
179 | } | ||
180 | |||
181 | scsi_cmd[0] = ATA_16; | ||
182 | |||
183 | scsi_cmd[4] = args[2]; | ||
184 | if (args[0] == WIN_SMART) { /* hack -- ide driver does this too... */ | ||
185 | scsi_cmd[6] = args[3]; | ||
186 | scsi_cmd[8] = args[1]; | ||
187 | scsi_cmd[10] = 0x4f; | ||
188 | scsi_cmd[12] = 0xc2; | ||
189 | } else { | ||
190 | scsi_cmd[6] = args[1]; | ||
191 | } | ||
192 | scsi_cmd[14] = args[0]; | ||
193 | |||
194 | /* Good values for timeout and retries? Values below | ||
195 | from scsi_ioctl_send_command() for default case... */ | ||
196 | scsi_wait_req(sreq, scsi_cmd, argbuf, argsize, (10*HZ), 5); | ||
197 | |||
198 | if (sreq->sr_result) { | ||
199 | rc = -EIO; | ||
200 | goto error; | ||
201 | } | ||
202 | |||
203 | /* Need code to retrieve data from check condition? */ | ||
204 | |||
205 | if ((argbuf) | ||
206 | && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) | ||
207 | rc = -EFAULT; | ||
208 | error: | ||
209 | scsi_release_request(sreq); | ||
210 | |||
211 | if (argbuf) | ||
212 | kfree(argbuf); | ||
213 | |||
214 | return rc; | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * ata_task_ioctl - Handler for HDIO_DRIVE_TASK ioctl | ||
219 | * @dev: Device to whom we are issuing command | ||
220 | * @arg: User provided data for issuing command | ||
221 | * | ||
222 | * LOCKING: | ||
223 | * Defined by the SCSI layer. We don't really care. | ||
224 | * | ||
225 | * RETURNS: | ||
226 | * Zero on success, negative errno on error. | ||
227 | */ | ||
228 | int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | ||
229 | { | ||
230 | int rc = 0; | ||
231 | u8 scsi_cmd[MAX_COMMAND_SIZE]; | ||
232 | u8 args[7]; | ||
233 | struct scsi_request *sreq; | ||
234 | |||
235 | if (NULL == (void *)arg) | ||
236 | return -EINVAL; | ||
237 | |||
238 | if (copy_from_user(args, arg, sizeof(args))) | ||
239 | return -EFAULT; | ||
240 | |||
241 | memset(scsi_cmd, 0, sizeof(scsi_cmd)); | ||
242 | scsi_cmd[0] = ATA_16; | ||
243 | scsi_cmd[1] = (3 << 1); /* Non-data */ | ||
244 | /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ | ||
245 | scsi_cmd[4] = args[1]; | ||
246 | scsi_cmd[6] = args[2]; | ||
247 | scsi_cmd[8] = args[3]; | ||
248 | scsi_cmd[10] = args[4]; | ||
249 | scsi_cmd[12] = args[5]; | ||
250 | scsi_cmd[14] = args[0]; | ||
251 | |||
252 | sreq = scsi_allocate_request(scsidev, GFP_KERNEL); | ||
253 | if (!sreq) { | ||
254 | rc = -EINTR; | ||
255 | goto error; | ||
256 | } | ||
257 | |||
258 | sreq->sr_data_direction = DMA_NONE; | ||
259 | /* Good values for timeout and retries? Values below | ||
260 | from scsi_ioctl_send_command() for default case... */ | ||
261 | scsi_wait_req(sreq, scsi_cmd, NULL, 0, (10*HZ), 5); | ||
262 | |||
263 | if (sreq->sr_result) { | ||
264 | rc = -EIO; | ||
265 | goto error; | ||
266 | } | ||
267 | |||
268 | /* Need code to retrieve data from check condition? */ | ||
269 | |||
270 | error: | ||
271 | scsi_release_request(sreq); | ||
272 | return rc; | ||
273 | } | ||
274 | |||
89 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | 275 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) |
90 | { | 276 | { |
91 | struct ata_port *ap; | 277 | struct ata_port *ap; |
@@ -115,6 +301,16 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | |||
115 | return -EINVAL; | 301 | return -EINVAL; |
116 | return 0; | 302 | return 0; |
117 | 303 | ||
304 | case HDIO_DRIVE_CMD: | ||
305 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
306 | return -EACCES; | ||
307 | return ata_cmd_ioctl(scsidev, arg); | ||
308 | |||
309 | case HDIO_DRIVE_TASK: | ||
310 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
311 | return -EACCES; | ||
312 | return ata_task_ioctl(scsidev, arg); | ||
313 | |||
118 | default: | 314 | default: |
119 | rc = -ENOTTY; | 315 | rc = -ENOTTY; |
120 | break; | 316 | break; |
@@ -173,23 +369,70 @@ struct ata_queued_cmd *ata_scsi_qc_new(struct ata_port *ap, | |||
173 | } | 369 | } |
174 | 370 | ||
175 | /** | 371 | /** |
372 | * ata_dump_status - user friendly display of error info | ||
373 | * @id: id of the port in question | ||
374 | * @tf: ptr to filled out taskfile | ||
375 | * | ||
376 | * Decode and dump the ATA error/status registers for the user so | ||
377 | * that they have some idea what really happened at the non | ||
378 | * make-believe layer. | ||
379 | * | ||
380 | * LOCKING: | ||
381 | * inherited from caller | ||
382 | */ | ||
383 | void ata_dump_status(unsigned id, struct ata_taskfile *tf) | ||
384 | { | ||
385 | u8 stat = tf->command, err = tf->feature; | ||
386 | |||
387 | printk(KERN_WARNING "ata%u: status=0x%02x { ", id, stat); | ||
388 | if (stat & ATA_BUSY) { | ||
389 | printk("Busy }\n"); /* Data is not valid in this case */ | ||
390 | } else { | ||
391 | if (stat & 0x40) printk("DriveReady "); | ||
392 | if (stat & 0x20) printk("DeviceFault "); | ||
393 | if (stat & 0x10) printk("SeekComplete "); | ||
394 | if (stat & 0x08) printk("DataRequest "); | ||
395 | if (stat & 0x04) printk("CorrectedError "); | ||
396 | if (stat & 0x02) printk("Index "); | ||
397 | if (stat & 0x01) printk("Error "); | ||
398 | printk("}\n"); | ||
399 | |||
400 | if (err) { | ||
401 | printk(KERN_WARNING "ata%u: error=0x%02x { ", id, err); | ||
402 | if (err & 0x04) printk("DriveStatusError "); | ||
403 | if (err & 0x80) { | ||
404 | if (err & 0x04) printk("BadCRC "); | ||
405 | else printk("Sector "); | ||
406 | } | ||
407 | if (err & 0x40) printk("UncorrectableError "); | ||
408 | if (err & 0x10) printk("SectorIdNotFound "); | ||
409 | if (err & 0x02) printk("TrackZeroNotFound "); | ||
410 | if (err & 0x01) printk("AddrMarkNotFound "); | ||
411 | printk("}\n"); | ||
412 | } | ||
413 | } | ||
414 | } | ||
415 | |||
416 | /** | ||
176 | * ata_to_sense_error - convert ATA error to SCSI error | 417 | * ata_to_sense_error - convert ATA error to SCSI error |
177 | * @qc: Command that we are erroring out | ||
178 | * @drv_stat: value contained in ATA status register | 418 | * @drv_stat: value contained in ATA status register |
419 | * @drv_err: value contained in ATA error register | ||
420 | * @sk: the sense key we'll fill out | ||
421 | * @asc: the additional sense code we'll fill out | ||
422 | * @ascq: the additional sense code qualifier we'll fill out | ||
179 | * | 423 | * |
180 | * Converts an ATA error into a SCSI error. While we are at it | 424 | * Converts an ATA error into a SCSI error. Fill out pointers to |
181 | * we decode and dump the ATA error for the user so that they | 425 | * SK, ASC, and ASCQ bytes for later use in fixed or descriptor |
182 | * have some idea what really happened at the non make-believe | 426 | * format sense blocks. |
183 | * layer. | ||
184 | * | 427 | * |
185 | * LOCKING: | 428 | * LOCKING: |
186 | * spin_lock_irqsave(host_set lock) | 429 | * spin_lock_irqsave(host_set lock) |
187 | */ | 430 | */ |
188 | 431 | void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | |
189 | void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat) | 432 | u8 *ascq) |
190 | { | 433 | { |
191 | struct scsi_cmnd *cmd = qc->scsicmd; | 434 | int i; |
192 | u8 err = 0; | 435 | |
193 | /* Based on the 3ware driver translation table */ | 436 | /* Based on the 3ware driver translation table */ |
194 | static unsigned char sense_table[][4] = { | 437 | static unsigned char sense_table[][4] = { |
195 | /* BBD|ECC|ID|MAR */ | 438 | /* BBD|ECC|ID|MAR */ |
@@ -230,96 +473,184 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat) | |||
230 | {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered | 473 | {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered |
231 | {0xFF, 0xFF, 0xFF, 0xFF}, // END mark | 474 | {0xFF, 0xFF, 0xFF, 0xFF}, // END mark |
232 | }; | 475 | }; |
233 | int i = 0; | ||
234 | 476 | ||
235 | /* | 477 | /* |
236 | * Is this an error we can process/parse | 478 | * Is this an error we can process/parse |
237 | */ | 479 | */ |
238 | 480 | if (drv_stat & ATA_BUSY) { | |
239 | if(drv_stat & ATA_ERR) | 481 | drv_err = 0; /* Ignore the err bits, they're invalid */ |
240 | /* Read the err bits */ | ||
241 | err = ata_chk_err(qc->ap); | ||
242 | |||
243 | /* Display the ATA level error info */ | ||
244 | |||
245 | printk(KERN_WARNING "ata%u: status=0x%02x { ", qc->ap->id, drv_stat); | ||
246 | if(drv_stat & 0x80) | ||
247 | { | ||
248 | printk("Busy "); | ||
249 | err = 0; /* Data is not valid in this case */ | ||
250 | } | 482 | } |
251 | else { | 483 | |
252 | if(drv_stat & 0x40) printk("DriveReady "); | 484 | if (drv_err) { |
253 | if(drv_stat & 0x20) printk("DeviceFault "); | 485 | /* Look for drv_err */ |
254 | if(drv_stat & 0x10) printk("SeekComplete "); | 486 | for (i = 0; sense_table[i][0] != 0xFF; i++) { |
255 | if(drv_stat & 0x08) printk("DataRequest "); | 487 | /* Look for best matches first */ |
256 | if(drv_stat & 0x04) printk("CorrectedError "); | 488 | if ((sense_table[i][0] & drv_err) == |
257 | if(drv_stat & 0x02) printk("Index "); | 489 | sense_table[i][0]) { |
258 | if(drv_stat & 0x01) printk("Error "); | 490 | *sk = sense_table[i][1]; |
491 | *asc = sense_table[i][2]; | ||
492 | *ascq = sense_table[i][3]; | ||
493 | goto translate_done; | ||
494 | } | ||
495 | } | ||
496 | /* No immediate match */ | ||
497 | printk(KERN_WARNING "ata%u: no sense translation for " | ||
498 | "error 0x%02x\n", id, drv_err); | ||
259 | } | 499 | } |
260 | printk("}\n"); | 500 | |
261 | 501 | /* Fall back to interpreting status bits */ | |
262 | if(err) | 502 | for (i = 0; stat_table[i][0] != 0xFF; i++) { |
263 | { | 503 | if (stat_table[i][0] & drv_stat) { |
264 | printk(KERN_WARNING "ata%u: error=0x%02x { ", qc->ap->id, err); | 504 | *sk = stat_table[i][1]; |
265 | if(err & 0x04) printk("DriveStatusError "); | 505 | *asc = stat_table[i][2]; |
266 | if(err & 0x80) | 506 | *ascq = stat_table[i][3]; |
267 | { | 507 | goto translate_done; |
268 | if(err & 0x04) | ||
269 | printk("BadCRC "); | ||
270 | else | ||
271 | printk("Sector "); | ||
272 | } | 508 | } |
273 | if(err & 0x40) printk("UncorrectableError "); | 509 | } |
274 | if(err & 0x10) printk("SectorIdNotFound "); | 510 | /* No error? Undecoded? */ |
275 | if(err & 0x02) printk("TrackZeroNotFound "); | 511 | printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", |
276 | if(err & 0x01) printk("AddrMarkNotFound "); | 512 | id, drv_stat); |
277 | printk("}\n"); | ||
278 | 513 | ||
279 | /* Should we dump sector info here too ?? */ | 514 | /* For our last chance pick, use medium read error because |
515 | * it's much more common than an ATA drive telling you a write | ||
516 | * has failed. | ||
517 | */ | ||
518 | *sk = MEDIUM_ERROR; | ||
519 | *asc = 0x11; /* "unrecovered read error" */ | ||
520 | *ascq = 0x04; /* "auto-reallocation failed" */ | ||
521 | |||
522 | translate_done: | ||
523 | printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " | ||
524 | "SCSI SK/ASC/ASCQ 0x%x/%02x/%02x\n", id, drv_stat, drv_err, | ||
525 | *sk, *asc, *ascq); | ||
526 | return; | ||
527 | } | ||
528 | |||
529 | /* | ||
530 | * ata_gen_ata_desc_sense - Generate check condition sense block. | ||
531 | * @qc: Command that completed. | ||
532 | * | ||
533 | * This function is specific to the ATA descriptor format sense | ||
534 | * block specified for the ATA pass through commands. Regardless | ||
535 | * of whether the command errored or not, return a sense | ||
536 | * block. Copy all controller registers into the sense | ||
537 | * block. Clear sense key, ASC & ASCQ if there is no error. | ||
538 | * | ||
539 | * LOCKING: | ||
540 | * spin_lock_irqsave(host_set lock) | ||
541 | */ | ||
542 | void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) | ||
543 | { | ||
544 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
545 | struct ata_taskfile *tf = &qc->tf; | ||
546 | unsigned char *sb = cmd->sense_buffer; | ||
547 | unsigned char *desc = sb + 8; | ||
548 | |||
549 | memset(sb, 0, SCSI_SENSE_BUFFERSIZE); | ||
550 | |||
551 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | ||
552 | |||
553 | /* | ||
554 | * Read the controller registers. | ||
555 | */ | ||
556 | assert(NULL != qc->ap->ops->tf_read); | ||
557 | qc->ap->ops->tf_read(qc->ap, tf); | ||
558 | |||
559 | /* | ||
560 | * Use ata_to_sense_error() to map status register bits | ||
561 | * onto sense key, asc & ascq. | ||
562 | */ | ||
563 | if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { | ||
564 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | ||
565 | &sb[1], &sb[2], &sb[3]); | ||
566 | sb[1] &= 0x0f; | ||
280 | } | 567 | } |
281 | 568 | ||
569 | /* | ||
570 | * Sense data is current and format is descriptor. | ||
571 | */ | ||
572 | sb[0] = 0x72; | ||
282 | 573 | ||
283 | /* Look for err */ | 574 | desc[0] = 0x09; |
284 | while(sense_table[i][0] != 0xFF) | 575 | |
285 | { | 576 | /* |
286 | /* Look for best matches first */ | 577 | * Set length of additional sense data. |
287 | if((sense_table[i][0] & err) == sense_table[i][0]) | 578 | * Since we only populate descriptor 0, the total |
288 | { | 579 | * length is the same (fixed) length as descriptor 0. |
289 | ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, | 580 | */ |
290 | sense_table[i][2] /* asc */, | 581 | desc[1] = sb[7] = 14; |
291 | sense_table[i][3] /* ascq */ ); | 582 | |
292 | return; | 583 | /* |
293 | } | 584 | * Copy registers into sense buffer. |
294 | i++; | 585 | */ |
586 | desc[2] = 0x00; | ||
587 | desc[3] = tf->feature; /* == error reg */ | ||
588 | desc[5] = tf->nsect; | ||
589 | desc[7] = tf->lbal; | ||
590 | desc[9] = tf->lbam; | ||
591 | desc[11] = tf->lbah; | ||
592 | desc[12] = tf->device; | ||
593 | desc[13] = tf->command; /* == status reg */ | ||
594 | |||
595 | /* | ||
596 | * Fill in Extend bit, and the high order bytes | ||
597 | * if applicable. | ||
598 | */ | ||
599 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
600 | desc[2] |= 0x01; | ||
601 | desc[4] = tf->hob_nsect; | ||
602 | desc[6] = tf->hob_lbal; | ||
603 | desc[8] = tf->hob_lbam; | ||
604 | desc[10] = tf->hob_lbah; | ||
295 | } | 605 | } |
296 | /* No immediate match */ | 606 | } |
297 | if(err) | ||
298 | printk(KERN_DEBUG "ata%u: no sense translation for 0x%02x\n", qc->ap->id, err); | ||
299 | 607 | ||
300 | i = 0; | 608 | /** |
301 | /* Fall back to interpreting status bits */ | 609 | * ata_gen_fixed_sense - generate a SCSI fixed sense block |
302 | while(stat_table[i][0] != 0xFF) | 610 | * @qc: Command that we are erroring out |
303 | { | 611 | * |
304 | if(stat_table[i][0] & drv_stat) | 612 | * Leverage ata_to_sense_error() to give us the codes. Fit our |
305 | { | 613 | * LBA in here if there's room. |
306 | ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, | 614 | * |
307 | sense_table[i][2] /* asc */, | 615 | * LOCKING: |
308 | sense_table[i][3] /* ascq */ ); | 616 | * inherited from caller |
309 | return; | 617 | */ |
310 | } | 618 | void ata_gen_fixed_sense(struct ata_queued_cmd *qc) |
311 | i++; | 619 | { |
620 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
621 | struct ata_taskfile *tf = &qc->tf; | ||
622 | unsigned char *sb = cmd->sense_buffer; | ||
623 | |||
624 | memset(sb, 0, SCSI_SENSE_BUFFERSIZE); | ||
625 | |||
626 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | ||
627 | |||
628 | /* | ||
629 | * Read the controller registers. | ||
630 | */ | ||
631 | assert(NULL != qc->ap->ops->tf_read); | ||
632 | qc->ap->ops->tf_read(qc->ap, tf); | ||
633 | |||
634 | /* | ||
635 | * Use ata_to_sense_error() to map status register bits | ||
636 | * onto sense key, asc & ascq. | ||
637 | */ | ||
638 | if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { | ||
639 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | ||
640 | &sb[2], &sb[12], &sb[13]); | ||
641 | sb[2] &= 0x0f; | ||
312 | } | 642 | } |
313 | /* No error ?? */ | ||
314 | printk(KERN_ERR "ata%u: called with no error (%02X)!\n", qc->ap->id, drv_stat); | ||
315 | /* additional-sense-code[-qualifier] */ | ||
316 | 643 | ||
317 | if (cmd->sc_data_direction == DMA_FROM_DEVICE) { | 644 | sb[0] = 0x70; |
318 | ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0x11, 0x4); | 645 | sb[7] = 0x0a; |
319 | /* "unrecovered read error" */ | 646 | |
320 | } else { | 647 | if (tf->flags & ATA_TFLAG_LBA && !(tf->flags & ATA_TFLAG_LBA48)) { |
321 | ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0xc, 0x2); | 648 | /* A small (28b) LBA will fit in the 32b info field */ |
322 | /* "write error - auto-reallocation failed" */ | 649 | sb[0] |= 0x80; /* set valid bit */ |
650 | sb[3] = tf->device & 0x0f; | ||
651 | sb[4] = tf->lbah; | ||
652 | sb[5] = tf->lbam; | ||
653 | sb[6] = tf->lbal; | ||
323 | } | 654 | } |
324 | } | 655 | } |
325 | 656 | ||
@@ -881,11 +1212,36 @@ nothing_to_do: | |||
881 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | 1212 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) |
882 | { | 1213 | { |
883 | struct scsi_cmnd *cmd = qc->scsicmd; | 1214 | struct scsi_cmnd *cmd = qc->scsicmd; |
1215 | int need_sense = drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ); | ||
1216 | |||
1217 | /* For ATA pass thru (SAT) commands, generate a sense block if | ||
1218 | * user mandated it or if there's an error. Note that if we | ||
1219 | * generate because the user forced us to, a check condition | ||
1220 | * is generated and the ATA register values are returned | ||
1221 | * whether the command completed successfully or not. If there | ||
1222 | * was no error, SK, ASC and ASCQ will all be zero. | ||
1223 | */ | ||
1224 | if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && | ||
1225 | ((cmd->cmnd[2] & 0x20) || need_sense)) { | ||
1226 | ata_gen_ata_desc_sense(qc); | ||
1227 | } else { | ||
1228 | if (!need_sense) { | ||
1229 | cmd->result = SAM_STAT_GOOD; | ||
1230 | } else { | ||
1231 | /* TODO: decide which descriptor format to use | ||
1232 | * for 48b LBA devices and call that here | ||
1233 | * instead of the fixed desc, which is only | ||
1234 | * good for smaller LBA (and maybe CHS?) | ||
1235 | * devices. | ||
1236 | */ | ||
1237 | ata_gen_fixed_sense(qc); | ||
1238 | } | ||
1239 | } | ||
884 | 1240 | ||
885 | if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) | 1241 | if (need_sense) { |
886 | ata_to_sense_error(qc, drv_stat); | 1242 | /* The ata_gen_..._sense routines fill in tf */ |
887 | else | 1243 | ata_dump_status(qc->ap->id, &qc->tf); |
888 | cmd->result = SAM_STAT_GOOD; | 1244 | } |
889 | 1245 | ||
890 | qc->scsidone(cmd); | 1246 | qc->scsidone(cmd); |
891 | 1247 | ||
@@ -1276,13 +1632,9 @@ static void ata_msense_push(u8 **ptr_io, const u8 *last, | |||
1276 | static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, | 1632 | static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, |
1277 | const u8 *last) | 1633 | const u8 *last) |
1278 | { | 1634 | { |
1279 | u8 page[] = { | 1635 | u8 page[CACHE_MPAGE_LEN]; |
1280 | 0x8, /* page code */ | ||
1281 | 0x12, /* page length */ | ||
1282 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 zeroes */ | ||
1283 | 0, 0, 0, 0, 0, 0, 0, 0 /* 8 zeroes */ | ||
1284 | }; | ||
1285 | 1636 | ||
1637 | memcpy(page, def_cache_mpage, sizeof(page)); | ||
1286 | if (ata_id_wcache_enabled(id)) | 1638 | if (ata_id_wcache_enabled(id)) |
1287 | page[2] |= (1 << 2); /* write cache enable */ | 1639 | page[2] |= (1 << 2); /* write cache enable */ |
1288 | if (!ata_id_rahead_enabled(id)) | 1640 | if (!ata_id_rahead_enabled(id)) |
@@ -1306,15 +1658,9 @@ static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, | |||
1306 | 1658 | ||
1307 | static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) | 1659 | static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) |
1308 | { | 1660 | { |
1309 | const u8 page[] = {0xa, 0xa, 6, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 30}; | 1661 | ata_msense_push(ptr_io, last, def_control_mpage, |
1310 | 1662 | sizeof(def_control_mpage)); | |
1311 | /* byte 2: set the descriptor format sense data bit (bit 2) | 1663 | return sizeof(def_control_mpage); |
1312 | * since we need to support returning this format for SAT | ||
1313 | * commands and any SCSI commands against a 48b LBA device. | ||
1314 | */ | ||
1315 | |||
1316 | ata_msense_push(ptr_io, last, page, sizeof(page)); | ||
1317 | return sizeof(page); | ||
1318 | } | 1664 | } |
1319 | 1665 | ||
1320 | /** | 1666 | /** |
@@ -1331,15 +1677,10 @@ static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) | |||
1331 | 1677 | ||
1332 | static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) | 1678 | static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) |
1333 | { | 1679 | { |
1334 | const u8 page[] = { | ||
1335 | 0x1, /* page code */ | ||
1336 | 0xa, /* page length */ | ||
1337 | (1 << 7) | (1 << 6), /* note auto r/w reallocation */ | ||
1338 | 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 9 zeroes */ | ||
1339 | }; | ||
1340 | 1680 | ||
1341 | ata_msense_push(ptr_io, last, page, sizeof(page)); | 1681 | ata_msense_push(ptr_io, last, def_rw_recovery_mpage, |
1342 | return sizeof(page); | 1682 | sizeof(def_rw_recovery_mpage)); |
1683 | return sizeof(def_rw_recovery_mpage); | ||
1343 | } | 1684 | } |
1344 | 1685 | ||
1345 | /** | 1686 | /** |
@@ -1348,7 +1689,9 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) | |||
1348 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. | 1689 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. |
1349 | * @buflen: Response buffer length. | 1690 | * @buflen: Response buffer length. |
1350 | * | 1691 | * |
1351 | * Simulate MODE SENSE commands. | 1692 | * Simulate MODE SENSE commands. Assume this is invoked for direct |
1693 | * access devices (e.g. disks) only. There should be no block | ||
1694 | * descriptor for other device types. | ||
1352 | * | 1695 | * |
1353 | * LOCKING: | 1696 | * LOCKING: |
1354 | * spin_lock_irqsave(host_set lock) | 1697 | * spin_lock_irqsave(host_set lock) |
@@ -1358,15 +1701,22 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1358 | unsigned int buflen) | 1701 | unsigned int buflen) |
1359 | { | 1702 | { |
1360 | u8 *scsicmd = args->cmd->cmnd, *p, *last; | 1703 | u8 *scsicmd = args->cmd->cmnd, *p, *last; |
1361 | unsigned int page_control, six_byte, output_len; | 1704 | const u8 sat_blk_desc[] = { |
1705 | 0, 0, 0, 0, /* number of blocks: sat unspecified */ | ||
1706 | 0, | ||
1707 | 0, 0x2, 0x0 /* block length: 512 bytes */ | ||
1708 | }; | ||
1709 | u8 pg, spg; | ||
1710 | unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; | ||
1362 | 1711 | ||
1363 | VPRINTK("ENTER\n"); | 1712 | VPRINTK("ENTER\n"); |
1364 | 1713 | ||
1365 | six_byte = (scsicmd[0] == MODE_SENSE); | 1714 | six_byte = (scsicmd[0] == MODE_SENSE); |
1366 | 1715 | ebd = !(scsicmd[1] & 0x8); /* dbd bit inverted == edb */ | |
1367 | /* we only support saved and current values (which we treat | 1716 | /* |
1368 | * in the same manner) | 1717 | * LLBA bit in msense(10) ignored (compliant) |
1369 | */ | 1718 | */ |
1719 | |||
1370 | page_control = scsicmd[2] >> 6; | 1720 | page_control = scsicmd[2] >> 6; |
1371 | switch (page_control) { | 1721 | switch (page_control) { |
1372 | case 0: /* current */ | 1722 | case 0: /* current */ |
@@ -1379,29 +1729,42 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1379 | goto invalid_fld; | 1729 | goto invalid_fld; |
1380 | } | 1730 | } |
1381 | 1731 | ||
1382 | if (six_byte) | 1732 | if (six_byte) { |
1383 | output_len = 4; | 1733 | output_len = 4 + (ebd ? 8 : 0); |
1384 | else | 1734 | alloc_len = scsicmd[4]; |
1385 | output_len = 8; | 1735 | } else { |
1736 | output_len = 8 + (ebd ? 8 : 0); | ||
1737 | alloc_len = (scsicmd[7] << 8) + scsicmd[8]; | ||
1738 | } | ||
1739 | minlen = (alloc_len < buflen) ? alloc_len : buflen; | ||
1386 | 1740 | ||
1387 | p = rbuf + output_len; | 1741 | p = rbuf + output_len; |
1388 | last = rbuf + buflen - 1; | 1742 | last = rbuf + minlen - 1; |
1743 | |||
1744 | pg = scsicmd[2] & 0x3f; | ||
1745 | spg = scsicmd[3]; | ||
1746 | /* | ||
1747 | * No mode subpages supported (yet) but asking for _all_ | ||
1748 | * subpages may be valid | ||
1749 | */ | ||
1750 | if (spg && (spg != ALL_SUB_MPAGES)) | ||
1751 | goto invalid_fld; | ||
1389 | 1752 | ||
1390 | switch(scsicmd[2] & 0x3f) { | 1753 | switch(pg) { |
1391 | case 0x01: /* r/w error recovery */ | 1754 | case RW_RECOVERY_MPAGE: |
1392 | output_len += ata_msense_rw_recovery(&p, last); | 1755 | output_len += ata_msense_rw_recovery(&p, last); |
1393 | break; | 1756 | break; |
1394 | 1757 | ||
1395 | case 0x08: /* caching */ | 1758 | case CACHE_MPAGE: |
1396 | output_len += ata_msense_caching(args->id, &p, last); | 1759 | output_len += ata_msense_caching(args->id, &p, last); |
1397 | break; | 1760 | break; |
1398 | 1761 | ||
1399 | case 0x0a: { /* control mode */ | 1762 | case CONTROL_MPAGE: { |
1400 | output_len += ata_msense_ctl_mode(&p, last); | 1763 | output_len += ata_msense_ctl_mode(&p, last); |
1401 | break; | 1764 | break; |
1402 | } | 1765 | } |
1403 | 1766 | ||
1404 | case 0x3f: /* all pages */ | 1767 | case ALL_MPAGES: |
1405 | output_len += ata_msense_rw_recovery(&p, last); | 1768 | output_len += ata_msense_rw_recovery(&p, last); |
1406 | output_len += ata_msense_caching(args->id, &p, last); | 1769 | output_len += ata_msense_caching(args->id, &p, last); |
1407 | output_len += ata_msense_ctl_mode(&p, last); | 1770 | output_len += ata_msense_ctl_mode(&p, last); |
@@ -1411,15 +1774,31 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1411 | goto invalid_fld; | 1774 | goto invalid_fld; |
1412 | } | 1775 | } |
1413 | 1776 | ||
1777 | if (minlen < 1) | ||
1778 | return 0; | ||
1414 | if (six_byte) { | 1779 | if (six_byte) { |
1415 | output_len--; | 1780 | output_len--; |
1416 | rbuf[0] = output_len; | 1781 | rbuf[0] = output_len; |
1782 | if (ebd) { | ||
1783 | if (minlen > 3) | ||
1784 | rbuf[3] = sizeof(sat_blk_desc); | ||
1785 | if (minlen > 11) | ||
1786 | memcpy(rbuf + 4, sat_blk_desc, | ||
1787 | sizeof(sat_blk_desc)); | ||
1788 | } | ||
1417 | } else { | 1789 | } else { |
1418 | output_len -= 2; | 1790 | output_len -= 2; |
1419 | rbuf[0] = output_len >> 8; | 1791 | rbuf[0] = output_len >> 8; |
1420 | rbuf[1] = output_len; | 1792 | if (minlen > 1) |
1793 | rbuf[1] = output_len; | ||
1794 | if (ebd) { | ||
1795 | if (minlen > 7) | ||
1796 | rbuf[7] = sizeof(sat_blk_desc); | ||
1797 | if (minlen > 15) | ||
1798 | memcpy(rbuf + 8, sat_blk_desc, | ||
1799 | sizeof(sat_blk_desc)); | ||
1800 | } | ||
1421 | } | 1801 | } |
1422 | |||
1423 | return 0; | 1802 | return 0; |
1424 | 1803 | ||
1425 | invalid_fld: | 1804 | invalid_fld: |
@@ -1633,7 +2012,12 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | |||
1633 | VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); | 2012 | VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); |
1634 | 2013 | ||
1635 | if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) | 2014 | if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) |
1636 | ata_to_sense_error(qc, drv_stat); | 2015 | /* FIXME: not quite right; we don't want the |
2016 | * translation of taskfile registers into | ||
2017 | * a sense descriptors, since that's only | ||
2018 | * correct for ATA, not ATAPI | ||
2019 | */ | ||
2020 | ata_gen_ata_desc_sense(qc); | ||
1637 | 2021 | ||
1638 | else if (unlikely(drv_stat & ATA_ERR)) { | 2022 | else if (unlikely(drv_stat & ATA_ERR)) { |
1639 | DPRINTK("request check condition\n"); | 2023 | DPRINTK("request check condition\n"); |
@@ -1792,6 +2176,143 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev) | |||
1792 | return dev; | 2176 | return dev; |
1793 | } | 2177 | } |
1794 | 2178 | ||
2179 | /* | ||
2180 | * ata_scsi_map_proto - Map pass-thru protocol value to taskfile value. | ||
2181 | * @byte1: Byte 1 from pass-thru CDB. | ||
2182 | * | ||
2183 | * RETURNS: | ||
2184 | * ATA_PROT_UNKNOWN if mapping failed/unimplemented, protocol otherwise. | ||
2185 | */ | ||
2186 | static u8 | ||
2187 | ata_scsi_map_proto(u8 byte1) | ||
2188 | { | ||
2189 | switch((byte1 & 0x1e) >> 1) { | ||
2190 | case 3: /* Non-data */ | ||
2191 | return ATA_PROT_NODATA; | ||
2192 | |||
2193 | case 6: /* DMA */ | ||
2194 | return ATA_PROT_DMA; | ||
2195 | |||
2196 | case 4: /* PIO Data-in */ | ||
2197 | case 5: /* PIO Data-out */ | ||
2198 | if (byte1 & 0xe0) { | ||
2199 | return ATA_PROT_PIO_MULT; | ||
2200 | } | ||
2201 | return ATA_PROT_PIO; | ||
2202 | |||
2203 | case 10: /* Device Reset */ | ||
2204 | case 0: /* Hard Reset */ | ||
2205 | case 1: /* SRST */ | ||
2206 | case 2: /* Bus Idle */ | ||
2207 | case 7: /* Packet */ | ||
2208 | case 8: /* DMA Queued */ | ||
2209 | case 9: /* Device Diagnostic */ | ||
2210 | case 11: /* UDMA Data-in */ | ||
2211 | case 12: /* UDMA Data-Out */ | ||
2212 | case 13: /* FPDMA */ | ||
2213 | default: /* Reserved */ | ||
2214 | break; | ||
2215 | } | ||
2216 | |||
2217 | return ATA_PROT_UNKNOWN; | ||
2218 | } | ||
2219 | |||
2220 | /** | ||
2221 | * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile | ||
2222 | * @qc: command structure to be initialized | ||
2223 | * @cmd: SCSI command to convert | ||
2224 | * | ||
2225 | * Handles either 12 or 16-byte versions of the CDB. | ||
2226 | * | ||
2227 | * RETURNS: | ||
2228 | * Zero on success, non-zero on failure. | ||
2229 | */ | ||
2230 | static unsigned int | ||
2231 | ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
2232 | { | ||
2233 | struct ata_taskfile *tf = &(qc->tf); | ||
2234 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
2235 | |||
2236 | if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) | ||
2237 | return 1; | ||
2238 | |||
2239 | /* | ||
2240 | * 12 and 16 byte CDBs use different offsets to | ||
2241 | * provide the various register values. | ||
2242 | */ | ||
2243 | if (scsicmd[0] == ATA_16) { | ||
2244 | /* | ||
2245 | * 16-byte CDB - may contain extended commands. | ||
2246 | * | ||
2247 | * If that is the case, copy the upper byte register values. | ||
2248 | */ | ||
2249 | if (scsicmd[1] & 0x01) { | ||
2250 | tf->hob_feature = scsicmd[3]; | ||
2251 | tf->hob_nsect = scsicmd[5]; | ||
2252 | tf->hob_lbal = scsicmd[7]; | ||
2253 | tf->hob_lbam = scsicmd[9]; | ||
2254 | tf->hob_lbah = scsicmd[11]; | ||
2255 | tf->flags |= ATA_TFLAG_LBA48; | ||
2256 | } else | ||
2257 | tf->flags &= ~ATA_TFLAG_LBA48; | ||
2258 | |||
2259 | /* | ||
2260 | * Always copy low byte, device and command registers. | ||
2261 | */ | ||
2262 | tf->feature = scsicmd[4]; | ||
2263 | tf->nsect = scsicmd[6]; | ||
2264 | tf->lbal = scsicmd[8]; | ||
2265 | tf->lbam = scsicmd[10]; | ||
2266 | tf->lbah = scsicmd[12]; | ||
2267 | tf->device = scsicmd[13]; | ||
2268 | tf->command = scsicmd[14]; | ||
2269 | } else { | ||
2270 | /* | ||
2271 | * 12-byte CDB - incapable of extended commands. | ||
2272 | */ | ||
2273 | tf->flags &= ~ATA_TFLAG_LBA48; | ||
2274 | |||
2275 | tf->feature = scsicmd[3]; | ||
2276 | tf->nsect = scsicmd[4]; | ||
2277 | tf->lbal = scsicmd[5]; | ||
2278 | tf->lbam = scsicmd[6]; | ||
2279 | tf->lbah = scsicmd[7]; | ||
2280 | tf->device = scsicmd[8]; | ||
2281 | tf->command = scsicmd[9]; | ||
2282 | } | ||
2283 | |||
2284 | /* | ||
2285 | * Filter SET_FEATURES - XFER MODE command -- otherwise, | ||
2286 | * SET_FEATURES - XFER MODE must be preceded/succeeded | ||
2287 | * by an update to hardware-specific registers for each | ||
2288 | * controller (i.e. the reason for ->set_piomode(), | ||
2289 | * ->set_dmamode(), and ->post_set_mode() hooks). | ||
2290 | */ | ||
2291 | if ((tf->command == ATA_CMD_SET_FEATURES) | ||
2292 | && (tf->feature == SETFEATURES_XFER)) | ||
2293 | return 1; | ||
2294 | |||
2295 | /* | ||
2296 | * Set flags so that all registers will be written, | ||
2297 | * and pass on write indication (used for PIO/DMA | ||
2298 | * setup.) | ||
2299 | */ | ||
2300 | tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); | ||
2301 | |||
2302 | if (cmd->sc_data_direction == DMA_TO_DEVICE) | ||
2303 | tf->flags |= ATA_TFLAG_WRITE; | ||
2304 | |||
2305 | /* | ||
2306 | * Set transfer length. | ||
2307 | * | ||
2308 | * TODO: find out if we need to do more here to | ||
2309 | * cover scatter/gather case. | ||
2310 | */ | ||
2311 | qc->nsect = cmd->bufflen / ATA_SECT_SIZE; | ||
2312 | |||
2313 | return 0; | ||
2314 | } | ||
2315 | |||
1795 | /** | 2316 | /** |
1796 | * ata_get_xlat_func - check if SCSI to ATA translation is possible | 2317 | * ata_get_xlat_func - check if SCSI to ATA translation is possible |
1797 | * @dev: ATA device | 2318 | * @dev: ATA device |
@@ -1824,6 +2345,11 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) | |||
1824 | case VERIFY: | 2345 | case VERIFY: |
1825 | case VERIFY_16: | 2346 | case VERIFY_16: |
1826 | return ata_scsi_verify_xlat; | 2347 | return ata_scsi_verify_xlat; |
2348 | |||
2349 | case ATA_12: | ||
2350 | case ATA_16: | ||
2351 | return ata_scsi_pass_thru; | ||
2352 | |||
1827 | case START_STOP: | 2353 | case START_STOP: |
1828 | return ata_scsi_start_stop_xlat; | 2354 | return ata_scsi_start_stop_xlat; |
1829 | } | 2355 | } |
@@ -1982,7 +2508,7 @@ void ata_scsi_simulate(u16 *id, | |||
1982 | ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); | 2508 | ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); |
1983 | break; | 2509 | break; |
1984 | 2510 | ||
1985 | /* mandantory commands we haven't implemented yet */ | 2511 | /* mandatory commands we haven't implemented yet */ |
1986 | case REQUEST_SENSE: | 2512 | case REQUEST_SENSE: |
1987 | 2513 | ||
1988 | /* all other commands */ | 2514 | /* all other commands */ |
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 3d60190584ba..65c264b91136 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -50,13 +50,14 @@ extern void ata_dev_select(struct ata_port *ap, unsigned int device, | |||
50 | unsigned int wait, unsigned int can_sleep); | 50 | unsigned int wait, unsigned int can_sleep); |
51 | extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); | 51 | extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); |
52 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); | 52 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); |
53 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); | ||
54 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | ||
53 | 55 | ||
54 | 56 | ||
55 | /* libata-scsi.c */ | 57 | /* libata-scsi.c */ |
56 | extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | 58 | extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, |
57 | struct scsi_cmnd *cmd); | 59 | struct scsi_cmnd *cmd); |
58 | extern void ata_scsi_scan_host(struct ata_port *ap); | 60 | extern void ata_scsi_scan_host(struct ata_port *ap); |
59 | extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat); | ||
60 | extern int ata_scsi_error(struct Scsi_Host *host); | 61 | extern int ata_scsi_error(struct Scsi_Host *host); |
61 | extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, | 62 | extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, |
62 | unsigned int buflen); | 63 | unsigned int buflen); |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index af1133104b3f..172839fce0eb 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5629,7 +5629,7 @@ static void osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * | |||
5629 | 5629 | ||
5630 | if (!osst_sysfs_valid) return; | 5630 | if (!osst_sysfs_valid) return; |
5631 | 5631 | ||
5632 | osst_class_member = class_device_create(osst_sysfs_class, dev, device, "%s", name); | 5632 | osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, device, "%s", name); |
5633 | if (IS_ERR(osst_class_member)) { | 5633 | if (IS_ERR(osst_class_member)) { |
5634 | printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); | 5634 | printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); |
5635 | return; | 5635 | return; |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index 85ec5b1d7aa9..eebb3eb20255 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "pdc_adma" | 48 | #define DRV_NAME "pdc_adma" |
49 | #define DRV_VERSION "0.01" | 49 | #define DRV_VERSION "0.03" |
50 | 50 | ||
51 | /* macro to calculate base address for ATA regs */ | 51 | /* macro to calculate base address for ATA regs */ |
52 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) | 52 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) |
@@ -79,7 +79,6 @@ enum { | |||
79 | aNIEN = (1 << 8), /* irq mask: 1==masked */ | 79 | aNIEN = (1 << 8), /* irq mask: 1==masked */ |
80 | aGO = (1 << 7), /* packet trigger ("Go!") */ | 80 | aGO = (1 << 7), /* packet trigger ("Go!") */ |
81 | aRSTADM = (1 << 5), /* ADMA logic reset */ | 81 | aRSTADM = (1 << 5), /* ADMA logic reset */ |
82 | aRSTA = (1 << 2), /* ATA hard reset */ | ||
83 | aPIOMD4 = 0x0003, /* PIO mode 4 */ | 82 | aPIOMD4 = 0x0003, /* PIO mode 4 */ |
84 | 83 | ||
85 | /* ADMA_STATUS register bits */ | 84 | /* ADMA_STATUS register bits */ |
@@ -452,24 +451,25 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
452 | struct adma_port_priv *pp; | 451 | struct adma_port_priv *pp; |
453 | struct ata_queued_cmd *qc; | 452 | struct ata_queued_cmd *qc; |
454 | void __iomem *chan = ADMA_REGS(mmio_base, port_no); | 453 | void __iomem *chan = ADMA_REGS(mmio_base, port_no); |
455 | u8 drv_stat, status = readb(chan + ADMA_STATUS); | 454 | u8 drv_stat = 0, status = readb(chan + ADMA_STATUS); |
456 | 455 | ||
457 | if (status == 0) | 456 | if (status == 0) |
458 | continue; | 457 | continue; |
459 | handled = 1; | 458 | handled = 1; |
460 | adma_enter_reg_mode(ap); | 459 | adma_enter_reg_mode(ap); |
461 | if ((ap->flags & ATA_FLAG_PORT_DISABLED)) | 460 | if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)) |
462 | continue; | 461 | continue; |
463 | pp = ap->private_data; | 462 | pp = ap->private_data; |
464 | if (!pp || pp->state != adma_state_pkt) | 463 | if (!pp || pp->state != adma_state_pkt) |
465 | continue; | 464 | continue; |
466 | qc = ata_qc_from_tag(ap, ap->active_tag); | 465 | qc = ata_qc_from_tag(ap, ap->active_tag); |
467 | drv_stat = 0; | 466 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { |
468 | if ((status & (aPERR | aPSD | aUIRQ))) | 467 | if ((status & (aPERR | aPSD | aUIRQ))) |
469 | drv_stat = ATA_ERR; | 468 | drv_stat = ATA_ERR; |
470 | else if (pp->pkt[0] != cDONE) | 469 | else if (pp->pkt[0] != cDONE) |
471 | drv_stat = ATA_ERR; | 470 | drv_stat = ATA_ERR; |
472 | ata_qc_complete(qc, drv_stat); | 471 | ata_qc_complete(qc, drv_stat); |
472 | } | ||
473 | } | 473 | } |
474 | return handled; | 474 | return handled; |
475 | } | 475 | } |
@@ -561,15 +561,15 @@ static int adma_port_start(struct ata_port *ap) | |||
561 | if ((pp->pkt_dma & 7) != 0) { | 561 | if ((pp->pkt_dma & 7) != 0) { |
562 | printk("bad alignment for pp->pkt_dma: %08x\n", | 562 | printk("bad alignment for pp->pkt_dma: %08x\n", |
563 | (u32)pp->pkt_dma); | 563 | (u32)pp->pkt_dma); |
564 | goto err_out_kfree2; | 564 | dma_free_coherent(dev, ADMA_PKT_BYTES, |
565 | pp->pkt, pp->pkt_dma); | ||
566 | goto err_out_kfree; | ||
565 | } | 567 | } |
566 | memset(pp->pkt, 0, ADMA_PKT_BYTES); | 568 | memset(pp->pkt, 0, ADMA_PKT_BYTES); |
567 | ap->private_data = pp; | 569 | ap->private_data = pp; |
568 | adma_reinit_engine(ap); | 570 | adma_reinit_engine(ap); |
569 | return 0; | 571 | return 0; |
570 | 572 | ||
571 | err_out_kfree2: | ||
572 | kfree(pp); | ||
573 | err_out_kfree: | 573 | err_out_kfree: |
574 | kfree(pp); | 574 | kfree(pp); |
575 | err_out: | 575 | err_out: |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index eee93b0016df..63911f16b6ec 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -195,6 +195,8 @@ static struct ata_port_info pdc_port_info[] = { | |||
195 | static struct pci_device_id pdc_ata_pci_tbl[] = { | 195 | static struct pci_device_id pdc_ata_pci_tbl[] = { |
196 | { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 196 | { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
197 | board_2037x }, | 197 | board_2037x }, |
198 | { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
199 | board_2037x }, | ||
198 | { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 200 | { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
199 | board_2037x }, | 201 | board_2037x }, |
200 | { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 202 | { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
@@ -207,6 +209,8 @@ static struct pci_device_id pdc_ata_pci_tbl[] = { | |||
207 | board_2037x }, | 209 | board_2037x }, |
208 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 210 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
209 | board_2037x }, | 211 | board_2037x }, |
212 | { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
213 | board_2037x }, | ||
210 | 214 | ||
211 | { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 215 | { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
212 | board_20319 }, | 216 | board_20319 }, |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index fd56b7ec88b6..861e51375d70 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -104,8 +104,8 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF; | |||
104 | 104 | ||
105 | #define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ | 105 | #define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ |
106 | 106 | ||
107 | static int sg_add(struct class_device *); | 107 | static int sg_add(struct class_device *, struct class_interface *); |
108 | static void sg_remove(struct class_device *); | 108 | static void sg_remove(struct class_device *, struct class_interface *); |
109 | 109 | ||
110 | static Scsi_Request *dummy_cmdp; /* only used for sizeof */ | 110 | static Scsi_Request *dummy_cmdp; /* only used for sizeof */ |
111 | 111 | ||
@@ -1506,7 +1506,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | static int | 1508 | static int |
1509 | sg_add(struct class_device *cl_dev) | 1509 | sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) |
1510 | { | 1510 | { |
1511 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1511 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); |
1512 | struct gendisk *disk; | 1512 | struct gendisk *disk; |
@@ -1550,7 +1550,7 @@ sg_add(struct class_device *cl_dev) | |||
1550 | if (sg_sysfs_valid) { | 1550 | if (sg_sysfs_valid) { |
1551 | struct class_device * sg_class_member; | 1551 | struct class_device * sg_class_member; |
1552 | 1552 | ||
1553 | sg_class_member = class_device_create(sg_sysfs_class, | 1553 | sg_class_member = class_device_create(sg_sysfs_class, NULL, |
1554 | MKDEV(SCSI_GENERIC_MAJOR, k), | 1554 | MKDEV(SCSI_GENERIC_MAJOR, k), |
1555 | cl_dev->dev, "%s", | 1555 | cl_dev->dev, "%s", |
1556 | disk->disk_name); | 1556 | disk->disk_name); |
@@ -1582,7 +1582,7 @@ out: | |||
1582 | } | 1582 | } |
1583 | 1583 | ||
1584 | static void | 1584 | static void |
1585 | sg_remove(struct class_device *cl_dev) | 1585 | sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) |
1586 | { | 1586 | { |
1587 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1587 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); |
1588 | Sg_device *sdp = NULL; | 1588 | Sg_device *sdp = NULL; |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 927d700f0073..5eb54d8019b4 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -4377,7 +4377,7 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) | |||
4377 | snprintf(name, 10, "%s%s%s", rew ? "n" : "", | 4377 | snprintf(name, 10, "%s%s%s", rew ? "n" : "", |
4378 | STp->disk->disk_name, st_formats[i]); | 4378 | STp->disk->disk_name, st_formats[i]); |
4379 | st_class_member = | 4379 | st_class_member = |
4380 | class_device_create(st_sysfs_class, | 4380 | class_device_create(st_sysfs_class, NULL, |
4381 | MKDEV(SCSI_TAPE_MAJOR, | 4381 | MKDEV(SCSI_TAPE_MAJOR, |
4382 | TAPE_MINOR(dev_num, mode, rew)), | 4382 | TAPE_MINOR(dev_num, mode, rew)), |
4383 | &STp->device->sdev_gendev, "%s", name); | 4383 | &STp->device->sdev_gendev, "%s", name); |
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c index 5a51051e31f0..b131432c677d 100644 --- a/drivers/scsi/zalon.c +++ b/drivers/scsi/zalon.c | |||
@@ -88,7 +88,7 @@ zalon_probe(struct parisc_device *dev) | |||
88 | struct gsc_irq gsc_irq; | 88 | struct gsc_irq gsc_irq; |
89 | u32 zalon_vers; | 89 | u32 zalon_vers; |
90 | int error = -ENODEV; | 90 | int error = -ENODEV; |
91 | void __iomem *zalon = ioremap(dev->hpa, 4096); | 91 | void __iomem *zalon = ioremap(dev->hpa.start, 4096); |
92 | void __iomem *io_port = zalon + GSC_SCSI_ZALON_OFFSET; | 92 | void __iomem *io_port = zalon + GSC_SCSI_ZALON_OFFSET; |
93 | static int unit = 0; | 93 | static int unit = 0; |
94 | struct Scsi_Host *host; | 94 | struct Scsi_Host *host; |
@@ -127,7 +127,7 @@ zalon_probe(struct parisc_device *dev) | |||
127 | device.chip = zalon720_chip; | 127 | device.chip = zalon720_chip; |
128 | device.host_id = 7; | 128 | device.host_id = 7; |
129 | device.dev = &dev->dev; | 129 | device.dev = &dev->dev; |
130 | device.slot.base = dev->hpa + GSC_SCSI_ZALON_OFFSET; | 130 | device.slot.base = dev->hpa.start + GSC_SCSI_ZALON_OFFSET; |
131 | device.slot.base_v = io_port; | 131 | device.slot.base_v = io_port; |
132 | device.slot.irq = dev->irq; | 132 | device.slot.irq = dev->irq; |
133 | device.differential = 2; | 133 | device.differential = 2; |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 4d75cdfa0a0a..afb7ddf200e0 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -2358,13 +2358,10 @@ static int __devexit serial8250_remove(struct device *dev) | |||
2358 | return 0; | 2358 | return 0; |
2359 | } | 2359 | } |
2360 | 2360 | ||
2361 | static int serial8250_suspend(struct device *dev, pm_message_t state, u32 level) | 2361 | static int serial8250_suspend(struct device *dev, pm_message_t state) |
2362 | { | 2362 | { |
2363 | int i; | 2363 | int i; |
2364 | 2364 | ||
2365 | if (level != SUSPEND_DISABLE) | ||
2366 | return 0; | ||
2367 | |||
2368 | for (i = 0; i < UART_NR; i++) { | 2365 | for (i = 0; i < UART_NR; i++) { |
2369 | struct uart_8250_port *up = &serial8250_ports[i]; | 2366 | struct uart_8250_port *up = &serial8250_ports[i]; |
2370 | 2367 | ||
@@ -2375,13 +2372,10 @@ static int serial8250_suspend(struct device *dev, pm_message_t state, u32 level) | |||
2375 | return 0; | 2372 | return 0; |
2376 | } | 2373 | } |
2377 | 2374 | ||
2378 | static int serial8250_resume(struct device *dev, u32 level) | 2375 | static int serial8250_resume(struct device *dev) |
2379 | { | 2376 | { |
2380 | int i; | 2377 | int i; |
2381 | 2378 | ||
2382 | if (level != RESUME_ENABLE) | ||
2383 | return 0; | ||
2384 | |||
2385 | for (i = 0; i < UART_NR; i++) { | 2379 | for (i = 0; i < UART_NR; i++) { |
2386 | struct uart_8250_port *up = &serial8250_ports[i]; | 2380 | struct uart_8250_port *up = &serial8250_ports[i]; |
2387 | 2381 | ||
diff --git a/drivers/serial/8250_gsc.c b/drivers/serial/8250_gsc.c index 431aa5761a7a..8b4947933d9b 100644 --- a/drivers/serial/8250_gsc.c +++ b/drivers/serial/8250_gsc.c | |||
@@ -29,7 +29,6 @@ | |||
29 | static int __init | 29 | static int __init |
30 | serial_init_chip(struct parisc_device *dev) | 30 | serial_init_chip(struct parisc_device *dev) |
31 | { | 31 | { |
32 | static int serial_line_nr; | ||
33 | struct uart_port port; | 32 | struct uart_port port; |
34 | unsigned long address; | 33 | unsigned long address; |
35 | int err; | 34 | int err; |
@@ -42,12 +41,13 @@ serial_init_chip(struct parisc_device *dev) | |||
42 | */ | 41 | */ |
43 | if (parisc_parent(dev)->id.hw_type != HPHW_IOA) { | 42 | if (parisc_parent(dev)->id.hw_type != HPHW_IOA) { |
44 | printk(KERN_INFO "Serial: device 0x%lx not configured.\n" | 43 | printk(KERN_INFO "Serial: device 0x%lx not configured.\n" |
45 | "Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa); | 44 | "Enable support for Wax, Lasi, Asp or Dino.\n", |
45 | dev->hpa.start); | ||
46 | } | 46 | } |
47 | return -ENODEV; | 47 | return -ENODEV; |
48 | } | 48 | } |
49 | 49 | ||
50 | address = dev->hpa; | 50 | address = dev->hpa.start; |
51 | if (dev->id.sversion != 0x8d) { | 51 | if (dev->id.sversion != 0x8d) { |
52 | address += 0x800; | 52 | address += 0x800; |
53 | } | 53 | } |
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c index 679e678c7e6a..ddd0307fece2 100644 --- a/drivers/serial/amba-pl010.c +++ b/drivers/serial/amba-pl010.c | |||
@@ -50,6 +50,7 @@ | |||
50 | 50 | ||
51 | #include <asm/io.h> | 51 | #include <asm/io.h> |
52 | #include <asm/irq.h> | 52 | #include <asm/irq.h> |
53 | #include <asm/hardware.h> | ||
53 | #include <asm/hardware/amba.h> | 54 | #include <asm/hardware/amba.h> |
54 | #include <asm/hardware/amba_serial.h> | 55 | #include <asm/hardware/amba_serial.h> |
55 | 56 | ||
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 1ff629c74750..938d185841c9 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c | |||
@@ -50,6 +50,7 @@ | |||
50 | 50 | ||
51 | #include <asm/io.h> | 51 | #include <asm/io.h> |
52 | #include <asm/irq.h> | 52 | #include <asm/irq.h> |
53 | #include <asm/sizes.h> | ||
53 | #include <asm/hardware/amba.h> | 54 | #include <asm/hardware/amba.h> |
54 | #include <asm/hardware/clock.h> | 55 | #include <asm/hardware/clock.h> |
55 | #include <asm/hardware/amba_serial.h> | 56 | #include <asm/hardware/amba_serial.h> |
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c index 87ef368384fb..6a67e8f585b3 100644 --- a/drivers/serial/clps711x.c +++ b/drivers/serial/clps711x.c | |||
@@ -408,7 +408,11 @@ static struct uart_port clps711x_ports[UART_NR] = { | |||
408 | { | 408 | { |
409 | .iobase = SYSCON1, | 409 | .iobase = SYSCON1, |
410 | .irq = IRQ_UTXINT1, /* IRQ_URXINT1, IRQ_UMSINT */ | 410 | .irq = IRQ_UTXINT1, /* IRQ_URXINT1, IRQ_UMSINT */ |
411 | #ifdef CONFIG_MP1000_90MHZ | ||
412 | .uartclk = 4515840, | ||
413 | #else | ||
411 | .uartclk = 3686400, | 414 | .uartclk = 3686400, |
415 | #endif | ||
412 | .fifosize = 16, | 416 | .fifosize = 16, |
413 | .ops = &clps711x_pops, | 417 | .ops = &clps711x_pops, |
414 | .line = 0, | 418 | .line = 0, |
@@ -417,7 +421,11 @@ static struct uart_port clps711x_ports[UART_NR] = { | |||
417 | { | 421 | { |
418 | .iobase = SYSCON2, | 422 | .iobase = SYSCON2, |
419 | .irq = IRQ_UTXINT2, /* IRQ_URXINT2 */ | 423 | .irq = IRQ_UTXINT2, /* IRQ_URXINT2 */ |
424 | #ifdef CONFIG_MP1000_90MHZ | ||
425 | .uartclk = 4515840, | ||
426 | #else | ||
420 | .uartclk = 3686400, | 427 | .uartclk = 3686400, |
428 | #endif | ||
421 | .fifosize = 16, | 429 | .fifosize = 16, |
422 | .ops = &clps711x_pops, | 430 | .ops = &clps711x_pops, |
423 | .line = 1, | 431 | .line = 1, |
@@ -551,6 +559,7 @@ console_initcall(clps711xuart_console_init); | |||
551 | static struct uart_driver clps711x_reg = { | 559 | static struct uart_driver clps711x_reg = { |
552 | .driver_name = "ttyCL", | 560 | .driver_name = "ttyCL", |
553 | .dev_name = "ttyCL", | 561 | .dev_name = "ttyCL", |
562 | .devfs_name = "ttyCL", | ||
554 | .major = SERIAL_CLPS711X_MAJOR, | 563 | .major = SERIAL_CLPS711X_MAJOR, |
555 | .minor = SERIAL_CLPS711X_MINOR, | 564 | .minor = SERIAL_CLPS711X_MINOR, |
556 | .nr = UART_NR, | 565 | .nr = UART_NR, |
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index bdb4e454b8b0..5b3933b0c997 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c | |||
@@ -921,21 +921,21 @@ static struct uart_driver imx_reg = { | |||
921 | .cons = IMX_CONSOLE, | 921 | .cons = IMX_CONSOLE, |
922 | }; | 922 | }; |
923 | 923 | ||
924 | static int serial_imx_suspend(struct device *_dev, pm_message_t state, u32 level) | 924 | static int serial_imx_suspend(struct device *_dev, pm_message_t state) |
925 | { | 925 | { |
926 | struct imx_port *sport = dev_get_drvdata(_dev); | 926 | struct imx_port *sport = dev_get_drvdata(_dev); |
927 | 927 | ||
928 | if (sport && level == SUSPEND_DISABLE) | 928 | if (sport) |
929 | uart_suspend_port(&imx_reg, &sport->port); | 929 | uart_suspend_port(&imx_reg, &sport->port); |
930 | 930 | ||
931 | return 0; | 931 | return 0; |
932 | } | 932 | } |
933 | 933 | ||
934 | static int serial_imx_resume(struct device *_dev, u32 level) | 934 | static int serial_imx_resume(struct device *_dev) |
935 | { | 935 | { |
936 | struct imx_port *sport = dev_get_drvdata(_dev); | 936 | struct imx_port *sport = dev_get_drvdata(_dev); |
937 | 937 | ||
938 | if (sport && level == RESUME_ENABLE) | 938 | if (sport) |
939 | uart_resume_port(&imx_reg, &sport->port); | 939 | uart_resume_port(&imx_reg, &sport->port); |
940 | 940 | ||
941 | return 0; | 941 | return 0; |
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 0585ab27ffde..8a79968f8ce1 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -781,22 +781,22 @@ mpc52xx_uart_remove(struct device *dev) | |||
781 | 781 | ||
782 | #ifdef CONFIG_PM | 782 | #ifdef CONFIG_PM |
783 | static int | 783 | static int |
784 | mpc52xx_uart_suspend(struct device *dev, pm_message_t state, u32 level) | 784 | mpc52xx_uart_suspend(struct device *dev, pm_message_t state) |
785 | { | 785 | { |
786 | struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); | 786 | struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); |
787 | 787 | ||
788 | if (sport && level == SUSPEND_DISABLE) | 788 | if (sport) |
789 | uart_suspend_port(&mpc52xx_uart_driver, port); | 789 | uart_suspend_port(&mpc52xx_uart_driver, port); |
790 | 790 | ||
791 | return 0; | 791 | return 0; |
792 | } | 792 | } |
793 | 793 | ||
794 | static int | 794 | static int |
795 | mpc52xx_uart_resume(struct device *dev, u32 level) | 795 | mpc52xx_uart_resume(struct device *dev) |
796 | { | 796 | { |
797 | struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); | 797 | struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); |
798 | 798 | ||
799 | if (port && level == RESUME_ENABLE) | 799 | if (port) |
800 | uart_resume_port(&mpc52xx_uart_driver, port); | 800 | uart_resume_port(&mpc52xx_uart_driver, port); |
801 | 801 | ||
802 | return 0; | 802 | return 0; |
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c index 189064607709..660bae5ba179 100644 --- a/drivers/serial/mux.c +++ b/drivers/serial/mux.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/delay.h> /* for udelay */ | 27 | #include <linux/delay.h> /* for udelay */ |
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <asm/io.h> | 29 | #include <asm/io.h> |
30 | #include <asm/irq.h> | ||
30 | #include <asm/parisc-device.h> | 31 | #include <asm/parisc-device.h> |
31 | 32 | ||
32 | #ifdef CONFIG_MAGIC_SYSRQ | 33 | #ifdef CONFIG_MAGIC_SYSRQ |
@@ -444,7 +445,7 @@ static int __init mux_probe(struct parisc_device *dev) | |||
444 | unsigned long bytecnt; | 445 | unsigned long bytecnt; |
445 | struct uart_port *port; | 446 | struct uart_port *port; |
446 | 447 | ||
447 | status = pdc_iodc_read(&bytecnt, dev->hpa, 0, iodc_data, 32); | 448 | status = pdc_iodc_read(&bytecnt, dev->hpa.start, 0, iodc_data, 32); |
448 | if(status != PDC_OK) { | 449 | if(status != PDC_OK) { |
449 | printk(KERN_ERR "Serial mux: Unable to read IODC.\n"); | 450 | printk(KERN_ERR "Serial mux: Unable to read IODC.\n"); |
450 | return 1; | 451 | return 1; |
@@ -469,16 +470,18 @@ static int __init mux_probe(struct parisc_device *dev) | |||
469 | for(i = 0; i < ports; ++i, ++port_cnt) { | 470 | for(i = 0; i < ports; ++i, ++port_cnt) { |
470 | port = &mux_ports[port_cnt]; | 471 | port = &mux_ports[port_cnt]; |
471 | port->iobase = 0; | 472 | port->iobase = 0; |
472 | port->mapbase = dev->hpa + MUX_OFFSET + (i * MUX_LINE_OFFSET); | 473 | port->mapbase = dev->hpa.start + MUX_OFFSET + |
474 | (i * MUX_LINE_OFFSET); | ||
473 | port->membase = ioremap(port->mapbase, MUX_LINE_OFFSET); | 475 | port->membase = ioremap(port->mapbase, MUX_LINE_OFFSET); |
474 | port->iotype = SERIAL_IO_MEM; | 476 | port->iotype = SERIAL_IO_MEM; |
475 | port->type = PORT_MUX; | 477 | port->type = PORT_MUX; |
476 | port->irq = SERIAL_IRQ_NONE; | 478 | port->irq = NO_IRQ; |
477 | port->uartclk = 0; | 479 | port->uartclk = 0; |
478 | port->fifosize = MUX_FIFO_SIZE; | 480 | port->fifosize = MUX_FIFO_SIZE; |
479 | port->ops = &mux_pops; | 481 | port->ops = &mux_pops; |
480 | port->flags = UPF_BOOT_AUTOCONF; | 482 | port->flags = UPF_BOOT_AUTOCONF; |
481 | port->line = port_cnt; | 483 | port->line = port_cnt; |
484 | spin_lock_init(&port->lock); | ||
482 | status = uart_add_one_port(&mux_driver, port); | 485 | status = uart_add_one_port(&mux_driver, port); |
483 | BUG_ON(status); | 486 | BUG_ON(status); |
484 | } | 487 | } |
@@ -497,7 +500,7 @@ static struct parisc_device_id mux_tbl[] = { | |||
497 | MODULE_DEVICE_TABLE(parisc, mux_tbl); | 500 | MODULE_DEVICE_TABLE(parisc, mux_tbl); |
498 | 501 | ||
499 | static struct parisc_driver serial_mux_driver = { | 502 | static struct parisc_driver serial_mux_driver = { |
500 | .name = "Serial MUX", | 503 | .name = "serial_mux", |
501 | .id_table = mux_tbl, | 504 | .id_table = mux_tbl, |
502 | .probe = mux_probe, | 505 | .probe = mux_probe, |
503 | }; | 506 | }; |
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c index 90c2a86c421b..8cc4cedadd99 100644 --- a/drivers/serial/pxa.c +++ b/drivers/serial/pxa.c | |||
@@ -358,6 +358,9 @@ static int serial_pxa_startup(struct uart_port *port) | |||
358 | unsigned long flags; | 358 | unsigned long flags; |
359 | int retval; | 359 | int retval; |
360 | 360 | ||
361 | if (port->line == 3) /* HWUART */ | ||
362 | up->mcr |= UART_MCR_AFE; | ||
363 | else | ||
361 | up->mcr = 0; | 364 | up->mcr = 0; |
362 | 365 | ||
363 | /* | 366 | /* |
@@ -481,8 +484,10 @@ serial_pxa_set_termios(struct uart_port *port, struct termios *termios, | |||
481 | 484 | ||
482 | if ((up->port.uartclk / quot) < (2400 * 16)) | 485 | if ((up->port.uartclk / quot) < (2400 * 16)) |
483 | fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR1; | 486 | fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR1; |
484 | else | 487 | else if ((up->port.uartclk / quot) < (230400 * 16)) |
485 | fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR8; | 488 | fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR8; |
489 | else | ||
490 | fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR32; | ||
486 | 491 | ||
487 | /* | 492 | /* |
488 | * Ok, we're now changing the port state. Do it with | 493 | * Ok, we're now changing the port state. Do it with |
@@ -772,6 +777,20 @@ static struct uart_pxa_port serial_pxa_ports[] = { | |||
772 | .ops = &serial_pxa_pops, | 777 | .ops = &serial_pxa_pops, |
773 | .line = 2, | 778 | .line = 2, |
774 | }, | 779 | }, |
780 | }, { /* HWUART */ | ||
781 | .name = "HWUART", | ||
782 | .cken = CKEN4_HWUART, | ||
783 | .port = { | ||
784 | .type = PORT_PXA, | ||
785 | .iotype = UPIO_MEM, | ||
786 | .membase = (void *)&HWUART, | ||
787 | .mapbase = __PREG(HWUART), | ||
788 | .irq = IRQ_HWUART, | ||
789 | .uartclk = 921600 * 16, | ||
790 | .fifosize = 64, | ||
791 | .ops = &serial_pxa_pops, | ||
792 | .line = 3, | ||
793 | }, | ||
775 | } | 794 | } |
776 | }; | 795 | }; |
777 | 796 | ||
@@ -786,21 +805,21 @@ static struct uart_driver serial_pxa_reg = { | |||
786 | .cons = PXA_CONSOLE, | 805 | .cons = PXA_CONSOLE, |
787 | }; | 806 | }; |
788 | 807 | ||
789 | static int serial_pxa_suspend(struct device *_dev, pm_message_t state, u32 level) | 808 | static int serial_pxa_suspend(struct device *_dev, pm_message_t state) |
790 | { | 809 | { |
791 | struct uart_pxa_port *sport = dev_get_drvdata(_dev); | 810 | struct uart_pxa_port *sport = dev_get_drvdata(_dev); |
792 | 811 | ||
793 | if (sport && level == SUSPEND_DISABLE) | 812 | if (sport) |
794 | uart_suspend_port(&serial_pxa_reg, &sport->port); | 813 | uart_suspend_port(&serial_pxa_reg, &sport->port); |
795 | 814 | ||
796 | return 0; | 815 | return 0; |
797 | } | 816 | } |
798 | 817 | ||
799 | static int serial_pxa_resume(struct device *_dev, u32 level) | 818 | static int serial_pxa_resume(struct device *_dev) |
800 | { | 819 | { |
801 | struct uart_pxa_port *sport = dev_get_drvdata(_dev); | 820 | struct uart_pxa_port *sport = dev_get_drvdata(_dev); |
802 | 821 | ||
803 | if (sport && level == RESUME_ENABLE) | 822 | if (sport) |
804 | uart_resume_port(&serial_pxa_reg, &sport->port); | 823 | uart_resume_port(&serial_pxa_reg, &sport->port); |
805 | 824 | ||
806 | return 0; | 825 | return 0; |
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 52692aa345ec..06a17dff1a73 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c | |||
@@ -1134,23 +1134,22 @@ static int s3c24xx_serial_remove(struct device *_dev) | |||
1134 | 1134 | ||
1135 | #ifdef CONFIG_PM | 1135 | #ifdef CONFIG_PM |
1136 | 1136 | ||
1137 | static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state, | 1137 | static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state) |
1138 | u32 level) | ||
1139 | { | 1138 | { |
1140 | struct uart_port *port = s3c24xx_dev_to_port(dev); | 1139 | struct uart_port *port = s3c24xx_dev_to_port(dev); |
1141 | 1140 | ||
1142 | if (port && level == SUSPEND_DISABLE) | 1141 | if (port) |
1143 | uart_suspend_port(&s3c24xx_uart_drv, port); | 1142 | uart_suspend_port(&s3c24xx_uart_drv, port); |
1144 | 1143 | ||
1145 | return 0; | 1144 | return 0; |
1146 | } | 1145 | } |
1147 | 1146 | ||
1148 | static int s3c24xx_serial_resume(struct device *dev, u32 level) | 1147 | static int s3c24xx_serial_resume(struct device *dev) |
1149 | { | 1148 | { |
1150 | struct uart_port *port = s3c24xx_dev_to_port(dev); | 1149 | struct uart_port *port = s3c24xx_dev_to_port(dev); |
1151 | struct s3c24xx_uart_port *ourport = to_ourport(port); | 1150 | struct s3c24xx_uart_port *ourport = to_ourport(port); |
1152 | 1151 | ||
1153 | if (port && level == RESUME_ENABLE) { | 1152 | if (port) { |
1154 | clk_enable(ourport->clk); | 1153 | clk_enable(ourport->clk); |
1155 | s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); | 1154 | s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); |
1156 | clk_disable(ourport->clk); | 1155 | clk_disable(ourport->clk); |
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c index dd8aed242357..c4a789e6af44 100644 --- a/drivers/serial/sa1100.c +++ b/drivers/serial/sa1100.c | |||
@@ -834,21 +834,21 @@ static struct uart_driver sa1100_reg = { | |||
834 | .cons = SA1100_CONSOLE, | 834 | .cons = SA1100_CONSOLE, |
835 | }; | 835 | }; |
836 | 836 | ||
837 | static int sa1100_serial_suspend(struct device *_dev, pm_message_t state, u32 level) | 837 | static int sa1100_serial_suspend(struct device *_dev, pm_message_t state) |
838 | { | 838 | { |
839 | struct sa1100_port *sport = dev_get_drvdata(_dev); | 839 | struct sa1100_port *sport = dev_get_drvdata(_dev); |
840 | 840 | ||
841 | if (sport && level == SUSPEND_DISABLE) | 841 | if (sport) |
842 | uart_suspend_port(&sa1100_reg, &sport->port); | 842 | uart_suspend_port(&sa1100_reg, &sport->port); |
843 | 843 | ||
844 | return 0; | 844 | return 0; |
845 | } | 845 | } |
846 | 846 | ||
847 | static int sa1100_serial_resume(struct device *_dev, u32 level) | 847 | static int sa1100_serial_resume(struct device *_dev) |
848 | { | 848 | { |
849 | struct sa1100_port *sport = dev_get_drvdata(_dev); | 849 | struct sa1100_port *sport = dev_get_drvdata(_dev); |
850 | 850 | ||
851 | if (sport && level == RESUME_ENABLE) | 851 | if (sport) |
852 | uart_resume_port(&sa1100_reg, &sport->port); | 852 | uart_resume_port(&sa1100_reg, &sport->port); |
853 | 853 | ||
854 | return 0; | 854 | return 0; |
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 0c5d65a08f6e..2b623ab0e36e 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c | |||
@@ -976,14 +976,11 @@ static int siu_remove(struct device *dev) | |||
976 | return 0; | 976 | return 0; |
977 | } | 977 | } |
978 | 978 | ||
979 | static int siu_suspend(struct device *dev, pm_message_t state, u32 level) | 979 | static int siu_suspend(struct device *dev, pm_message_t state) |
980 | { | 980 | { |
981 | struct uart_port *port; | 981 | struct uart_port *port; |
982 | int i; | 982 | int i; |
983 | 983 | ||
984 | if (level != SUSPEND_DISABLE) | ||
985 | return 0; | ||
986 | |||
987 | for (i = 0; i < siu_uart_driver.nr; i++) { | 984 | for (i = 0; i < siu_uart_driver.nr; i++) { |
988 | port = &siu_uart_ports[i]; | 985 | port = &siu_uart_ports[i]; |
989 | if ((port->type == PORT_VR41XX_SIU || | 986 | if ((port->type == PORT_VR41XX_SIU || |
@@ -995,14 +992,11 @@ static int siu_suspend(struct device *dev, pm_message_t state, u32 level) | |||
995 | return 0; | 992 | return 0; |
996 | } | 993 | } |
997 | 994 | ||
998 | static int siu_resume(struct device *dev, u32 level) | 995 | static int siu_resume(struct device *dev) |
999 | { | 996 | { |
1000 | struct uart_port *port; | 997 | struct uart_port *port; |
1001 | int i; | 998 | int i; |
1002 | 999 | ||
1003 | if (level != RESUME_ENABLE) | ||
1004 | return 0; | ||
1005 | |||
1006 | for (i = 0; i < siu_uart_driver.nr; i++) { | 1000 | for (i = 0; i < siu_uart_driver.nr; i++) { |
1007 | port = &siu_uart_ports[i]; | 1001 | port = &siu_uart_ports[i]; |
1008 | if ((port->type == PORT_VR41XX_SIU || | 1002 | if ((port->type == PORT_VR41XX_SIU || |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 487ff672b104..befe0c7f63d1 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -1509,7 +1509,7 @@ void usbdev_add(struct usb_device *dev) | |||
1509 | { | 1509 | { |
1510 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); | 1510 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); |
1511 | 1511 | ||
1512 | dev->class_dev = class_device_create(usb_device_class, | 1512 | dev->class_dev = class_device_create(usb_device_class, NULL, |
1513 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, | 1513 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, |
1514 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); | 1514 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); |
1515 | 1515 | ||
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 65ca131cc44c..78cb4be9529f 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -172,7 +172,9 @@ int usb_register_dev(struct usb_interface *intf, | |||
172 | ++temp; | 172 | ++temp; |
173 | else | 173 | else |
174 | temp = name; | 174 | temp = name; |
175 | intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); | 175 | intf->class_dev = class_device_create(usb_class, NULL, |
176 | MKDEV(USB_MAJOR, minor), | ||
177 | &intf->dev, "%s", temp); | ||
176 | if (IS_ERR(intf->class_dev)) { | 178 | if (IS_ERR(intf->class_dev)) { |
177 | spin_lock (&minor_lock); | 179 | spin_lock (&minor_lock); |
178 | usb_minors[intf->minor] = NULL; | 180 | usb_minors[intf->minor] = NULL; |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ff19d64041b5..14c47a10da86 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -782,7 +782,8 @@ static int usb_register_bus(struct usb_bus *bus) | |||
782 | return -E2BIG; | 782 | return -E2BIG; |
783 | } | 783 | } |
784 | 784 | ||
785 | bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum); | 785 | bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), |
786 | bus->controller, "usb_host%d", busnum); | ||
786 | if (IS_ERR(bus->class_dev)) { | 787 | if (IS_ERR(bus->class_dev)) { |
787 | clear_bit(busnum, busmap.busmap); | 788 | clear_bit(busnum, busmap.busmap); |
788 | up(&usb_bus_list_lock); | 789 | up(&usb_bus_list_lock); |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a12cab5314e9..c3e2024c4347 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -1020,9 +1020,15 @@ void usb_set_device_state(struct usb_device *udev, | |||
1020 | spin_lock_irqsave(&device_state_lock, flags); | 1020 | spin_lock_irqsave(&device_state_lock, flags); |
1021 | if (udev->state == USB_STATE_NOTATTACHED) | 1021 | if (udev->state == USB_STATE_NOTATTACHED) |
1022 | ; /* do nothing */ | 1022 | ; /* do nothing */ |
1023 | else if (new_state != USB_STATE_NOTATTACHED) | 1023 | else if (new_state != USB_STATE_NOTATTACHED) { |
1024 | udev->state = new_state; | 1024 | udev->state = new_state; |
1025 | else | 1025 | if (new_state == USB_STATE_CONFIGURED) |
1026 | device_init_wakeup(&udev->dev, | ||
1027 | (udev->actconfig->desc.bmAttributes | ||
1028 | & USB_CONFIG_ATT_WAKEUP)); | ||
1029 | else if (new_state != USB_STATE_SUSPENDED) | ||
1030 | device_init_wakeup(&udev->dev, 0); | ||
1031 | } else | ||
1026 | recursively_mark_NOTATTACHED(udev); | 1032 | recursively_mark_NOTATTACHED(udev); |
1027 | spin_unlock_irqrestore(&device_state_lock, flags); | 1033 | spin_unlock_irqrestore(&device_state_lock, flags); |
1028 | } | 1034 | } |
@@ -1546,11 +1552,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1, | |||
1546 | * NOTE: OTG devices may issue remote wakeup (or SRP) even when | 1552 | * NOTE: OTG devices may issue remote wakeup (or SRP) even when |
1547 | * we don't explicitly enable it here. | 1553 | * we don't explicitly enable it here. |
1548 | */ | 1554 | */ |
1549 | if (udev->actconfig | 1555 | if (device_may_wakeup(&udev->dev)) { |
1550 | // && FIXME (remote wakeup enabled on this bus) | ||
1551 | // ... currently assuming it's always appropriate | ||
1552 | && (udev->actconfig->desc.bmAttributes | ||
1553 | & USB_CONFIG_ATT_WAKEUP) != 0) { | ||
1554 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 1556 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
1555 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, | 1557 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, |
1556 | USB_DEVICE_REMOTE_WAKEUP, 0, | 1558 | USB_DEVICE_REMOTE_WAKEUP, 0, |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 8d9d8ee89554..503201764f6b 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -935,14 +935,10 @@ static int dummy_udc_remove (struct device *dev) | |||
935 | return 0; | 935 | return 0; |
936 | } | 936 | } |
937 | 937 | ||
938 | static int dummy_udc_suspend (struct device *dev, pm_message_t state, | 938 | static int dummy_udc_suspend (struct device *dev, pm_message_t state) |
939 | u32 level) | ||
940 | { | 939 | { |
941 | struct dummy *dum = dev_get_drvdata(dev); | 940 | struct dummy *dum = dev_get_drvdata(dev); |
942 | 941 | ||
943 | if (level != SUSPEND_DISABLE) | ||
944 | return 0; | ||
945 | |||
946 | dev_dbg (dev, "%s\n", __FUNCTION__); | 942 | dev_dbg (dev, "%s\n", __FUNCTION__); |
947 | spin_lock_irq (&dum->lock); | 943 | spin_lock_irq (&dum->lock); |
948 | dum->udc_suspended = 1; | 944 | dum->udc_suspended = 1; |
@@ -954,13 +950,10 @@ static int dummy_udc_suspend (struct device *dev, pm_message_t state, | |||
954 | return 0; | 950 | return 0; |
955 | } | 951 | } |
956 | 952 | ||
957 | static int dummy_udc_resume (struct device *dev, u32 level) | 953 | static int dummy_udc_resume (struct device *dev) |
958 | { | 954 | { |
959 | struct dummy *dum = dev_get_drvdata(dev); | 955 | struct dummy *dum = dev_get_drvdata(dev); |
960 | 956 | ||
961 | if (level != RESUME_ENABLE) | ||
962 | return 0; | ||
963 | |||
964 | dev_dbg (dev, "%s\n", __FUNCTION__); | 957 | dev_dbg (dev, "%s\n", __FUNCTION__); |
965 | spin_lock_irq (&dum->lock); | 958 | spin_lock_irq (&dum->lock); |
966 | dum->udc_suspended = 0; | 959 | dum->udc_suspended = 0; |
@@ -1936,14 +1929,10 @@ static int dummy_hcd_remove (struct device *dev) | |||
1936 | return 0; | 1929 | return 0; |
1937 | } | 1930 | } |
1938 | 1931 | ||
1939 | static int dummy_hcd_suspend (struct device *dev, pm_message_t state, | 1932 | static int dummy_hcd_suspend (struct device *dev, pm_message_t state) |
1940 | u32 level) | ||
1941 | { | 1933 | { |
1942 | struct usb_hcd *hcd; | 1934 | struct usb_hcd *hcd; |
1943 | 1935 | ||
1944 | if (level != SUSPEND_DISABLE) | ||
1945 | return 0; | ||
1946 | |||
1947 | dev_dbg (dev, "%s\n", __FUNCTION__); | 1936 | dev_dbg (dev, "%s\n", __FUNCTION__); |
1948 | hcd = dev_get_drvdata (dev); | 1937 | hcd = dev_get_drvdata (dev); |
1949 | 1938 | ||
@@ -1958,13 +1947,10 @@ static int dummy_hcd_suspend (struct device *dev, pm_message_t state, | |||
1958 | return 0; | 1947 | return 0; |
1959 | } | 1948 | } |
1960 | 1949 | ||
1961 | static int dummy_hcd_resume (struct device *dev, u32 level) | 1950 | static int dummy_hcd_resume (struct device *dev) |
1962 | { | 1951 | { |
1963 | struct usb_hcd *hcd; | 1952 | struct usb_hcd *hcd; |
1964 | 1953 | ||
1965 | if (level != RESUME_ENABLE) | ||
1966 | return 0; | ||
1967 | |||
1968 | dev_dbg (dev, "%s\n", __FUNCTION__); | 1954 | dev_dbg (dev, "%s\n", __FUNCTION__); |
1969 | hcd = dev_get_drvdata (dev); | 1955 | hcd = dev_get_drvdata (dev); |
1970 | hcd->state = HC_STATE_RUNNING; | 1956 | hcd->state = HC_STATE_RUNNING; |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 287c5900fb13..b7885dc0f42f 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -2909,12 +2909,10 @@ static int __exit omap_udc_remove(struct device *dev) | |||
2909 | * may involve talking to an external transceiver (e.g. isp1301). | 2909 | * may involve talking to an external transceiver (e.g. isp1301). |
2910 | */ | 2910 | */ |
2911 | 2911 | ||
2912 | static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) | 2912 | static int omap_udc_suspend(struct device *dev, pm_message_t message) |
2913 | { | 2913 | { |
2914 | u32 devstat; | 2914 | u32 devstat; |
2915 | 2915 | ||
2916 | if (level != SUSPEND_POWER_DOWN) | ||
2917 | return 0; | ||
2918 | devstat = UDC_DEVSTAT_REG; | 2916 | devstat = UDC_DEVSTAT_REG; |
2919 | 2917 | ||
2920 | /* we're requesting 48 MHz clock if the pullup is enabled | 2918 | /* we're requesting 48 MHz clock if the pullup is enabled |
@@ -2931,11 +2929,8 @@ static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) | |||
2931 | return 0; | 2929 | return 0; |
2932 | } | 2930 | } |
2933 | 2931 | ||
2934 | static int omap_udc_resume(struct device *dev, u32 level) | 2932 | static int omap_udc_resume(struct device *dev) |
2935 | { | 2933 | { |
2936 | if (level != RESUME_POWER_ON) | ||
2937 | return 0; | ||
2938 | |||
2939 | DBG("resume + wakeup/SRP\n"); | 2934 | DBG("resume + wakeup/SRP\n"); |
2940 | omap_pullup(&udc->gadget, 1); | 2935 | omap_pullup(&udc->gadget, 1); |
2941 | 2936 | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 6e545393cfff..647028590b23 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -422,7 +422,7 @@ static inline void ep0_idle (struct pxa2xx_udc *dev) | |||
422 | } | 422 | } |
423 | 423 | ||
424 | static int | 424 | static int |
425 | write_packet(volatile unsigned long *uddr, struct pxa2xx_request *req, unsigned max) | 425 | write_packet(volatile u32 *uddr, struct pxa2xx_request *req, unsigned max) |
426 | { | 426 | { |
427 | u8 *buf; | 427 | u8 *buf; |
428 | unsigned length, count; | 428 | unsigned length, count; |
@@ -2602,24 +2602,23 @@ static int __exit pxa2xx_udc_remove(struct device *_dev) | |||
2602 | * VBUS IRQs should probably be ignored so that the PXA device just acts | 2602 | * VBUS IRQs should probably be ignored so that the PXA device just acts |
2603 | * "dead" to USB hosts until system resume. | 2603 | * "dead" to USB hosts until system resume. |
2604 | */ | 2604 | */ |
2605 | static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state, u32 level) | 2605 | static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state) |
2606 | { | 2606 | { |
2607 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); | 2607 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); |
2608 | 2608 | ||
2609 | if (level == SUSPEND_POWER_DOWN) { | 2609 | if (!udc->mach->udc_command) |
2610 | if (!udc->mach->udc_command) | 2610 | WARN("USB host won't detect disconnect!\n"); |
2611 | WARN("USB host won't detect disconnect!\n"); | 2611 | pullup(udc, 0); |
2612 | pullup(udc, 0); | 2612 | |
2613 | } | ||
2614 | return 0; | 2613 | return 0; |
2615 | } | 2614 | } |
2616 | 2615 | ||
2617 | static int pxa2xx_udc_resume(struct device *dev, u32 level) | 2616 | static int pxa2xx_udc_resume(struct device *dev) |
2618 | { | 2617 | { |
2619 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); | 2618 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); |
2620 | 2619 | ||
2621 | if (level == RESUME_POWER_ON) | 2620 | pullup(udc, 1); |
2622 | pullup(udc, 1); | 2621 | |
2623 | return 0; | 2622 | return 0; |
2624 | } | 2623 | } |
2625 | 2624 | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h index a58f3e6e71f1..19a883f7d1b8 100644 --- a/drivers/usb/gadget/pxa2xx_udc.h +++ b/drivers/usb/gadget/pxa2xx_udc.h | |||
@@ -69,11 +69,11 @@ struct pxa2xx_ep { | |||
69 | * UDDR = UDC Endpoint Data Register (the fifo) | 69 | * UDDR = UDC Endpoint Data Register (the fifo) |
70 | * DRCM = DMA Request Channel Map | 70 | * DRCM = DMA Request Channel Map |
71 | */ | 71 | */ |
72 | volatile unsigned long *reg_udccs; | 72 | volatile u32 *reg_udccs; |
73 | volatile unsigned long *reg_ubcr; | 73 | volatile u32 *reg_ubcr; |
74 | volatile unsigned long *reg_uddr; | 74 | volatile u32 *reg_uddr; |
75 | #ifdef USE_DMA | 75 | #ifdef USE_DMA |
76 | volatile unsigned long *reg_drcmr; | 76 | volatile u32 *reg_drcmr; |
77 | #define drcmr(n) .reg_drcmr = & DRCMR ## n , | 77 | #define drcmr(n) .reg_drcmr = & DRCMR ## n , |
78 | #else | 78 | #else |
79 | #define drcmr(n) | 79 | #define drcmr(n) |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 2548d94fcd72..642f35068ce2 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -1774,15 +1774,12 @@ static int __init isp116x_probe(struct device *dev) | |||
1774 | /* | 1774 | /* |
1775 | Suspend of platform device | 1775 | Suspend of platform device |
1776 | */ | 1776 | */ |
1777 | static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) | 1777 | static int isp116x_suspend(struct device *dev, pm_message_t state) |
1778 | { | 1778 | { |
1779 | int ret = 0; | 1779 | int ret = 0; |
1780 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1780 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
1781 | 1781 | ||
1782 | VDBG("%s: state %x, phase %x\n", __func__, state, phase); | 1782 | VDBG("%s: state %x\n", __func__, state); |
1783 | |||
1784 | if (phase != SUSPEND_DISABLE && phase != SUSPEND_POWER_DOWN) | ||
1785 | return 0; | ||
1786 | 1783 | ||
1787 | ret = usb_suspend_device(hcd->self.root_hub, state); | 1784 | ret = usb_suspend_device(hcd->self.root_hub, state); |
1788 | if (!ret) { | 1785 | if (!ret) { |
@@ -1797,15 +1794,12 @@ static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) | |||
1797 | /* | 1794 | /* |
1798 | Resume platform device | 1795 | Resume platform device |
1799 | */ | 1796 | */ |
1800 | static int isp116x_resume(struct device *dev, u32 phase) | 1797 | static int isp116x_resume(struct device *dev) |
1801 | { | 1798 | { |
1802 | int ret = 0; | 1799 | int ret = 0; |
1803 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1800 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
1804 | 1801 | ||
1805 | VDBG("%s: state %x, phase %x\n", __func__, dev->power.power_state, | 1802 | VDBG("%s: state %x\n", __func__, dev->power.power_state); |
1806 | phase); | ||
1807 | if (phase != RESUME_POWER_ON) | ||
1808 | return 0; | ||
1809 | 1803 | ||
1810 | ret = usb_resume_device(hcd->self.root_hub); | 1804 | ret = usb_resume_device(hcd->self.root_hub); |
1811 | if (!ret) { | 1805 | if (!ret) { |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index d8f3ba7ad52e..a574216625a0 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -455,14 +455,11 @@ static int ohci_hcd_omap_drv_remove(struct device *dev) | |||
455 | 455 | ||
456 | #ifdef CONFIG_PM | 456 | #ifdef CONFIG_PM |
457 | 457 | ||
458 | static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level) | 458 | static int ohci_omap_suspend(struct device *dev, pm_message_t message) |
459 | { | 459 | { |
460 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); | 460 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); |
461 | int status = -EINVAL; | 461 | int status = -EINVAL; |
462 | 462 | ||
463 | if (level != SUSPEND_POWER_DOWN) | ||
464 | return 0; | ||
465 | |||
466 | down(&ohci_to_hcd(ohci)->self.root_hub->serialize); | 463 | down(&ohci_to_hcd(ohci)->self.root_hub->serialize); |
467 | status = ohci_hub_suspend(ohci_to_hcd(ohci)); | 464 | status = ohci_hub_suspend(ohci_to_hcd(ohci)); |
468 | if (status == 0) { | 465 | if (status == 0) { |
@@ -476,14 +473,11 @@ static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level | |||
476 | return status; | 473 | return status; |
477 | } | 474 | } |
478 | 475 | ||
479 | static int ohci_omap_resume(struct device *dev, u32 level) | 476 | static int ohci_omap_resume(struct device *dev) |
480 | { | 477 | { |
481 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); | 478 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); |
482 | int status = 0; | 479 | int status = 0; |
483 | 480 | ||
484 | if (level != RESUME_POWER_ON) | ||
485 | return 0; | ||
486 | |||
487 | if (time_before(jiffies, ohci->next_statechange)) | 481 | if (time_before(jiffies, ohci->next_statechange)) |
488 | msleep(5); | 482 | msleep(5); |
489 | ohci->next_statechange = jiffies; | 483 | ohci->next_statechange = jiffies; |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 2fdb262d4726..f042261ecb8e 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -309,7 +309,7 @@ static int ohci_hcd_pxa27x_drv_remove(struct device *dev) | |||
309 | return 0; | 309 | return 0; |
310 | } | 310 | } |
311 | 311 | ||
312 | static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u32 level) | 312 | static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state) |
313 | { | 313 | { |
314 | // struct platform_device *pdev = to_platform_device(dev); | 314 | // struct platform_device *pdev = to_platform_device(dev); |
315 | // struct usb_hcd *hcd = dev_get_drvdata(dev); | 315 | // struct usb_hcd *hcd = dev_get_drvdata(dev); |
@@ -318,7 +318,7 @@ static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u | |||
318 | return 0; | 318 | return 0; |
319 | } | 319 | } |
320 | 320 | ||
321 | static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 level) | 321 | static int ohci_hcd_pxa27x_drv_resume(struct device *dev) |
322 | { | 322 | { |
323 | // struct platform_device *pdev = to_platform_device(dev); | 323 | // struct platform_device *pdev = to_platform_device(dev); |
324 | // struct usb_hcd *hcd = dev_get_drvdata(dev); | 324 | // struct usb_hcd *hcd = dev_get_drvdata(dev); |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index cad858575cea..b5e7a478bc01 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -1784,15 +1784,12 @@ sl811h_probe(struct device *dev) | |||
1784 | */ | 1784 | */ |
1785 | 1785 | ||
1786 | static int | 1786 | static int |
1787 | sl811h_suspend(struct device *dev, pm_message_t state, u32 phase) | 1787 | sl811h_suspend(struct device *dev, pm_message_t state) |
1788 | { | 1788 | { |
1789 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1789 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
1790 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1790 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
1791 | int retval = 0; | 1791 | int retval = 0; |
1792 | 1792 | ||
1793 | if (phase != SUSPEND_POWER_DOWN) | ||
1794 | return retval; | ||
1795 | |||
1796 | if (state.event == PM_EVENT_FREEZE) | 1793 | if (state.event == PM_EVENT_FREEZE) |
1797 | retval = sl811h_hub_suspend(hcd); | 1794 | retval = sl811h_hub_suspend(hcd); |
1798 | else if (state.event == PM_EVENT_SUSPEND) | 1795 | else if (state.event == PM_EVENT_SUSPEND) |
@@ -1803,14 +1800,11 @@ sl811h_suspend(struct device *dev, pm_message_t state, u32 phase) | |||
1803 | } | 1800 | } |
1804 | 1801 | ||
1805 | static int | 1802 | static int |
1806 | sl811h_resume(struct device *dev, u32 phase) | 1803 | sl811h_resume(struct device *dev) |
1807 | { | 1804 | { |
1808 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1805 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
1809 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1806 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
1810 | 1807 | ||
1811 | if (phase != RESUME_POWER_ON) | ||
1812 | return 0; | ||
1813 | |||
1814 | /* with no "check to see if VBUS is still powered" board hook, | 1808 | /* with no "check to see if VBUS is still powered" board hook, |
1815 | * let's assume it'd only be powered to enable remote wakeup. | 1809 | * let's assume it'd only be powered to enable remote wakeup. |
1816 | */ | 1810 | */ |
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c index 74f8760d7c07..a32558b4048e 100644 --- a/drivers/usb/input/acecad.c +++ b/drivers/usb/input/acecad.c | |||
@@ -53,7 +53,7 @@ struct usb_acecad { | |||
53 | char name[128]; | 53 | char name[128]; |
54 | char phys[64]; | 54 | char phys[64]; |
55 | struct usb_device *usbdev; | 55 | struct usb_device *usbdev; |
56 | struct input_dev dev; | 56 | struct input_dev *input; |
57 | struct urb *irq; | 57 | struct urb *irq; |
58 | 58 | ||
59 | signed char *data; | 59 | signed char *data; |
@@ -64,7 +64,7 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) | |||
64 | { | 64 | { |
65 | struct usb_acecad *acecad = urb->context; | 65 | struct usb_acecad *acecad = urb->context; |
66 | unsigned char *data = acecad->data; | 66 | unsigned char *data = acecad->data; |
67 | struct input_dev *dev = &acecad->dev; | 67 | struct input_dev *dev = acecad->input; |
68 | int prox, status; | 68 | int prox, status; |
69 | 69 | ||
70 | switch (urb->status) { | 70 | switch (urb->status) { |
@@ -135,8 +135,8 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
135 | struct usb_host_interface *interface = intf->cur_altsetting; | 135 | struct usb_host_interface *interface = intf->cur_altsetting; |
136 | struct usb_endpoint_descriptor *endpoint; | 136 | struct usb_endpoint_descriptor *endpoint; |
137 | struct usb_acecad *acecad; | 137 | struct usb_acecad *acecad; |
138 | struct input_dev *input_dev; | ||
138 | int pipe, maxp; | 139 | int pipe, maxp; |
139 | char path[64]; | ||
140 | 140 | ||
141 | if (interface->desc.bNumEndpoints != 1) | 141 | if (interface->desc.bNumEndpoints != 1) |
142 | return -ENODEV; | 142 | return -ENODEV; |
@@ -153,8 +153,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
154 | 154 | ||
155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); | 155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); |
156 | if (!acecad) | 156 | input_dev = input_allocate_device(); |
157 | return -ENOMEM; | 157 | if (!acecad || !input_dev) |
158 | goto fail1; | ||
158 | 159 | ||
159 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); | 160 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); |
160 | if (!acecad->data) | 161 | if (!acecad->data) |
@@ -164,6 +165,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
164 | if (!acecad->irq) | 165 | if (!acecad->irq) |
165 | goto fail2; | 166 | goto fail2; |
166 | 167 | ||
168 | acecad->usbdev = dev; | ||
169 | acecad->input = input_dev; | ||
170 | |||
167 | if (dev->manufacturer) | 171 | if (dev->manufacturer) |
168 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); | 172 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); |
169 | 173 | ||
@@ -173,48 +177,48 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
173 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); | 177 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); |
174 | } | 178 | } |
175 | 179 | ||
176 | usb_make_path(dev, path, sizeof(path)); | 180 | usb_make_path(dev, acecad->phys, sizeof(acecad->phys)); |
177 | snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); | 181 | strlcat(acecad->phys, "/input0", sizeof(acecad->phys)); |
178 | 182 | ||
179 | acecad->usbdev = dev; | 183 | input_dev->name = acecad->name; |
184 | input_dev->phys = acecad->phys; | ||
185 | usb_to_input_id(dev, &input_dev->id); | ||
186 | input_dev->cdev.dev = &intf->dev; | ||
187 | input_dev->private = acecad; | ||
180 | 188 | ||
181 | acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 189 | input_dev->open = usb_acecad_open; |
182 | acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 190 | input_dev->close = usb_acecad_close; |
183 | acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 191 | |
184 | acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | 192 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
193 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
194 | input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
195 | input_dev->keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | ||
185 | 196 | ||
186 | switch (id->driver_info) { | 197 | switch (id->driver_info) { |
187 | case 0: | 198 | case 0: |
188 | acecad->dev.absmax[ABS_X] = 5000; | 199 | input_dev->absmax[ABS_X] = 5000; |
189 | acecad->dev.absmax[ABS_Y] = 3750; | 200 | input_dev->absmax[ABS_Y] = 3750; |
190 | acecad->dev.absmax[ABS_PRESSURE] = 512; | 201 | input_dev->absmax[ABS_PRESSURE] = 512; |
191 | if (!strlen(acecad->name)) | 202 | if (!strlen(acecad->name)) |
192 | snprintf(acecad->name, sizeof(acecad->name), | 203 | snprintf(acecad->name, sizeof(acecad->name), |
193 | "USB Acecad Flair Tablet %04x:%04x", | 204 | "USB Acecad Flair Tablet %04x:%04x", |
194 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 205 | le16_to_cpu(dev->descriptor.idVendor), |
206 | le16_to_cpu(dev->descriptor.idProduct)); | ||
195 | break; | 207 | break; |
196 | case 1: | 208 | case 1: |
197 | acecad->dev.absmax[ABS_X] = 3000; | 209 | input_dev->absmax[ABS_X] = 3000; |
198 | acecad->dev.absmax[ABS_Y] = 2250; | 210 | input_dev->absmax[ABS_Y] = 2250; |
199 | acecad->dev.absmax[ABS_PRESSURE] = 1024; | 211 | input_dev->absmax[ABS_PRESSURE] = 1024; |
200 | if (!strlen(acecad->name)) | 212 | if (!strlen(acecad->name)) |
201 | snprintf(acecad->name, sizeof(acecad->name), | 213 | snprintf(acecad->name, sizeof(acecad->name), |
202 | "USB Acecad 302 Tablet %04x:%04x", | 214 | "USB Acecad 302 Tablet %04x:%04x", |
203 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 215 | le16_to_cpu(dev->descriptor.idVendor), |
216 | le16_to_cpu(dev->descriptor.idProduct)); | ||
204 | break; | 217 | break; |
205 | } | 218 | } |
206 | 219 | ||
207 | acecad->dev.absfuzz[ABS_X] = 4; | 220 | input_dev->absfuzz[ABS_X] = 4; |
208 | acecad->dev.absfuzz[ABS_Y] = 4; | 221 | input_dev->absfuzz[ABS_Y] = 4; |
209 | |||
210 | acecad->dev.private = acecad; | ||
211 | acecad->dev.open = usb_acecad_open; | ||
212 | acecad->dev.close = usb_acecad_close; | ||
213 | |||
214 | acecad->dev.name = acecad->name; | ||
215 | acecad->dev.phys = acecad->phys; | ||
216 | usb_to_input_id(dev, &acecad->dev.id); | ||
217 | acecad->dev.dev = &intf->dev; | ||
218 | 222 | ||
219 | usb_fill_int_urb(acecad->irq, dev, pipe, | 223 | usb_fill_int_urb(acecad->irq, dev, pipe, |
220 | acecad->data, maxp > 8 ? 8 : maxp, | 224 | acecad->data, maxp > 8 ? 8 : maxp, |
@@ -222,17 +226,15 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
222 | acecad->irq->transfer_dma = acecad->data_dma; | 226 | acecad->irq->transfer_dma = acecad->data_dma; |
223 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 227 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
224 | 228 | ||
225 | input_register_device(&acecad->dev); | 229 | input_register_device(acecad->input); |
226 | |||
227 | printk(KERN_INFO "input: %s with packet size %d on %s\n", | ||
228 | acecad->name, maxp, path); | ||
229 | 230 | ||
230 | usb_set_intfdata(intf, acecad); | 231 | usb_set_intfdata(intf, acecad); |
231 | 232 | ||
232 | return 0; | 233 | return 0; |
233 | 234 | ||
234 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); | 235 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); |
235 | fail1: kfree(acecad); | 236 | fail1: input_free_device(input_dev); |
237 | kfree(acecad); | ||
236 | return -ENOMEM; | 238 | return -ENOMEM; |
237 | } | 239 | } |
238 | 240 | ||
@@ -243,7 +245,7 @@ static void usb_acecad_disconnect(struct usb_interface *intf) | |||
243 | usb_set_intfdata(intf, NULL); | 245 | usb_set_intfdata(intf, NULL); |
244 | if (acecad) { | 246 | if (acecad) { |
245 | usb_kill_urb(acecad->irq); | 247 | usb_kill_urb(acecad->irq); |
246 | input_unregister_device(&acecad->dev); | 248 | input_unregister_device(acecad->input); |
247 | usb_free_urb(acecad->irq); | 249 | usb_free_urb(acecad->irq); |
248 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); | 250 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); |
249 | kfree(acecad); | 251 | kfree(acecad); |
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index cd0cbfe20723..1c5205321d83 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
@@ -317,7 +317,7 @@ struct aiptek_settings { | |||
317 | }; | 317 | }; |
318 | 318 | ||
319 | struct aiptek { | 319 | struct aiptek { |
320 | struct input_dev inputdev; /* input device struct */ | 320 | struct input_dev *inputdev; /* input device struct */ |
321 | struct usb_device *usbdev; /* usb device struct */ | 321 | struct usb_device *usbdev; /* usb device struct */ |
322 | struct urb *urb; /* urb for incoming reports */ | 322 | struct urb *urb; /* urb for incoming reports */ |
323 | dma_addr_t data_dma; /* our dma stuffage */ | 323 | dma_addr_t data_dma; /* our dma stuffage */ |
@@ -402,7 +402,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) | |||
402 | { | 402 | { |
403 | struct aiptek *aiptek = urb->context; | 403 | struct aiptek *aiptek = urb->context; |
404 | unsigned char *data = aiptek->data; | 404 | unsigned char *data = aiptek->data; |
405 | struct input_dev *inputdev = &aiptek->inputdev; | 405 | struct input_dev *inputdev = aiptek->inputdev; |
406 | int jitterable = 0; | 406 | int jitterable = 0; |
407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; | 407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; |
408 | 408 | ||
@@ -955,20 +955,20 @@ static int aiptek_program_tablet(struct aiptek *aiptek) | |||
955 | /* Query getXextension */ | 955 | /* Query getXextension */ |
956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) | 956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) |
957 | return ret; | 957 | return ret; |
958 | aiptek->inputdev.absmin[ABS_X] = 0; | 958 | aiptek->inputdev->absmin[ABS_X] = 0; |
959 | aiptek->inputdev.absmax[ABS_X] = ret - 1; | 959 | aiptek->inputdev->absmax[ABS_X] = ret - 1; |
960 | 960 | ||
961 | /* Query getYextension */ | 961 | /* Query getYextension */ |
962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) | 962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) |
963 | return ret; | 963 | return ret; |
964 | aiptek->inputdev.absmin[ABS_Y] = 0; | 964 | aiptek->inputdev->absmin[ABS_Y] = 0; |
965 | aiptek->inputdev.absmax[ABS_Y] = ret - 1; | 965 | aiptek->inputdev->absmax[ABS_Y] = ret - 1; |
966 | 966 | ||
967 | /* Query getPressureLevels */ | 967 | /* Query getPressureLevels */ |
968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) | 968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) |
969 | return ret; | 969 | return ret; |
970 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 970 | aiptek->inputdev->absmin[ABS_PRESSURE] = 0; |
971 | aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1; | 971 | aiptek->inputdev->absmax[ABS_PRESSURE] = ret - 1; |
972 | 972 | ||
973 | /* Depending on whether we are in absolute or relative mode, we will | 973 | /* Depending on whether we are in absolute or relative mode, we will |
974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. | 974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. |
@@ -1025,8 +1025,8 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr | |||
1025 | return 0; | 1025 | return 0; |
1026 | 1026 | ||
1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", | 1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", |
1028 | aiptek->inputdev.absmax[ABS_X] + 1, | 1028 | aiptek->inputdev->absmax[ABS_X] + 1, |
1029 | aiptek->inputdev.absmax[ABS_Y] + 1); | 1029 | aiptek->inputdev->absmax[ABS_Y] + 1); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | /* These structs define the sysfs files, param #1 is the name of the | 1032 | /* These structs define the sysfs files, param #1 is the name of the |
@@ -1048,7 +1048,7 @@ static ssize_t show_tabletProductId(struct device *dev, struct device_attribute | |||
1048 | return 0; | 1048 | return 0; |
1049 | 1049 | ||
1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", | 1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", |
1051 | aiptek->inputdev.id.product); | 1051 | aiptek->inputdev->id.product); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); | 1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); |
@@ -1063,7 +1063,7 @@ static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute * | |||
1063 | if (aiptek == NULL) | 1063 | if (aiptek == NULL) |
1064 | return 0; | 1064 | return 0; |
1065 | 1065 | ||
1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor); | 1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev->id.vendor); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); | 1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); |
@@ -1977,7 +1977,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1977 | struct input_dev *inputdev; | 1977 | struct input_dev *inputdev; |
1978 | struct input_handle *inputhandle; | 1978 | struct input_handle *inputhandle; |
1979 | struct list_head *node, *next; | 1979 | struct list_head *node, *next; |
1980 | char path[64 + 1]; | ||
1981 | int i; | 1980 | int i; |
1982 | int speeds[] = { 0, | 1981 | int speeds[] = { 0, |
1983 | AIPTEK_PROGRAMMABLE_DELAY_50, | 1982 | AIPTEK_PROGRAMMABLE_DELAY_50, |
@@ -1996,24 +1995,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1996 | */ | 1995 | */ |
1997 | speeds[0] = programmableDelay; | 1996 | speeds[0] = programmableDelay; |
1998 | 1997 | ||
1999 | if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL) | 1998 | aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); |
2000 | return -ENOMEM; | 1999 | inputdev = input_allocate_device(); |
2001 | memset(aiptek, 0, sizeof(struct aiptek)); | 2000 | if (!aiptek || !inputdev) |
2001 | goto fail1; | ||
2002 | 2002 | ||
2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, | 2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, |
2004 | SLAB_ATOMIC, &aiptek->data_dma); | 2004 | SLAB_ATOMIC, &aiptek->data_dma); |
2005 | if (aiptek->data == NULL) { | 2005 | if (!aiptek->data) |
2006 | kfree(aiptek); | 2006 | goto fail1; |
2007 | return -ENOMEM; | ||
2008 | } | ||
2009 | 2007 | ||
2010 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); | 2008 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); |
2011 | if (aiptek->urb == NULL) { | 2009 | if (!aiptek->urb) |
2012 | usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | 2010 | goto fail2; |
2013 | aiptek->data_dma); | 2011 | |
2014 | kfree(aiptek); | 2012 | aiptek->inputdev = inputdev; |
2015 | return -ENOMEM; | 2013 | aiptek->usbdev = usbdev; |
2016 | } | 2014 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; |
2015 | aiptek->inDelay = 0; | ||
2016 | aiptek->endDelay = 0; | ||
2017 | aiptek->previousJitterable = 0; | ||
2017 | 2018 | ||
2018 | /* Set up the curSettings struct. Said struct contains the current | 2019 | /* Set up the curSettings struct. Said struct contains the current |
2019 | * programmable parameters. The newSetting struct contains changes | 2020 | * programmable parameters. The newSetting struct contains changes |
@@ -2036,31 +2037,48 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2036 | 2037 | ||
2037 | /* Both structs should have equivalent settings | 2038 | /* Both structs should have equivalent settings |
2038 | */ | 2039 | */ |
2039 | memcpy(&aiptek->newSetting, &aiptek->curSetting, | 2040 | aiptek->newSetting = aiptek->curSetting; |
2040 | sizeof(struct aiptek_settings)); | 2041 | |
2042 | /* Determine the usb devices' physical path. | ||
2043 | * Asketh not why we always pretend we're using "../input0", | ||
2044 | * but I suspect this will have to be refactored one | ||
2045 | * day if a single USB device can be a keyboard & a mouse | ||
2046 | * & a tablet, and the inputX number actually will tell | ||
2047 | * us something... | ||
2048 | */ | ||
2049 | usb_make_path(usbdev, aiptek->features.usbPath, | ||
2050 | sizeof(aiptek->features.usbPath)); | ||
2051 | strlcat(aiptek->features.usbPath, "/input0", | ||
2052 | sizeof(aiptek->features.usbPath)); | ||
2053 | |||
2054 | /* Set up client data, pointers to open and close routines | ||
2055 | * for the input device. | ||
2056 | */ | ||
2057 | inputdev->name = "Aiptek"; | ||
2058 | inputdev->phys = aiptek->features.usbPath; | ||
2059 | usb_to_input_id(usbdev, &inputdev->id); | ||
2060 | inputdev->cdev.dev = &intf->dev; | ||
2061 | inputdev->private = aiptek; | ||
2062 | inputdev->open = aiptek_open; | ||
2063 | inputdev->close = aiptek_close; | ||
2041 | 2064 | ||
2042 | /* Now program the capacities of the tablet, in terms of being | 2065 | /* Now program the capacities of the tablet, in terms of being |
2043 | * an input device. | 2066 | * an input device. |
2044 | */ | 2067 | */ |
2045 | aiptek->inputdev.evbit[0] |= BIT(EV_KEY) | 2068 | inputdev->evbit[0] |= BIT(EV_KEY) |
2046 | | BIT(EV_ABS) | 2069 | | BIT(EV_ABS) |
2047 | | BIT(EV_REL) | 2070 | | BIT(EV_REL) |
2048 | | BIT(EV_MSC); | 2071 | | BIT(EV_MSC); |
2049 | 2072 | ||
2050 | aiptek->inputdev.absbit[0] |= | 2073 | inputdev->absbit[0] |= BIT(ABS_MISC); |
2051 | (BIT(ABS_X) | | ||
2052 | BIT(ABS_Y) | | ||
2053 | BIT(ABS_PRESSURE) | | ||
2054 | BIT(ABS_TILT_X) | | ||
2055 | BIT(ABS_TILT_Y) | BIT(ABS_WHEEL) | BIT(ABS_MISC)); | ||
2056 | 2074 | ||
2057 | aiptek->inputdev.relbit[0] |= | 2075 | inputdev->relbit[0] |= |
2058 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); | 2076 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); |
2059 | 2077 | ||
2060 | aiptek->inputdev.keybit[LONG(BTN_LEFT)] |= | 2078 | inputdev->keybit[LONG(BTN_LEFT)] |= |
2061 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); | 2079 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); |
2062 | 2080 | ||
2063 | aiptek->inputdev.keybit[LONG(BTN_DIGI)] |= | 2081 | inputdev->keybit[LONG(BTN_DIGI)] |= |
2064 | (BIT(BTN_TOOL_PEN) | | 2082 | (BIT(BTN_TOOL_PEN) | |
2065 | BIT(BTN_TOOL_RUBBER) | | 2083 | BIT(BTN_TOOL_RUBBER) | |
2066 | BIT(BTN_TOOL_PENCIL) | | 2084 | BIT(BTN_TOOL_PENCIL) | |
@@ -2070,70 +2088,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2070 | BIT(BTN_TOOL_LENS) | | 2088 | BIT(BTN_TOOL_LENS) | |
2071 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); | 2089 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); |
2072 | 2090 | ||
2073 | aiptek->inputdev.mscbit[0] = BIT(MSC_SERIAL); | 2091 | inputdev->mscbit[0] = BIT(MSC_SERIAL); |
2074 | 2092 | ||
2075 | /* Programming the tablet macro keys needs to be done with a for loop | 2093 | /* Programming the tablet macro keys needs to be done with a for loop |
2076 | * as the keycodes are discontiguous. | 2094 | * as the keycodes are discontiguous. |
2077 | */ | 2095 | */ |
2078 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) | 2096 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) |
2079 | set_bit(macroKeyEvents[i], aiptek->inputdev.keybit); | 2097 | set_bit(macroKeyEvents[i], inputdev->keybit); |
2080 | |||
2081 | /* Set up client data, pointers to open and close routines | ||
2082 | * for the input device. | ||
2083 | */ | ||
2084 | aiptek->inputdev.private = aiptek; | ||
2085 | aiptek->inputdev.open = aiptek_open; | ||
2086 | aiptek->inputdev.close = aiptek_close; | ||
2087 | |||
2088 | /* Determine the usb devices' physical path. | ||
2089 | * Asketh not why we always pretend we're using "../input0", | ||
2090 | * but I suspect this will have to be refactored one | ||
2091 | * day if a single USB device can be a keyboard & a mouse | ||
2092 | * & a tablet, and the inputX number actually will tell | ||
2093 | * us something... | ||
2094 | */ | ||
2095 | if (usb_make_path(usbdev, path, 64) > 0) | ||
2096 | sprintf(aiptek->features.usbPath, "%s/input0", path); | ||
2097 | 2098 | ||
2098 | /* Program the input device coordinate capacities. We do not yet | 2099 | /* |
2100 | * Program the input device coordinate capacities. We do not yet | ||
2099 | * know what maximum X, Y, and Z values are, so we're putting fake | 2101 | * know what maximum X, Y, and Z values are, so we're putting fake |
2100 | * values in. Later, we'll ask the tablet to put in the correct | 2102 | * values in. Later, we'll ask the tablet to put in the correct |
2101 | * values. | 2103 | * values. |
2102 | */ | 2104 | */ |
2103 | aiptek->inputdev.absmin[ABS_X] = 0; | 2105 | input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0); |
2104 | aiptek->inputdev.absmax[ABS_X] = 2999; | 2106 | input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0); |
2105 | aiptek->inputdev.absmin[ABS_Y] = 0; | 2107 | input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0); |
2106 | aiptek->inputdev.absmax[ABS_Y] = 2249; | 2108 | input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
2107 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 2109 | input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
2108 | aiptek->inputdev.absmax[ABS_PRESSURE] = 511; | 2110 | input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); |
2109 | aiptek->inputdev.absmin[ABS_TILT_X] = AIPTEK_TILT_MIN; | ||
2110 | aiptek->inputdev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX; | ||
2111 | aiptek->inputdev.absmin[ABS_TILT_Y] = AIPTEK_TILT_MIN; | ||
2112 | aiptek->inputdev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX; | ||
2113 | aiptek->inputdev.absmin[ABS_WHEEL] = AIPTEK_WHEEL_MIN; | ||
2114 | aiptek->inputdev.absmax[ABS_WHEEL] = AIPTEK_WHEEL_MAX - 1; | ||
2115 | aiptek->inputdev.absfuzz[ABS_X] = 0; | ||
2116 | aiptek->inputdev.absfuzz[ABS_Y] = 0; | ||
2117 | aiptek->inputdev.absfuzz[ABS_PRESSURE] = 0; | ||
2118 | aiptek->inputdev.absfuzz[ABS_TILT_X] = 0; | ||
2119 | aiptek->inputdev.absfuzz[ABS_TILT_Y] = 0; | ||
2120 | aiptek->inputdev.absfuzz[ABS_WHEEL] = 0; | ||
2121 | aiptek->inputdev.absflat[ABS_X] = 0; | ||
2122 | aiptek->inputdev.absflat[ABS_Y] = 0; | ||
2123 | aiptek->inputdev.absflat[ABS_PRESSURE] = 0; | ||
2124 | aiptek->inputdev.absflat[ABS_TILT_X] = 0; | ||
2125 | aiptek->inputdev.absflat[ABS_TILT_Y] = 0; | ||
2126 | aiptek->inputdev.absflat[ABS_WHEEL] = 0; | ||
2127 | aiptek->inputdev.name = "Aiptek"; | ||
2128 | aiptek->inputdev.phys = aiptek->features.usbPath; | ||
2129 | usb_to_input_id(usbdev, &aiptek->inputdev.id); | ||
2130 | aiptek->inputdev.dev = &intf->dev; | ||
2131 | |||
2132 | aiptek->usbdev = usbdev; | ||
2133 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; | ||
2134 | aiptek->inDelay = 0; | ||
2135 | aiptek->endDelay = 0; | ||
2136 | aiptek->previousJitterable = 0; | ||
2137 | 2111 | ||
2138 | endpoint = &intf->altsetting[0].endpoint[0].desc; | 2112 | endpoint = &intf->altsetting[0].endpoint[0].desc; |
2139 | 2113 | ||
@@ -2150,28 +2124,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2150 | aiptek->urb->transfer_dma = aiptek->data_dma; | 2124 | aiptek->urb->transfer_dma = aiptek->data_dma; |
2151 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 2125 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
2152 | 2126 | ||
2153 | /* Register the tablet as an Input Device | ||
2154 | */ | ||
2155 | input_register_device(&aiptek->inputdev); | ||
2156 | |||
2157 | /* We now will look for the evdev device which is mapped to | ||
2158 | * the tablet. The partial name is kept in the link list of | ||
2159 | * input_handles associated with this input device. | ||
2160 | * What identifies an evdev input_handler is that it begins | ||
2161 | * with 'event', continues with a digit, and that in turn | ||
2162 | * is mapped to /{devfs}/input/eventN. | ||
2163 | */ | ||
2164 | inputdev = &aiptek->inputdev; | ||
2165 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
2166 | inputhandle = to_handle(node); | ||
2167 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
2168 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
2169 | break; | ||
2170 | } | ||
2171 | } | ||
2172 | |||
2173 | info("input: Aiptek on %s (%s)\n", path, aiptek->features.inputPath); | ||
2174 | |||
2175 | /* Program the tablet. This sets the tablet up in the mode | 2127 | /* Program the tablet. This sets the tablet up in the mode |
2176 | * specified in newSetting, and also queries the tablet's | 2128 | * specified in newSetting, and also queries the tablet's |
2177 | * physical capacities. | 2129 | * physical capacities. |
@@ -2186,13 +2138,32 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2186 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { | 2138 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { |
2187 | aiptek->curSetting.programmableDelay = speeds[i]; | 2139 | aiptek->curSetting.programmableDelay = speeds[i]; |
2188 | (void)aiptek_program_tablet(aiptek); | 2140 | (void)aiptek_program_tablet(aiptek); |
2189 | if (aiptek->inputdev.absmax[ABS_X] > 0) { | 2141 | if (aiptek->inputdev->absmax[ABS_X] > 0) { |
2190 | info("input: Aiptek using %d ms programming speed\n", | 2142 | info("input: Aiptek using %d ms programming speed\n", |
2191 | aiptek->curSetting.programmableDelay); | 2143 | aiptek->curSetting.programmableDelay); |
2192 | break; | 2144 | break; |
2193 | } | 2145 | } |
2194 | } | 2146 | } |
2195 | 2147 | ||
2148 | /* Register the tablet as an Input Device | ||
2149 | */ | ||
2150 | input_register_device(aiptek->inputdev); | ||
2151 | |||
2152 | /* We now will look for the evdev device which is mapped to | ||
2153 | * the tablet. The partial name is kept in the link list of | ||
2154 | * input_handles associated with this input device. | ||
2155 | * What identifies an evdev input_handler is that it begins | ||
2156 | * with 'event', continues with a digit, and that in turn | ||
2157 | * is mapped to /{devfs}/input/eventN. | ||
2158 | */ | ||
2159 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
2160 | inputhandle = to_handle(node); | ||
2161 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
2162 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
2163 | break; | ||
2164 | } | ||
2165 | } | ||
2166 | |||
2196 | /* Associate this driver's struct with the usb interface. | 2167 | /* Associate this driver's struct with the usb interface. |
2197 | */ | 2168 | */ |
2198 | usb_set_intfdata(intf, aiptek); | 2169 | usb_set_intfdata(intf, aiptek); |
@@ -2207,6 +2178,12 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2207 | info("aiptek: error loading 'evdev' module"); | 2178 | info("aiptek: error loading 'evdev' module"); |
2208 | 2179 | ||
2209 | return 0; | 2180 | return 0; |
2181 | |||
2182 | fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | ||
2183 | aiptek->data_dma); | ||
2184 | fail1: input_free_device(inputdev); | ||
2185 | kfree(aiptek); | ||
2186 | return -ENOMEM; | ||
2210 | } | 2187 | } |
2211 | 2188 | ||
2212 | /* Forward declaration */ | 2189 | /* Forward declaration */ |
@@ -2234,7 +2211,7 @@ static void aiptek_disconnect(struct usb_interface *intf) | |||
2234 | /* Free & unhook everything from the system. | 2211 | /* Free & unhook everything from the system. |
2235 | */ | 2212 | */ |
2236 | usb_kill_urb(aiptek->urb); | 2213 | usb_kill_urb(aiptek->urb); |
2237 | input_unregister_device(&aiptek->inputdev); | 2214 | input_unregister_device(aiptek->inputdev); |
2238 | aiptek_delete_files(&intf->dev); | 2215 | aiptek_delete_files(&intf->dev); |
2239 | usb_free_urb(aiptek->urb); | 2216 | usb_free_urb(aiptek->urb); |
2240 | usb_buffer_free(interface_to_usbdev(intf), | 2217 | usb_buffer_free(interface_to_usbdev(intf), |
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c index e03c1c567a14..15840db092a5 100644 --- a/drivers/usb/input/appletouch.c +++ b/drivers/usb/input/appletouch.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #define APPLE_VENDOR_ID 0x05AC | 39 | #define APPLE_VENDOR_ID 0x05AC |
40 | 40 | ||
41 | #define ATP_DEVICE(prod) \ | 41 | #define ATP_DEVICE(prod) \ |
42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ | 42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | 43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ |
44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ | 44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ |
45 | .idVendor = APPLE_VENDOR_ID, \ | 45 | .idVendor = APPLE_VENDOR_ID, \ |
@@ -78,9 +78,9 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
78 | * We try to keep the touchpad aspect ratio while still doing only simple | 78 | * We try to keep the touchpad aspect ratio while still doing only simple |
79 | * arithmetics. | 79 | * arithmetics. |
80 | * The factors below give coordinates like: | 80 | * The factors below give coordinates like: |
81 | * 0 <= x < 960 on 12" and 15" Powerbooks | 81 | * 0 <= x < 960 on 12" and 15" Powerbooks |
82 | * 0 <= x < 1600 on 17" Powerbooks | 82 | * 0 <= x < 1600 on 17" Powerbooks |
83 | * 0 <= y < 646 | 83 | * 0 <= y < 646 |
84 | */ | 84 | */ |
85 | #define ATP_XFACT 64 | 85 | #define ATP_XFACT 64 |
86 | #define ATP_YFACT 43 | 86 | #define ATP_YFACT 43 |
@@ -93,11 +93,12 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
93 | 93 | ||
94 | /* Structure to hold all of our device specific stuff */ | 94 | /* Structure to hold all of our device specific stuff */ |
95 | struct atp { | 95 | struct atp { |
96 | char phys[64]; | ||
96 | struct usb_device * udev; /* usb device */ | 97 | struct usb_device * udev; /* usb device */ |
97 | struct urb * urb; /* usb request block */ | 98 | struct urb * urb; /* usb request block */ |
98 | signed char * data; /* transferred data */ | 99 | signed char * data; /* transferred data */ |
99 | int open; /* non-zero if opened */ | 100 | int open; /* non-zero if opened */ |
100 | struct input_dev input; /* input dev */ | 101 | struct input_dev *input; /* input dev */ |
101 | int valid; /* are the sensors valid ? */ | 102 | int valid; /* are the sensors valid ? */ |
102 | int x_old; /* last reported x/y, */ | 103 | int x_old; /* last reported x/y, */ |
103 | int y_old; /* used for smoothing */ | 104 | int y_old; /* used for smoothing */ |
@@ -114,11 +115,11 @@ struct atp { | |||
114 | int i; \ | 115 | int i; \ |
115 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ | 116 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ |
116 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ | 117 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ |
117 | printk(" %02x", tab[i]); \ | 118 | printk(" %02x", tab[i]); \ |
118 | printk("\n"); \ | 119 | printk("\n"); \ |
119 | } | 120 | } |
120 | 121 | ||
121 | #define dprintk(format, a...) \ | 122 | #define dprintk(format, a...) \ |
122 | do { \ | 123 | do { \ |
123 | if (debug) printk(format, ##a); \ | 124 | if (debug) printk(format, ##a); \ |
124 | } while (0) | 125 | } while (0) |
@@ -219,8 +220,8 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
219 | for (i = 16; i < ATP_XSENSORS; i++) | 220 | for (i = 16; i < ATP_XSENSORS; i++) |
220 | if (dev->xy_cur[i]) { | 221 | if (dev->xy_cur[i]) { |
221 | printk("appletouch: 17\" model detected.\n"); | 222 | printk("appletouch: 17\" model detected.\n"); |
222 | input_set_abs_params(&dev->input, ABS_X, 0, | 223 | input_set_abs_params(dev->input, ABS_X, 0, |
223 | (ATP_XSENSORS - 1) * | 224 | (ATP_XSENSORS - 1) * |
224 | ATP_XFACT - 1, | 225 | ATP_XFACT - 1, |
225 | ATP_FUZZ, 0); | 226 | ATP_FUZZ, 0); |
226 | break; | 227 | break; |
@@ -260,12 +261,12 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
260 | "Xz: %3d Yz: %3d\n", | 261 | "Xz: %3d Yz: %3d\n", |
261 | x, y, x_z, y_z); | 262 | x, y, x_z, y_z); |
262 | 263 | ||
263 | input_report_key(&dev->input, BTN_TOUCH, 1); | 264 | input_report_key(dev->input, BTN_TOUCH, 1); |
264 | input_report_abs(&dev->input, ABS_X, x); | 265 | input_report_abs(dev->input, ABS_X, x); |
265 | input_report_abs(&dev->input, ABS_Y, y); | 266 | input_report_abs(dev->input, ABS_Y, y); |
266 | input_report_abs(&dev->input, ABS_PRESSURE, | 267 | input_report_abs(dev->input, ABS_PRESSURE, |
267 | min(ATP_PRESSURE, x_z + y_z)); | 268 | min(ATP_PRESSURE, x_z + y_z)); |
268 | atp_report_fingers(&dev->input, max(x_f, y_f)); | 269 | atp_report_fingers(dev->input, max(x_f, y_f)); |
269 | } | 270 | } |
270 | dev->x_old = x; | 271 | dev->x_old = x; |
271 | dev->y_old = y; | 272 | dev->y_old = y; |
@@ -273,17 +274,17 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
273 | else if (!x && !y) { | 274 | else if (!x && !y) { |
274 | 275 | ||
275 | dev->x_old = dev->y_old = -1; | 276 | dev->x_old = dev->y_old = -1; |
276 | input_report_key(&dev->input, BTN_TOUCH, 0); | 277 | input_report_key(dev->input, BTN_TOUCH, 0); |
277 | input_report_abs(&dev->input, ABS_PRESSURE, 0); | 278 | input_report_abs(dev->input, ABS_PRESSURE, 0); |
278 | atp_report_fingers(&dev->input, 0); | 279 | atp_report_fingers(dev->input, 0); |
279 | 280 | ||
280 | /* reset the accumulator on release */ | 281 | /* reset the accumulator on release */ |
281 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); | 282 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); |
282 | } | 283 | } |
283 | 284 | ||
284 | input_report_key(&dev->input, BTN_LEFT, !!dev->data[80]); | 285 | input_report_key(dev->input, BTN_LEFT, !!dev->data[80]); |
285 | 286 | ||
286 | input_sync(&dev->input); | 287 | input_sync(dev->input); |
287 | 288 | ||
288 | exit: | 289 | exit: |
289 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 290 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
@@ -314,21 +315,14 @@ static void atp_close(struct input_dev *input) | |||
314 | 315 | ||
315 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) | 316 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) |
316 | { | 317 | { |
317 | struct atp *dev = NULL; | 318 | struct atp *dev; |
319 | struct input_dev *input_dev; | ||
320 | struct usb_device *udev = interface_to_usbdev(iface); | ||
318 | struct usb_host_interface *iface_desc; | 321 | struct usb_host_interface *iface_desc; |
319 | struct usb_endpoint_descriptor *endpoint; | 322 | struct usb_endpoint_descriptor *endpoint; |
320 | int int_in_endpointAddr = 0; | 323 | int int_in_endpointAddr = 0; |
321 | int i, retval = -ENOMEM; | 324 | int i, retval = -ENOMEM; |
322 | 325 | ||
323 | /* allocate memory for our device state and initialize it */ | ||
324 | dev = kmalloc(sizeof(struct atp), GFP_KERNEL); | ||
325 | if (dev == NULL) { | ||
326 | err("Out of memory"); | ||
327 | goto err_kmalloc; | ||
328 | } | ||
329 | memset(dev, 0, sizeof(struct atp)); | ||
330 | |||
331 | dev->udev = interface_to_usbdev(iface); | ||
332 | 326 | ||
333 | /* set up the endpoint information */ | 327 | /* set up the endpoint information */ |
334 | /* use only the first interrupt-in endpoint */ | 328 | /* use only the first interrupt-in endpoint */ |
@@ -345,70 +339,82 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
345 | } | 339 | } |
346 | } | 340 | } |
347 | if (!int_in_endpointAddr) { | 341 | if (!int_in_endpointAddr) { |
348 | retval = -EIO; | ||
349 | err("Could not find int-in endpoint"); | 342 | err("Could not find int-in endpoint"); |
350 | goto err_endpoint; | 343 | return -EIO; |
351 | } | 344 | } |
352 | 345 | ||
353 | /* save our data pointer in this interface device */ | 346 | /* allocate memory for our device state and initialize it */ |
354 | usb_set_intfdata(iface, dev); | 347 | dev = kzalloc(sizeof(struct atp), GFP_KERNEL); |
348 | input_dev = input_allocate_device(); | ||
349 | if (!dev || !input_dev) { | ||
350 | err("Out of memory"); | ||
351 | goto err_free_devs; | ||
352 | } | ||
353 | |||
354 | dev->udev = udev; | ||
355 | dev->input = input_dev; | ||
355 | 356 | ||
356 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | 357 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
357 | if (!dev->urb) { | 358 | if (!dev->urb) { |
358 | retval = -ENOMEM; | 359 | retval = -ENOMEM; |
359 | goto err_usballoc; | 360 | goto err_free_devs; |
360 | } | 361 | } |
362 | |||
361 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, | 363 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, |
362 | &dev->urb->transfer_dma); | 364 | &dev->urb->transfer_dma); |
363 | if (!dev->data) { | 365 | if (!dev->data) { |
364 | retval = -ENOMEM; | 366 | retval = -ENOMEM; |
365 | goto err_usbbufalloc; | 367 | goto err_free_urb; |
366 | } | 368 | } |
367 | usb_fill_int_urb(dev->urb, dev->udev, | 369 | |
368 | usb_rcvintpipe(dev->udev, int_in_endpointAddr), | 370 | usb_fill_int_urb(dev->urb, udev, |
371 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
369 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); | 372 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); |
370 | 373 | ||
371 | init_input_dev(&dev->input); | 374 | usb_make_path(udev, dev->phys, sizeof(dev->phys)); |
372 | dev->input.name = "appletouch"; | 375 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); |
373 | dev->input.dev = &iface->dev; | 376 | |
374 | dev->input.private = dev; | 377 | input_dev->name = "appletouch"; |
375 | dev->input.open = atp_open; | 378 | input_dev->phys = dev->phys; |
376 | dev->input.close = atp_close; | 379 | usb_to_input_id(dev->udev, &input_dev->id); |
380 | input_dev->cdev.dev = &iface->dev; | ||
377 | 381 | ||
378 | usb_to_input_id(dev->udev, &dev->input.id); | 382 | input_dev->private = dev; |
383 | input_dev->open = atp_open; | ||
384 | input_dev->close = atp_close; | ||
379 | 385 | ||
380 | set_bit(EV_ABS, dev->input.evbit); | 386 | set_bit(EV_ABS, input_dev->evbit); |
381 | 387 | ||
382 | /* | 388 | /* |
383 | * 12" and 15" Powerbooks only have 16 x sensors, | 389 | * 12" and 15" Powerbooks only have 16 x sensors, |
384 | * 17" models are detected later. | 390 | * 17" models are detected later. |
385 | */ | 391 | */ |
386 | input_set_abs_params(&dev->input, ABS_X, 0, | 392 | input_set_abs_params(input_dev, ABS_X, 0, |
387 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); | 393 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); |
388 | input_set_abs_params(&dev->input, ABS_Y, 0, | 394 | input_set_abs_params(input_dev, ABS_Y, 0, |
389 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); | 395 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); |
390 | input_set_abs_params(&dev->input, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | 396 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
391 | 397 | ||
392 | set_bit(EV_KEY, dev->input.evbit); | 398 | set_bit(EV_KEY, input_dev->evbit); |
393 | set_bit(BTN_TOUCH, dev->input.keybit); | 399 | set_bit(BTN_TOUCH, input_dev->keybit); |
394 | set_bit(BTN_TOOL_FINGER, dev->input.keybit); | 400 | set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
395 | set_bit(BTN_TOOL_DOUBLETAP, dev->input.keybit); | 401 | set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
396 | set_bit(BTN_TOOL_TRIPLETAP, dev->input.keybit); | 402 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
397 | set_bit(BTN_LEFT, dev->input.keybit); | 403 | set_bit(BTN_LEFT, input_dev->keybit); |
398 | 404 | ||
399 | input_register_device(&dev->input); | 405 | input_register_device(dev->input); |
400 | 406 | ||
401 | printk(KERN_INFO "input: appletouch connected\n"); | 407 | /* save our data pointer in this interface device */ |
408 | usb_set_intfdata(iface, dev); | ||
402 | 409 | ||
403 | return 0; | 410 | return 0; |
404 | 411 | ||
405 | err_usbbufalloc: | 412 | err_free_urb: |
406 | usb_free_urb(dev->urb); | 413 | usb_free_urb(dev->urb); |
407 | err_usballoc: | 414 | err_free_devs: |
408 | usb_set_intfdata(iface, NULL); | 415 | usb_set_intfdata(iface, NULL); |
409 | err_endpoint: | ||
410 | kfree(dev); | 416 | kfree(dev); |
411 | err_kmalloc: | 417 | input_free_device(input_dev); |
412 | return retval; | 418 | return retval; |
413 | } | 419 | } |
414 | 420 | ||
@@ -419,7 +425,7 @@ static void atp_disconnect(struct usb_interface *iface) | |||
419 | usb_set_intfdata(iface, NULL); | 425 | usb_set_intfdata(iface, NULL); |
420 | if (dev) { | 426 | if (dev) { |
421 | usb_kill_urb(dev->urb); | 427 | usb_kill_urb(dev->urb); |
422 | input_unregister_device(&dev->input); | 428 | input_unregister_device(dev->input); |
423 | usb_free_urb(dev->urb); | 429 | usb_free_urb(dev->urb); |
424 | usb_buffer_free(dev->udev, ATP_DATASIZE, | 430 | usb_buffer_free(dev->udev, ATP_DATASIZE, |
425 | dev->data, dev->urb->transfer_dma); | 431 | dev->data, dev->urb->transfer_dma); |
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index fd99681ee483..9a2a47db9494 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -112,7 +112,6 @@ | |||
112 | 112 | ||
113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ | 113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ |
114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ | 114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ |
115 | #define ATI_INPUTNUM 1 /* Which input device to register as */ | ||
116 | 115 | ||
117 | static unsigned long channel_mask; | 116 | static unsigned long channel_mask; |
118 | module_param(channel_mask, ulong, 0444); | 117 | module_param(channel_mask, ulong, 0444); |
@@ -162,7 +161,7 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | |||
162 | static DECLARE_MUTEX(disconnect_sem); | 161 | static DECLARE_MUTEX(disconnect_sem); |
163 | 162 | ||
164 | struct ati_remote { | 163 | struct ati_remote { |
165 | struct input_dev idev; | 164 | struct input_dev *idev; |
166 | struct usb_device *udev; | 165 | struct usb_device *udev; |
167 | struct usb_interface *interface; | 166 | struct usb_interface *interface; |
168 | 167 | ||
@@ -198,15 +197,13 @@ struct ati_remote { | |||
198 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ | 197 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ |
199 | 198 | ||
200 | /* Translation table from hardware messages to input events. */ | 199 | /* Translation table from hardware messages to input events. */ |
201 | static struct | 200 | static struct { |
202 | { | ||
203 | short kind; | 201 | short kind; |
204 | unsigned char data1, data2; | 202 | unsigned char data1, data2; |
205 | int type; | 203 | int type; |
206 | unsigned int code; | 204 | unsigned int code; |
207 | int value; | 205 | int value; |
208 | } ati_remote_tbl[] = | 206 | } ati_remote_tbl[] = { |
209 | { | ||
210 | /* Directional control pad axes */ | 207 | /* Directional control pad axes */ |
211 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ | 208 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ |
212 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ | 209 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ |
@@ -286,7 +283,6 @@ static struct | |||
286 | 283 | ||
287 | /* Local function prototypes */ | 284 | /* Local function prototypes */ |
288 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); | 285 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); |
289 | static void ati_remote_delete (struct ati_remote *dev); | ||
290 | static int ati_remote_open (struct input_dev *inputdev); | 286 | static int ati_remote_open (struct input_dev *inputdev); |
291 | static void ati_remote_close (struct input_dev *inputdev); | 287 | static void ati_remote_close (struct input_dev *inputdev); |
292 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); | 288 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); |
@@ -428,7 +424,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
428 | { | 424 | { |
429 | struct ati_remote *ati_remote = urb->context; | 425 | struct ati_remote *ati_remote = urb->context; |
430 | unsigned char *data= ati_remote->inbuf; | 426 | unsigned char *data= ati_remote->inbuf; |
431 | struct input_dev *dev = &ati_remote->idev; | 427 | struct input_dev *dev = ati_remote->idev; |
432 | int index, acc; | 428 | int index, acc; |
433 | int remote_num; | 429 | int remote_num; |
434 | 430 | ||
@@ -587,38 +583,55 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) | |||
587 | } | 583 | } |
588 | 584 | ||
589 | /* | 585 | /* |
590 | * ati_remote_delete | 586 | * ati_remote_alloc_buffers |
591 | */ | 587 | */ |
592 | static void ati_remote_delete(struct ati_remote *ati_remote) | 588 | static int ati_remote_alloc_buffers(struct usb_device *udev, |
589 | struct ati_remote *ati_remote) | ||
593 | { | 590 | { |
594 | if (ati_remote->irq_urb) | 591 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
595 | usb_kill_urb(ati_remote->irq_urb); | 592 | &ati_remote->inbuf_dma); |
593 | if (!ati_remote->inbuf) | ||
594 | return -1; | ||
596 | 595 | ||
597 | if (ati_remote->out_urb) | 596 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
598 | usb_kill_urb(ati_remote->out_urb); | 597 | &ati_remote->outbuf_dma); |
598 | if (!ati_remote->outbuf) | ||
599 | return -1; | ||
599 | 600 | ||
600 | input_unregister_device(&ati_remote->idev); | 601 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
602 | if (!ati_remote->irq_urb) | ||
603 | return -1; | ||
601 | 604 | ||
602 | if (ati_remote->inbuf) | 605 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); |
603 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 606 | if (!ati_remote->out_urb) |
604 | ati_remote->inbuf, ati_remote->inbuf_dma); | 607 | return -1; |
605 | 608 | ||
606 | if (ati_remote->outbuf) | 609 | return 0; |
607 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 610 | } |
608 | ati_remote->outbuf, ati_remote->outbuf_dma); | ||
609 | 611 | ||
612 | /* | ||
613 | * ati_remote_free_buffers | ||
614 | */ | ||
615 | static void ati_remote_free_buffers(struct ati_remote *ati_remote) | ||
616 | { | ||
610 | if (ati_remote->irq_urb) | 617 | if (ati_remote->irq_urb) |
611 | usb_free_urb(ati_remote->irq_urb); | 618 | usb_free_urb(ati_remote->irq_urb); |
612 | 619 | ||
613 | if (ati_remote->out_urb) | 620 | if (ati_remote->out_urb) |
614 | usb_free_urb(ati_remote->out_urb); | 621 | usb_free_urb(ati_remote->out_urb); |
615 | 622 | ||
616 | kfree(ati_remote); | 623 | if (ati_remote->inbuf) |
624 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
625 | ati_remote->inbuf, ati_remote->inbuf_dma); | ||
626 | |||
627 | if (ati_remote->outbuf) | ||
628 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
629 | ati_remote->inbuf, ati_remote->outbuf_dma); | ||
617 | } | 630 | } |
618 | 631 | ||
619 | static void ati_remote_input_init(struct ati_remote *ati_remote) | 632 | static void ati_remote_input_init(struct ati_remote *ati_remote) |
620 | { | 633 | { |
621 | struct input_dev *idev = &(ati_remote->idev); | 634 | struct input_dev *idev = ati_remote->idev; |
622 | int i; | 635 | int i; |
623 | 636 | ||
624 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 637 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
@@ -637,7 +650,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
637 | idev->phys = ati_remote->phys; | 650 | idev->phys = ati_remote->phys; |
638 | 651 | ||
639 | usb_to_input_id(ati_remote->udev, &idev->id); | 652 | usb_to_input_id(ati_remote->udev, &idev->id); |
640 | idev->dev = &ati_remote->udev->dev; | 653 | idev->cdev.dev = &ati_remote->udev->dev; |
641 | } | 654 | } |
642 | 655 | ||
643 | static int ati_remote_initialize(struct ati_remote *ati_remote) | 656 | static int ati_remote_initialize(struct ati_remote *ati_remote) |
@@ -674,7 +687,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
674 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { | 687 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { |
675 | dev_err(&ati_remote->interface->dev, | 688 | dev_err(&ati_remote->interface->dev, |
676 | "Initializing ati_remote hardware failed.\n"); | 689 | "Initializing ati_remote hardware failed.\n"); |
677 | return 1; | 690 | return -EIO; |
678 | } | 691 | } |
679 | 692 | ||
680 | return 0; | 693 | return 0; |
@@ -686,95 +699,83 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
686 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) | 699 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) |
687 | { | 700 | { |
688 | struct usb_device *udev = interface_to_usbdev(interface); | 701 | struct usb_device *udev = interface_to_usbdev(interface); |
689 | struct ati_remote *ati_remote = NULL; | 702 | struct usb_host_interface *iface_host = interface->cur_altsetting; |
690 | struct usb_host_interface *iface_host; | 703 | struct usb_endpoint_descriptor *endpoint_in, *endpoint_out; |
691 | int retval = -ENOMEM; | 704 | struct ati_remote *ati_remote; |
692 | char path[64]; | 705 | struct input_dev *input_dev; |
693 | 706 | int err = -ENOMEM; | |
694 | /* Allocate and clear an ati_remote struct */ | ||
695 | if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL))) | ||
696 | return -ENOMEM; | ||
697 | memset(ati_remote, 0x00, sizeof (struct ati_remote)); | ||
698 | 707 | ||
699 | iface_host = interface->cur_altsetting; | ||
700 | if (iface_host->desc.bNumEndpoints != 2) { | 708 | if (iface_host->desc.bNumEndpoints != 2) { |
701 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); | 709 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); |
702 | retval = -ENODEV; | 710 | return -ENODEV; |
703 | goto error; | ||
704 | } | 711 | } |
705 | 712 | ||
706 | ati_remote->endpoint_in = &(iface_host->endpoint[0].desc); | 713 | endpoint_in = &iface_host->endpoint[0].desc; |
707 | ati_remote->endpoint_out = &(iface_host->endpoint[1].desc); | 714 | endpoint_out = &iface_host->endpoint[1].desc; |
708 | ati_remote->udev = udev; | ||
709 | ati_remote->interface = interface; | ||
710 | 715 | ||
711 | if (!(ati_remote->endpoint_in->bEndpointAddress & 0x80)) { | 716 | if (!(endpoint_in->bEndpointAddress & USB_DIR_IN)) { |
712 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); | 717 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); |
713 | retval = -ENODEV; | 718 | return -ENODEV; |
714 | goto error; | ||
715 | } | 719 | } |
716 | if ((ati_remote->endpoint_in->bmAttributes & 3) != 3) { | 720 | if ((endpoint_in->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) { |
717 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); | 721 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); |
718 | retval = -ENODEV; | 722 | return -ENODEV; |
719 | goto error; | ||
720 | } | 723 | } |
721 | if (le16_to_cpu(ati_remote->endpoint_in->wMaxPacketSize) == 0) { | 724 | if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) { |
722 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); | 725 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); |
723 | retval = -ENODEV; | 726 | return -ENODEV; |
724 | goto error; | ||
725 | } | 727 | } |
726 | 728 | ||
727 | /* Allocate URB buffers, URBs */ | 729 | ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); |
728 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 730 | input_dev = input_allocate_device(); |
729 | &ati_remote->inbuf_dma); | 731 | if (!ati_remote || !input_dev) |
730 | if (!ati_remote->inbuf) | 732 | goto fail1; |
731 | goto error; | ||
732 | 733 | ||
733 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 734 | /* Allocate URB buffers, URBs */ |
734 | &ati_remote->outbuf_dma); | 735 | if (ati_remote_alloc_buffers(udev, ati_remote)) |
735 | if (!ati_remote->outbuf) | 736 | goto fail2; |
736 | goto error; | ||
737 | 737 | ||
738 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 738 | ati_remote->endpoint_in = endpoint_in; |
739 | if (!ati_remote->irq_urb) | 739 | ati_remote->endpoint_out = endpoint_out; |
740 | goto error; | 740 | ati_remote->udev = udev; |
741 | ati_remote->idev = input_dev; | ||
742 | ati_remote->interface = interface; | ||
741 | 743 | ||
742 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); | 744 | usb_make_path(udev, ati_remote->phys, sizeof(ati_remote->phys)); |
743 | if (!ati_remote->out_urb) | 745 | strlcpy(ati_remote->phys, "/input0", sizeof(ati_remote->phys)); |
744 | goto error; | ||
745 | 746 | ||
746 | usb_make_path(udev, path, NAME_BUFSIZE); | ||
747 | sprintf(ati_remote->phys, "%s/input%d", path, ATI_INPUTNUM); | ||
748 | if (udev->manufacturer) | 747 | if (udev->manufacturer) |
749 | strcat(ati_remote->name, udev->manufacturer); | 748 | strlcpy(ati_remote->name, udev->manufacturer, sizeof(ati_remote->name)); |
750 | 749 | ||
751 | if (udev->product) | 750 | if (udev->product) |
752 | sprintf(ati_remote->name, "%s %s", ati_remote->name, udev->product); | 751 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
752 | "%s %s", ati_remote->name, udev->product); | ||
753 | 753 | ||
754 | if (!strlen(ati_remote->name)) | 754 | if (!strlen(ati_remote->name)) |
755 | sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", | 755 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
756 | DRIVER_DESC "(%04x,%04x)", | ||
756 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), | 757 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), |
757 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); | 758 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); |
758 | 759 | ||
760 | ati_remote_input_init(ati_remote); | ||
761 | |||
759 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ | 762 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ |
760 | retval = ati_remote_initialize(ati_remote); | 763 | err = ati_remote_initialize(ati_remote); |
761 | if (retval) | 764 | if (err) |
762 | goto error; | 765 | goto fail3; |
763 | 766 | ||
764 | /* Set up and register input device */ | 767 | /* Set up and register input device */ |
765 | ati_remote_input_init(ati_remote); | 768 | input_register_device(ati_remote->idev); |
766 | input_register_device(&ati_remote->idev); | ||
767 | |||
768 | dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", | ||
769 | ati_remote->name, path); | ||
770 | 769 | ||
771 | usb_set_intfdata(interface, ati_remote); | 770 | usb_set_intfdata(interface, ati_remote); |
771 | return 0; | ||
772 | 772 | ||
773 | error: | 773 | fail3: usb_kill_urb(ati_remote->irq_urb); |
774 | if (retval) | 774 | usb_kill_urb(ati_remote->out_urb); |
775 | ati_remote_delete(ati_remote); | 775 | fail2: ati_remote_free_buffers(ati_remote); |
776 | 776 | fail1: input_free_device(input_dev); | |
777 | return retval; | 777 | kfree(ati_remote); |
778 | return err; | ||
778 | } | 779 | } |
779 | 780 | ||
780 | /* | 781 | /* |
@@ -791,7 +792,11 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
791 | return; | 792 | return; |
792 | } | 793 | } |
793 | 794 | ||
794 | ati_remote_delete(ati_remote); | 795 | usb_kill_urb(ati_remote->irq_urb); |
796 | usb_kill_urb(ati_remote->out_urb); | ||
797 | input_unregister_device(ati_remote->idev); | ||
798 | ati_remote_free_buffers(ati_remote); | ||
799 | kfree(ati_remote); | ||
795 | } | 800 | } |
796 | 801 | ||
797 | /* | 802 | /* |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 41f92b924761..411a0645a7a3 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -1619,8 +1619,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1619 | struct hid_descriptor *hdesc; | 1619 | struct hid_descriptor *hdesc; |
1620 | struct hid_device *hid; | 1620 | struct hid_device *hid; |
1621 | unsigned quirks = 0, rsize = 0; | 1621 | unsigned quirks = 0, rsize = 0; |
1622 | char *buf, *rdesc; | 1622 | char *rdesc; |
1623 | int n, insize = 0; | 1623 | int n, len, insize = 0; |
1624 | 1624 | ||
1625 | for (n = 0; hid_blacklist[n].idVendor; n++) | 1625 | for (n = 0; hid_blacklist[n].idVendor; n++) |
1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && | 1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
@@ -1630,10 +1630,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1630 | if (quirks & HID_QUIRK_IGNORE) | 1630 | if (quirks & HID_QUIRK_IGNORE) |
1631 | return NULL; | 1631 | return NULL; |
1632 | 1632 | ||
1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || | 1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
1634 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { | 1634 | (!interface->desc.bNumEndpoints || |
1635 | dbg("class descriptor not present\n"); | 1635 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
1636 | return NULL; | 1636 | dbg("class descriptor not present\n"); |
1637 | return NULL; | ||
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | for (n = 0; n < hdesc->bNumDescriptors; n++) | 1640 | for (n = 0; n < hdesc->bNumDescriptors; n++) |
@@ -1749,32 +1750,34 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1749 | 1750 | ||
1750 | hid->name[0] = 0; | 1751 | hid->name[0] = 0; |
1751 | 1752 | ||
1752 | if (!(buf = kmalloc(64, GFP_KERNEL))) | 1753 | if (dev->manufacturer) |
1753 | goto fail; | 1754 | strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); |
1755 | |||
1756 | if (dev->product) { | ||
1757 | if (dev->manufacturer) | ||
1758 | strlcat(hid->name, " ", sizeof(hid->name)); | ||
1759 | strlcat(hid->name, dev->product, sizeof(hid->name)); | ||
1760 | } | ||
1761 | |||
1762 | if (!strlen(hid->name)) | ||
1763 | snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", | ||
1764 | le16_to_cpu(dev->descriptor.idVendor), | ||
1765 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1754 | 1766 | ||
1755 | if (dev->manufacturer) { | 1767 | usb_make_path(dev, hid->phys, sizeof(hid->phys)); |
1756 | strcat(hid->name, dev->manufacturer); | 1768 | strlcat(hid->phys, "/input", sizeof(hid->phys)); |
1757 | if (dev->product) | 1769 | len = strlen(hid->phys); |
1758 | snprintf(hid->name, 64, "%s %s", hid->name, dev->product); | 1770 | if (len < sizeof(hid->phys) - 1) |
1759 | } else if (dev->product) { | 1771 | snprintf(hid->phys + len, sizeof(hid->phys) - len, |
1760 | snprintf(hid->name, 128, "%s", dev->product); | 1772 | "%d", intf->altsetting[0].desc.bInterfaceNumber); |
1761 | } else | ||
1762 | snprintf(hid->name, 128, "%04x:%04x", | ||
1763 | le16_to_cpu(dev->descriptor.idVendor), | ||
1764 | le16_to_cpu(dev->descriptor.idProduct)); | ||
1765 | |||
1766 | usb_make_path(dev, buf, 64); | ||
1767 | snprintf(hid->phys, 64, "%s/input%d", buf, | ||
1768 | intf->altsetting[0].desc.bInterfaceNumber); | ||
1769 | 1773 | ||
1770 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1774 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
1771 | hid->uniq[0] = 0; | 1775 | hid->uniq[0] = 0; |
1772 | 1776 | ||
1773 | kfree(buf); | ||
1774 | |||
1775 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1777 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
1776 | if (!hid->urbctrl) | 1778 | if (!hid->urbctrl) |
1777 | goto fail; | 1779 | goto fail; |
1780 | |||
1778 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, | 1781 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, |
1779 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1782 | hid->ctrlbuf, 1, hid_ctrl, hid); |
1780 | hid->urbctrl->setup_dma = hid->cr_dma; | 1783 | hid->urbctrl->setup_dma = hid->cr_dma; |
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 0b6452248a39..9ff25eb520a6 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
@@ -76,8 +76,8 @@ static struct { | |||
76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
77 | struct hid_usage *usage) | 77 | struct hid_usage *usage) |
78 | { | 78 | { |
79 | struct input_dev *input = &hidinput->input; | 79 | struct input_dev *input = hidinput->input; |
80 | struct hid_device *device = hidinput->input.private; | 80 | struct hid_device *device = input->private; |
81 | int max = 0, code; | 81 | int max = 0, code; |
82 | unsigned long *bit = NULL; | 82 | unsigned long *bit = NULL; |
83 | 83 | ||
@@ -461,7 +461,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
461 | 461 | ||
462 | if (!field->hidinput) | 462 | if (!field->hidinput) |
463 | return; | 463 | return; |
464 | input = &field->hidinput->input; | 464 | |
465 | input = field->hidinput->input; | ||
465 | 466 | ||
466 | input_regs(input, regs); | 467 | input_regs(input, regs); |
467 | 468 | ||
@@ -533,13 +534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
533 | 534 | ||
534 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) | 535 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) |
535 | { | 536 | { |
536 | struct list_head *lh; | ||
537 | struct hid_input *hidinput; | 537 | struct hid_input *hidinput; |
538 | 538 | ||
539 | list_for_each (lh, &hid->inputs) { | 539 | list_for_each_entry(hidinput, &hid->inputs, list) |
540 | hidinput = list_entry(lh, struct hid_input, list); | 540 | input_sync(hidinput->input); |
541 | input_sync(&hidinput->input); | ||
542 | } | ||
543 | } | 541 | } |
544 | 542 | ||
545 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) | 543 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) |
@@ -604,6 +602,7 @@ int hidinput_connect(struct hid_device *hid) | |||
604 | struct usb_device *dev = hid->dev; | 602 | struct usb_device *dev = hid->dev; |
605 | struct hid_report *report; | 603 | struct hid_report *report; |
606 | struct hid_input *hidinput = NULL; | 604 | struct hid_input *hidinput = NULL; |
605 | struct input_dev *input_dev; | ||
607 | int i, j, k; | 606 | int i, j, k; |
608 | 607 | ||
609 | INIT_LIST_HEAD(&hid->inputs); | 608 | INIT_LIST_HEAD(&hid->inputs); |
@@ -624,25 +623,28 @@ int hidinput_connect(struct hid_device *hid) | |||
624 | continue; | 623 | continue; |
625 | 624 | ||
626 | if (!hidinput) { | 625 | if (!hidinput) { |
627 | hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL); | 626 | hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); |
628 | if (!hidinput) { | 627 | input_dev = input_allocate_device(); |
628 | if (!hidinput || !input_dev) { | ||
629 | kfree(hidinput); | ||
630 | input_free_device(input_dev); | ||
629 | err("Out of memory during hid input probe"); | 631 | err("Out of memory during hid input probe"); |
630 | return -1; | 632 | return -1; |
631 | } | 633 | } |
632 | memset(hidinput, 0, sizeof(*hidinput)); | ||
633 | 634 | ||
634 | list_add_tail(&hidinput->list, &hid->inputs); | 635 | input_dev->private = hid; |
636 | input_dev->event = hidinput_input_event; | ||
637 | input_dev->open = hidinput_open; | ||
638 | input_dev->close = hidinput_close; | ||
635 | 639 | ||
636 | hidinput->input.private = hid; | 640 | input_dev->name = hid->name; |
637 | hidinput->input.event = hidinput_input_event; | 641 | input_dev->phys = hid->phys; |
638 | hidinput->input.open = hidinput_open; | 642 | input_dev->uniq = hid->uniq; |
639 | hidinput->input.close = hidinput_close; | 643 | usb_to_input_id(dev, &input_dev->id); |
644 | input_dev->cdev.dev = &hid->intf->dev; | ||
640 | 645 | ||
641 | hidinput->input.name = hid->name; | 646 | hidinput->input = input_dev; |
642 | hidinput->input.phys = hid->phys; | 647 | list_add_tail(&hidinput->list, &hid->inputs); |
643 | hidinput->input.uniq = hid->uniq; | ||
644 | usb_to_input_id(dev, &hidinput->input.id); | ||
645 | hidinput->input.dev = &hid->intf->dev; | ||
646 | } | 648 | } |
647 | 649 | ||
648 | for (i = 0; i < report->maxfield; i++) | 650 | for (i = 0; i < report->maxfield; i++) |
@@ -657,7 +659,7 @@ int hidinput_connect(struct hid_device *hid) | |||
657 | * UGCI) cram a lot of unrelated inputs into the | 659 | * UGCI) cram a lot of unrelated inputs into the |
658 | * same interface. */ | 660 | * same interface. */ |
659 | hidinput->report = report; | 661 | hidinput->report = report; |
660 | input_register_device(&hidinput->input); | 662 | input_register_device(hidinput->input); |
661 | hidinput = NULL; | 663 | hidinput = NULL; |
662 | } | 664 | } |
663 | } | 665 | } |
@@ -667,7 +669,7 @@ int hidinput_connect(struct hid_device *hid) | |||
667 | * only useful in this case, and not for multi-input quirks. */ | 669 | * only useful in this case, and not for multi-input quirks. */ |
668 | if (hidinput) { | 670 | if (hidinput) { |
669 | hid_ff_init(hid); | 671 | hid_ff_init(hid); |
670 | input_register_device(&hidinput->input); | 672 | input_register_device(hidinput->input); |
671 | } | 673 | } |
672 | 674 | ||
673 | return 0; | 675 | return 0; |
@@ -675,13 +677,11 @@ int hidinput_connect(struct hid_device *hid) | |||
675 | 677 | ||
676 | void hidinput_disconnect(struct hid_device *hid) | 678 | void hidinput_disconnect(struct hid_device *hid) |
677 | { | 679 | { |
678 | struct list_head *lh, *next; | 680 | struct hid_input *hidinput, *next; |
679 | struct hid_input *hidinput; | ||
680 | 681 | ||
681 | list_for_each_safe(lh, next, &hid->inputs) { | 682 | list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { |
682 | hidinput = list_entry(lh, struct hid_input, list); | ||
683 | input_unregister_device(&hidinput->input); | ||
684 | list_del(&hidinput->list); | 683 | list_del(&hidinput->list); |
684 | input_unregister_device(hidinput->input); | ||
685 | kfree(hidinput); | 685 | kfree(hidinput); |
686 | } | 686 | } |
687 | } | 687 | } |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index 0c4c77aa31ea..f82c9c9e5d51 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -255,22 +255,19 @@ static void hid_lgff_input_init(struct hid_device* hid) | |||
255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); | 255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); |
256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); | 256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); |
257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
258 | struct input_dev *input_dev = hidinput->input; | ||
258 | 259 | ||
259 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) | 260 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) |
260 | dev++; | 261 | dev++; |
261 | 262 | ||
262 | ff = dev->ff; | 263 | for (ff = dev->ff; *ff >= 0; ff++) |
264 | set_bit(*ff, input_dev->ffbit); | ||
263 | 265 | ||
264 | while (*ff >= 0) { | 266 | input_dev->upload_effect = hid_lgff_upload_effect; |
265 | set_bit(*ff, hidinput->input.ffbit); | 267 | input_dev->flush = hid_lgff_flush; |
266 | ++ff; | ||
267 | } | ||
268 | |||
269 | hidinput->input.upload_effect = hid_lgff_upload_effect; | ||
270 | hidinput->input.flush = hid_lgff_flush; | ||
271 | 268 | ||
272 | set_bit(EV_FF, hidinput->input.evbit); | 269 | set_bit(EV_FF, input_dev->evbit); |
273 | hidinput->input.ff_effects_max = LGFF_EFFECTS; | 270 | input_dev->ff_effects_max = LGFF_EFFECTS; |
274 | } | 271 | } |
275 | 272 | ||
276 | static void hid_lgff_exit(struct hid_device* hid) | 273 | static void hid_lgff_exit(struct hid_device* hid) |
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c index 8f6a0a6f94a9..023fd5ac31c8 100644 --- a/drivers/usb/input/hid-tmff.c +++ b/drivers/usb/input/hid-tmff.c | |||
@@ -111,6 +111,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
111 | struct tmff_device *private; | 111 | struct tmff_device *private; |
112 | struct list_head *pos; | 112 | struct list_head *pos; |
113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
114 | struct input_dev *input_dev = hidinput->input; | ||
114 | 115 | ||
115 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); | 116 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); |
116 | if (!private) | 117 | if (!private) |
@@ -155,7 +156,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
155 | private->report = report; | 156 | private->report = report; |
156 | private->rumble = field; | 157 | private->rumble = field; |
157 | 158 | ||
158 | set_bit(FF_RUMBLE, hidinput->input.ffbit); | 159 | set_bit(FF_RUMBLE, input_dev->ffbit); |
159 | break; | 160 | break; |
160 | 161 | ||
161 | default: | 162 | default: |
@@ -164,11 +165,11 @@ int hid_tmff_init(struct hid_device *hid) | |||
164 | } | 165 | } |
165 | 166 | ||
166 | /* Fallthrough to here only when a valid usage is found */ | 167 | /* Fallthrough to here only when a valid usage is found */ |
167 | hidinput->input.upload_effect = hid_tmff_upload_effect; | 168 | input_dev->upload_effect = hid_tmff_upload_effect; |
168 | hidinput->input.flush = hid_tmff_flush; | 169 | input_dev->flush = hid_tmff_flush; |
169 | 170 | ||
170 | set_bit(EV_FF, hidinput->input.evbit); | 171 | set_bit(EV_FF, input_dev->evbit); |
171 | hidinput->input.ff_effects_max = TMFF_EFFECTS; | 172 | input_dev->ff_effects_max = TMFF_EFFECTS; |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index ec2412c42f1e..ee48a2276104 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
@@ -371,7 +371,7 @@ struct hid_control_fifo { | |||
371 | struct hid_input { | 371 | struct hid_input { |
372 | struct list_head list; | 372 | struct list_head list; |
373 | struct hid_report *report; | 373 | struct hid_report *report; |
374 | struct input_dev input; | 374 | struct input_dev *input; |
375 | }; | 375 | }; |
376 | 376 | ||
377 | struct hid_device { /* device report descriptor */ | 377 | struct hid_device { /* device report descriptor */ |
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c index becb87efb869..3b581853cf10 100644 --- a/drivers/usb/input/itmtouch.c +++ b/drivers/usb/input/itmtouch.c | |||
@@ -73,7 +73,7 @@ MODULE_LICENSE( DRIVER_LICENSE ); | |||
73 | 73 | ||
74 | struct itmtouch_dev { | 74 | struct itmtouch_dev { |
75 | struct usb_device *usbdev; /* usb device */ | 75 | struct usb_device *usbdev; /* usb device */ |
76 | struct input_dev inputdev; /* input device */ | 76 | struct input_dev *inputdev; /* input device */ |
77 | struct urb *readurb; /* urb */ | 77 | struct urb *readurb; /* urb */ |
78 | char rbuf[ITM_BUFSIZE]; /* data */ | 78 | char rbuf[ITM_BUFSIZE]; /* data */ |
79 | int users; | 79 | int users; |
@@ -88,9 +88,9 @@ static struct usb_device_id itmtouch_ids [] = { | |||
88 | 88 | ||
89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) | 89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) |
90 | { | 90 | { |
91 | struct itmtouch_dev * itmtouch = urb->context; | 91 | struct itmtouch_dev *itmtouch = urb->context; |
92 | unsigned char *data = urb->transfer_buffer; | 92 | unsigned char *data = urb->transfer_buffer; |
93 | struct input_dev *dev = &itmtouch->inputdev; | 93 | struct input_dev *dev = itmtouch->inputdev; |
94 | int retval; | 94 | int retval; |
95 | 95 | ||
96 | switch (urb->status) { | 96 | switch (urb->status) { |
@@ -156,49 +156,62 @@ static void itmtouch_close(struct input_dev *input) | |||
156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) | 156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) |
157 | { | 157 | { |
158 | struct itmtouch_dev *itmtouch; | 158 | struct itmtouch_dev *itmtouch; |
159 | struct input_dev *input_dev; | ||
159 | struct usb_host_interface *interface; | 160 | struct usb_host_interface *interface; |
160 | struct usb_endpoint_descriptor *endpoint; | 161 | struct usb_endpoint_descriptor *endpoint; |
161 | struct usb_device *udev = interface_to_usbdev(intf); | 162 | struct usb_device *udev = interface_to_usbdev(intf); |
162 | unsigned int pipe; | 163 | unsigned int pipe; |
163 | unsigned int maxp; | 164 | unsigned int maxp; |
164 | char path[PATH_SIZE]; | ||
165 | 165 | ||
166 | interface = intf->cur_altsetting; | 166 | interface = intf->cur_altsetting; |
167 | endpoint = &interface->endpoint[0].desc; | 167 | endpoint = &interface->endpoint[0].desc; |
168 | 168 | ||
169 | if (!(itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL))) { | 169 | itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL); |
170 | input_dev = input_allocate_device(); | ||
171 | if (!itmtouch || !input_dev) { | ||
170 | err("%s - Out of memory.", __FUNCTION__); | 172 | err("%s - Out of memory.", __FUNCTION__); |
171 | return -ENOMEM; | 173 | goto fail; |
172 | } | 174 | } |
173 | 175 | ||
174 | itmtouch->usbdev = udev; | 176 | itmtouch->usbdev = udev; |
177 | itmtouch->inputdev = input_dev; | ||
175 | 178 | ||
176 | itmtouch->inputdev.private = itmtouch; | 179 | if (udev->manufacturer) |
177 | itmtouch->inputdev.open = itmtouch_open; | 180 | strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name)); |
178 | itmtouch->inputdev.close = itmtouch_close; | ||
179 | 181 | ||
180 | usb_make_path(udev, path, PATH_SIZE); | 182 | if (udev->product) { |
181 | 183 | if (udev->manufacturer) | |
182 | itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 184 | strlcat(itmtouch->name, " ", sizeof(itmtouch->name)); |
183 | itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 185 | strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name)); |
184 | itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 186 | } |
185 | |||
186 | itmtouch->inputdev.name = itmtouch->name; | ||
187 | itmtouch->inputdev.phys = itmtouch->phys; | ||
188 | usb_to_input_id(udev, &itmtouch->inputdev.id); | ||
189 | itmtouch->inputdev.dev = &intf->dev; | ||
190 | 187 | ||
191 | if (!strlen(itmtouch->name)) | 188 | if (!strlen(itmtouch->name)) |
192 | sprintf(itmtouch->name, "USB ITM touchscreen"); | 189 | sprintf(itmtouch->name, "USB ITM touchscreen"); |
193 | 190 | ||
191 | usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys)); | ||
192 | strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys)); | ||
193 | |||
194 | input_dev->name = itmtouch->name; | ||
195 | input_dev->phys = itmtouch->phys; | ||
196 | usb_to_input_id(udev, &input_dev->id); | ||
197 | input_dev->cdev.dev = &intf->dev; | ||
198 | input_dev->private = itmtouch; | ||
199 | |||
200 | input_dev->open = itmtouch_open; | ||
201 | input_dev->close = itmtouch_close; | ||
202 | |||
203 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
204 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
205 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
206 | |||
194 | /* device limits */ | 207 | /* device limits */ |
195 | /* as specified by the ITM datasheet, X and Y are 12bit, | 208 | /* as specified by the ITM datasheet, X and Y are 12bit, |
196 | * Z (pressure) is 8 bit. However, the fields are defined up | 209 | * Z (pressure) is 8 bit. However, the fields are defined up |
197 | * to 14 bits for future possible expansion. | 210 | * to 14 bits for future possible expansion. |
198 | */ | 211 | */ |
199 | input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); | 212 | input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0); |
200 | input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); | 213 | input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0); |
201 | input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); | 214 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0); |
202 | 215 | ||
203 | /* initialise the URB so we can read from the transport stream */ | 216 | /* initialise the URB so we can read from the transport stream */ |
204 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); | 217 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); |
@@ -208,22 +221,23 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id | |||
208 | maxp = ITM_BUFSIZE; | 221 | maxp = ITM_BUFSIZE; |
209 | 222 | ||
210 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); | 223 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); |
211 | |||
212 | if (!itmtouch->readurb) { | 224 | if (!itmtouch->readurb) { |
213 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); | 225 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); |
214 | kfree(itmtouch); | 226 | goto fail; |
215 | return -ENOMEM; | ||
216 | } | 227 | } |
217 | 228 | ||
218 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, | 229 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, |
219 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); | 230 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); |
220 | 231 | ||
221 | input_register_device(&itmtouch->inputdev); | 232 | input_register_device(itmtouch->inputdev); |
222 | 233 | ||
223 | printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path); | ||
224 | usb_set_intfdata(intf, itmtouch); | 234 | usb_set_intfdata(intf, itmtouch); |
225 | 235 | ||
226 | return 0; | 236 | return 0; |
237 | |||
238 | fail: input_free_device(input_dev); | ||
239 | kfree(itmtouch); | ||
240 | return -ENOMEM; | ||
227 | } | 241 | } |
228 | 242 | ||
229 | static void itmtouch_disconnect(struct usb_interface *intf) | 243 | static void itmtouch_disconnect(struct usb_interface *intf) |
@@ -233,7 +247,7 @@ static void itmtouch_disconnect(struct usb_interface *intf) | |||
233 | usb_set_intfdata(intf, NULL); | 247 | usb_set_intfdata(intf, NULL); |
234 | 248 | ||
235 | if (itmtouch) { | 249 | if (itmtouch) { |
236 | input_unregister_device(&itmtouch->inputdev); | 250 | input_unregister_device(itmtouch->inputdev); |
237 | usb_kill_urb(itmtouch->readurb); | 251 | usb_kill_urb(itmtouch->readurb); |
238 | usb_free_urb(itmtouch->readurb); | 252 | usb_free_urb(itmtouch->readurb); |
239 | kfree(itmtouch); | 253 | kfree(itmtouch); |
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index b6f6ac8d9c2f..a248664b5d1d 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -34,7 +34,7 @@ MODULE_PARM_DESC(kb_pressure_click, "pressure threshold for clicks"); | |||
34 | struct kbtab { | 34 | struct kbtab { |
35 | signed char *data; | 35 | signed char *data; |
36 | dma_addr_t data_dma; | 36 | dma_addr_t data_dma; |
37 | struct input_dev dev; | 37 | struct input_dev *dev; |
38 | struct usb_device *usbdev; | 38 | struct usb_device *usbdev; |
39 | struct urb *irq; | 39 | struct urb *irq; |
40 | int x, y; | 40 | int x, y; |
@@ -48,7 +48,7 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs) | |||
48 | { | 48 | { |
49 | struct kbtab *kbtab = urb->context; | 49 | struct kbtab *kbtab = urb->context; |
50 | unsigned char *data = kbtab->data; | 50 | unsigned char *data = kbtab->data; |
51 | struct input_dev *dev = &kbtab->dev; | 51 | struct input_dev *dev = kbtab->dev; |
52 | int retval; | 52 | int retval; |
53 | 53 | ||
54 | switch (urb->status) { | 54 | switch (urb->status) { |
@@ -124,53 +124,43 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
124 | struct usb_device *dev = interface_to_usbdev(intf); | 124 | struct usb_device *dev = interface_to_usbdev(intf); |
125 | struct usb_endpoint_descriptor *endpoint; | 125 | struct usb_endpoint_descriptor *endpoint; |
126 | struct kbtab *kbtab; | 126 | struct kbtab *kbtab; |
127 | char path[64]; | 127 | struct input_dev *input_dev; |
128 | 128 | ||
129 | if (!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL))) | 129 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
130 | return -ENOMEM; | 130 | input_dev = input_allocate_device(); |
131 | memset(kbtab, 0, sizeof(struct kbtab)); | 131 | if (!kbtab || !input_dev) |
132 | goto fail1; | ||
132 | 133 | ||
133 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); | 134 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); |
134 | if (!kbtab->data) { | 135 | if (!kbtab->data) |
135 | kfree(kbtab); | 136 | goto fail1; |
136 | return -ENOMEM; | ||
137 | } | ||
138 | 137 | ||
139 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); | 138 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); |
140 | if (!kbtab->irq) { | 139 | if (!kbtab->irq) |
141 | usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 140 | goto fail2; |
142 | kfree(kbtab); | ||
143 | return -ENOMEM; | ||
144 | } | ||
145 | |||
146 | kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | ||
147 | kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
148 | |||
149 | kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
150 | |||
151 | kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); | ||
152 | 141 | ||
153 | kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL); | 142 | kbtab->usbdev = dev; |
154 | 143 | kbtab->dev = input_dev; | |
155 | kbtab->dev.absmax[ABS_X] = 0x2000; | ||
156 | kbtab->dev.absmax[ABS_Y] = 0x1750; | ||
157 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; | ||
158 | 144 | ||
159 | kbtab->dev.absfuzz[ABS_X] = 4; | 145 | usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys)); |
160 | kbtab->dev.absfuzz[ABS_Y] = 4; | 146 | strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys)); |
161 | 147 | ||
162 | kbtab->dev.private = kbtab; | 148 | input_dev->name = "KB Gear Tablet"; |
163 | kbtab->dev.open = kbtab_open; | 149 | input_dev->phys = kbtab->phys; |
164 | kbtab->dev.close = kbtab_close; | 150 | usb_to_input_id(dev, &input_dev->id); |
151 | input_dev->cdev.dev = &intf->dev; | ||
152 | input_dev->private = kbtab; | ||
165 | 153 | ||
166 | usb_make_path(dev, path, 64); | 154 | input_dev->open = kbtab_open; |
167 | sprintf(kbtab->phys, "%s/input0", path); | 155 | input_dev->close = kbtab_close; |
168 | 156 | ||
169 | kbtab->dev.name = "KB Gear Tablet"; | 157 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); |
170 | kbtab->dev.phys = kbtab->phys; | 158 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
171 | usb_to_input_id(dev, &kbtab->dev.id); | 159 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); |
172 | kbtab->dev.dev = &intf->dev; | 160 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
173 | kbtab->usbdev = dev; | 161 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); |
162 | input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0); | ||
163 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | ||
174 | 164 | ||
175 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 165 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
176 | 166 | ||
@@ -181,23 +171,25 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
181 | kbtab->irq->transfer_dma = kbtab->data_dma; | 171 | kbtab->irq->transfer_dma = kbtab->data_dma; |
182 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 172 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
183 | 173 | ||
184 | input_register_device(&kbtab->dev); | 174 | input_register_device(kbtab->dev); |
185 | |||
186 | printk(KERN_INFO "input: KB Gear Tablet on %s\n", path); | ||
187 | 175 | ||
188 | usb_set_intfdata(intf, kbtab); | 176 | usb_set_intfdata(intf, kbtab); |
189 | |||
190 | return 0; | 177 | return 0; |
178 | |||
179 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | ||
180 | fail1: input_free_device(input_dev); | ||
181 | kfree(kbtab); | ||
182 | return -ENOMEM; | ||
191 | } | 183 | } |
192 | 184 | ||
193 | static void kbtab_disconnect(struct usb_interface *intf) | 185 | static void kbtab_disconnect(struct usb_interface *intf) |
194 | { | 186 | { |
195 | struct kbtab *kbtab = usb_get_intfdata (intf); | 187 | struct kbtab *kbtab = usb_get_intfdata(intf); |
196 | 188 | ||
197 | usb_set_intfdata(intf, NULL); | 189 | usb_set_intfdata(intf, NULL); |
198 | if (kbtab) { | 190 | if (kbtab) { |
199 | usb_kill_urb(kbtab->irq); | 191 | usb_kill_urb(kbtab->irq); |
200 | input_unregister_device(&kbtab->dev); | 192 | input_unregister_device(kbtab->dev); |
201 | usb_free_urb(kbtab->irq); | 193 | usb_free_urb(kbtab->irq); |
202 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); | 194 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); |
203 | kfree(kbtab); | 195 | kfree(kbtab); |
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 99de1b33c07d..5b8d65f62abf 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
22 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
23 | #include <linux/usb_input.h> | ||
23 | 24 | ||
24 | #define DRIVER_VERSION "v0.1" | 25 | #define DRIVER_VERSION "v0.1" |
25 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" | 26 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" |
@@ -75,7 +76,7 @@ struct usb_keyspan { | |||
75 | char name[128]; | 76 | char name[128]; |
76 | char phys[64]; | 77 | char phys[64]; |
77 | struct usb_device* udev; | 78 | struct usb_device* udev; |
78 | struct input_dev input; | 79 | struct input_dev *input; |
79 | struct usb_interface* interface; | 80 | struct usb_interface* interface; |
80 | struct usb_endpoint_descriptor* in_endpoint; | 81 | struct usb_endpoint_descriptor* in_endpoint; |
81 | struct urb* irq_urb; | 82 | struct urb* irq_urb; |
@@ -136,12 +137,11 @@ static struct usb_driver keyspan_driver; | |||
136 | */ | 137 | */ |
137 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | 138 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ |
138 | { | 139 | { |
139 | char codes[4*RECV_SIZE]; | 140 | char codes[4 * RECV_SIZE]; |
140 | int i; | 141 | int i; |
141 | 142 | ||
142 | for (i = 0; i < RECV_SIZE; i++) { | 143 | for (i = 0; i < RECV_SIZE; i++) |
143 | snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]); | 144 | snprintf(codes + i * 3, 4, "%02x ", dev->in_buffer[i]); |
144 | } | ||
145 | 145 | ||
146 | dev_info(&dev->udev->dev, "%s\n", codes); | 146 | dev_info(&dev->udev->dev, "%s\n", codes); |
147 | } | 147 | } |
@@ -153,7 +153,7 @@ static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | |||
153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | 153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) |
154 | { | 154 | { |
155 | if (dev->data.bits_left >= bits_needed) | 155 | if (dev->data.bits_left >= bits_needed) |
156 | return(0); | 156 | return 0; |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * Somehow we've missed the last message. The message will be repeated | 159 | * Somehow we've missed the last message. The message will be repeated |
@@ -162,7 +162,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
162 | if (dev->data.pos >= dev->data.len) { | 162 | if (dev->data.pos >= dev->data.len) { |
163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", | 163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", |
164 | __FUNCTION__, dev->data.pos, dev->data.len); | 164 | __FUNCTION__, dev->data.pos, dev->data.len); |
165 | return(-1); | 165 | return -1; |
166 | } | 166 | } |
167 | 167 | ||
168 | /* Load as much as we can into the tester. */ | 168 | /* Load as much as we can into the tester. */ |
@@ -172,7 +172,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
172 | dev->data.bits_left += 8; | 172 | dev->data.bits_left += 8; |
173 | } | 173 | } |
174 | 174 | ||
175 | return(0); | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* | 178 | /* |
@@ -311,10 +311,10 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs) | |||
311 | __FUNCTION__, message.system, message.button, message.toggle); | 311 | __FUNCTION__, message.system, message.button, message.toggle); |
312 | 312 | ||
313 | if (message.toggle != remote->toggle) { | 313 | if (message.toggle != remote->toggle) { |
314 | input_regs(&remote->input, regs); | 314 | input_regs(remote->input, regs); |
315 | input_report_key(&remote->input, keyspan_key_table[message.button], 1); | 315 | input_report_key(remote->input, keyspan_key_table[message.button], 1); |
316 | input_report_key(&remote->input, keyspan_key_table[message.button], 0); | 316 | input_report_key(remote->input, keyspan_key_table[message.button], 0); |
317 | input_sync(&remote->input); | 317 | input_sync(remote->input); |
318 | remote->toggle = message.toggle; | 318 | remote->toggle = message.toggle; |
319 | } | 319 | } |
320 | 320 | ||
@@ -397,14 +397,9 @@ static int keyspan_open(struct input_dev *dev) | |||
397 | { | 397 | { |
398 | struct usb_keyspan *remote = dev->private; | 398 | struct usb_keyspan *remote = dev->private; |
399 | 399 | ||
400 | if (remote->open++) | ||
401 | return 0; | ||
402 | |||
403 | remote->irq_urb->dev = remote->udev; | 400 | remote->irq_urb->dev = remote->udev; |
404 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) { | 401 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) |
405 | remote->open--; | ||
406 | return -EIO; | 402 | return -EIO; |
407 | } | ||
408 | 403 | ||
409 | return 0; | 404 | return 0; |
410 | } | 405 | } |
@@ -413,8 +408,26 @@ static void keyspan_close(struct input_dev *dev) | |||
413 | { | 408 | { |
414 | struct usb_keyspan *remote = dev->private; | 409 | struct usb_keyspan *remote = dev->private; |
415 | 410 | ||
416 | if (!--remote->open) | 411 | usb_kill_urb(remote->irq_urb); |
417 | usb_kill_urb(remote->irq_urb); | 412 | } |
413 | |||
414 | static struct usb_endpoint_descriptor *keyspan_get_in_endpoint(struct usb_host_interface *iface) | ||
415 | { | ||
416 | |||
417 | struct usb_endpoint_descriptor *endpoint; | ||
418 | int i; | ||
419 | |||
420 | for (i = 0; i < iface->desc.bNumEndpoints; ++i) { | ||
421 | endpoint = &iface->endpoint[i].desc; | ||
422 | |||
423 | if ((endpoint->bEndpointAddress & USB_DIR_IN) && | ||
424 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
425 | /* we found our interrupt in endpoint */ | ||
426 | return endpoint; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | return NULL; | ||
418 | } | 431 | } |
419 | 432 | ||
420 | /* | 433 | /* |
@@ -422,110 +435,78 @@ static void keyspan_close(struct input_dev *dev) | |||
422 | */ | 435 | */ |
423 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) | 436 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) |
424 | { | 437 | { |
425 | int i; | 438 | struct usb_device *udev = interface_to_usbdev(interface); |
426 | int retval = -ENOMEM; | ||
427 | char path[64]; | ||
428 | char *buf; | ||
429 | struct usb_keyspan *remote = NULL; | ||
430 | struct usb_host_interface *iface_desc; | ||
431 | struct usb_endpoint_descriptor *endpoint; | 439 | struct usb_endpoint_descriptor *endpoint; |
432 | struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); | 440 | struct usb_keyspan *remote; |
441 | struct input_dev *input_dev; | ||
442 | int i, retval; | ||
433 | 443 | ||
434 | /* allocate memory for our device state and initialize it */ | 444 | endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); |
435 | remote = kmalloc(sizeof(*remote), GFP_KERNEL); | 445 | if (!endpoint) |
436 | if (remote == NULL) { | 446 | return -ENODEV; |
437 | err("Out of memory\n"); | 447 | |
438 | goto error; | 448 | remote = kzalloc(sizeof(*remote), GFP_KERNEL); |
449 | input_dev = input_allocate_device(); | ||
450 | if (!remote || !input_dev) { | ||
451 | retval = -ENOMEM; | ||
452 | goto fail1; | ||
439 | } | 453 | } |
440 | memset(remote, 0x00, sizeof(*remote)); | ||
441 | 454 | ||
442 | remote->udev = udev; | 455 | remote->udev = udev; |
456 | remote->input = input_dev; | ||
443 | remote->interface = interface; | 457 | remote->interface = interface; |
458 | remote->in_endpoint = endpoint; | ||
444 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ | 459 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ |
445 | 460 | ||
446 | /* set up the endpoint information */ | 461 | remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); |
447 | /* use only the first in interrupt endpoint */ | 462 | if (!remote->in_buffer) { |
448 | iface_desc = interface->cur_altsetting; | 463 | retval = -ENOMEM; |
449 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 464 | goto fail1; |
450 | endpoint = &iface_desc->endpoint[i].desc; | ||
451 | |||
452 | if (!remote->in_endpoint && | ||
453 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
454 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
455 | /* we found our interrupt in endpoint */ | ||
456 | remote->in_endpoint = endpoint; | ||
457 | |||
458 | remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); | ||
459 | if (!remote->in_buffer) { | ||
460 | retval = -ENOMEM; | ||
461 | goto error; | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | |||
466 | if (!remote->in_endpoint) { | ||
467 | err("Could not find interrupt input endpoint.\n"); | ||
468 | retval = -ENODEV; | ||
469 | goto error; | ||
470 | } | 465 | } |
471 | 466 | ||
472 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 467 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
473 | if (!remote->irq_urb) { | 468 | if (!remote->irq_urb) { |
474 | err("Failed to allocate urb.\n"); | ||
475 | retval = -ENOMEM; | 469 | retval = -ENOMEM; |
476 | goto error; | 470 | goto fail2; |
477 | } | 471 | } |
478 | 472 | ||
479 | retval = keyspan_setup(remote->udev); | 473 | retval = keyspan_setup(udev); |
480 | if (retval) { | 474 | if (retval) { |
481 | err("Failed to setup device.\n"); | ||
482 | retval = -ENODEV; | 475 | retval = -ENODEV; |
483 | goto error; | 476 | goto fail3; |
484 | } | ||
485 | |||
486 | /* | ||
487 | * Setup the input system with the bits we are going to be reporting | ||
488 | */ | ||
489 | remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ | ||
490 | for (i = 0; i < 32; ++i) { | ||
491 | if (keyspan_key_table[i] != KEY_RESERVED) { | ||
492 | set_bit(keyspan_key_table[i], remote->input.keybit); | ||
493 | } | ||
494 | } | 477 | } |
495 | 478 | ||
496 | remote->input.private = remote; | 479 | if (udev->manufacturer) |
497 | remote->input.open = keyspan_open; | 480 | strlcpy(remote->name, udev->manufacturer, sizeof(remote->name)); |
498 | remote->input.close = keyspan_close; | ||
499 | |||
500 | usb_make_path(remote->udev, path, 64); | ||
501 | sprintf(remote->phys, "%s/input0", path); | ||
502 | 481 | ||
503 | remote->input.name = remote->name; | 482 | if (udev->product) { |
504 | remote->input.phys = remote->phys; | 483 | if (udev->manufacturer) |
505 | remote->input.id.bustype = BUS_USB; | 484 | strlcat(remote->name, " ", sizeof(remote->name)); |
506 | remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor); | 485 | strlcat(remote->name, udev->product, sizeof(remote->name)); |
507 | remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct); | ||
508 | remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice); | ||
509 | |||
510 | if (!(buf = kmalloc(63, GFP_KERNEL))) { | ||
511 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
512 | kfree(remote); | ||
513 | return -ENOMEM; | ||
514 | } | 486 | } |
515 | 487 | ||
516 | if (remote->udev->descriptor.iManufacturer && | 488 | if (!strlen(remote->name)) |
517 | usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0) | 489 | snprintf(remote->name, sizeof(remote->name), |
518 | strcat(remote->name, buf); | 490 | "USB Keyspan Remote %04x:%04x", |
491 | le16_to_cpu(udev->descriptor.idVendor), | ||
492 | le16_to_cpu(udev->descriptor.idProduct)); | ||
519 | 493 | ||
520 | if (remote->udev->descriptor.iProduct && | 494 | usb_make_path(udev, remote->phys, sizeof(remote->phys)); |
521 | usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0) | 495 | strlcat(remote->phys, "/input0", sizeof(remote->phys)); |
522 | sprintf(remote->name, "%s %s", remote->name, buf); | ||
523 | 496 | ||
524 | if (!strlen(remote->name)) | 497 | input_dev->name = remote->name; |
525 | sprintf(remote->name, "USB Keyspan Remote %04x:%04x", | 498 | input_dev->phys = remote->phys; |
526 | remote->input.id.vendor, remote->input.id.product); | 499 | usb_to_input_id(udev, &input_dev->id); |
500 | input_dev->cdev.dev = &interface->dev; | ||
527 | 501 | ||
528 | kfree(buf); | 502 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ |
503 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) | ||
504 | if (keyspan_key_table[i] != KEY_RESERVED) | ||
505 | set_bit(keyspan_key_table[i], input_dev->keybit); | ||
506 | |||
507 | input_dev->private = remote; | ||
508 | input_dev->open = keyspan_open; | ||
509 | input_dev->close = keyspan_close; | ||
529 | 510 | ||
530 | /* | 511 | /* |
531 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() | 512 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() |
@@ -538,27 +519,17 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
538 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 519 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
539 | 520 | ||
540 | /* we can register the device now, as it is ready */ | 521 | /* we can register the device now, as it is ready */ |
541 | input_register_device(&remote->input); | 522 | input_register_device(remote->input); |
542 | 523 | ||
543 | /* save our data pointer in this interface device */ | 524 | /* save our data pointer in this interface device */ |
544 | usb_set_intfdata(interface, remote); | 525 | usb_set_intfdata(interface, remote); |
545 | 526 | ||
546 | /* let the user know what node this device is now attached to */ | ||
547 | info("connected: %s on %s", remote->name, path); | ||
548 | return 0; | 527 | return 0; |
549 | 528 | ||
550 | error: | 529 | fail3: usb_free_urb(remote->irq_urb); |
551 | /* | 530 | fail2: usb_buffer_free(udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
552 | * In case of error we need to clean up any allocated buffers | 531 | fail1: kfree(remote); |
553 | */ | 532 | input_free_device(input_dev); |
554 | if (remote->irq_urb) | ||
555 | usb_free_urb(remote->irq_urb); | ||
556 | |||
557 | if (remote->in_buffer) | ||
558 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
559 | |||
560 | if (remote) | ||
561 | kfree(remote); | ||
562 | 533 | ||
563 | return retval; | 534 | return retval; |
564 | } | 535 | } |
@@ -570,23 +541,16 @@ static void keyspan_disconnect(struct usb_interface *interface) | |||
570 | { | 541 | { |
571 | struct usb_keyspan *remote; | 542 | struct usb_keyspan *remote; |
572 | 543 | ||
573 | /* prevent keyspan_open() from racing keyspan_disconnect() */ | ||
574 | lock_kernel(); | ||
575 | |||
576 | remote = usb_get_intfdata(interface); | 544 | remote = usb_get_intfdata(interface); |
577 | usb_set_intfdata(interface, NULL); | 545 | usb_set_intfdata(interface, NULL); |
578 | 546 | ||
579 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ | 547 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ |
580 | input_unregister_device(&remote->input); | 548 | input_unregister_device(remote->input); |
581 | usb_kill_urb(remote->irq_urb); | 549 | usb_kill_urb(remote->irq_urb); |
582 | usb_free_urb(remote->irq_urb); | 550 | usb_free_urb(remote->irq_urb); |
583 | usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma); | 551 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
584 | kfree(remote); | 552 | kfree(remote); |
585 | } | 553 | } |
586 | |||
587 | unlock_kernel(); | ||
588 | |||
589 | info("USB Keyspan now disconnected"); | ||
590 | } | 554 | } |
591 | 555 | ||
592 | /* | 556 | /* |
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index ff9275057a18..7fce526560ca 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c | |||
@@ -98,7 +98,7 @@ struct mtouch_usb { | |||
98 | dma_addr_t data_dma; | 98 | dma_addr_t data_dma; |
99 | struct urb *irq; | 99 | struct urb *irq; |
100 | struct usb_device *udev; | 100 | struct usb_device *udev; |
101 | struct input_dev input; | 101 | struct input_dev *input; |
102 | char name[128]; | 102 | char name[128]; |
103 | char phys[64]; | 103 | char phys[64]; |
104 | }; | 104 | }; |
@@ -135,14 +135,14 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) | |||
135 | goto exit; | 135 | goto exit; |
136 | } | 136 | } |
137 | 137 | ||
138 | input_regs(&mtouch->input, regs); | 138 | input_regs(mtouch->input, regs); |
139 | input_report_key(&mtouch->input, BTN_TOUCH, | 139 | input_report_key(mtouch->input, BTN_TOUCH, |
140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); | 140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); |
141 | input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); | 141 | input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); |
142 | input_report_abs(&mtouch->input, ABS_Y, | 142 | input_report_abs(mtouch->input, ABS_Y, |
143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) | 143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) |
144 | - MTOUCHUSB_GET_YC(mtouch->data)); | 144 | - MTOUCHUSB_GET_YC(mtouch->data)); |
145 | input_sync(&mtouch->input); | 145 | input_sync(mtouch->input); |
146 | 146 | ||
147 | exit: | 147 | exit: |
148 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 148 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -195,10 +195,10 @@ static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *m | |||
195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
196 | { | 196 | { |
197 | struct mtouch_usb *mtouch; | 197 | struct mtouch_usb *mtouch; |
198 | struct input_dev *input_dev; | ||
198 | struct usb_host_interface *interface; | 199 | struct usb_host_interface *interface; |
199 | struct usb_endpoint_descriptor *endpoint; | 200 | struct usb_endpoint_descriptor *endpoint; |
200 | struct usb_device *udev = interface_to_usbdev(intf); | 201 | struct usb_device *udev = interface_to_usbdev(intf); |
201 | char path[64]; | ||
202 | int nRet; | 202 | int nRet; |
203 | 203 | ||
204 | dbg("%s - called", __FUNCTION__); | 204 | dbg("%s - called", __FUNCTION__); |
@@ -209,57 +209,55 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
209 | dbg("%s - setting endpoint", __FUNCTION__); | 209 | dbg("%s - setting endpoint", __FUNCTION__); |
210 | endpoint = &interface->endpoint[0].desc; | 210 | endpoint = &interface->endpoint[0].desc; |
211 | 211 | ||
212 | if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { | 212 | mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL); |
213 | input_dev = input_allocate_device(); | ||
214 | if (!mtouch || !input_dev) { | ||
213 | err("%s - Out of memory.", __FUNCTION__); | 215 | err("%s - Out of memory.", __FUNCTION__); |
214 | return -ENOMEM; | 216 | goto fail1; |
215 | } | 217 | } |
216 | 218 | ||
217 | memset(mtouch, 0, sizeof(struct mtouch_usb)); | ||
218 | mtouch->udev = udev; | ||
219 | |||
220 | dbg("%s - allocating buffers", __FUNCTION__); | 219 | dbg("%s - allocating buffers", __FUNCTION__); |
221 | if (mtouchusb_alloc_buffers(udev, mtouch)) { | 220 | if (mtouchusb_alloc_buffers(udev, mtouch)) |
222 | mtouchusb_free_buffers(udev, mtouch); | 221 | goto fail2; |
223 | kfree(mtouch); | ||
224 | return -ENOMEM; | ||
225 | } | ||
226 | 222 | ||
227 | mtouch->input.private = mtouch; | 223 | mtouch->udev = udev; |
228 | mtouch->input.open = mtouchusb_open; | 224 | mtouch->input = input_dev; |
229 | mtouch->input.close = mtouchusb_close; | ||
230 | |||
231 | usb_make_path(udev, path, 64); | ||
232 | sprintf(mtouch->phys, "%s/input0", path); | ||
233 | |||
234 | mtouch->input.name = mtouch->name; | ||
235 | mtouch->input.phys = mtouch->phys; | ||
236 | usb_to_input_id(udev, &mtouch->input.id); | ||
237 | mtouch->input.dev = &intf->dev; | ||
238 | |||
239 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
240 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
241 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
242 | |||
243 | /* Used to Scale Compensated Data and Flip Y */ | ||
244 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; | ||
245 | mtouch->input.absmax[ABS_X] = raw_coordinates ? | ||
246 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; | ||
247 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; | ||
248 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; | ||
249 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; | ||
250 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? | ||
251 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; | ||
252 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; | ||
253 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; | ||
254 | 225 | ||
255 | if (udev->manufacturer) | 226 | if (udev->manufacturer) |
256 | strcat(mtouch->name, udev->manufacturer); | 227 | strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name)); |
257 | if (udev->product) | 228 | |
258 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); | 229 | if (udev->product) { |
230 | if (udev->manufacturer) | ||
231 | strlcat(mtouch->name, " ", sizeof(mtouch->name)); | ||
232 | strlcat(mtouch->name, udev->product, sizeof(mtouch->name)); | ||
233 | } | ||
259 | 234 | ||
260 | if (!strlen(mtouch->name)) | 235 | if (!strlen(mtouch->name)) |
261 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", | 236 | snprintf(mtouch->name, sizeof(mtouch->name), |
262 | mtouch->input.id.vendor, mtouch->input.id.product); | 237 | "USB Touchscreen %04x:%04x", |
238 | le16_to_cpu(udev->descriptor.idVendor), | ||
239 | le16_to_cpu(udev->descriptor.idProduct)); | ||
240 | |||
241 | usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys)); | ||
242 | strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys)); | ||
243 | |||
244 | input_dev->name = mtouch->name; | ||
245 | input_dev->phys = mtouch->phys; | ||
246 | usb_to_input_id(udev, &input_dev->id); | ||
247 | input_dev->cdev.dev = &intf->dev; | ||
248 | input_dev->private = mtouch; | ||
249 | |||
250 | input_dev->open = mtouchusb_open; | ||
251 | input_dev->close = mtouchusb_close; | ||
252 | |||
253 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
254 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
255 | input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC, | ||
256 | raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC, | ||
257 | MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT); | ||
258 | input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC, | ||
259 | raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC, | ||
260 | MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT); | ||
263 | 261 | ||
264 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 262 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
265 | MTOUCHUSB_RESET, | 263 | MTOUCHUSB_RESET, |
@@ -272,9 +270,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
272 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 270 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
273 | if (!mtouch->irq) { | 271 | if (!mtouch->irq) { |
274 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); | 272 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); |
275 | mtouchusb_free_buffers(udev, mtouch); | 273 | goto fail2; |
276 | kfree(mtouch); | ||
277 | return -ENOMEM; | ||
278 | } | 274 | } |
279 | 275 | ||
280 | dbg("%s - usb_fill_int_urb", __FUNCTION__); | 276 | dbg("%s - usb_fill_int_urb", __FUNCTION__); |
@@ -284,7 +280,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
284 | mtouchusb_irq, mtouch, endpoint->bInterval); | 280 | mtouchusb_irq, mtouch, endpoint->bInterval); |
285 | 281 | ||
286 | dbg("%s - input_register_device", __FUNCTION__); | 282 | dbg("%s - input_register_device", __FUNCTION__); |
287 | input_register_device(&mtouch->input); | 283 | input_register_device(mtouch->input); |
288 | 284 | ||
289 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 285 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
290 | MTOUCHUSB_ASYNC_REPORT, | 286 | MTOUCHUSB_ASYNC_REPORT, |
@@ -293,10 +289,13 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
293 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", | 289 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
294 | __FUNCTION__, nRet); | 290 | __FUNCTION__, nRet); |
295 | 291 | ||
296 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); | ||
297 | usb_set_intfdata(intf, mtouch); | 292 | usb_set_intfdata(intf, mtouch); |
298 | |||
299 | return 0; | 293 | return 0; |
294 | |||
295 | fail2: mtouchusb_free_buffers(udev, mtouch); | ||
296 | fail1: input_free_device(input_dev); | ||
297 | kfree(mtouch); | ||
298 | return -ENOMEM; | ||
300 | } | 299 | } |
301 | 300 | ||
302 | static void mtouchusb_disconnect(struct usb_interface *intf) | 301 | static void mtouchusb_disconnect(struct usb_interface *intf) |
@@ -308,7 +307,7 @@ static void mtouchusb_disconnect(struct usb_interface *intf) | |||
308 | if (mtouch) { | 307 | if (mtouch) { |
309 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); | 308 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); |
310 | usb_kill_urb(mtouch->irq); | 309 | usb_kill_urb(mtouch->irq); |
311 | input_unregister_device(&mtouch->input); | 310 | input_unregister_device(mtouch->input); |
312 | usb_free_urb(mtouch->irq); | 311 | usb_free_urb(mtouch->irq); |
313 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); | 312 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); |
314 | kfree(mtouch); | 313 | kfree(mtouch); |
diff --git a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c index acc71ec560e9..a00672c96644 100644 --- a/drivers/usb/input/pid.c +++ b/drivers/usb/input/pid.c | |||
@@ -262,6 +262,7 @@ int hid_pid_init(struct hid_device *hid) | |||
262 | { | 262 | { |
263 | struct hid_ff_pid *private; | 263 | struct hid_ff_pid *private; |
264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); | 264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); |
265 | struct input_dev *input_dev = hidinput->input; | ||
265 | 266 | ||
266 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); | 267 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); |
267 | if (!private) | 268 | if (!private) |
@@ -281,11 +282,12 @@ int hid_pid_init(struct hid_device *hid) | |||
281 | usb_fill_control_urb(private->urbffout, hid->dev, 0, | 282 | usb_fill_control_urb(private->urbffout, hid->dev, 0, |
282 | (void *)&private->ffcr, private->ctrl_buffer, 8, | 283 | (void *)&private->ffcr, private->ctrl_buffer, 8, |
283 | hid_pid_ctrl_out, hid); | 284 | hid_pid_ctrl_out, hid); |
284 | hidinput->input.upload_effect = hid_pid_upload_effect; | 285 | |
285 | hidinput->input.flush = hid_pid_flush; | 286 | input_dev->upload_effect = hid_pid_upload_effect; |
286 | hidinput->input.ff_effects_max = 8; // A random default | 287 | input_dev->flush = hid_pid_flush; |
287 | set_bit(EV_FF, hidinput->input.evbit); | 288 | input_dev->ff_effects_max = 8; // A random default |
288 | set_bit(EV_FF_STATUS, hidinput->input.evbit); | 289 | set_bit(EV_FF, input_dev->evbit); |
290 | set_bit(EV_FF_STATUS, input_dev->evbit); | ||
289 | 291 | ||
290 | spin_lock_init(&private->lock); | 292 | spin_lock_init(&private->lock); |
291 | 293 | ||
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index ad4afe7e5897..b7476233ef5d 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c | |||
@@ -68,7 +68,7 @@ struct powermate_device { | |||
68 | struct usb_ctrlrequest *configcr; | 68 | struct usb_ctrlrequest *configcr; |
69 | dma_addr_t configcr_dma; | 69 | dma_addr_t configcr_dma; |
70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
71 | struct input_dev input; | 71 | struct input_dev *input; |
72 | spinlock_t lock; | 72 | spinlock_t lock; |
73 | int static_brightness; | 73 | int static_brightness; |
74 | int pulse_speed; | 74 | int pulse_speed; |
@@ -106,10 +106,10 @@ static void powermate_irq(struct urb *urb, struct pt_regs *regs) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | /* handle updates to device state */ | 108 | /* handle updates to device state */ |
109 | input_regs(&pm->input, regs); | 109 | input_regs(pm->input, regs); |
110 | input_report_key(&pm->input, BTN_0, pm->data[0] & 0x01); | 110 | input_report_key(pm->input, BTN_0, pm->data[0] & 0x01); |
111 | input_report_rel(&pm->input, REL_DIAL, pm->data[1]); | 111 | input_report_rel(pm->input, REL_DIAL, pm->data[1]); |
112 | input_sync(&pm->input); | 112 | input_sync(pm->input); |
113 | 113 | ||
114 | exit: | 114 | exit: |
115 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 115 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
@@ -153,10 +153,10 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
153 | 153 | ||
154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. | 154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. |
155 | */ | 155 | */ |
156 | if (pm->pulse_speed < 255){ | 156 | if (pm->pulse_speed < 255) { |
157 | op = 0; // divide | 157 | op = 0; // divide |
158 | arg = 255 - pm->pulse_speed; | 158 | arg = 255 - pm->pulse_speed; |
159 | } else if (pm->pulse_speed > 255){ | 159 | } else if (pm->pulse_speed > 255) { |
160 | op = 2; // multiply | 160 | op = 2; // multiply |
161 | arg = pm->pulse_speed - 255; | 161 | arg = pm->pulse_speed - 255; |
162 | } else { | 162 | } else { |
@@ -166,11 +166,11 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); | 166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); |
167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); | 167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); |
168 | pm->requires_update &= ~UPDATE_PULSE_MODE; | 168 | pm->requires_update &= ~UPDATE_PULSE_MODE; |
169 | }else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS){ | 169 | } else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS) { |
170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); | 170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); |
171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); | 171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); |
172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; | 172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; |
173 | }else{ | 173 | } else { |
174 | printk(KERN_ERR "powermate: unknown update required"); | 174 | printk(KERN_ERR "powermate: unknown update required"); |
175 | pm->requires_update = 0; /* fudge the bug */ | 175 | pm->requires_update = 0; /* fudge the bug */ |
176 | return; | 176 | return; |
@@ -228,19 +228,19 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
228 | spin_lock_irqsave(&pm->lock, flags); | 228 | spin_lock_irqsave(&pm->lock, flags); |
229 | 229 | ||
230 | /* mark state updates which are required */ | 230 | /* mark state updates which are required */ |
231 | if (static_brightness != pm->static_brightness){ | 231 | if (static_brightness != pm->static_brightness) { |
232 | pm->static_brightness = static_brightness; | 232 | pm->static_brightness = static_brightness; |
233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; | 233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; |
234 | } | 234 | } |
235 | if (pulse_asleep != pm->pulse_asleep){ | 235 | if (pulse_asleep != pm->pulse_asleep) { |
236 | pm->pulse_asleep = pulse_asleep; | 236 | pm->pulse_asleep = pulse_asleep; |
237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); | 237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); |
238 | } | 238 | } |
239 | if (pulse_awake != pm->pulse_awake){ | 239 | if (pulse_awake != pm->pulse_awake) { |
240 | pm->pulse_awake = pulse_awake; | 240 | pm->pulse_awake = pulse_awake; |
241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); | 241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); |
242 | } | 242 | } |
243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table){ | 243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table) { |
244 | pm->pulse_speed = pulse_speed; | 244 | pm->pulse_speed = pulse_speed; |
245 | pm->pulse_table = pulse_table; | 245 | pm->pulse_table = pulse_table; |
246 | pm->requires_update |= UPDATE_PULSE_MODE; | 246 | pm->requires_update |= UPDATE_PULSE_MODE; |
@@ -283,6 +283,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev | |||
283 | SLAB_ATOMIC, &pm->data_dma); | 283 | SLAB_ATOMIC, &pm->data_dma); |
284 | if (!pm->data) | 284 | if (!pm->data) |
285 | return -1; | 285 | return -1; |
286 | |||
286 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), | 287 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), |
287 | SLAB_ATOMIC, &pm->configcr_dma); | 288 | SLAB_ATOMIC, &pm->configcr_dma); |
288 | if (!pm->configcr) | 289 | if (!pm->configcr) |
@@ -308,8 +309,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
308 | struct usb_host_interface *interface; | 309 | struct usb_host_interface *interface; |
309 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
310 | struct powermate_device *pm; | 311 | struct powermate_device *pm; |
312 | struct input_dev *input_dev; | ||
311 | int pipe, maxp; | 313 | int pipe, maxp; |
312 | char path[64]; | 314 | int err = -ENOMEM; |
313 | 315 | ||
314 | interface = intf->cur_altsetting; | 316 | interface = intf->cur_altsetting; |
315 | endpoint = &interface->endpoint[0].desc; | 317 | endpoint = &interface->endpoint[0].desc; |
@@ -323,42 +325,61 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
323 | 0, interface->desc.bInterfaceNumber, NULL, 0, | 325 | 0, interface->desc.bInterfaceNumber, NULL, 0, |
324 | USB_CTRL_SET_TIMEOUT); | 326 | USB_CTRL_SET_TIMEOUT); |
325 | 327 | ||
326 | if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) | 328 | pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL); |
327 | return -ENOMEM; | 329 | input_dev = input_allocate_device(); |
328 | 330 | if (!pm || !input_dev) | |
329 | memset(pm, 0, sizeof(struct powermate_device)); | 331 | goto fail1; |
330 | pm->udev = udev; | ||
331 | 332 | ||
332 | if (powermate_alloc_buffers(udev, pm)) { | 333 | if (powermate_alloc_buffers(udev, pm)) |
333 | powermate_free_buffers(udev, pm); | 334 | goto fail2; |
334 | kfree(pm); | ||
335 | return -ENOMEM; | ||
336 | } | ||
337 | 335 | ||
338 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); | 336 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); |
339 | if (!pm->irq) { | 337 | if (!pm->irq) |
340 | powermate_free_buffers(udev, pm); | 338 | goto fail2; |
341 | kfree(pm); | ||
342 | return -ENOMEM; | ||
343 | } | ||
344 | 339 | ||
345 | pm->config = usb_alloc_urb(0, GFP_KERNEL); | 340 | pm->config = usb_alloc_urb(0, GFP_KERNEL); |
346 | if (!pm->config) { | 341 | if (!pm->config) |
347 | usb_free_urb(pm->irq); | 342 | goto fail3; |
348 | powermate_free_buffers(udev, pm); | 343 | |
349 | kfree(pm); | 344 | pm->udev = udev; |
350 | return -ENOMEM; | 345 | pm->input = input_dev; |
351 | } | 346 | |
347 | usb_make_path(udev, pm->phys, sizeof(pm->phys)); | ||
348 | strlcpy(pm->phys, "/input0", sizeof(pm->phys)); | ||
352 | 349 | ||
353 | spin_lock_init(&pm->lock); | 350 | spin_lock_init(&pm->lock); |
354 | init_input_dev(&pm->input); | 351 | |
352 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | ||
353 | case POWERMATE_PRODUCT_NEW: | ||
354 | input_dev->name = pm_name_powermate; | ||
355 | break; | ||
356 | case POWERMATE_PRODUCT_OLD: | ||
357 | input_dev->name = pm_name_soundknob; | ||
358 | break; | ||
359 | default: | ||
360 | input_dev->name = pm_name_soundknob; | ||
361 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
362 | le16_to_cpu(udev->descriptor.idProduct)); | ||
363 | } | ||
364 | |||
365 | input_dev->phys = pm->phys; | ||
366 | usb_to_input_id(udev, &input_dev->id); | ||
367 | input_dev->cdev.dev = &intf->dev; | ||
368 | input_dev->private = pm; | ||
369 | |||
370 | input_dev->event = powermate_input_event; | ||
371 | |||
372 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
373 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
374 | input_dev->relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
375 | input_dev->mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
355 | 376 | ||
356 | /* get a handle to the interrupt data pipe */ | 377 | /* get a handle to the interrupt data pipe */ |
357 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 378 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
358 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 379 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
359 | 380 | ||
360 | if(maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX){ | 381 | if (maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX) { |
361 | printk("powermate: Expected payload of %d--%d bytes, found %d bytes!\n", | 382 | printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n", |
362 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); | 383 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); |
363 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; | 384 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; |
364 | } | 385 | } |
@@ -371,35 +392,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
371 | 392 | ||
372 | /* register our interrupt URB with the USB system */ | 393 | /* register our interrupt URB with the USB system */ |
373 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { | 394 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { |
374 | powermate_free_buffers(udev, pm); | 395 | err = -EIO; |
375 | kfree(pm); | 396 | goto fail4; |
376 | return -EIO; /* failure */ | ||
377 | } | 397 | } |
378 | 398 | ||
379 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | 399 | input_register_device(pm->input); |
380 | case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; | ||
381 | case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; | ||
382 | default: | ||
383 | pm->input.name = pm_name_soundknob; | ||
384 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
385 | le16_to_cpu(udev->descriptor.idProduct)); | ||
386 | } | ||
387 | |||
388 | pm->input.private = pm; | ||
389 | pm->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
390 | pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
391 | pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
392 | pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
393 | usb_to_input_id(udev, &pm->input.id); | ||
394 | pm->input.event = powermate_input_event; | ||
395 | pm->input.dev = &intf->dev; | ||
396 | pm->input.phys = pm->phys; | ||
397 | |||
398 | input_register_device(&pm->input); | ||
399 | |||
400 | usb_make_path(udev, path, 64); | ||
401 | snprintf(pm->phys, 64, "%s/input0", path); | ||
402 | printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); | ||
403 | 400 | ||
404 | /* force an update of everything */ | 401 | /* force an update of everything */ |
405 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; | 402 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; |
@@ -407,6 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
407 | 404 | ||
408 | usb_set_intfdata(intf, pm); | 405 | usb_set_intfdata(intf, pm); |
409 | return 0; | 406 | return 0; |
407 | |||
408 | fail4: usb_free_urb(pm->config); | ||
409 | fail3: usb_free_urb(pm->irq); | ||
410 | fail2: powermate_free_buffers(udev, pm); | ||
411 | fail1: input_free_device(input_dev); | ||
412 | kfree(pm); | ||
413 | return err; | ||
410 | } | 414 | } |
411 | 415 | ||
412 | /* Called when a USB device we've accepted ownership of is removed */ | 416 | /* Called when a USB device we've accepted ownership of is removed */ |
@@ -418,7 +422,7 @@ static void powermate_disconnect(struct usb_interface *intf) | |||
418 | if (pm) { | 422 | if (pm) { |
419 | pm->requires_update = 0; | 423 | pm->requires_update = 0; |
420 | usb_kill_urb(pm->irq); | 424 | usb_kill_urb(pm->irq); |
421 | input_unregister_device(&pm->input); | 425 | input_unregister_device(pm->input); |
422 | usb_free_urb(pm->irq); | 426 | usb_free_urb(pm->irq); |
423 | usb_free_urb(pm->config); | 427 | usb_free_urb(pm->config); |
424 | powermate_free_buffers(interface_to_usbdev(intf), pm); | 428 | powermate_free_buffers(interface_to_usbdev(intf), pm); |
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 4276c24a5080..3766ccc271be 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c | |||
@@ -68,7 +68,7 @@ struct touchkit_usb { | |||
68 | dma_addr_t data_dma; | 68 | dma_addr_t data_dma; |
69 | struct urb *irq; | 69 | struct urb *irq; |
70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
71 | struct input_dev input; | 71 | struct input_dev *input; |
72 | char name[128]; | 72 | char name[128]; |
73 | char phys[64]; | 73 | char phys[64]; |
74 | }; | 74 | }; |
@@ -115,12 +115,12 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs) | |||
115 | y = TOUCHKIT_GET_Y(touchkit->data); | 115 | y = TOUCHKIT_GET_Y(touchkit->data); |
116 | } | 116 | } |
117 | 117 | ||
118 | input_regs(&touchkit->input, regs); | 118 | input_regs(touchkit->input, regs); |
119 | input_report_key(&touchkit->input, BTN_TOUCH, | 119 | input_report_key(touchkit->input, BTN_TOUCH, |
120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); | 120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); |
121 | input_report_abs(&touchkit->input, ABS_X, x); | 121 | input_report_abs(touchkit->input, ABS_X, x); |
122 | input_report_abs(&touchkit->input, ABS_Y, y); | 122 | input_report_abs(touchkit->input, ABS_Y, y); |
123 | input_sync(&touchkit->input); | 123 | input_sync(touchkit->input); |
124 | 124 | ||
125 | exit: | 125 | exit: |
126 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 126 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -171,87 +171,81 @@ static void touchkit_free_buffers(struct usb_device *udev, | |||
171 | static int touchkit_probe(struct usb_interface *intf, | 171 | static int touchkit_probe(struct usb_interface *intf, |
172 | const struct usb_device_id *id) | 172 | const struct usb_device_id *id) |
173 | { | 173 | { |
174 | int ret; | ||
175 | struct touchkit_usb *touchkit; | 174 | struct touchkit_usb *touchkit; |
175 | struct input_dev *input_dev; | ||
176 | struct usb_host_interface *interface; | 176 | struct usb_host_interface *interface; |
177 | struct usb_endpoint_descriptor *endpoint; | 177 | struct usb_endpoint_descriptor *endpoint; |
178 | struct usb_device *udev = interface_to_usbdev(intf); | 178 | struct usb_device *udev = interface_to_usbdev(intf); |
179 | char path[64]; | ||
180 | 179 | ||
181 | interface = intf->cur_altsetting; | 180 | interface = intf->cur_altsetting; |
182 | endpoint = &interface->endpoint[0].desc; | 181 | endpoint = &interface->endpoint[0].desc; |
183 | 182 | ||
184 | touchkit = kmalloc(sizeof(struct touchkit_usb), GFP_KERNEL); | 183 | touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL); |
185 | if (!touchkit) | 184 | input_dev = input_allocate_device(); |
186 | return -ENOMEM; | 185 | if (!touchkit || !input_dev) |
187 | |||
188 | memset(touchkit, 0, sizeof(struct touchkit_usb)); | ||
189 | touchkit->udev = udev; | ||
190 | |||
191 | if (touchkit_alloc_buffers(udev, touchkit)) { | ||
192 | ret = -ENOMEM; | ||
193 | goto out_free; | 186 | goto out_free; |
194 | } | ||
195 | |||
196 | touchkit->input.private = touchkit; | ||
197 | touchkit->input.open = touchkit_open; | ||
198 | touchkit->input.close = touchkit_close; | ||
199 | |||
200 | usb_make_path(udev, path, 64); | ||
201 | sprintf(touchkit->phys, "%s/input0", path); | ||
202 | |||
203 | touchkit->input.name = touchkit->name; | ||
204 | touchkit->input.phys = touchkit->phys; | ||
205 | usb_to_input_id(udev, &touchkit->input.id); | ||
206 | touchkit->input.dev = &intf->dev; | ||
207 | |||
208 | touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
209 | touchkit->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
210 | touchkit->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
211 | |||
212 | /* Used to Scale Compensated Data */ | ||
213 | touchkit->input.absmin[ABS_X] = TOUCHKIT_MIN_XC; | ||
214 | touchkit->input.absmax[ABS_X] = TOUCHKIT_MAX_XC; | ||
215 | touchkit->input.absfuzz[ABS_X] = TOUCHKIT_XC_FUZZ; | ||
216 | touchkit->input.absflat[ABS_X] = TOUCHKIT_XC_FLAT; | ||
217 | touchkit->input.absmin[ABS_Y] = TOUCHKIT_MIN_YC; | ||
218 | touchkit->input.absmax[ABS_Y] = TOUCHKIT_MAX_YC; | ||
219 | touchkit->input.absfuzz[ABS_Y] = TOUCHKIT_YC_FUZZ; | ||
220 | touchkit->input.absflat[ABS_Y] = TOUCHKIT_YC_FLAT; | ||
221 | |||
222 | if (udev->manufacturer) | ||
223 | strcat(touchkit->name, udev->manufacturer); | ||
224 | if (udev->product) | ||
225 | sprintf(touchkit->name, "%s %s", touchkit->name, udev->product); | ||
226 | 187 | ||
227 | if (!strlen(touchkit->name)) | 188 | if (touchkit_alloc_buffers(udev, touchkit)) |
228 | sprintf(touchkit->name, "USB Touchscreen %04x:%04x", | 189 | goto out_free; |
229 | touchkit->input.id.vendor, touchkit->input.id.product); | ||
230 | 190 | ||
231 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); | 191 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); |
232 | if (!touchkit->irq) { | 192 | if (!touchkit->irq) { |
233 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); | 193 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); |
234 | ret = -ENOMEM; | ||
235 | goto out_free_buffers; | 194 | goto out_free_buffers; |
236 | } | 195 | } |
237 | 196 | ||
197 | touchkit->udev = udev; | ||
198 | touchkit->input = input_dev; | ||
199 | |||
200 | if (udev->manufacturer) | ||
201 | strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name)); | ||
202 | |||
203 | if (udev->product) { | ||
204 | if (udev->manufacturer) | ||
205 | strlcat(touchkit->name, " ", sizeof(touchkit->name)); | ||
206 | strlcat(touchkit->name, udev->product, sizeof(touchkit->name)); | ||
207 | } | ||
208 | |||
209 | if (!strlen(touchkit->name)) | ||
210 | snprintf(touchkit->name, sizeof(touchkit->name), | ||
211 | "USB Touchscreen %04x:%04x", | ||
212 | le16_to_cpu(udev->descriptor.idVendor), | ||
213 | le16_to_cpu(udev->descriptor.idProduct)); | ||
214 | |||
215 | usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys)); | ||
216 | strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys)); | ||
217 | |||
218 | input_dev->name = touchkit->name; | ||
219 | input_dev->phys = touchkit->phys; | ||
220 | usb_to_input_id(udev, &input_dev->id); | ||
221 | input_dev->cdev.dev = &intf->dev; | ||
222 | input_dev->private = touchkit; | ||
223 | input_dev->open = touchkit_open; | ||
224 | input_dev->close = touchkit_close; | ||
225 | |||
226 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
227 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
228 | input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC, | ||
229 | TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT); | ||
230 | input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC, | ||
231 | TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT); | ||
232 | |||
238 | usb_fill_int_urb(touchkit->irq, touchkit->udev, | 233 | usb_fill_int_urb(touchkit->irq, touchkit->udev, |
239 | usb_rcvintpipe(touchkit->udev, 0x81), | 234 | usb_rcvintpipe(touchkit->udev, 0x81), |
240 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, | 235 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, |
241 | touchkit_irq, touchkit, endpoint->bInterval); | 236 | touchkit_irq, touchkit, endpoint->bInterval); |
242 | 237 | ||
243 | input_register_device(&touchkit->input); | 238 | input_register_device(touchkit->input); |
244 | 239 | ||
245 | printk(KERN_INFO "input: %s on %s\n", touchkit->name, path); | ||
246 | usb_set_intfdata(intf, touchkit); | 240 | usb_set_intfdata(intf, touchkit); |
247 | |||
248 | return 0; | 241 | return 0; |
249 | 242 | ||
250 | out_free_buffers: | 243 | out_free_buffers: |
251 | touchkit_free_buffers(udev, touchkit); | 244 | touchkit_free_buffers(udev, touchkit); |
252 | out_free: | 245 | out_free: |
246 | input_free_device(input_dev); | ||
253 | kfree(touchkit); | 247 | kfree(touchkit); |
254 | return ret; | 248 | return -ENOMEM; |
255 | } | 249 | } |
256 | 250 | ||
257 | static void touchkit_disconnect(struct usb_interface *intf) | 251 | static void touchkit_disconnect(struct usb_interface *intf) |
@@ -265,8 +259,8 @@ static void touchkit_disconnect(struct usb_interface *intf) | |||
265 | 259 | ||
266 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); | 260 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); |
267 | usb_set_intfdata(intf, NULL); | 261 | usb_set_intfdata(intf, NULL); |
268 | input_unregister_device(&touchkit->input); | ||
269 | usb_kill_urb(touchkit->irq); | 262 | usb_kill_urb(touchkit->irq); |
263 | input_unregister_device(touchkit->input); | ||
270 | usb_free_urb(touchkit->irq); | 264 | usb_free_urb(touchkit->irq); |
271 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); | 265 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); |
272 | kfree(touchkit); | 266 | kfree(touchkit); |
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 28987f15eeee..226b6f90a907 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c | |||
@@ -66,7 +66,7 @@ static unsigned char usb_kbd_keycode[256] = { | |||
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct usb_kbd { | 68 | struct usb_kbd { |
69 | struct input_dev dev; | 69 | struct input_dev *dev; |
70 | struct usb_device *usbdev; | 70 | struct usb_device *usbdev; |
71 | unsigned char old[8]; | 71 | unsigned char old[8]; |
72 | struct urb *irq, *led; | 72 | struct urb *irq, *led; |
@@ -99,29 +99,29 @@ static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs) | |||
99 | goto resubmit; | 99 | goto resubmit; |
100 | } | 100 | } |
101 | 101 | ||
102 | input_regs(&kbd->dev, regs); | 102 | input_regs(kbd->dev, regs); |
103 | 103 | ||
104 | for (i = 0; i < 8; i++) | 104 | for (i = 0; i < 8; i++) |
105 | input_report_key(&kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); | 105 | input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
106 | 106 | ||
107 | for (i = 2; i < 8; i++) { | 107 | for (i = 2; i < 8; i++) { |
108 | 108 | ||
109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { | 109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { |
110 | if (usb_kbd_keycode[kbd->old[i]]) | 110 | if (usb_kbd_keycode[kbd->old[i]]) |
111 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); | 111 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); |
112 | else | 112 | else |
113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); | 113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); |
114 | } | 114 | } |
115 | 115 | ||
116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { | 116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { |
117 | if (usb_kbd_keycode[kbd->new[i]]) | 117 | if (usb_kbd_keycode[kbd->new[i]]) |
118 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); | 118 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); |
119 | else | 119 | else |
120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); | 120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | input_sync(&kbd->dev); | 124 | input_sync(kbd->dev); |
125 | 125 | ||
126 | memcpy(kbd->old, kbd->new, 8); | 126 | memcpy(kbd->old, kbd->new, 8); |
127 | 127 | ||
@@ -227,12 +227,12 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
227 | static int usb_kbd_probe(struct usb_interface *iface, | 227 | static int usb_kbd_probe(struct usb_interface *iface, |
228 | const struct usb_device_id *id) | 228 | const struct usb_device_id *id) |
229 | { | 229 | { |
230 | struct usb_device * dev = interface_to_usbdev(iface); | 230 | struct usb_device *dev = interface_to_usbdev(iface); |
231 | struct usb_host_interface *interface; | 231 | struct usb_host_interface *interface; |
232 | struct usb_endpoint_descriptor *endpoint; | 232 | struct usb_endpoint_descriptor *endpoint; |
233 | struct usb_kbd *kbd; | 233 | struct usb_kbd *kbd; |
234 | struct input_dev *input_dev; | ||
234 | int i, pipe, maxp; | 235 | int i, pipe, maxp; |
235 | char path[64]; | ||
236 | 236 | ||
237 | interface = iface->cur_altsetting; | 237 | interface = iface->cur_altsetting; |
238 | 238 | ||
@@ -240,37 +240,59 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
240 | return -ENODEV; | 240 | return -ENODEV; |
241 | 241 | ||
242 | endpoint = &interface->endpoint[0].desc; | 242 | endpoint = &interface->endpoint[0].desc; |
243 | if (!(endpoint->bEndpointAddress & 0x80)) | 243 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
244 | return -ENODEV; | 244 | return -ENODEV; |
245 | if ((endpoint->bmAttributes & 3) != 3) | 245 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
246 | return -ENODEV; | 246 | return -ENODEV; |
247 | 247 | ||
248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
250 | 250 | ||
251 | if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) | 251 | kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); |
252 | return -ENOMEM; | 252 | input_dev = input_allocate_device(); |
253 | memset(kbd, 0, sizeof(struct usb_kbd)); | 253 | if (!kbd || !input_dev) |
254 | goto fail1; | ||
254 | 255 | ||
255 | if (usb_kbd_alloc_mem(dev, kbd)) { | 256 | if (usb_kbd_alloc_mem(dev, kbd)) |
256 | usb_kbd_free_mem(dev, kbd); | 257 | goto fail2; |
257 | kfree(kbd); | ||
258 | return -ENOMEM; | ||
259 | } | ||
260 | 258 | ||
261 | kbd->usbdev = dev; | 259 | kbd->usbdev = dev; |
260 | kbd->dev = input_dev; | ||
261 | |||
262 | if (dev->manufacturer) | ||
263 | strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); | ||
264 | |||
265 | if (dev->product) { | ||
266 | if (dev->manufacturer) | ||
267 | strlcat(kbd->name, " ", sizeof(kbd->name)); | ||
268 | strlcat(kbd->name, dev->product, sizeof(kbd->name)); | ||
269 | } | ||
270 | |||
271 | if (!strlen(kbd->name)) | ||
272 | snprintf(kbd->name, sizeof(kbd->name), | ||
273 | "USB HIDBP Keyboard %04x:%04x", | ||
274 | le16_to_cpu(dev->descriptor.idVendor), | ||
275 | le16_to_cpu(dev->descriptor.idProduct)); | ||
276 | |||
277 | usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); | ||
278 | strlcpy(kbd->phys, "/input0", sizeof(kbd->phys)); | ||
262 | 279 | ||
263 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 280 | input_dev->name = kbd->name; |
264 | kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 281 | input_dev->phys = kbd->phys; |
282 | usb_to_input_id(dev, &input_dev->id); | ||
283 | input_dev->cdev.dev = &iface->dev; | ||
284 | input_dev->private = kbd; | ||
285 | |||
286 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | ||
287 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | ||
265 | 288 | ||
266 | for (i = 0; i < 255; i++) | 289 | for (i = 0; i < 255; i++) |
267 | set_bit(usb_kbd_keycode[i], kbd->dev.keybit); | 290 | set_bit(usb_kbd_keycode[i], input_dev->keybit); |
268 | clear_bit(0, kbd->dev.keybit); | 291 | clear_bit(0, input_dev->keybit); |
269 | 292 | ||
270 | kbd->dev.private = kbd; | 293 | input_dev->event = usb_kbd_event; |
271 | kbd->dev.event = usb_kbd_event; | 294 | input_dev->open = usb_kbd_open; |
272 | kbd->dev.open = usb_kbd_open; | 295 | input_dev->close = usb_kbd_close; |
273 | kbd->dev.close = usb_kbd_close; | ||
274 | 296 | ||
275 | usb_fill_int_urb(kbd->irq, dev, pipe, | 297 | usb_fill_int_urb(kbd->irq, dev, pipe, |
276 | kbd->new, (maxp > 8 ? 8 : maxp), | 298 | kbd->new, (maxp > 8 ? 8 : maxp), |
@@ -284,37 +306,22 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
284 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); | 306 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); |
285 | kbd->cr->wLength = cpu_to_le16(1); | 307 | kbd->cr->wLength = cpu_to_le16(1); |
286 | 308 | ||
287 | usb_make_path(dev, path, 64); | ||
288 | sprintf(kbd->phys, "%s/input0", path); | ||
289 | |||
290 | kbd->dev.name = kbd->name; | ||
291 | kbd->dev.phys = kbd->phys; | ||
292 | usb_to_input_id(dev, &kbd->dev.id); | ||
293 | kbd->dev.dev = &iface->dev; | ||
294 | |||
295 | if (dev->manufacturer) | ||
296 | strcat(kbd->name, dev->manufacturer); | ||
297 | if (dev->product) | ||
298 | sprintf(kbd->name, "%s %s", kbd->name, dev->product); | ||
299 | |||
300 | if (!strlen(kbd->name)) | ||
301 | sprintf(kbd->name, "USB HIDBP Keyboard %04x:%04x", | ||
302 | kbd->dev.id.vendor, kbd->dev.id.product); | ||
303 | |||
304 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), | 309 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), |
305 | (void *) kbd->cr, kbd->leds, 1, | 310 | (void *) kbd->cr, kbd->leds, 1, |
306 | usb_kbd_led, kbd); | 311 | usb_kbd_led, kbd); |
307 | kbd->led->setup_dma = kbd->cr_dma; | 312 | kbd->led->setup_dma = kbd->cr_dma; |
308 | kbd->led->transfer_dma = kbd->leds_dma; | 313 | kbd->led->transfer_dma = kbd->leds_dma; |
309 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 314 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
310 | | URB_NO_SETUP_DMA_MAP); | ||
311 | 315 | ||
312 | input_register_device(&kbd->dev); | 316 | input_register_device(kbd->dev); |
313 | |||
314 | printk(KERN_INFO "input: %s on %s\n", kbd->name, path); | ||
315 | 317 | ||
316 | usb_set_intfdata(iface, kbd); | 318 | usb_set_intfdata(iface, kbd); |
317 | return 0; | 319 | return 0; |
320 | |||
321 | fail2: usb_kbd_free_mem(dev, kbd); | ||
322 | fail1: input_free_device(input_dev); | ||
323 | kfree(kbd); | ||
324 | return -ENOMEM; | ||
318 | } | 325 | } |
319 | 326 | ||
320 | static void usb_kbd_disconnect(struct usb_interface *intf) | 327 | static void usb_kbd_disconnect(struct usb_interface *intf) |
@@ -324,7 +331,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf) | |||
324 | usb_set_intfdata(intf, NULL); | 331 | usb_set_intfdata(intf, NULL); |
325 | if (kbd) { | 332 | if (kbd) { |
326 | usb_kill_urb(kbd->irq); | 333 | usb_kill_urb(kbd->irq); |
327 | input_unregister_device(&kbd->dev); | 334 | input_unregister_device(kbd->dev); |
328 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); | 335 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); |
329 | kfree(kbd); | 336 | kfree(kbd); |
330 | } | 337 | } |
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 4104dec847fb..230f6b1b314a 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c | |||
@@ -50,7 +50,7 @@ struct usb_mouse { | |||
50 | char name[128]; | 50 | char name[128]; |
51 | char phys[64]; | 51 | char phys[64]; |
52 | struct usb_device *usbdev; | 52 | struct usb_device *usbdev; |
53 | struct input_dev dev; | 53 | struct input_dev *dev; |
54 | struct urb *irq; | 54 | struct urb *irq; |
55 | 55 | ||
56 | signed char *data; | 56 | signed char *data; |
@@ -61,7 +61,7 @@ static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs) | |||
61 | { | 61 | { |
62 | struct usb_mouse *mouse = urb->context; | 62 | struct usb_mouse *mouse = urb->context; |
63 | signed char *data = mouse->data; | 63 | signed char *data = mouse->data; |
64 | struct input_dev *dev = &mouse->dev; | 64 | struct input_dev *dev = mouse->dev; |
65 | int status; | 65 | int status; |
66 | 66 | ||
67 | switch (urb->status) { | 67 | switch (urb->status) { |
@@ -115,14 +115,14 @@ static void usb_mouse_close(struct input_dev *dev) | |||
115 | usb_kill_urb(mouse->irq); | 115 | usb_kill_urb(mouse->irq); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) | 118 | static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id) |
119 | { | 119 | { |
120 | struct usb_device * dev = interface_to_usbdev(intf); | 120 | struct usb_device *dev = interface_to_usbdev(intf); |
121 | struct usb_host_interface *interface; | 121 | struct usb_host_interface *interface; |
122 | struct usb_endpoint_descriptor *endpoint; | 122 | struct usb_endpoint_descriptor *endpoint; |
123 | struct usb_mouse *mouse; | 123 | struct usb_mouse *mouse; |
124 | struct input_dev *input_dev; | ||
124 | int pipe, maxp; | 125 | int pipe, maxp; |
125 | char path[64]; | ||
126 | 126 | ||
127 | interface = intf->cur_altsetting; | 127 | interface = intf->cur_altsetting; |
128 | 128 | ||
@@ -130,59 +130,62 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
130 | return -ENODEV; | 130 | return -ENODEV; |
131 | 131 | ||
132 | endpoint = &interface->endpoint[0].desc; | 132 | endpoint = &interface->endpoint[0].desc; |
133 | if (!(endpoint->bEndpointAddress & 0x80)) | 133 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
134 | return -ENODEV; | 134 | return -ENODEV; |
135 | if ((endpoint->bmAttributes & 3) != 3) | 135 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
136 | return -ENODEV; | 136 | return -ENODEV; |
137 | 137 | ||
138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
140 | 140 | ||
141 | if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) | 141 | mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); |
142 | return -ENOMEM; | 142 | input_dev = input_allocate_device(); |
143 | memset(mouse, 0, sizeof(struct usb_mouse)); | 143 | if (!mouse || !input_dev) |
144 | goto fail1; | ||
144 | 145 | ||
145 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); | 146 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); |
146 | if (!mouse->data) { | 147 | if (!mouse->data) |
147 | kfree(mouse); | 148 | goto fail1; |
148 | return -ENOMEM; | ||
149 | } | ||
150 | 149 | ||
151 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); | 150 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); |
152 | if (!mouse->irq) { | 151 | if (!mouse->irq) |
153 | usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | 152 | goto fail2; |
154 | kfree(mouse); | ||
155 | return -ENODEV; | ||
156 | } | ||
157 | 153 | ||
158 | mouse->usbdev = dev; | 154 | mouse->usbdev = dev; |
155 | mouse->dev = input_dev; | ||
156 | |||
157 | if (dev->manufacturer) | ||
158 | strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); | ||
159 | 159 | ||
160 | mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 160 | if (dev->product) { |
161 | mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 161 | if (dev->manufacturer) |
162 | mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 162 | strlcat(mouse->name, " ", sizeof(mouse->name)); |
163 | mouse->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 163 | strlcat(mouse->name, dev->product, sizeof(mouse->name)); |
164 | mouse->dev.relbit[0] |= BIT(REL_WHEEL); | 164 | } |
165 | 165 | ||
166 | mouse->dev.private = mouse; | 166 | if (!strlen(mouse->name)) |
167 | mouse->dev.open = usb_mouse_open; | 167 | snprintf(mouse->name, sizeof(mouse->name), |
168 | mouse->dev.close = usb_mouse_close; | 168 | "USB HIDBP Mouse %04x:%04x", |
169 | le16_to_cpu(dev->descriptor.idVendor), | ||
170 | le16_to_cpu(dev->descriptor.idProduct)); | ||
169 | 171 | ||
170 | usb_make_path(dev, path, 64); | 172 | usb_make_path(dev, mouse->phys, sizeof(mouse->phys)); |
171 | sprintf(mouse->phys, "%s/input0", path); | 173 | strlcat(mouse->phys, "/input0", sizeof(mouse->phys)); |
172 | 174 | ||
173 | mouse->dev.name = mouse->name; | 175 | input_dev->name = mouse->name; |
174 | mouse->dev.phys = mouse->phys; | 176 | input_dev->phys = mouse->phys; |
175 | usb_to_input_id(dev, &mouse->dev.id); | 177 | usb_to_input_id(dev, &input_dev->id); |
176 | mouse->dev.dev = &intf->dev; | 178 | input_dev->cdev.dev = &intf->dev; |
177 | 179 | ||
178 | if (dev->manufacturer) | 180 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
179 | strcat(mouse->name, dev->manufacturer); | 181 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
180 | if (dev->product) | 182 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
181 | sprintf(mouse->name, "%s %s", mouse->name, dev->product); | 183 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
184 | input_dev->relbit[0] |= BIT(REL_WHEEL); | ||
182 | 185 | ||
183 | if (!strlen(mouse->name)) | 186 | input_dev->private = mouse; |
184 | sprintf(mouse->name, "USB HIDBP Mouse %04x:%04x", | 187 | input_dev->open = usb_mouse_open; |
185 | mouse->dev.id.vendor, mouse->dev.id.product); | 188 | input_dev->close = usb_mouse_close; |
186 | 189 | ||
187 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, | 190 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, |
188 | (maxp > 8 ? 8 : maxp), | 191 | (maxp > 8 ? 8 : maxp), |
@@ -190,11 +193,15 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
190 | mouse->irq->transfer_dma = mouse->data_dma; | 193 | mouse->irq->transfer_dma = mouse->data_dma; |
191 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 194 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
192 | 195 | ||
193 | input_register_device(&mouse->dev); | 196 | input_register_device(mouse->dev); |
194 | printk(KERN_INFO "input: %s on %s\n", mouse->name, path); | ||
195 | 197 | ||
196 | usb_set_intfdata(intf, mouse); | 198 | usb_set_intfdata(intf, mouse); |
197 | return 0; | 199 | return 0; |
200 | |||
201 | fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | ||
202 | fail1: input_free_device(input_dev); | ||
203 | kfree(mouse); | ||
204 | return -ENOMEM; | ||
198 | } | 205 | } |
199 | 206 | ||
200 | static void usb_mouse_disconnect(struct usb_interface *intf) | 207 | static void usb_mouse_disconnect(struct usb_interface *intf) |
@@ -204,7 +211,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf) | |||
204 | usb_set_intfdata(intf, NULL); | 211 | usb_set_intfdata(intf, NULL); |
205 | if (mouse) { | 212 | if (mouse) { |
206 | usb_kill_urb(mouse->irq); | 213 | usb_kill_urb(mouse->irq); |
207 | input_unregister_device(&mouse->dev); | 214 | input_unregister_device(mouse->dev); |
208 | usb_free_urb(mouse->irq); | 215 | usb_free_urb(mouse->irq); |
209 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); | 216 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); |
210 | kfree(mouse); | 217 | kfree(mouse); |
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index 3b266af3048a..ea0f75773ae1 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c | |||
@@ -111,7 +111,7 @@ struct wacom_features { | |||
111 | struct wacom { | 111 | struct wacom { |
112 | signed char *data; | 112 | signed char *data; |
113 | dma_addr_t data_dma; | 113 | dma_addr_t data_dma; |
114 | struct input_dev dev; | 114 | struct input_dev *dev; |
115 | struct usb_device *usbdev; | 115 | struct usb_device *usbdev; |
116 | struct urb *irq; | 116 | struct urb *irq; |
117 | struct wacom_features *features; | 117 | struct wacom_features *features; |
@@ -135,7 +135,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
135 | { | 135 | { |
136 | struct wacom *wacom = urb->context; | 136 | struct wacom *wacom = urb->context; |
137 | unsigned char *data = wacom->data; | 137 | unsigned char *data = wacom->data; |
138 | struct input_dev *dev = &wacom->dev; | 138 | struct input_dev *dev = wacom->dev; |
139 | int prox, pressure; | 139 | int prox, pressure; |
140 | int retval; | 140 | int retval; |
141 | 141 | ||
@@ -225,7 +225,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
225 | { | 225 | { |
226 | struct wacom *wacom = urb->context; | 226 | struct wacom *wacom = urb->context; |
227 | unsigned char *data = wacom->data; | 227 | unsigned char *data = wacom->data; |
228 | struct input_dev *dev = &wacom->dev; | 228 | struct input_dev *dev = wacom->dev; |
229 | int retval; | 229 | int retval; |
230 | 230 | ||
231 | switch (urb->status) { | 231 | switch (urb->status) { |
@@ -275,7 +275,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs) | |||
275 | { | 275 | { |
276 | struct wacom *wacom = urb->context; | 276 | struct wacom *wacom = urb->context; |
277 | unsigned char *data = wacom->data; | 277 | unsigned char *data = wacom->data; |
278 | struct input_dev *dev = &wacom->dev; | 278 | struct input_dev *dev = wacom->dev; |
279 | int retval; | 279 | int retval; |
280 | 280 | ||
281 | switch (urb->status) { | 281 | switch (urb->status) { |
@@ -318,7 +318,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
318 | { | 318 | { |
319 | struct wacom *wacom = urb->context; | 319 | struct wacom *wacom = urb->context; |
320 | unsigned char *data = wacom->data; | 320 | unsigned char *data = wacom->data; |
321 | struct input_dev *dev = &wacom->dev; | 321 | struct input_dev *dev = wacom->dev; |
322 | int x, y; | 322 | int x, y; |
323 | int retval; | 323 | int retval; |
324 | 324 | ||
@@ -397,7 +397,7 @@ static int wacom_intuos_inout(struct urb *urb) | |||
397 | { | 397 | { |
398 | struct wacom *wacom = urb->context; | 398 | struct wacom *wacom = urb->context; |
399 | unsigned char *data = wacom->data; | 399 | unsigned char *data = wacom->data; |
400 | struct input_dev *dev = &wacom->dev; | 400 | struct input_dev *dev = wacom->dev; |
401 | int idx; | 401 | int idx; |
402 | 402 | ||
403 | /* tool number */ | 403 | /* tool number */ |
@@ -479,7 +479,7 @@ static void wacom_intuos_general(struct urb *urb) | |||
479 | { | 479 | { |
480 | struct wacom *wacom = urb->context; | 480 | struct wacom *wacom = urb->context; |
481 | unsigned char *data = wacom->data; | 481 | unsigned char *data = wacom->data; |
482 | struct input_dev *dev = &wacom->dev; | 482 | struct input_dev *dev = wacom->dev; |
483 | unsigned int t; | 483 | unsigned int t; |
484 | 484 | ||
485 | /* general pen packet */ | 485 | /* general pen packet */ |
@@ -509,7 +509,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
509 | { | 509 | { |
510 | struct wacom *wacom = urb->context; | 510 | struct wacom *wacom = urb->context; |
511 | unsigned char *data = wacom->data; | 511 | unsigned char *data = wacom->data; |
512 | struct input_dev *dev = &wacom->dev; | 512 | struct input_dev *dev = wacom->dev; |
513 | unsigned int t; | 513 | unsigned int t; |
514 | int idx; | 514 | int idx; |
515 | int retval; | 515 | int retval; |
@@ -738,95 +738,83 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
738 | { | 738 | { |
739 | struct usb_device *dev = interface_to_usbdev(intf); | 739 | struct usb_device *dev = interface_to_usbdev(intf); |
740 | struct usb_endpoint_descriptor *endpoint; | 740 | struct usb_endpoint_descriptor *endpoint; |
741 | char rep_data[2] = {0x02, 0x02}; | ||
742 | struct wacom *wacom; | 741 | struct wacom *wacom; |
743 | char path[64]; | 742 | struct input_dev *input_dev; |
743 | char rep_data[2] = {0x02, 0x02}; | ||
744 | 744 | ||
745 | if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) | 745 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
746 | return -ENOMEM; | 746 | input_dev = input_allocate_device(); |
747 | memset(wacom, 0, sizeof(struct wacom)); | 747 | if (!wacom || !input_dev) |
748 | goto fail1; | ||
748 | 749 | ||
749 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); | 750 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); |
750 | if (!wacom->data) { | 751 | if (!wacom->data) |
751 | kfree(wacom); | 752 | goto fail1; |
752 | return -ENOMEM; | ||
753 | } | ||
754 | 753 | ||
755 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); | 754 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); |
756 | if (!wacom->irq) { | 755 | if (!wacom->irq) |
757 | usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | 756 | goto fail2; |
758 | kfree(wacom); | 757 | |
759 | return -ENOMEM; | 758 | wacom->usbdev = dev; |
760 | } | 759 | wacom->dev = input_dev; |
760 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | ||
761 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | ||
761 | 762 | ||
762 | wacom->features = wacom_features + (id - wacom_ids); | 763 | wacom->features = wacom_features + (id - wacom_ids); |
764 | if (wacom->features->pktlen > 10) | ||
765 | BUG(); | ||
766 | |||
767 | input_dev->name = wacom->features->name; | ||
768 | usb_to_input_id(dev, &input_dev->id); | ||
763 | 769 | ||
764 | wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | 770 | input_dev->cdev.dev = &intf->dev; |
765 | wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 771 | input_dev->private = wacom; |
766 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | 772 | input_dev->open = wacom_open; |
773 | input_dev->close = wacom_close; | ||
774 | |||
775 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | ||
776 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | ||
777 | input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0); | ||
778 | input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0); | ||
779 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0); | ||
767 | 780 | ||
768 | switch (wacom->features->type) { | 781 | switch (wacom->features->type) { |
769 | case GRAPHIRE: | 782 | case GRAPHIRE: |
770 | wacom->dev.evbit[0] |= BIT(EV_REL); | 783 | input_dev->evbit[0] |= BIT(EV_REL); |
771 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 784 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
772 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); | 785 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
773 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 786 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); |
774 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); | 787 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
775 | break; | 788 | break; |
776 | 789 | ||
777 | case INTUOS3: | 790 | case INTUOS3: |
778 | case CINTIQ: | 791 | case CINTIQ: |
779 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 792 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); |
780 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | 793 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); |
781 | wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); | 794 | input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); |
795 | input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); | ||
782 | /* fall through */ | 796 | /* fall through */ |
783 | 797 | ||
784 | case INTUOS: | 798 | case INTUOS: |
785 | wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); | 799 | input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); |
786 | wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); | 800 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
787 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 801 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
788 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 802 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
789 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) | 803 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) |
790 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); | 804 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); |
791 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); | 805 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
806 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | ||
807 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | ||
808 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); | ||
809 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); | ||
810 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); | ||
792 | break; | 811 | break; |
793 | 812 | ||
794 | case PL: | 813 | case PL: |
795 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); | 814 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); |
796 | break; | 815 | break; |
797 | } | 816 | } |
798 | 817 | ||
799 | wacom->dev.absmax[ABS_X] = wacom->features->x_max; | ||
800 | wacom->dev.absmax[ABS_Y] = wacom->features->y_max; | ||
801 | wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max; | ||
802 | wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max; | ||
803 | wacom->dev.absmax[ABS_TILT_X] = 127; | ||
804 | wacom->dev.absmax[ABS_TILT_Y] = 127; | ||
805 | wacom->dev.absmax[ABS_WHEEL] = 1023; | ||
806 | |||
807 | wacom->dev.absmax[ABS_RX] = 4097; | ||
808 | wacom->dev.absmax[ABS_RY] = 4097; | ||
809 | wacom->dev.absmin[ABS_RZ] = -900; | ||
810 | wacom->dev.absmax[ABS_RZ] = 899; | ||
811 | wacom->dev.absmin[ABS_THROTTLE] = -1023; | ||
812 | wacom->dev.absmax[ABS_THROTTLE] = 1023; | ||
813 | |||
814 | wacom->dev.absfuzz[ABS_X] = 4; | ||
815 | wacom->dev.absfuzz[ABS_Y] = 4; | ||
816 | |||
817 | wacom->dev.private = wacom; | ||
818 | wacom->dev.open = wacom_open; | ||
819 | wacom->dev.close = wacom_close; | ||
820 | |||
821 | usb_make_path(dev, path, 64); | ||
822 | sprintf(wacom->phys, "%s/input0", path); | ||
823 | |||
824 | wacom->dev.name = wacom->features->name; | ||
825 | wacom->dev.phys = wacom->phys; | ||
826 | usb_to_input_id(dev, &wacom->dev.id); | ||
827 | wacom->dev.dev = &intf->dev; | ||
828 | wacom->usbdev = dev; | ||
829 | |||
830 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 818 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
831 | 819 | ||
832 | if (wacom->features->pktlen > 10) | 820 | if (wacom->features->pktlen > 10) |
@@ -839,18 +827,20 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
839 | wacom->irq->transfer_dma = wacom->data_dma; | 827 | wacom->irq->transfer_dma = wacom->data_dma; |
840 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 828 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
841 | 829 | ||
842 | input_register_device(&wacom->dev); | 830 | input_register_device(wacom->dev); |
843 | 831 | ||
844 | /* ask the tablet to report tablet data */ | 832 | /* ask the tablet to report tablet data */ |
845 | usb_set_report(intf, 3, 2, rep_data, 2); | 833 | usb_set_report(intf, 3, 2, rep_data, 2); |
846 | /* repeat once (not sure why the first call often fails) */ | 834 | /* repeat once (not sure why the first call often fails) */ |
847 | usb_set_report(intf, 3, 2, rep_data, 2); | 835 | usb_set_report(intf, 3, 2, rep_data, 2); |
848 | 836 | ||
849 | printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path); | ||
850 | |||
851 | usb_set_intfdata(intf, wacom); | 837 | usb_set_intfdata(intf, wacom); |
852 | |||
853 | return 0; | 838 | return 0; |
839 | |||
840 | fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | ||
841 | fail1: input_free_device(input_dev); | ||
842 | kfree(wacom); | ||
843 | return -ENOMEM; | ||
854 | } | 844 | } |
855 | 845 | ||
856 | static void wacom_disconnect(struct usb_interface *intf) | 846 | static void wacom_disconnect(struct usb_interface *intf) |
@@ -860,7 +850,7 @@ static void wacom_disconnect(struct usb_interface *intf) | |||
860 | usb_set_intfdata(intf, NULL); | 850 | usb_set_intfdata(intf, NULL); |
861 | if (wacom) { | 851 | if (wacom) { |
862 | usb_kill_urb(wacom->irq); | 852 | usb_kill_urb(wacom->irq); |
863 | input_unregister_device(&wacom->dev); | 853 | input_unregister_device(wacom->dev); |
864 | usb_free_urb(wacom->irq); | 854 | usb_free_urb(wacom->irq); |
865 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); | 855 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); |
866 | kfree(wacom); | 856 | kfree(wacom); |
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index 18125e0bffa2..43112f040b6d 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
@@ -103,7 +103,7 @@ static struct usb_device_id xpad_table [] = { | |||
103 | MODULE_DEVICE_TABLE (usb, xpad_table); | 103 | MODULE_DEVICE_TABLE (usb, xpad_table); |
104 | 104 | ||
105 | struct usb_xpad { | 105 | struct usb_xpad { |
106 | struct input_dev dev; /* input device interface */ | 106 | struct input_dev *dev; /* input device interface */ |
107 | struct usb_device *udev; /* usb device */ | 107 | struct usb_device *udev; /* usb device */ |
108 | 108 | ||
109 | struct urb *irq_in; /* urb for interrupt in report */ | 109 | struct urb *irq_in; /* urb for interrupt in report */ |
@@ -125,7 +125,7 @@ struct usb_xpad { | |||
125 | 125 | ||
126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) | 126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) |
127 | { | 127 | { |
128 | struct input_dev *dev = &xpad->dev; | 128 | struct input_dev *dev = xpad->dev; |
129 | 129 | ||
130 | input_regs(dev, regs); | 130 | input_regs(dev, regs); |
131 | 131 | ||
@@ -214,9 +214,9 @@ static void xpad_close (struct input_dev *dev) | |||
214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) | 214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) |
215 | { | 215 | { |
216 | struct usb_device *udev = interface_to_usbdev (intf); | 216 | struct usb_device *udev = interface_to_usbdev (intf); |
217 | struct usb_xpad *xpad = NULL; | 217 | struct usb_xpad *xpad; |
218 | struct input_dev *input_dev; | ||
218 | struct usb_endpoint_descriptor *ep_irq_in; | 219 | struct usb_endpoint_descriptor *ep_irq_in; |
219 | char path[64]; | ||
220 | int i; | 220 | int i; |
221 | 221 | ||
222 | for (i = 0; xpad_device[i].idVendor; i++) { | 222 | for (i = 0; xpad_device[i].idVendor; i++) { |
@@ -225,89 +225,80 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { | 228 | xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); |
229 | err("cannot allocate memory for new pad"); | 229 | input_dev = input_allocate_device(); |
230 | return -ENOMEM; | 230 | if (!xpad || !input_dev) |
231 | } | 231 | goto fail1; |
232 | memset(xpad, 0, sizeof(struct usb_xpad)); | ||
233 | 232 | ||
234 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, | 233 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, |
235 | SLAB_ATOMIC, &xpad->idata_dma); | 234 | SLAB_ATOMIC, &xpad->idata_dma); |
236 | if (!xpad->idata) { | 235 | if (!xpad->idata) |
237 | kfree(xpad); | 236 | goto fail1; |
238 | return -ENOMEM; | ||
239 | } | ||
240 | 237 | ||
241 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); | 238 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); |
242 | if (!xpad->irq_in) { | 239 | if (!xpad->irq_in) |
243 | err("cannot allocate memory for new pad irq urb"); | 240 | goto fail2; |
244 | usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
245 | kfree(xpad); | ||
246 | return -ENOMEM; | ||
247 | } | ||
248 | |||
249 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; | ||
250 | |||
251 | usb_fill_int_urb(xpad->irq_in, udev, | ||
252 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
253 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
254 | xpad, ep_irq_in->bInterval); | ||
255 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
256 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
257 | 241 | ||
258 | xpad->udev = udev; | 242 | xpad->udev = udev; |
243 | xpad->dev = input_dev; | ||
244 | usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); | ||
245 | strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); | ||
259 | 246 | ||
260 | usb_to_input_id(udev, &xpad->dev.id); | 247 | input_dev->name = xpad_device[i].name; |
261 | xpad->dev.dev = &intf->dev; | 248 | input_dev->phys = xpad->phys; |
262 | xpad->dev.private = xpad; | 249 | usb_to_input_id(udev, &input_dev->id); |
263 | xpad->dev.name = xpad_device[i].name; | 250 | input_dev->cdev.dev = &intf->dev; |
264 | xpad->dev.phys = xpad->phys; | 251 | input_dev->private = xpad; |
265 | xpad->dev.open = xpad_open; | 252 | input_dev->open = xpad_open; |
266 | xpad->dev.close = xpad_close; | 253 | input_dev->close = xpad_close; |
267 | |||
268 | usb_make_path(udev, path, 64); | ||
269 | snprintf(xpad->phys, 64, "%s/input0", path); | ||
270 | 254 | ||
271 | xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 255 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
272 | 256 | ||
273 | for (i = 0; xpad_btn[i] >= 0; i++) | 257 | for (i = 0; xpad_btn[i] >= 0; i++) |
274 | set_bit(xpad_btn[i], xpad->dev.keybit); | 258 | set_bit(xpad_btn[i], input_dev->keybit); |
275 | 259 | ||
276 | for (i = 0; xpad_abs[i] >= 0; i++) { | 260 | for (i = 0; xpad_abs[i] >= 0; i++) { |
277 | 261 | ||
278 | signed short t = xpad_abs[i]; | 262 | signed short t = xpad_abs[i]; |
279 | 263 | ||
280 | set_bit(t, xpad->dev.absbit); | 264 | set_bit(t, input_dev->absbit); |
281 | 265 | ||
282 | switch (t) { | 266 | switch (t) { |
283 | case ABS_X: | 267 | case ABS_X: |
284 | case ABS_Y: | 268 | case ABS_Y: |
285 | case ABS_RX: | 269 | case ABS_RX: |
286 | case ABS_RY: /* the two sticks */ | 270 | case ABS_RY: /* the two sticks */ |
287 | xpad->dev.absmax[t] = 32767; | 271 | input_set_abs_params(input_dev, t, -32768, 32767, 16, 128); |
288 | xpad->dev.absmin[t] = -32768; | ||
289 | xpad->dev.absflat[t] = 128; | ||
290 | xpad->dev.absfuzz[t] = 16; | ||
291 | break; | 272 | break; |
292 | case ABS_Z: | 273 | case ABS_Z: |
293 | case ABS_RZ: /* the triggers */ | 274 | case ABS_RZ: /* the triggers */ |
294 | xpad->dev.absmax[t] = 255; | 275 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
295 | xpad->dev.absmin[t] = 0; | ||
296 | break; | 276 | break; |
297 | case ABS_HAT0X: | 277 | case ABS_HAT0X: |
298 | case ABS_HAT0Y: /* the d-pad */ | 278 | case ABS_HAT0Y: /* the d-pad */ |
299 | xpad->dev.absmax[t] = 1; | 279 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
300 | xpad->dev.absmin[t] = -1; | ||
301 | break; | 280 | break; |
302 | } | 281 | } |
303 | } | 282 | } |
304 | 283 | ||
305 | input_register_device(&xpad->dev); | 284 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; |
285 | usb_fill_int_urb(xpad->irq_in, udev, | ||
286 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
287 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
288 | xpad, ep_irq_in->bInterval); | ||
289 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
290 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
306 | 291 | ||
307 | printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); | 292 | input_register_device(xpad->dev); |
308 | 293 | ||
309 | usb_set_intfdata(intf, xpad); | 294 | usb_set_intfdata(intf, xpad); |
310 | return 0; | 295 | return 0; |
296 | |||
297 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
298 | fail1: input_free_device(input_dev); | ||
299 | kfree(xpad); | ||
300 | return -ENOMEM; | ||
301 | |||
311 | } | 302 | } |
312 | 303 | ||
313 | static void xpad_disconnect(struct usb_interface *intf) | 304 | static void xpad_disconnect(struct usb_interface *intf) |
@@ -317,7 +308,7 @@ static void xpad_disconnect(struct usb_interface *intf) | |||
317 | usb_set_intfdata(intf, NULL); | 308 | usb_set_intfdata(intf, NULL); |
318 | if (xpad) { | 309 | if (xpad) { |
319 | usb_kill_urb(xpad->irq_in); | 310 | usb_kill_urb(xpad->irq_in); |
320 | input_unregister_device(&xpad->dev); | 311 | input_unregister_device(xpad->dev); |
321 | usb_free_urb(xpad->irq_in); | 312 | usb_free_urb(xpad->irq_in); |
322 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | 313 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); |
323 | kfree(xpad); | 314 | kfree(xpad); |
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index 58a176ef96a5..f526aebea502 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/rwsem.h> | 55 | #include <linux/rwsem.h> |
56 | #include <linux/usb.h> | 56 | #include <linux/usb.h> |
57 | #include <linux/usb_input.h> | ||
57 | 58 | ||
58 | #include "map_to_7segment.h" | 59 | #include "map_to_7segment.h" |
59 | #include "yealink.h" | 60 | #include "yealink.h" |
@@ -101,12 +102,12 @@ static const struct lcd_segment_map { | |||
101 | }; | 102 | }; |
102 | 103 | ||
103 | struct yealink_dev { | 104 | struct yealink_dev { |
104 | struct input_dev idev; /* input device */ | 105 | struct input_dev *idev; /* input device */ |
105 | struct usb_device *udev; /* usb device */ | 106 | struct usb_device *udev; /* usb device */ |
106 | 107 | ||
107 | /* irq input channel */ | 108 | /* irq input channel */ |
108 | struct yld_ctl_packet *irq_data; | 109 | struct yld_ctl_packet *irq_data; |
109 | dma_addr_t irq_dma; | 110 | dma_addr_t irq_dma; |
110 | struct urb *urb_irq; | 111 | struct urb *urb_irq; |
111 | 112 | ||
112 | /* control output channel */ | 113 | /* control output channel */ |
@@ -237,7 +238,7 @@ static int map_p1k_to_key(int scancode) | |||
237 | */ | 238 | */ |
238 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) | 239 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) |
239 | { | 240 | { |
240 | struct input_dev *idev = &yld->idev; | 241 | struct input_dev *idev = yld->idev; |
241 | 242 | ||
242 | input_regs(idev, regs); | 243 | input_regs(idev, regs); |
243 | if (yld->key_code >= 0) { | 244 | if (yld->key_code >= 0) { |
@@ -809,8 +810,12 @@ static int usb_cleanup(struct yealink_dev *yld, int err) | |||
809 | } | 810 | } |
810 | if (yld->urb_ctl) | 811 | if (yld->urb_ctl) |
811 | usb_free_urb(yld->urb_ctl); | 812 | usb_free_urb(yld->urb_ctl); |
812 | if (yld->idev.dev) | 813 | if (yld->idev) { |
813 | input_unregister_device(&yld->idev); | 814 | if (err) |
815 | input_free_device(yld->idev); | ||
816 | else | ||
817 | input_unregister_device(yld->idev); | ||
818 | } | ||
814 | if (yld->ctl_req) | 819 | if (yld->ctl_req) |
815 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), | 820 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), |
816 | yld->ctl_req, yld->ctl_req_dma); | 821 | yld->ctl_req, yld->ctl_req_dma); |
@@ -857,7 +862,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
857 | struct usb_host_interface *interface; | 862 | struct usb_host_interface *interface; |
858 | struct usb_endpoint_descriptor *endpoint; | 863 | struct usb_endpoint_descriptor *endpoint; |
859 | struct yealink_dev *yld; | 864 | struct yealink_dev *yld; |
860 | char path[64]; | 865 | struct input_dev *input_dev; |
861 | int ret, pipe, i; | 866 | int ret, pipe, i; |
862 | 867 | ||
863 | i = usb_match(udev); | 868 | i = usb_match(udev); |
@@ -866,17 +871,21 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
866 | 871 | ||
867 | interface = intf->cur_altsetting; | 872 | interface = intf->cur_altsetting; |
868 | endpoint = &interface->endpoint[0].desc; | 873 | endpoint = &interface->endpoint[0].desc; |
869 | if (!(endpoint->bEndpointAddress & 0x80)) | 874 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
870 | return -EIO; | 875 | return -EIO; |
871 | if ((endpoint->bmAttributes & 3) != 3) | 876 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
872 | return -EIO; | 877 | return -EIO; |
873 | 878 | ||
874 | if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) | 879 | yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); |
880 | if (!yld) | ||
875 | return -ENOMEM; | 881 | return -ENOMEM; |
876 | 882 | ||
877 | memset(yld, 0, sizeof(*yld)); | ||
878 | yld->udev = udev; | 883 | yld->udev = udev; |
879 | 884 | ||
885 | yld->idev = input_dev = input_allocate_device(); | ||
886 | if (!input_dev) | ||
887 | return usb_cleanup(yld, -ENOMEM); | ||
888 | |||
880 | /* allocate usb buffers */ | 889 | /* allocate usb buffers */ |
881 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, | 890 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, |
882 | SLAB_ATOMIC, &yld->irq_dma); | 891 | SLAB_ATOMIC, &yld->irq_dma); |
@@ -935,42 +944,37 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
935 | yld->urb_ctl->dev = udev; | 944 | yld->urb_ctl->dev = udev; |
936 | 945 | ||
937 | /* find out the physical bus location */ | 946 | /* find out the physical bus location */ |
938 | if (usb_make_path(udev, path, sizeof(path)) > 0) | 947 | usb_make_path(udev, yld->phys, sizeof(yld->phys)); |
939 | snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); | 948 | strlcat(yld->phys, "/input0", sizeof(yld->phys)); |
940 | 949 | ||
941 | /* register settings for the input device */ | 950 | /* register settings for the input device */ |
942 | init_input_dev(&yld->idev); | 951 | input_dev->name = yld_device[i].name; |
943 | yld->idev.private = yld; | 952 | input_dev->phys = yld->phys; |
944 | yld->idev.id.bustype = BUS_USB; | 953 | usb_to_input_id(udev, &input_dev->id); |
945 | yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | 954 | input_dev->cdev.dev = &intf->dev; |
946 | yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); | 955 | |
947 | yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); | 956 | input_dev->private = yld; |
948 | yld->idev.dev = &intf->dev; | 957 | input_dev->open = input_open; |
949 | yld->idev.name = yld_device[i].name; | 958 | input_dev->close = input_close; |
950 | yld->idev.phys = yld->phys; | 959 | /* input_dev->event = input_ev; TODO */ |
951 | /* yld->idev.event = input_ev; TODO */ | ||
952 | yld->idev.open = input_open; | ||
953 | yld->idev.close = input_close; | ||
954 | 960 | ||
955 | /* register available key events */ | 961 | /* register available key events */ |
956 | yld->idev.evbit[0] = BIT(EV_KEY); | 962 | input_dev->evbit[0] = BIT(EV_KEY); |
957 | for (i = 0; i < 256; i++) { | 963 | for (i = 0; i < 256; i++) { |
958 | int k = map_p1k_to_key(i); | 964 | int k = map_p1k_to_key(i); |
959 | if (k >= 0) { | 965 | if (k >= 0) { |
960 | set_bit(k & 0xff, yld->idev.keybit); | 966 | set_bit(k & 0xff, input_dev->keybit); |
961 | if (k >> 8) | 967 | if (k >> 8) |
962 | set_bit(k >> 8, yld->idev.keybit); | 968 | set_bit(k >> 8, input_dev->keybit); |
963 | } | 969 | } |
964 | } | 970 | } |
965 | 971 | ||
966 | printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); | 972 | input_register_device(yld->idev); |
967 | |||
968 | input_register_device(&yld->idev); | ||
969 | 973 | ||
970 | usb_set_intfdata(intf, yld); | 974 | usb_set_intfdata(intf, yld); |
971 | 975 | ||
972 | /* clear visible elements */ | 976 | /* clear visible elements */ |
973 | for (i=0; i<ARRAY_SIZE(lcdMap); i++) | 977 | for (i = 0; i < ARRAY_SIZE(lcdMap); i++) |
974 | setChar(yld, i, ' '); | 978 | setChar(yld, i, ' '); |
975 | 979 | ||
976 | /* display driver version on LCD line 3 */ | 980 | /* display driver version on LCD line 3 */ |
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c index 20ac9e1069d4..9fe2c2710d13 100644 --- a/drivers/usb/media/konicawc.c +++ b/drivers/usb/media/konicawc.c | |||
@@ -119,7 +119,7 @@ struct konicawc { | |||
119 | int yplanesz; /* Number of bytes in the Y plane */ | 119 | int yplanesz; /* Number of bytes in the Y plane */ |
120 | unsigned int buttonsts:1; | 120 | unsigned int buttonsts:1; |
121 | #ifdef CONFIG_INPUT | 121 | #ifdef CONFIG_INPUT |
122 | struct input_dev input; | 122 | struct input_dev *input; |
123 | char input_physname[64]; | 123 | char input_physname[64]; |
124 | #endif | 124 | #endif |
125 | }; | 125 | }; |
@@ -218,6 +218,57 @@ static void konicawc_adjust_picture(struct uvd *uvd) | |||
218 | konicawc_camera_on(uvd); | 218 | konicawc_camera_on(uvd); |
219 | } | 219 | } |
220 | 220 | ||
221 | #ifdef CONFIG_INPUT | ||
222 | |||
223 | static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) | ||
224 | { | ||
225 | struct input_dev *input_dev; | ||
226 | |||
227 | usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname)); | ||
228 | strncat(cam->input_physname, "/input0", sizeof(cam->input_physname)); | ||
229 | |||
230 | cam->input = input_dev = input_allocate_device(); | ||
231 | if (!input_dev) { | ||
232 | warn("Not enough memory for camera's input device\n"); | ||
233 | return; | ||
234 | } | ||
235 | |||
236 | input_dev->name = "Konicawc snapshot button"; | ||
237 | input_dev->phys = cam->input_physname; | ||
238 | usb_to_input_id(dev, &input_dev->id); | ||
239 | input_dev->cdev.dev = &dev->dev; | ||
240 | |||
241 | input_dev->evbit[0] = BIT(EV_KEY); | ||
242 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
243 | |||
244 | input_dev->private = cam; | ||
245 | |||
246 | input_register_device(cam->input); | ||
247 | } | ||
248 | |||
249 | static void konicawc_unregister_input(struct konicawc *cam) | ||
250 | { | ||
251 | if (cam->input) { | ||
252 | input_unregister_device(cam->input); | ||
253 | cam->input = NULL; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | static void konicawc_report_buttonstat(struct konicawc *cam) | ||
258 | { | ||
259 | if (cam->input) { | ||
260 | input_report_key(cam->input, BTN_0, cam->buttonsts); | ||
261 | input_sync(cam->input); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | #else | ||
266 | |||
267 | static inline void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) { } | ||
268 | static inline void konicawc_unregister_input(struct konicawc *cam) { } | ||
269 | static inline void konicawc_report_buttonstat(struct konicawc *cam) { } | ||
270 | |||
271 | #endif /* CONFIG_INPUT */ | ||
221 | 272 | ||
222 | static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) | 273 | static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) |
223 | { | 274 | { |
@@ -273,10 +324,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur | |||
273 | if(button != cam->buttonsts) { | 324 | if(button != cam->buttonsts) { |
274 | DEBUG(2, "button: %sclicked", button ? "" : "un"); | 325 | DEBUG(2, "button: %sclicked", button ? "" : "un"); |
275 | cam->buttonsts = button; | 326 | cam->buttonsts = button; |
276 | #ifdef CONFIG_INPUT | 327 | konicawc_report_buttonstat(cam); |
277 | input_report_key(&cam->input, BTN_0, cam->buttonsts); | ||
278 | input_sync(&cam->input); | ||
279 | #endif | ||
280 | } | 328 | } |
281 | 329 | ||
282 | if(sts == 0x01) { /* drop frame */ | 330 | if(sts == 0x01) { /* drop frame */ |
@@ -645,9 +693,9 @@ static int konicawc_set_video_mode(struct uvd *uvd, struct video_window *vw) | |||
645 | RingQueue_Flush(&uvd->dp); | 693 | RingQueue_Flush(&uvd->dp); |
646 | cam->lastframe = -2; | 694 | cam->lastframe = -2; |
647 | if(uvd->curframe != -1) { | 695 | if(uvd->curframe != -1) { |
648 | uvd->frame[uvd->curframe].curline = 0; | 696 | uvd->frame[uvd->curframe].curline = 0; |
649 | uvd->frame[uvd->curframe].seqRead_Length = 0; | 697 | uvd->frame[uvd->curframe].seqRead_Length = 0; |
650 | uvd->frame[uvd->curframe].seqRead_Index = 0; | 698 | uvd->frame[uvd->curframe].seqRead_Index = 0; |
651 | } | 699 | } |
652 | 700 | ||
653 | konicawc_start_data(uvd); | 701 | konicawc_start_data(uvd); |
@@ -718,7 +766,6 @@ static void konicawc_configure_video(struct uvd *uvd) | |||
718 | DEBUG(1, "setting initial values"); | 766 | DEBUG(1, "setting initial values"); |
719 | } | 767 | } |
720 | 768 | ||
721 | |||
722 | static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) | 769 | static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) |
723 | { | 770 | { |
724 | struct usb_device *dev = interface_to_usbdev(intf); | 771 | struct usb_device *dev = interface_to_usbdev(intf); |
@@ -839,21 +886,8 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id | |||
839 | err("usbvideo_RegisterVideoDevice() failed."); | 886 | err("usbvideo_RegisterVideoDevice() failed."); |
840 | uvd = NULL; | 887 | uvd = NULL; |
841 | } | 888 | } |
842 | #ifdef CONFIG_INPUT | 889 | |
843 | /* Register input device for button */ | 890 | konicawc_register_input(cam, dev); |
844 | memset(&cam->input, 0, sizeof(struct input_dev)); | ||
845 | cam->input.name = "Konicawc snapshot button"; | ||
846 | cam->input.private = cam; | ||
847 | cam->input.evbit[0] = BIT(EV_KEY); | ||
848 | cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
849 | usb_to_input_id(dev, &cam->input.id); | ||
850 | input_register_device(&cam->input); | ||
851 | |||
852 | usb_make_path(dev, cam->input_physname, 56); | ||
853 | strcat(cam->input_physname, "/input0"); | ||
854 | cam->input.phys = cam->input_physname; | ||
855 | info("konicawc: %s on %s\n", cam->input.name, cam->input.phys); | ||
856 | #endif | ||
857 | } | 891 | } |
858 | 892 | ||
859 | if (uvd) { | 893 | if (uvd) { |
@@ -869,10 +903,9 @@ static void konicawc_free_uvd(struct uvd *uvd) | |||
869 | int i; | 903 | int i; |
870 | struct konicawc *cam = (struct konicawc *)uvd->user_data; | 904 | struct konicawc *cam = (struct konicawc *)uvd->user_data; |
871 | 905 | ||
872 | #ifdef CONFIG_INPUT | 906 | konicawc_unregister_input(cam); |
873 | input_unregister_device(&cam->input); | 907 | |
874 | #endif | 908 | for (i = 0; i < USBVIDEO_NUMSBUF; i++) { |
875 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | ||
876 | usb_free_urb(cam->sts_urb[i]); | 909 | usb_free_urb(cam->sts_urb[i]); |
877 | cam->sts_urb[i] = NULL; | 910 | cam->sts_urb[i] = NULL; |
878 | } | 911 | } |
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 2c9402dc702b..89401a59f952 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> | 5 | * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> |
6 | * | 6 | * |
7 | * Initial work by: | 7 | * Initial work by: |
8 | * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> | 8 | * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> |
9 | * | 9 | * |
10 | * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) | 10 | * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) |
11 | * | 11 | * |
@@ -46,7 +46,7 @@ void onetouch_release_input(void *onetouch_); | |||
46 | struct usb_onetouch { | 46 | struct usb_onetouch { |
47 | char name[128]; | 47 | char name[128]; |
48 | char phys[64]; | 48 | char phys[64]; |
49 | struct input_dev dev; /* input device interface */ | 49 | struct input_dev *dev; /* input device interface */ |
50 | struct usb_device *udev; /* usb device */ | 50 | struct usb_device *udev; /* usb device */ |
51 | 51 | ||
52 | struct urb *irq; /* urb for interrupt in report */ | 52 | struct urb *irq; /* urb for interrupt in report */ |
@@ -58,7 +58,7 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) | |||
58 | { | 58 | { |
59 | struct usb_onetouch *onetouch = urb->context; | 59 | struct usb_onetouch *onetouch = urb->context; |
60 | signed char *data = onetouch->data; | 60 | signed char *data = onetouch->data; |
61 | struct input_dev *dev = &onetouch->dev; | 61 | struct input_dev *dev = onetouch->dev; |
62 | int status; | 62 | int status; |
63 | 63 | ||
64 | switch (urb->status) { | 64 | switch (urb->status) { |
@@ -74,11 +74,9 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | input_regs(dev, regs); | 76 | input_regs(dev, regs); |
77 | 77 | input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02); | |
78 | input_report_key(&onetouch->dev, ONETOUCH_BUTTON, | ||
79 | data[0] & 0x02); | ||
80 | |||
81 | input_sync(dev); | 78 | input_sync(dev); |
79 | |||
82 | resubmit: | 80 | resubmit: |
83 | status = usb_submit_urb (urb, SLAB_ATOMIC); | 81 | status = usb_submit_urb (urb, SLAB_ATOMIC); |
84 | if (status) | 82 | if (status) |
@@ -113,8 +111,8 @@ int onetouch_connect_input(struct us_data *ss) | |||
113 | struct usb_host_interface *interface; | 111 | struct usb_host_interface *interface; |
114 | struct usb_endpoint_descriptor *endpoint; | 112 | struct usb_endpoint_descriptor *endpoint; |
115 | struct usb_onetouch *onetouch; | 113 | struct usb_onetouch *onetouch; |
114 | struct input_dev *input_dev; | ||
116 | int pipe, maxp; | 115 | int pipe, maxp; |
117 | char path[64]; | ||
118 | 116 | ||
119 | interface = ss->pusb_intf->cur_altsetting; | 117 | interface = ss->pusb_intf->cur_altsetting; |
120 | 118 | ||
@@ -122,62 +120,62 @@ int onetouch_connect_input(struct us_data *ss) | |||
122 | return -ENODEV; | 120 | return -ENODEV; |
123 | 121 | ||
124 | endpoint = &interface->endpoint[2].desc; | 122 | endpoint = &interface->endpoint[2].desc; |
125 | if(!(endpoint->bEndpointAddress & USB_DIR_IN)) | 123 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
126 | return -ENODEV; | 124 | return -ENODEV; |
127 | if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | 125 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) |
128 | != USB_ENDPOINT_XFER_INT) | 126 | != USB_ENDPOINT_XFER_INT) |
129 | return -ENODEV; | 127 | return -ENODEV; |
130 | 128 | ||
131 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 129 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
132 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 130 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
133 | 131 | ||
134 | if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL))) | 132 | onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL); |
135 | return -ENOMEM; | 133 | input_dev = input_allocate_device(); |
134 | if (!onetouch || !input_dev) | ||
135 | goto fail1; | ||
136 | 136 | ||
137 | onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, | 137 | onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, |
138 | SLAB_ATOMIC, &onetouch->data_dma); | 138 | SLAB_ATOMIC, &onetouch->data_dma); |
139 | if (!onetouch->data){ | 139 | if (!onetouch->data) |
140 | kfree(onetouch); | 140 | goto fail1; |
141 | return -ENOMEM; | ||
142 | } | ||
143 | 141 | ||
144 | onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 142 | onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
145 | if (!onetouch->irq){ | 143 | if (!onetouch->irq) |
146 | kfree(onetouch); | 144 | goto fail2; |
147 | usb_buffer_free(udev, ONETOUCH_PKT_LEN, | ||
148 | onetouch->data, onetouch->data_dma); | ||
149 | return -ENODEV; | ||
150 | } | ||
151 | |||
152 | 145 | ||
153 | onetouch->udev = udev; | 146 | onetouch->udev = udev; |
147 | onetouch->dev = input_dev; | ||
154 | 148 | ||
155 | set_bit(EV_KEY, onetouch->dev.evbit); | 149 | if (udev->manufacturer) |
156 | set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit); | 150 | strlcpy(onetouch->name, udev->manufacturer, |
157 | clear_bit(0, onetouch->dev.keybit); | 151 | sizeof(onetouch->name)); |
152 | if (udev->product) { | ||
153 | if (udev->manufacturer) | ||
154 | strlcat(onetouch->name, " ", sizeof(onetouch->name)); | ||
155 | strlcat(onetouch->name, udev->product, sizeof(onetouch->name)); | ||
156 | } | ||
158 | 157 | ||
159 | onetouch->dev.private = onetouch; | 158 | if (!strlen(onetouch->name)) |
160 | onetouch->dev.open = usb_onetouch_open; | 159 | snprintf(onetouch->name, sizeof(onetouch->name), |
161 | onetouch->dev.close = usb_onetouch_close; | 160 | "Maxtor Onetouch %04x:%04x", |
161 | le16_to_cpu(udev->descriptor.idVendor), | ||
162 | le16_to_cpu(udev->descriptor.idProduct)); | ||
162 | 163 | ||
163 | usb_make_path(udev, path, sizeof(path)); | 164 | usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys)); |
164 | sprintf(onetouch->phys, "%s/input0", path); | 165 | strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys)); |
165 | 166 | ||
166 | onetouch->dev.name = onetouch->name; | 167 | input_dev->name = onetouch->name; |
167 | onetouch->dev.phys = onetouch->phys; | 168 | input_dev->phys = onetouch->phys; |
169 | usb_to_input_id(udev, &input_dev->id); | ||
170 | input_dev->cdev.dev = &udev->dev; | ||
168 | 171 | ||
169 | usb_to_input_id(udev, &onetouch->dev.id); | 172 | set_bit(EV_KEY, input_dev->evbit); |
173 | set_bit(ONETOUCH_BUTTON, input_dev->keybit); | ||
174 | clear_bit(0, input_dev->keybit); | ||
170 | 175 | ||
171 | onetouch->dev.dev = &udev->dev; | 176 | input_dev->private = onetouch; |
172 | 177 | input_dev->open = usb_onetouch_open; | |
173 | if (udev->manufacturer) | 178 | input_dev->close = usb_onetouch_close; |
174 | strcat(onetouch->name, udev->manufacturer); | ||
175 | if (udev->product) | ||
176 | sprintf(onetouch->name, "%s %s", onetouch->name, | ||
177 | udev->product); | ||
178 | if (!strlen(onetouch->name)) | ||
179 | sprintf(onetouch->name, "Maxtor Onetouch %04x:%04x", | ||
180 | onetouch->dev.id.vendor, onetouch->dev.id.product); | ||
181 | 179 | ||
182 | usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, | 180 | usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, |
183 | (maxp > 8 ? 8 : maxp), | 181 | (maxp > 8 ? 8 : maxp), |
@@ -188,10 +186,15 @@ int onetouch_connect_input(struct us_data *ss) | |||
188 | ss->extra_destructor = onetouch_release_input; | 186 | ss->extra_destructor = onetouch_release_input; |
189 | ss->extra = onetouch; | 187 | ss->extra = onetouch; |
190 | 188 | ||
191 | input_register_device(&onetouch->dev); | 189 | input_register_device(onetouch->dev); |
192 | printk(KERN_INFO "usb-input: %s on %s\n", onetouch->dev.name, path); | ||
193 | 190 | ||
194 | return 0; | 191 | return 0; |
192 | |||
193 | fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN, | ||
194 | onetouch->data, onetouch->data_dma); | ||
195 | fail1: kfree(onetouch); | ||
196 | input_free_device(input_dev); | ||
197 | return -ENOMEM; | ||
195 | } | 198 | } |
196 | 199 | ||
197 | void onetouch_release_input(void *onetouch_) | 200 | void onetouch_release_input(void *onetouch_) |
@@ -200,11 +203,9 @@ void onetouch_release_input(void *onetouch_) | |||
200 | 203 | ||
201 | if (onetouch) { | 204 | if (onetouch) { |
202 | usb_kill_urb(onetouch->irq); | 205 | usb_kill_urb(onetouch->irq); |
203 | input_unregister_device(&onetouch->dev); | 206 | input_unregister_device(onetouch->dev); |
204 | usb_free_urb(onetouch->irq); | 207 | usb_free_urb(onetouch->irq); |
205 | usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, | 208 | usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, |
206 | onetouch->data, onetouch->data_dma); | 209 | onetouch->data, onetouch->data_dma); |
207 | printk(KERN_INFO "usb-input: deregistering %s\n", | ||
208 | onetouch->dev.name); | ||
209 | } | 210 | } |
210 | } | 211 | } |
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 321dbe91dc14..cde6fd8eb390 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/ioport.h> | 22 | #include <linux/ioport.h> |
23 | #include <linux/list.h> | 23 | #include <linux/list.h> |
24 | 24 | ||
25 | #include <asm/sizes.h> | ||
25 | #include <asm/hardware/amba.h> | 26 | #include <asm/hardware/amba.h> |
26 | #include <asm/hardware/clock.h> | 27 | #include <asm/hardware/clock.h> |
27 | 28 | ||
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index 3c72c627e65e..1991fdb32dfb 100644 --- a/drivers/video/backlight/corgi_bl.c +++ b/drivers/video/backlight/corgi_bl.c | |||
@@ -73,17 +73,15 @@ static void corgibl_blank(int blank) | |||
73 | } | 73 | } |
74 | 74 | ||
75 | #ifdef CONFIG_PM | 75 | #ifdef CONFIG_PM |
76 | static int corgibl_suspend(struct device *dev, pm_message_t state, u32 level) | 76 | static int corgibl_suspend(struct device *dev, pm_message_t state) |
77 | { | 77 | { |
78 | if (level == SUSPEND_POWER_DOWN) | 78 | corgibl_blank(FB_BLANK_POWERDOWN); |
79 | corgibl_blank(FB_BLANK_POWERDOWN); | ||
80 | return 0; | 79 | return 0; |
81 | } | 80 | } |
82 | 81 | ||
83 | static int corgibl_resume(struct device *dev, u32 level) | 82 | static int corgibl_resume(struct device *dev) |
84 | { | 83 | { |
85 | if (level == RESUME_POWER_ON) | 84 | corgibl_blank(FB_BLANK_UNBLANK); |
86 | corgibl_blank(FB_BLANK_UNBLANK); | ||
87 | return 0; | 85 | return 0; |
88 | } | 86 | } |
89 | #else | 87 | #else |
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index eb83a7874c71..7e731691e2a9 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig | |||
@@ -110,7 +110,7 @@ config STI_CONSOLE | |||
110 | 110 | ||
111 | config FONTS | 111 | config FONTS |
112 | bool "Select compiled-in fonts" | 112 | bool "Select compiled-in fonts" |
113 | depends on FRAMEBUFFER_CONSOLE | 113 | depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE |
114 | help | 114 | help |
115 | Say Y here if you would like to use fonts other than the default | 115 | Say Y here if you would like to use fonts other than the default |
116 | your frame buffer console usually use. | 116 | your frame buffer console usually use. |
@@ -123,7 +123,7 @@ config FONTS | |||
123 | 123 | ||
124 | config FONT_8x8 | 124 | config FONT_8x8 |
125 | bool "VGA 8x8 font" if FONTS | 125 | bool "VGA 8x8 font" if FONTS |
126 | depends on FRAMEBUFFER_CONSOLE | 126 | depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE |
127 | default y if !SPARC32 && !SPARC64 && !FONTS | 127 | default y if !SPARC32 && !SPARC64 && !FONTS |
128 | help | 128 | help |
129 | This is the "high resolution" font for the VGA frame buffer (the one | 129 | This is the "high resolution" font for the VGA frame buffer (the one |
@@ -137,7 +137,7 @@ config FONT_8x8 | |||
137 | 137 | ||
138 | config FONT_8x16 | 138 | config FONT_8x16 |
139 | bool "VGA 8x16 font" if FONTS | 139 | bool "VGA 8x16 font" if FONTS |
140 | depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || USB_SISUSBVGA_CON | 140 | depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON |
141 | default y if !SPARC32 && !SPARC64 && !FONTS | 141 | default y if !SPARC32 && !SPARC64 && !FONTS |
142 | help | 142 | help |
143 | This is the "high resolution" font for the VGA frame buffer (the one | 143 | This is the "high resolution" font for the VGA frame buffer (the one |
@@ -147,7 +147,7 @@ config FONT_8x16 | |||
147 | 147 | ||
148 | config FONT_6x11 | 148 | config FONT_6x11 |
149 | bool "Mac console 6x11 font (not supported by all drivers)" if FONTS | 149 | bool "Mac console 6x11 font (not supported by all drivers)" if FONTS |
150 | depends on FRAMEBUFFER_CONSOLE | 150 | depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE |
151 | default y if !SPARC32 && !SPARC64 && !FONTS && MAC | 151 | default y if !SPARC32 && !SPARC64 && !FONTS && MAC |
152 | help | 152 | help |
153 | Small console font with Macintosh-style high-half glyphs. Some Mac | 153 | Small console font with Macintosh-style high-half glyphs. Some Mac |
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c index d940f605acb6..a7bcd17112c0 100644 --- a/drivers/video/console/sticore.c +++ b/drivers/video/console/sticore.c | |||
@@ -511,12 +511,12 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) | |||
511 | struct sti_cooked_font *cooked_font; | 511 | struct sti_cooked_font *cooked_font; |
512 | 512 | ||
513 | if (!fbfont_name || !strlen(fbfont_name)) | 513 | if (!fbfont_name || !strlen(fbfont_name)) |
514 | return NULL; | 514 | return NULL; |
515 | fbfont = find_font(fbfont_name); | 515 | fbfont = find_font(fbfont_name); |
516 | if (!fbfont) | 516 | if (!fbfont) |
517 | fbfont = get_default_font(1024,768); | 517 | fbfont = get_default_font(1024,768); |
518 | if (!fbfont) | 518 | if (!fbfont) |
519 | return NULL; | 519 | return NULL; |
520 | 520 | ||
521 | DPRINTK((KERN_DEBUG "selected %dx%d fb-font %s\n", | 521 | DPRINTK((KERN_DEBUG "selected %dx%d fb-font %s\n", |
522 | fbfont->width, fbfont->height, fbfont->name)); | 522 | fbfont->width, fbfont->height, fbfont->name)); |
@@ -527,7 +527,7 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) | |||
527 | 527 | ||
528 | nf = kmalloc(size, GFP_KERNEL); | 528 | nf = kmalloc(size, GFP_KERNEL); |
529 | if (!nf) | 529 | if (!nf) |
530 | return NULL; | 530 | return NULL; |
531 | memset(nf, 0, size); | 531 | memset(nf, 0, size); |
532 | 532 | ||
533 | nf->first_char = 0; | 533 | nf->first_char = 0; |
@@ -546,8 +546,8 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) | |||
546 | 546 | ||
547 | cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); | 547 | cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); |
548 | if (!cooked_font) { | 548 | if (!cooked_font) { |
549 | kfree(nf); | 549 | kfree(nf); |
550 | return NULL; | 550 | return NULL; |
551 | } | 551 | } |
552 | 552 | ||
553 | cooked_font->raw = nf; | 553 | cooked_font->raw = nf; |
@@ -595,7 +595,7 @@ sti_select_font(struct sti_cooked_rom *rom, | |||
595 | static void __init | 595 | static void __init |
596 | sti_dump_rom(struct sti_rom *rom) | 596 | sti_dump_rom(struct sti_rom *rom) |
597 | { | 597 | { |
598 | printk(KERN_INFO " id %04x-%04x, conforms to spec rev. %d.%02x\n", | 598 | printk(KERN_INFO " id %04x-%04x, conforms to spec rev. %d.%02x\n", |
599 | rom->graphics_id[0], | 599 | rom->graphics_id[0], |
600 | rom->graphics_id[1], | 600 | rom->graphics_id[1], |
601 | rom->revno[0] >> 4, | 601 | rom->revno[0] >> 4, |
@@ -651,15 +651,16 @@ sti_search_font(struct sti_cooked_rom *rom, int height, int width) | |||
651 | struct sti_cooked_font *font; | 651 | struct sti_cooked_font *font; |
652 | int i = 0; | 652 | int i = 0; |
653 | 653 | ||
654 | for(font = rom->font_start; font; font = font->next_font, i++) { | 654 | for (font = rom->font_start; font; font = font->next_font, i++) { |
655 | if((font->raw->width == width) && (font->raw->height == height)) | 655 | if ((font->raw->width == width) && |
656 | (font->raw->height == height)) | ||
656 | return i; | 657 | return i; |
657 | } | 658 | } |
658 | return 0; | 659 | return 0; |
659 | } | 660 | } |
660 | 661 | ||
661 | #define BMODE_RELOCATE(offset) offset = (offset) / 4; | 662 | #define BMODE_RELOCATE(offset) offset = (offset) / 4; |
662 | #define BMODE_LAST_ADDR_OFFS 0x50 | 663 | #define BMODE_LAST_ADDR_OFFS 0x50 |
663 | 664 | ||
664 | static void * __init | 665 | static void * __init |
665 | sti_bmode_font_raw(struct sti_cooked_font *f) | 666 | sti_bmode_font_raw(struct sti_cooked_font *f) |
@@ -700,35 +701,35 @@ sti_get_bmode_rom (unsigned long address) | |||
700 | { | 701 | { |
701 | struct sti_rom *raw; | 702 | struct sti_rom *raw; |
702 | u32 size; | 703 | u32 size; |
703 | struct sti_rom_font *raw_font, *font_start; | 704 | struct sti_rom_font *raw_font, *font_start; |
704 | 705 | ||
705 | sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size); | 706 | sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size); |
706 | 707 | ||
707 | size = (size+3) / 4; | 708 | size = (size+3) / 4; |
708 | raw = kmalloc(size, GFP_KERNEL); | 709 | raw = kmalloc(size, GFP_KERNEL); |
709 | if (raw) { | 710 | if (raw) { |
710 | sti_bmode_rom_copy(address, size, raw); | 711 | sti_bmode_rom_copy(address, size, raw); |
711 | memmove (&raw->res004, &raw->type[0], 0x3c); | 712 | memmove (&raw->res004, &raw->type[0], 0x3c); |
712 | raw->type[3] = raw->res004; | 713 | raw->type[3] = raw->res004; |
713 | 714 | ||
714 | BMODE_RELOCATE (raw->region_list); | 715 | BMODE_RELOCATE (raw->region_list); |
715 | BMODE_RELOCATE (raw->font_start); | 716 | BMODE_RELOCATE (raw->font_start); |
716 | 717 | ||
717 | BMODE_RELOCATE (raw->init_graph); | 718 | BMODE_RELOCATE (raw->init_graph); |
718 | BMODE_RELOCATE (raw->state_mgmt); | 719 | BMODE_RELOCATE (raw->state_mgmt); |
719 | BMODE_RELOCATE (raw->font_unpmv); | 720 | BMODE_RELOCATE (raw->font_unpmv); |
720 | BMODE_RELOCATE (raw->block_move); | 721 | BMODE_RELOCATE (raw->block_move); |
721 | BMODE_RELOCATE (raw->inq_conf); | 722 | BMODE_RELOCATE (raw->inq_conf); |
722 | 723 | ||
723 | raw_font = ((void *)raw) + raw->font_start; | 724 | raw_font = ((void *)raw) + raw->font_start; |
724 | font_start = raw_font; | 725 | font_start = raw_font; |
725 | 726 | ||
726 | while (raw_font->next_font) { | 727 | while (raw_font->next_font) { |
727 | BMODE_RELOCATE (raw_font->next_font); | 728 | BMODE_RELOCATE (raw_font->next_font); |
728 | raw_font = ((void *)font_start) + raw_font->next_font; | 729 | raw_font = ((void *)font_start) + raw_font->next_font; |
729 | } | 730 | } |
730 | } | 731 | } |
731 | return raw; | 732 | return raw; |
732 | } | 733 | } |
733 | 734 | ||
734 | struct sti_rom * __init | 735 | struct sti_rom * __init |
@@ -736,15 +737,15 @@ sti_get_wmode_rom (unsigned long address) | |||
736 | { | 737 | { |
737 | struct sti_rom *raw; | 738 | struct sti_rom *raw; |
738 | unsigned long size; | 739 | unsigned long size; |
739 | 740 | ||
740 | /* read the ROM size directly from the struct in ROM */ | 741 | /* read the ROM size directly from the struct in ROM */ |
741 | size = gsc_readl(address + offsetof(struct sti_rom,last_addr)); | 742 | size = gsc_readl(address + offsetof(struct sti_rom,last_addr)); |
742 | 743 | ||
743 | raw = kmalloc(size, GFP_KERNEL); | 744 | raw = kmalloc(size, GFP_KERNEL); |
744 | if(raw) | 745 | if (raw) |
745 | sti_rom_copy(address, size, raw); | 746 | sti_rom_copy(address, size, raw); |
746 | 747 | ||
747 | return raw; | 748 | return raw; |
748 | } | 749 | } |
749 | 750 | ||
750 | int __init | 751 | int __init |
@@ -757,14 +758,14 @@ sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address) | |||
757 | if (!cooked) | 758 | if (!cooked) |
758 | goto out_err; | 759 | goto out_err; |
759 | 760 | ||
760 | if (wordmode) | 761 | if (wordmode) |
761 | raw = sti_get_wmode_rom (address); | 762 | raw = sti_get_wmode_rom (address); |
762 | else | 763 | else |
763 | raw = sti_get_bmode_rom (address); | 764 | raw = sti_get_bmode_rom (address); |
765 | |||
766 | if (!raw) | ||
767 | goto out_err; | ||
764 | 768 | ||
765 | if (!raw) | ||
766 | goto out_err; | ||
767 | |||
768 | if (!sti_cook_fonts(cooked, raw)) { | 769 | if (!sti_cook_fonts(cooked, raw)) { |
769 | printk(KERN_ERR "No font found for STI at %08lx\n", address); | 770 | printk(KERN_ERR "No font found for STI at %08lx\n", address); |
770 | goto out_err; | 771 | goto out_err; |
@@ -787,7 +788,7 @@ sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address) | |||
787 | sti->font_width = sti->font->raw->width; | 788 | sti->font_width = sti->font->raw->width; |
788 | sti->font_height = sti->font->raw->height; | 789 | sti->font_height = sti->font->raw->height; |
789 | if (!wordmode) | 790 | if (!wordmode) |
790 | sti->font->raw = sti_bmode_font_raw(sti->font); | 791 | sti->font->raw = sti_bmode_font_raw(sti->font); |
791 | 792 | ||
792 | sti->sti_mem_request = raw->sti_mem_req; | 793 | sti->sti_mem_request = raw->sti_mem_req; |
793 | sti->graphics_id[0] = raw->graphics_id[0]; | 794 | sti->graphics_id[0] = raw->graphics_id[0]; |
@@ -811,16 +812,16 @@ sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd | |||
811 | u32 sig; | 812 | u32 sig; |
812 | 813 | ||
813 | if (num_sti_roms >= MAX_STI_ROMS) { | 814 | if (num_sti_roms >= MAX_STI_ROMS) { |
814 | printk(KERN_WARNING "maximum number of STI ROMS reached !\n"); | 815 | printk(KERN_WARNING "maximum number of STI ROMS reached !\n"); |
815 | return NULL; | 816 | return NULL; |
816 | } | 817 | } |
817 | 818 | ||
818 | sti = kmalloc(sizeof(*sti), GFP_KERNEL); | 819 | sti = kmalloc(sizeof(*sti), GFP_KERNEL); |
819 | if (!sti) { | 820 | if (!sti) { |
820 | printk(KERN_ERR "Not enough memory !\n"); | 821 | printk(KERN_ERR "Not enough memory !\n"); |
821 | return NULL; | 822 | return NULL; |
822 | } | 823 | } |
823 | 824 | ||
824 | memset(sti, 0, sizeof(*sti)); | 825 | memset(sti, 0, sizeof(*sti)); |
825 | spin_lock_init(&sti->lock); | 826 | spin_lock_init(&sti->lock); |
826 | 827 | ||
@@ -932,28 +933,21 @@ static void __init sticore_check_for_default_sti(struct sti_struct *sti, char *p | |||
932 | */ | 933 | */ |
933 | static int __init sticore_pa_init(struct parisc_device *dev) | 934 | static int __init sticore_pa_init(struct parisc_device *dev) |
934 | { | 935 | { |
935 | unsigned long rom = 0; | ||
936 | char pa_path[21]; | 936 | char pa_path[21]; |
937 | struct sti_struct *sti = NULL; | 937 | struct sti_struct *sti = NULL; |
938 | 938 | int hpa = dev->hpa.start; | |
939 | if(dev->num_addrs) { | 939 | |
940 | rom = dev->addr[0]; | 940 | if (dev->num_addrs && dev->addr[0]) |
941 | } | 941 | sti = sti_try_rom_generic(dev->addr[0], hpa, NULL); |
942 | if (!rom) { | 942 | if (!sti) |
943 | rom = dev->hpa; | 943 | sti = sti_try_rom_generic(hpa, hpa, NULL); |
944 | DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n", rom, dev->hpa)); | 944 | if (!sti) |
945 | sti = sti_try_rom_generic(rom, dev->hpa, NULL); | 945 | sti = sti_try_rom_generic(PAGE0->proc_sti, hpa, NULL); |
946 | rom = PAGE0->proc_sti; | ||
947 | } | ||
948 | if (!sti) { | ||
949 | DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n", rom, dev->hpa)); | ||
950 | sti = sti_try_rom_generic(rom, dev->hpa, NULL); | ||
951 | } | ||
952 | if (!sti) | 946 | if (!sti) |
953 | return 1; | 947 | return 1; |
954 | 948 | ||
955 | print_pa_hwpath(dev, pa_path); | 949 | print_pa_hwpath(dev, pa_path); |
956 | sticore_check_for_default_sti (sti, pa_path); | 950 | sticore_check_for_default_sti(sti, pa_path); |
957 | return 0; | 951 | return 0; |
958 | } | 952 | } |
959 | 953 | ||
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 70be7009f8af..9073be4221a8 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1031,7 +1031,7 @@ register_framebuffer(struct fb_info *fb_info) | |||
1031 | break; | 1031 | break; |
1032 | fb_info->node = i; | 1032 | fb_info->node = i; |
1033 | 1033 | ||
1034 | fb_info->class_device = class_device_create(fb_class, MKDEV(FB_MAJOR, i), | 1034 | fb_info->class_device = class_device_create(fb_class, NULL, MKDEV(FB_MAJOR, i), |
1035 | fb_info->device, "fb%d", i); | 1035 | fb_info->device, "fb%d", i); |
1036 | if (IS_ERR(fb_info->class_device)) { | 1036 | if (IS_ERR(fb_info->class_device)) { |
1037 | /* Not fatal */ | 1037 | /* Not fatal */ |
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 1d54d3d6960b..0b9301facbd3 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
@@ -424,23 +424,21 @@ static void imxfb_setup_gpio(struct imxfb_info *fbi) | |||
424 | * Power management hooks. Note that we won't be called from IRQ context, | 424 | * Power management hooks. Note that we won't be called from IRQ context, |
425 | * unlike the blank functions above, so we may sleep. | 425 | * unlike the blank functions above, so we may sleep. |
426 | */ | 426 | */ |
427 | static int imxfb_suspend(struct device *dev, pm_message_t state, u32 level) | 427 | static int imxfb_suspend(struct device *dev, pm_message_t state) |
428 | { | 428 | { |
429 | struct imxfb_info *fbi = dev_get_drvdata(dev); | 429 | struct imxfb_info *fbi = dev_get_drvdata(dev); |
430 | pr_debug("%s\n",__FUNCTION__); | 430 | pr_debug("%s\n",__FUNCTION__); |
431 | 431 | ||
432 | if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) | 432 | imxfb_disable_controller(fbi); |
433 | imxfb_disable_controller(fbi); | ||
434 | return 0; | 433 | return 0; |
435 | } | 434 | } |
436 | 435 | ||
437 | static int imxfb_resume(struct device *dev, u32 level) | 436 | static int imxfb_resume(struct device *dev) |
438 | { | 437 | { |
439 | struct imxfb_info *fbi = dev_get_drvdata(dev); | 438 | struct imxfb_info *fbi = dev_get_drvdata(dev); |
440 | pr_debug("%s\n",__FUNCTION__); | 439 | pr_debug("%s\n",__FUNCTION__); |
441 | 440 | ||
442 | if (level == RESUME_ENABLE) | 441 | imxfb_enable_controller(fbi); |
443 | imxfb_enable_controller(fbi); | ||
444 | return 0; | 442 | return 0; |
445 | } | 443 | } |
446 | #else | 444 | #else |
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 194eed0a238c..6206da9dd5da 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -981,21 +981,19 @@ pxafb_freq_policy(struct notifier_block *nb, unsigned long val, void *data) | |||
981 | * Power management hooks. Note that we won't be called from IRQ context, | 981 | * Power management hooks. Note that we won't be called from IRQ context, |
982 | * unlike the blank functions above, so we may sleep. | 982 | * unlike the blank functions above, so we may sleep. |
983 | */ | 983 | */ |
984 | static int pxafb_suspend(struct device *dev, pm_message_t state, u32 level) | 984 | static int pxafb_suspend(struct device *dev, pm_message_t state) |
985 | { | 985 | { |
986 | struct pxafb_info *fbi = dev_get_drvdata(dev); | 986 | struct pxafb_info *fbi = dev_get_drvdata(dev); |
987 | 987 | ||
988 | if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) | 988 | set_ctrlr_state(fbi, C_DISABLE_PM); |
989 | set_ctrlr_state(fbi, C_DISABLE_PM); | ||
990 | return 0; | 989 | return 0; |
991 | } | 990 | } |
992 | 991 | ||
993 | static int pxafb_resume(struct device *dev, u32 level) | 992 | static int pxafb_resume(struct device *dev) |
994 | { | 993 | { |
995 | struct pxafb_info *fbi = dev_get_drvdata(dev); | 994 | struct pxafb_info *fbi = dev_get_drvdata(dev); |
996 | 995 | ||
997 | if (level == RESUME_ENABLE) | 996 | set_ctrlr_state(fbi, C_ENABLE_PM); |
998 | set_ctrlr_state(fbi, C_ENABLE_PM); | ||
999 | return 0; | 997 | return 0; |
1000 | } | 998 | } |
1001 | #else | 999 | #else |
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c index fa98d91c42eb..cb2f7a1de947 100644 --- a/drivers/video/s1d13xxxfb.c +++ b/drivers/video/s1d13xxxfb.c | |||
@@ -655,7 +655,7 @@ bail: | |||
655 | } | 655 | } |
656 | 656 | ||
657 | #ifdef CONFIG_PM | 657 | #ifdef CONFIG_PM |
658 | static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state, u32 level) | 658 | static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state) |
659 | { | 659 | { |
660 | struct fb_info *info = dev_get_drvdata(dev); | 660 | struct fb_info *info = dev_get_drvdata(dev); |
661 | struct s1d13xxxfb_par *s1dfb = info->par; | 661 | struct s1d13xxxfb_par *s1dfb = info->par; |
@@ -702,15 +702,12 @@ static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state, u32 level) | |||
702 | return 0; | 702 | return 0; |
703 | } | 703 | } |
704 | 704 | ||
705 | static int s1d13xxxfb_resume(struct device *dev, u32 level) | 705 | static int s1d13xxxfb_resume(struct device *dev) |
706 | { | 706 | { |
707 | struct fb_info *info = dev_get_drvdata(dev); | 707 | struct fb_info *info = dev_get_drvdata(dev); |
708 | struct s1d13xxxfb_par *s1dfb = info->par; | 708 | struct s1d13xxxfb_par *s1dfb = info->par; |
709 | struct s1d13xxxfb_pdata *pdata = NULL; | 709 | struct s1d13xxxfb_pdata *pdata = NULL; |
710 | 710 | ||
711 | if (level != RESUME_ENABLE) | ||
712 | return 0; | ||
713 | |||
714 | /* awaken the chip */ | 711 | /* awaken the chip */ |
715 | s1d13xxxfb_writereg(s1dfb, S1DREG_PS_CNF, 0x10); | 712 | s1d13xxxfb_writereg(s1dfb, S1DREG_PS_CNF, 0x10); |
716 | 713 | ||
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index 5ab79afb53b7..3862d3cb1fb2 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c | |||
@@ -847,37 +847,32 @@ static int s3c2410fb_remove(struct device *dev) | |||
847 | 847 | ||
848 | /* suspend and resume support for the lcd controller */ | 848 | /* suspend and resume support for the lcd controller */ |
849 | 849 | ||
850 | static int s3c2410fb_suspend(struct device *dev, pm_message_t state, u32 level) | 850 | static int s3c2410fb_suspend(struct device *dev, pm_message_t state) |
851 | { | 851 | { |
852 | struct fb_info *fbinfo = dev_get_drvdata(dev); | 852 | struct fb_info *fbinfo = dev_get_drvdata(dev); |
853 | struct s3c2410fb_info *info = fbinfo->par; | 853 | struct s3c2410fb_info *info = fbinfo->par; |
854 | 854 | ||
855 | if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) { | 855 | s3c2410fb_stop_lcd(); |
856 | s3c2410fb_stop_lcd(); | ||
857 | 856 | ||
858 | /* sleep before disabling the clock, we need to ensure | 857 | /* sleep before disabling the clock, we need to ensure |
859 | * the LCD DMA engine is not going to get back on the bus | 858 | * the LCD DMA engine is not going to get back on the bus |
860 | * before the clock goes off again (bjd) */ | 859 | * before the clock goes off again (bjd) */ |
861 | 860 | ||
862 | msleep(1); | 861 | msleep(1); |
863 | clk_disable(info->clk); | 862 | clk_disable(info->clk); |
864 | } | ||
865 | 863 | ||
866 | return 0; | 864 | return 0; |
867 | } | 865 | } |
868 | 866 | ||
869 | static int s3c2410fb_resume(struct device *dev, u32 level) | 867 | static int s3c2410fb_resume(struct device *dev) |
870 | { | 868 | { |
871 | struct fb_info *fbinfo = dev_get_drvdata(dev); | 869 | struct fb_info *fbinfo = dev_get_drvdata(dev); |
872 | struct s3c2410fb_info *info = fbinfo->par; | 870 | struct s3c2410fb_info *info = fbinfo->par; |
873 | 871 | ||
874 | if (level == RESUME_ENABLE) { | 872 | clk_enable(info->clk); |
875 | clk_enable(info->clk); | 873 | msleep(1); |
876 | msleep(1); | ||
877 | |||
878 | s3c2410fb_init_registers(info); | ||
879 | 874 | ||
880 | } | 875 | s3c2410fb_init_registers(info); |
881 | 876 | ||
882 | return 0; | 877 | return 0; |
883 | } | 878 | } |
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c index 8000890e4271..78e5f194b0df 100644 --- a/drivers/video/sa1100fb.c +++ b/drivers/video/sa1100fb.c | |||
@@ -1309,21 +1309,19 @@ sa1100fb_freq_policy(struct notifier_block *nb, unsigned long val, | |||
1309 | * Power management hooks. Note that we won't be called from IRQ context, | 1309 | * Power management hooks. Note that we won't be called from IRQ context, |
1310 | * unlike the blank functions above, so we may sleep. | 1310 | * unlike the blank functions above, so we may sleep. |
1311 | */ | 1311 | */ |
1312 | static int sa1100fb_suspend(struct device *dev, pm_message_t state, u32 level) | 1312 | static int sa1100fb_suspend(struct device *dev, pm_message_t state) |
1313 | { | 1313 | { |
1314 | struct sa1100fb_info *fbi = dev_get_drvdata(dev); | 1314 | struct sa1100fb_info *fbi = dev_get_drvdata(dev); |
1315 | 1315 | ||
1316 | if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) | 1316 | set_ctrlr_state(fbi, C_DISABLE_PM); |
1317 | set_ctrlr_state(fbi, C_DISABLE_PM); | ||
1318 | return 0; | 1317 | return 0; |
1319 | } | 1318 | } |
1320 | 1319 | ||
1321 | static int sa1100fb_resume(struct device *dev, u32 level) | 1320 | static int sa1100fb_resume(struct device *dev) |
1322 | { | 1321 | { |
1323 | struct sa1100fb_info *fbi = dev_get_drvdata(dev); | 1322 | struct sa1100fb_info *fbi = dev_get_drvdata(dev); |
1324 | 1323 | ||
1325 | if (level == RESUME_ENABLE) | 1324 | set_ctrlr_state(fbi, C_ENABLE_PM); |
1326 | set_ctrlr_state(fbi, C_ENABLE_PM); | ||
1327 | return 0; | 1325 | return 0; |
1328 | } | 1326 | } |
1329 | #else | 1327 | #else |
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c index 0030c071da8f..752bf88906a9 100644 --- a/drivers/video/w100fb.c +++ b/drivers/video/w100fb.c | |||
@@ -438,36 +438,34 @@ static void w100fb_restore_vidmem(struct w100fb_par *par) | |||
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | static int w100fb_suspend(struct device *dev, pm_message_t state, uint32_t level) | 441 | static int w100fb_suspend(struct device *dev, pm_message_t state) |
442 | { | 442 | { |
443 | if (level == SUSPEND_POWER_DOWN) { | 443 | struct fb_info *info = dev_get_drvdata(dev); |
444 | struct fb_info *info = dev_get_drvdata(dev); | 444 | struct w100fb_par *par=info->par; |
445 | struct w100fb_par *par=info->par; | 445 | struct w100_tg_info *tg = par->mach->tg; |
446 | struct w100_tg_info *tg = par->mach->tg; | 446 | |
447 | 447 | w100fb_save_vidmem(par); | |
448 | w100fb_save_vidmem(par); | 448 | if(tg && tg->suspend) |
449 | if(tg && tg->suspend) | 449 | tg->suspend(par); |
450 | tg->suspend(par); | 450 | w100_suspend(W100_SUSPEND_ALL); |
451 | w100_suspend(W100_SUSPEND_ALL); | 451 | par->blanked = 1; |
452 | par->blanked = 1; | 452 | |
453 | } | ||
454 | return 0; | 453 | return 0; |
455 | } | 454 | } |
456 | 455 | ||
457 | static int w100fb_resume(struct device *dev, uint32_t level) | 456 | static int w100fb_resume(struct device *dev) |
458 | { | 457 | { |
459 | if (level == RESUME_POWER_ON) { | 458 | struct fb_info *info = dev_get_drvdata(dev); |
460 | struct fb_info *info = dev_get_drvdata(dev); | 459 | struct w100fb_par *par=info->par; |
461 | struct w100fb_par *par=info->par; | 460 | struct w100_tg_info *tg = par->mach->tg; |
462 | struct w100_tg_info *tg = par->mach->tg; | 461 | |
462 | w100_hw_init(par); | ||
463 | w100fb_activate_var(par); | ||
464 | w100fb_restore_vidmem(par); | ||
465 | if(tg && tg->resume) | ||
466 | tg->resume(par); | ||
467 | par->blanked = 0; | ||
463 | 468 | ||
464 | w100_hw_init(par); | ||
465 | w100fb_activate_var(par); | ||
466 | w100fb_restore_vidmem(par); | ||
467 | if(tg && tg->resume) | ||
468 | tg->resume(par); | ||
469 | par->blanked = 0; | ||
470 | } | ||
471 | return 0; | 469 | return 0; |
472 | } | 470 | } |
473 | #else | 471 | #else |