aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-roccat-pyra.c
diff options
context:
space:
mode:
authorStefan Achatz <erazor_de@users.sourceforge.net>2010-11-26 14:57:33 -0500
committerJiri Kosina <jkosina@suse.cz>2011-01-07 19:11:00 -0500
commit5012aada506cb8b570e46579077c0ec5b82ebd5d (patch)
treecf2d49567af63b16f7cdbef80ae5662938bd539c /drivers/hid/hid-roccat-pyra.c
parentc97415a72521071c235e0879f9a600014afd87b1 (diff)
HID: roccat: use class for char device for sysfs attribute creation
Adding sysfs attributes to an already created device raises no userland notification. Now the device drivers associate the devices attributes with a class and use this for roccat event char device creation. Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-roccat-pyra.c')
-rw-r--r--drivers/hid/hid-roccat-pyra.c273
1 files changed, 74 insertions, 199 deletions
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c
index e7b4affe2664..7273e1e9093d 100644
--- a/drivers/hid/hid-roccat-pyra.c
+++ b/drivers/hid/hid-roccat-pyra.c
@@ -27,6 +27,9 @@
27#include "hid-roccat.h" 27#include "hid-roccat.h"
28#include "hid-roccat-pyra.h" 28#include "hid-roccat-pyra.h"
29 29
30/* pyra_class is used for creating sysfs attributes via roccat char device */
31static struct class *pyra_class;
32
30static void profile_activated(struct pyra_device *pyra, 33static void profile_activated(struct pyra_device *pyra,
31 unsigned int new_profile) 34 unsigned int new_profile)
32{ 35{
@@ -222,7 +225,8 @@ static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp,
222 struct kobject *kobj, struct bin_attribute *attr, char *buf, 225 struct kobject *kobj, struct bin_attribute *attr, char *buf,
223 loff_t off, size_t count, int number) 226 loff_t off, size_t count, int number)
224{ 227{
225 struct device *dev = container_of(kobj, struct device, kobj); 228 struct device *dev =
229 container_of(kobj, struct device, kobj)->parent->parent;
226 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 230 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
227 231
228 if (off >= sizeof(struct pyra_profile_settings)) 232 if (off >= sizeof(struct pyra_profile_settings))
@@ -283,7 +287,8 @@ static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp,
283 struct kobject *kobj, struct bin_attribute *attr, char *buf, 287 struct kobject *kobj, struct bin_attribute *attr, char *buf,
284 loff_t off, size_t count, int number) 288 loff_t off, size_t count, int number)
285{ 289{
286 struct device *dev = container_of(kobj, struct device, kobj); 290 struct device *dev =
291 container_of(kobj, struct device, kobj)->parent->parent;
287 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 292 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
288 293
289 if (off >= sizeof(struct pyra_profile_buttons)) 294 if (off >= sizeof(struct pyra_profile_buttons))
@@ -344,7 +349,8 @@ static ssize_t pyra_sysfs_write_profile_settings(struct file *fp,
344 struct kobject *kobj, struct bin_attribute *attr, char *buf, 349 struct kobject *kobj, struct bin_attribute *attr, char *buf,
345 loff_t off, size_t count) 350 loff_t off, size_t count)
346{ 351{
347 struct device *dev = container_of(kobj, struct device, kobj); 352 struct device *dev =
353 container_of(kobj, struct device, kobj)->parent->parent;
348 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 354 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
349 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); 355 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
350 int retval = 0; 356 int retval = 0;
@@ -380,7 +386,8 @@ static ssize_t pyra_sysfs_write_profile_buttons(struct file *fp,
380 struct kobject *kobj, struct bin_attribute *attr, char *buf, 386 struct kobject *kobj, struct bin_attribute *attr, char *buf,
381 loff_t off, size_t count) 387 loff_t off, size_t count)
382{ 388{
383 struct device *dev = container_of(kobj, struct device, kobj); 389 struct device *dev =
390 container_of(kobj, struct device, kobj)->parent->parent;
384 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 391 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
385 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); 392 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
386 int retval = 0; 393 int retval = 0;
@@ -416,7 +423,8 @@ static ssize_t pyra_sysfs_read_settings(struct file *fp,
416 struct kobject *kobj, struct bin_attribute *attr, char *buf, 423 struct kobject *kobj, struct bin_attribute *attr, char *buf,
417 loff_t off, size_t count) 424 loff_t off, size_t count)
418{ 425{
419 struct device *dev = container_of(kobj, struct device, kobj); 426 struct device *dev =
427 container_of(kobj, struct device, kobj)->parent->parent;
420 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 428 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
421 429
422 if (off >= sizeof(struct pyra_settings)) 430 if (off >= sizeof(struct pyra_settings))
@@ -436,7 +444,8 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp,
436 struct kobject *kobj, struct bin_attribute *attr, char *buf, 444 struct kobject *kobj, struct bin_attribute *attr, char *buf,
437 loff_t off, size_t count) 445 loff_t off, size_t count)
438{ 446{
439 struct device *dev = container_of(kobj, struct device, kobj); 447 struct device *dev =
448 container_of(kobj, struct device, kobj)->parent->parent;
440 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 449 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
441 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); 450 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
442 int retval = 0; 451 int retval = 0;
@@ -468,255 +477,115 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp,
468static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, 477static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
469 struct device_attribute *attr, char *buf) 478 struct device_attribute *attr, char *buf)
470{ 479{
471 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 480 struct pyra_device *pyra =
481 hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
472 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi); 482 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
473} 483}
474 484
475static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, 485static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
476 struct device_attribute *attr, char *buf) 486 struct device_attribute *attr, char *buf)
477{ 487{
478 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 488 struct pyra_device *pyra =
489 hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
479 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_profile); 490 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_profile);
480} 491}
481 492
482static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, 493static ssize_t pyra_sysfs_show_firmware_version(struct device *dev,
483 struct device_attribute *attr, char *buf) 494 struct device_attribute *attr, char *buf)
484{ 495{
485 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 496 struct pyra_device *pyra =
497 hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
486 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->firmware_version); 498 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->firmware_version);
487} 499}
488 500
489static ssize_t pyra_sysfs_show_startup_profile(struct device *dev, 501static ssize_t pyra_sysfs_show_startup_profile(struct device *dev,
490 struct device_attribute *attr, char *buf) 502 struct device_attribute *attr, char *buf)
491{ 503{
492 struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); 504 struct pyra_device *pyra =
505 hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
493 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->settings.startup_profile); 506 return snprintf(buf, PAGE_SIZE, "%d\n", pyra->settings.startup_profile);
494} 507}
495 508
496static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL); 509static struct device_attribute pyra_attributes[] = {
497 510 __ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL),
498static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL); 511 __ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL),
499 512 __ATTR(firmware_version, 0440,
500static DEVICE_ATTR(firmware_version, 0440, 513 pyra_sysfs_show_firmware_version, NULL),
501 pyra_sysfs_show_firmware_version, NULL); 514 __ATTR(startup_profile, 0440,
502 515 pyra_sysfs_show_startup_profile, NULL),
503static DEVICE_ATTR(startup_profile, 0440, 516 __ATTR_NULL
504 pyra_sysfs_show_startup_profile, NULL);
505
506static struct attribute *pyra_attributes[] = {
507 &dev_attr_actual_cpi.attr,
508 &dev_attr_actual_profile.attr,
509 &dev_attr_firmware_version.attr,
510 &dev_attr_startup_profile.attr,
511 NULL
512};
513
514static struct attribute_group pyra_attribute_group = {
515 .attrs = pyra_attributes
516}; 517};
517 518
518static struct bin_attribute pyra_profile_settings_attr = { 519static struct bin_attribute pyra_bin_attributes[] = {
520 {
519 .attr = { .name = "profile_settings", .mode = 0220 }, 521 .attr = { .name = "profile_settings", .mode = 0220 },
520 .size = sizeof(struct pyra_profile_settings), 522 .size = sizeof(struct pyra_profile_settings),
521 .write = pyra_sysfs_write_profile_settings 523 .write = pyra_sysfs_write_profile_settings
522}; 524 },
523 525 {
524static struct bin_attribute pyra_profile1_settings_attr = {
525 .attr = { .name = "profile1_settings", .mode = 0440 }, 526 .attr = { .name = "profile1_settings", .mode = 0440 },
526 .size = sizeof(struct pyra_profile_settings), 527 .size = sizeof(struct pyra_profile_settings),
527 .read = pyra_sysfs_read_profile1_settings 528 .read = pyra_sysfs_read_profile1_settings
528}; 529 },
529 530 {
530static struct bin_attribute pyra_profile2_settings_attr = {
531 .attr = { .name = "profile2_settings", .mode = 0440 }, 531 .attr = { .name = "profile2_settings", .mode = 0440 },
532 .size = sizeof(struct pyra_profile_settings), 532 .size = sizeof(struct pyra_profile_settings),
533 .read = pyra_sysfs_read_profile2_settings 533 .read = pyra_sysfs_read_profile2_settings
534}; 534 },
535 535 {
536static struct bin_attribute pyra_profile3_settings_attr = {
537 .attr = { .name = "profile3_settings", .mode = 0440 }, 536 .attr = { .name = "profile3_settings", .mode = 0440 },
538 .size = sizeof(struct pyra_profile_settings), 537 .size = sizeof(struct pyra_profile_settings),
539 .read = pyra_sysfs_read_profile3_settings 538 .read = pyra_sysfs_read_profile3_settings
540}; 539 },
541 540 {
542static struct bin_attribute pyra_profile4_settings_attr = {
543 .attr = { .name = "profile4_settings", .mode = 0440 }, 541 .attr = { .name = "profile4_settings", .mode = 0440 },
544 .size = sizeof(struct pyra_profile_settings), 542 .size = sizeof(struct pyra_profile_settings),
545 .read = pyra_sysfs_read_profile4_settings 543 .read = pyra_sysfs_read_profile4_settings
546}; 544 },
547 545 {
548static struct bin_attribute pyra_profile5_settings_attr = {
549 .attr = { .name = "profile5_settings", .mode = 0440 }, 546 .attr = { .name = "profile5_settings", .mode = 0440 },
550 .size = sizeof(struct pyra_profile_settings), 547 .size = sizeof(struct pyra_profile_settings),
551 .read = pyra_sysfs_read_profile5_settings 548 .read = pyra_sysfs_read_profile5_settings
552}; 549 },
553 550 {
554static struct bin_attribute pyra_profile_buttons_attr = {
555 .attr = { .name = "profile_buttons", .mode = 0220 }, 551 .attr = { .name = "profile_buttons", .mode = 0220 },
556 .size = sizeof(struct pyra_profile_buttons), 552 .size = sizeof(struct pyra_profile_buttons),
557 .write = pyra_sysfs_write_profile_buttons 553 .write = pyra_sysfs_write_profile_buttons
558}; 554 },
559 555 {
560static struct bin_attribute pyra_profile1_buttons_attr = {
561 .attr = { .name = "profile1_buttons", .mode = 0440 }, 556 .attr = { .name = "profile1_buttons", .mode = 0440 },
562 .size = sizeof(struct pyra_profile_buttons), 557 .size = sizeof(struct pyra_profile_buttons),
563 .read = pyra_sysfs_read_profile1_buttons 558 .read = pyra_sysfs_read_profile1_buttons
564}; 559 },
565 560 {
566static struct bin_attribute pyra_profile2_buttons_attr = {
567 .attr = { .name = "profile2_buttons", .mode = 0440 }, 561 .attr = { .name = "profile2_buttons", .mode = 0440 },
568 .size = sizeof(struct pyra_profile_buttons), 562 .size = sizeof(struct pyra_profile_buttons),
569 .read = pyra_sysfs_read_profile2_buttons 563 .read = pyra_sysfs_read_profile2_buttons
570}; 564 },
571 565 {
572static struct bin_attribute pyra_profile3_buttons_attr = {
573 .attr = { .name = "profile3_buttons", .mode = 0440 }, 566 .attr = { .name = "profile3_buttons", .mode = 0440 },
574 .size = sizeof(struct pyra_profile_buttons), 567 .size = sizeof(struct pyra_profile_buttons),
575 .read = pyra_sysfs_read_profile3_buttons 568 .read = pyra_sysfs_read_profile3_buttons
576}; 569 },
577 570 {
578static struct bin_attribute pyra_profile4_buttons_attr = {
579 .attr = { .name = "profile4_buttons", .mode = 0440 }, 571 .attr = { .name = "profile4_buttons", .mode = 0440 },
580 .size = sizeof(struct pyra_profile_buttons), 572 .size = sizeof(struct pyra_profile_buttons),
581 .read = pyra_sysfs_read_profile4_buttons 573 .read = pyra_sysfs_read_profile4_buttons
582}; 574 },
583 575 {
584static struct bin_attribute pyra_profile5_buttons_attr = {
585 .attr = { .name = "profile5_buttons", .mode = 0440 }, 576 .attr = { .name = "profile5_buttons", .mode = 0440 },
586 .size = sizeof(struct pyra_profile_buttons), 577 .size = sizeof(struct pyra_profile_buttons),
587 .read = pyra_sysfs_read_profile5_buttons 578 .read = pyra_sysfs_read_profile5_buttons
588}; 579 },
589 580 {
590static struct bin_attribute pyra_settings_attr = {
591 .attr = { .name = "settings", .mode = 0660 }, 581 .attr = { .name = "settings", .mode = 0660 },
592 .size = sizeof(struct pyra_settings), 582 .size = sizeof(struct pyra_settings),
593 .read = pyra_sysfs_read_settings, 583 .read = pyra_sysfs_read_settings,
594 .write = pyra_sysfs_write_settings 584 .write = pyra_sysfs_write_settings
585 },
586 __ATTR_NULL
595}; 587};
596 588
597static int pyra_create_sysfs_attributes(struct usb_interface *intf)
598{
599 int retval;
600
601 retval = sysfs_create_group(&intf->dev.kobj, &pyra_attribute_group);
602 if (retval)
603 goto exit_1;
604
605 retval = sysfs_create_bin_file(&intf->dev.kobj,
606 &pyra_profile_settings_attr);
607 if (retval)
608 goto exit_2;
609
610 retval = sysfs_create_bin_file(&intf->dev.kobj,
611 &pyra_profile1_settings_attr);
612 if (retval)
613 goto exit_3;
614
615 retval = sysfs_create_bin_file(&intf->dev.kobj,
616 &pyra_profile2_settings_attr);
617 if (retval)
618 goto exit_4;
619
620 retval = sysfs_create_bin_file(&intf->dev.kobj,
621 &pyra_profile3_settings_attr);
622 if (retval)
623 goto exit_5;
624
625 retval = sysfs_create_bin_file(&intf->dev.kobj,
626 &pyra_profile4_settings_attr);
627 if (retval)
628 goto exit_6;
629
630 retval = sysfs_create_bin_file(&intf->dev.kobj,
631 &pyra_profile5_settings_attr);
632 if (retval)
633 goto exit_7;
634
635 retval = sysfs_create_bin_file(&intf->dev.kobj,
636 &pyra_profile_buttons_attr);
637 if (retval)
638 goto exit_8;
639
640 retval = sysfs_create_bin_file(&intf->dev.kobj,
641 &pyra_profile1_buttons_attr);
642 if (retval)
643 goto exit_9;
644
645 retval = sysfs_create_bin_file(&intf->dev.kobj,
646 &pyra_profile2_buttons_attr);
647 if (retval)
648 goto exit_10;
649
650 retval = sysfs_create_bin_file(&intf->dev.kobj,
651 &pyra_profile3_buttons_attr);
652 if (retval)
653 goto exit_11;
654
655 retval = sysfs_create_bin_file(&intf->dev.kobj,
656 &pyra_profile4_buttons_attr);
657 if (retval)
658 goto exit_12;
659
660 retval = sysfs_create_bin_file(&intf->dev.kobj,
661 &pyra_profile5_buttons_attr);
662 if (retval)
663 goto exit_13;
664
665 retval = sysfs_create_bin_file(&intf->dev.kobj,
666 &pyra_settings_attr);
667 if (retval)
668 goto exit_14;
669
670 return 0;
671
672exit_14:
673 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_buttons_attr);
674exit_13:
675 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_buttons_attr);
676exit_12:
677 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_buttons_attr);
678exit_11:
679 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_buttons_attr);
680exit_10:
681 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_buttons_attr);
682exit_9:
683 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_buttons_attr);
684exit_8:
685 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_settings_attr);
686exit_7:
687 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_settings_attr);
688exit_6:
689 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_settings_attr);
690exit_5:
691 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_settings_attr);
692exit_4:
693 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_settings_attr);
694exit_3:
695 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_settings_attr);
696exit_2:
697 sysfs_remove_group(&intf->dev.kobj, &pyra_attribute_group);
698exit_1:
699 return retval;
700}
701
702static void pyra_remove_sysfs_attributes(struct usb_interface *intf)
703{
704 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_settings_attr);
705 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_buttons_attr);
706 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_buttons_attr);
707 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_buttons_attr);
708 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_buttons_attr);
709 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_buttons_attr);
710 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_buttons_attr);
711 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_settings_attr);
712 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_settings_attr);
713 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_settings_attr);
714 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_settings_attr);
715 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_settings_attr);
716 sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_settings_attr);
717 sysfs_remove_group(&intf->dev.kobj, &pyra_attribute_group);
718}
719
720static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, 589static int pyra_init_pyra_device_struct(struct usb_device *usb_dev,
721 struct pyra_device *pyra) 590 struct pyra_device *pyra)
722{ 591{
@@ -780,19 +649,13 @@ static int pyra_init_specials(struct hid_device *hdev)
780 goto exit_free; 649 goto exit_free;
781 } 650 }
782 651
783 retval = roccat_connect(hdev); 652 retval = roccat_connect(pyra_class, hdev);
784 if (retval < 0) { 653 if (retval < 0) {
785 hid_err(hdev, "couldn't init char dev\n"); 654 hid_err(hdev, "couldn't init char dev\n");
786 } else { 655 } else {
787 pyra->chrdev_minor = retval; 656 pyra->chrdev_minor = retval;
788 pyra->roccat_claimed = 1; 657 pyra->roccat_claimed = 1;
789 } 658 }
790
791 retval = pyra_create_sysfs_attributes(intf);
792 if (retval) {
793 hid_err(hdev, "cannot create sysfs files\n");
794 goto exit_free;
795 }
796 } else { 659 } else {
797 hid_set_drvdata(hdev, NULL); 660 hid_set_drvdata(hdev, NULL);
798 } 661 }
@@ -810,7 +673,6 @@ static void pyra_remove_specials(struct hid_device *hdev)
810 673
811 if (intf->cur_altsetting->desc.bInterfaceProtocol 674 if (intf->cur_altsetting->desc.bInterfaceProtocol
812 == USB_INTERFACE_PROTOCOL_MOUSE) { 675 == USB_INTERFACE_PROTOCOL_MOUSE) {
813 pyra_remove_sysfs_attributes(intf);
814 pyra = hid_get_drvdata(hdev); 676 pyra = hid_get_drvdata(hdev);
815 if (pyra->roccat_claimed) 677 if (pyra->roccat_claimed)
816 roccat_disconnect(pyra->chrdev_minor); 678 roccat_disconnect(pyra->chrdev_minor);
@@ -950,11 +812,24 @@ static struct hid_driver pyra_driver = {
950 812
951static int __init pyra_init(void) 813static int __init pyra_init(void)
952{ 814{
953 return hid_register_driver(&pyra_driver); 815 int retval;
816
817 /* class name has to be same as driver name */
818 pyra_class = class_create(THIS_MODULE, "pyra");
819 if (IS_ERR(pyra_class))
820 return PTR_ERR(pyra_class);
821 pyra_class->dev_attrs = pyra_attributes;
822 pyra_class->dev_bin_attrs = pyra_bin_attributes;
823
824 retval = hid_register_driver(&pyra_driver);
825 if (retval)
826 class_destroy(pyra_class);
827 return retval;
954} 828}
955 829
956static void __exit pyra_exit(void) 830static void __exit pyra_exit(void)
957{ 831{
832 class_destroy(pyra_class);
958 hid_unregister_driver(&pyra_driver); 833 hid_unregister_driver(&pyra_driver);
959} 834}
960 835