Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-6.6/roccat' into for-linus

Constify class struct by Ivan Orlov and Greg Kroah-Hartman

+117 -98
+11 -9
drivers/hid/hid-roccat-arvo.c
··· 23 23 #include "hid-roccat-common.h" 24 24 #include "hid-roccat-arvo.h" 25 25 26 - static struct class *arvo_class; 27 - 28 26 static ssize_t arvo_sysfs_show_mode_key(struct device *dev, 29 27 struct device_attribute *attr, char *buf) 30 28 { ··· 266 268 NULL, 267 269 }; 268 270 271 + static const struct class arvo_class = { 272 + .name = "arvo", 273 + .dev_groups = arvo_groups, 274 + }; 275 + 269 276 static int arvo_init_arvo_device_struct(struct usb_device *usb_dev, 270 277 struct arvo_device *arvo) 271 278 { ··· 312 309 goto exit_free; 313 310 } 314 311 315 - retval = roccat_connect(arvo_class, hdev, 312 + retval = roccat_connect(&arvo_class, hdev, 316 313 sizeof(struct arvo_roccat_report)); 317 314 if (retval < 0) { 318 315 hid_err(hdev, "couldn't init char dev\n"); ··· 436 433 { 437 434 int retval; 438 435 439 - arvo_class = class_create("arvo"); 440 - if (IS_ERR(arvo_class)) 441 - return PTR_ERR(arvo_class); 442 - arvo_class->dev_groups = arvo_groups; 436 + retval = class_register(&arvo_class); 437 + if (retval) 438 + return retval; 443 439 444 440 retval = hid_register_driver(&arvo_driver); 445 441 if (retval) 446 - class_destroy(arvo_class); 442 + class_unregister(&arvo_class); 447 443 return retval; 448 444 } 449 445 450 446 static void __exit arvo_exit(void) 451 447 { 452 448 hid_unregister_driver(&arvo_driver); 453 - class_destroy(arvo_class); 449 + class_unregister(&arvo_class); 454 450 } 455 451 456 452 module_init(arvo_init);
+12 -9
drivers/hid/hid-roccat-isku.c
··· 23 23 #include "hid-roccat-common.h" 24 24 #include "hid-roccat-isku.h" 25 25 26 - static struct class *isku_class; 27 - 28 26 static void isku_profile_activated(struct isku_device *isku, uint new_profile) 29 27 { 30 28 isku->actual_profile = new_profile; ··· 246 248 NULL, 247 249 }; 248 250 251 + static const struct class isku_class = { 252 + .name = "isku", 253 + .dev_groups = isku_groups, 254 + }; 255 + 249 256 static int isku_init_isku_device_struct(struct usb_device *usb_dev, 250 257 struct isku_device *isku) 251 258 { ··· 292 289 goto exit_free; 293 290 } 294 291 295 - retval = roccat_connect(isku_class, hdev, 292 + retval = roccat_connect(&isku_class, hdev, 296 293 sizeof(struct isku_roccat_report)); 297 294 if (retval < 0) { 298 295 hid_err(hdev, "couldn't init char dev\n"); ··· 438 435 static int __init isku_init(void) 439 436 { 440 437 int retval; 441 - isku_class = class_create("isku"); 442 - if (IS_ERR(isku_class)) 443 - return PTR_ERR(isku_class); 444 - isku_class->dev_groups = isku_groups; 438 + 439 + retval = class_register(&isku_class); 440 + if (retval) 441 + return retval; 445 442 446 443 retval = hid_register_driver(&isku_driver); 447 444 if (retval) 448 - class_destroy(isku_class); 445 + class_unregister(&isku_class); 449 446 return retval; 450 447 } 451 448 452 449 static void __exit isku_exit(void) 453 450 { 454 451 hid_unregister_driver(&isku_driver); 455 - class_destroy(isku_class); 452 + class_unregister(&isku_class); 456 453 } 457 454 458 455 module_init(isku_init);
+13 -11
drivers/hid/hid-roccat-kone.c
··· 89 89 return ((len < 0) ? len : ((len != size) ? -EIO : 0)); 90 90 } 91 91 92 - /* kone_class is used for creating sysfs attributes via roccat char device */ 93 - static struct class *kone_class; 94 - 95 92 static void kone_set_settings_checksum(struct kone_settings *settings) 96 93 { 97 94 uint16_t checksum = 0; ··· 654 657 NULL, 655 658 }; 656 659 660 + /* kone_class is used for creating sysfs attributes via roccat char device */ 661 + static const struct class kone_class = { 662 + .name = "kone", 663 + .dev_groups = kone_groups, 664 + }; 665 + 657 666 static int kone_init_kone_device_struct(struct usb_device *usb_dev, 658 667 struct kone_device *kone) 659 668 { ··· 715 712 goto exit_free; 716 713 } 717 714 718 - retval = roccat_connect(kone_class, hdev, 719 - sizeof(struct kone_roccat_report)); 715 + retval = roccat_connect(&kone_class, hdev, 716 + sizeof(struct kone_roccat_report)); 720 717 if (retval < 0) { 721 718 hid_err(hdev, "couldn't init char dev\n"); 722 719 /* be tolerant about not getting chrdev */ ··· 893 890 int retval; 894 891 895 892 /* class name has to be same as driver name */ 896 - kone_class = class_create("kone"); 897 - if (IS_ERR(kone_class)) 898 - return PTR_ERR(kone_class); 899 - kone_class->dev_groups = kone_groups; 893 + retval = class_register(&kone_class); 894 + if (retval) 895 + return retval; 900 896 901 897 retval = hid_register_driver(&kone_driver); 902 898 if (retval) 903 - class_destroy(kone_class); 899 + class_unregister(&kone_class); 904 900 return retval; 905 901 } 906 902 907 903 static void __exit kone_exit(void) 908 904 { 909 905 hid_unregister_driver(&kone_driver); 910 - class_destroy(kone_class); 906 + class_unregister(&kone_class); 911 907 } 912 908 913 909 module_init(kone_init);
+12 -10
drivers/hid/hid-roccat-koneplus.c
··· 26 26 27 27 static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 28 28 29 - static struct class *koneplus_class; 30 - 31 29 static void koneplus_profile_activated(struct koneplus_device *koneplus, 32 30 uint new_profile) 33 31 { ··· 354 356 NULL, 355 357 }; 356 358 359 + static const struct class koneplus_class = { 360 + .name = "koneplus", 361 + .dev_groups = koneplus_groups, 362 + }; 363 + 357 364 static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, 358 365 struct koneplus_device *koneplus) 359 366 { ··· 397 394 goto exit_free; 398 395 } 399 396 400 - retval = roccat_connect(koneplus_class, hdev, 401 - sizeof(struct koneplus_roccat_report)); 397 + retval = roccat_connect(&koneplus_class, hdev, 398 + sizeof(struct koneplus_roccat_report)); 402 399 if (retval < 0) { 403 400 hid_err(hdev, "couldn't init char dev\n"); 404 401 } else { ··· 552 549 int retval; 553 550 554 551 /* class name has to be same as driver name */ 555 - koneplus_class = class_create("koneplus"); 556 - if (IS_ERR(koneplus_class)) 557 - return PTR_ERR(koneplus_class); 558 - koneplus_class->dev_groups = koneplus_groups; 552 + retval = class_register(&koneplus_class); 553 + if (retval) 554 + return retval; 559 555 560 556 retval = hid_register_driver(&koneplus_driver); 561 557 if (retval) 562 - class_destroy(koneplus_class); 558 + class_unregister(&koneplus_class); 563 559 return retval; 564 560 } 565 561 566 562 static void __exit koneplus_exit(void) 567 563 { 568 564 hid_unregister_driver(&koneplus_driver); 569 - class_destroy(koneplus_class); 565 + class_unregister(&koneplus_class); 570 566 } 571 567 572 568 module_init(koneplus_init);
+12 -10
drivers/hid/hid-roccat-konepure.c
··· 36 36 uint8_t unknown[2]; 37 37 } __packed; 38 38 39 - static struct class *konepure_class; 40 - 41 39 ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x04, 0x03); 42 40 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(actual_profile, 0x05, 0x03); 43 41 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile_settings, 0x06, 0x1f); ··· 70 72 NULL, 71 73 }; 72 74 75 + static const struct class konepure_class = { 76 + .name = "konepure", 77 + .dev_groups = konepure_groups, 78 + }; 79 + 73 80 static int konepure_init_specials(struct hid_device *hdev) 74 81 { 75 82 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ··· 101 98 goto exit_free; 102 99 } 103 100 104 - retval = roccat_connect(konepure_class, hdev, 105 - sizeof(struct konepure_mouse_report_button)); 101 + retval = roccat_connect(&konepure_class, hdev, 102 + sizeof(struct konepure_mouse_report_button)); 106 103 if (retval < 0) { 107 104 hid_err(hdev, "couldn't init char dev\n"); 108 105 } else { ··· 210 207 { 211 208 int retval; 212 209 213 - konepure_class = class_create("konepure"); 214 - if (IS_ERR(konepure_class)) 215 - return PTR_ERR(konepure_class); 216 - konepure_class->dev_groups = konepure_groups; 210 + retval = class_register(&konepure_class); 211 + if (retval) 212 + return retval; 217 213 218 214 retval = hid_register_driver(&konepure_driver); 219 215 if (retval) 220 - class_destroy(konepure_class); 216 + class_unregister(&konepure_class); 221 217 return retval; 222 218 } 223 219 224 220 static void __exit konepure_exit(void) 225 221 { 226 222 hid_unregister_driver(&konepure_driver); 227 - class_destroy(konepure_class); 223 + class_unregister(&konepure_class); 228 224 } 229 225 230 226 module_init(konepure_init);
+12 -10
drivers/hid/hid-roccat-kovaplus.c
··· 24 24 25 25 static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 26 26 27 - static struct class *kovaplus_class; 28 - 29 27 static uint kovaplus_convert_event_cpi(uint value) 30 28 { 31 29 return (value == 7 ? 4 : (value == 4 ? 3 : value)); ··· 407 409 NULL, 408 410 }; 409 411 412 + static const struct class kovaplus_class = { 413 + .name = "kovaplus", 414 + .dev_groups = kovaplus_groups, 415 + }; 416 + 410 417 static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev, 411 418 struct kovaplus_device *kovaplus) 412 419 { ··· 466 463 goto exit_free; 467 464 } 468 465 469 - retval = roccat_connect(kovaplus_class, hdev, 470 - sizeof(struct kovaplus_roccat_report)); 466 + retval = roccat_connect(&kovaplus_class, hdev, 467 + sizeof(struct kovaplus_roccat_report)); 471 468 if (retval < 0) { 472 469 hid_err(hdev, "couldn't init char dev\n"); 473 470 } else { ··· 641 638 { 642 639 int retval; 643 640 644 - kovaplus_class = class_create("kovaplus"); 645 - if (IS_ERR(kovaplus_class)) 646 - return PTR_ERR(kovaplus_class); 647 - kovaplus_class->dev_groups = kovaplus_groups; 641 + retval = class_register(&kovaplus_class); 642 + if (retval) 643 + return retval; 648 644 649 645 retval = hid_register_driver(&kovaplus_driver); 650 646 if (retval) 651 - class_destroy(kovaplus_class); 647 + class_unregister(&kovaplus_class); 652 648 return retval; 653 649 } 654 650 655 651 static void __exit kovaplus_exit(void) 656 652 { 657 653 hid_unregister_driver(&kovaplus_driver); 658 - class_destroy(kovaplus_class); 654 + class_unregister(&kovaplus_class); 659 655 } 660 656 661 657 module_init(kovaplus_init);
+12 -10
drivers/hid/hid-roccat-pyra.c
··· 26 26 27 27 static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 28 28 29 - /* pyra_class is used for creating sysfs attributes via roccat char device */ 30 - static struct class *pyra_class; 31 - 32 29 static void profile_activated(struct pyra_device *pyra, 33 30 unsigned int new_profile) 34 31 { ··· 363 366 NULL, 364 367 }; 365 368 369 + /* pyra_class is used for creating sysfs attributes via roccat char device */ 370 + static const struct class pyra_class = { 371 + .name = "pyra", 372 + .dev_groups = pyra_groups, 373 + }; 374 + 366 375 static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, 367 376 struct pyra_device *pyra) 368 377 { ··· 416 413 goto exit_free; 417 414 } 418 415 419 - retval = roccat_connect(pyra_class, hdev, 416 + retval = roccat_connect(&pyra_class, hdev, 420 417 sizeof(struct pyra_roccat_report)); 421 418 if (retval < 0) { 422 419 hid_err(hdev, "couldn't init char dev\n"); ··· 588 585 int retval; 589 586 590 587 /* class name has to be same as driver name */ 591 - pyra_class = class_create("pyra"); 592 - if (IS_ERR(pyra_class)) 593 - return PTR_ERR(pyra_class); 594 - pyra_class->dev_groups = pyra_groups; 588 + retval = class_register(&pyra_class); 589 + if (retval) 590 + return retval; 595 591 596 592 retval = hid_register_driver(&pyra_driver); 597 593 if (retval) 598 - class_destroy(pyra_class); 594 + class_unregister(&pyra_class); 599 595 return retval; 600 596 } 601 597 602 598 static void __exit pyra_exit(void) 603 599 { 604 600 hid_unregister_driver(&pyra_driver); 605 - class_destroy(pyra_class); 601 + class_unregister(&pyra_class); 606 602 } 607 603 608 604 module_init(pyra_init);
+11 -9
drivers/hid/hid-roccat-ryos.c
··· 28 28 uint8_t data[4]; 29 29 } __packed; 30 30 31 - static struct class *ryos_class; 32 - 33 31 ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x04, 0x03); 34 32 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile, 0x05, 0x03); 35 33 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(keys_primary, 0x06, 0x7d); ··· 78 80 NULL, 79 81 }; 80 82 83 + static const struct class ryos_class = { 84 + .name = "ryos", 85 + .dev_groups = ryos_groups, 86 + }; 87 + 81 88 static int ryos_init_specials(struct hid_device *hdev) 82 89 { 83 90 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ··· 109 106 goto exit_free; 110 107 } 111 108 112 - retval = roccat_connect(ryos_class, hdev, 109 + retval = roccat_connect(&ryos_class, hdev, 113 110 sizeof(struct ryos_report_special)); 114 111 if (retval < 0) { 115 112 hid_err(hdev, "couldn't init char dev\n"); ··· 219 216 { 220 217 int retval; 221 218 222 - ryos_class = class_create("ryos"); 223 - if (IS_ERR(ryos_class)) 224 - return PTR_ERR(ryos_class); 225 - ryos_class->dev_groups = ryos_groups; 219 + retval = class_register(&ryos_class); 220 + if (retval) 221 + return retval; 226 222 227 223 retval = hid_register_driver(&ryos_driver); 228 224 if (retval) 229 - class_destroy(ryos_class); 225 + class_unregister(&ryos_class); 230 226 return retval; 231 227 } 232 228 233 229 static void __exit ryos_exit(void) 234 230 { 235 231 hid_unregister_driver(&ryos_driver); 236 - class_destroy(ryos_class); 232 + class_unregister(&ryos_class); 237 233 } 238 234 239 235 module_init(ryos_init);
+11 -9
drivers/hid/hid-roccat-savu.c
··· 22 22 #include "hid-roccat-common.h" 23 23 #include "hid-roccat-savu.h" 24 24 25 - static struct class *savu_class; 26 - 27 25 ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x4, 0x03); 28 26 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile, 0x5, 0x03); 29 27 ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(general, 0x6, 0x10); ··· 50 52 NULL, 51 53 }; 52 54 55 + static const struct class savu_class = { 56 + .name = "savu", 57 + .dev_groups = savu_groups, 58 + }; 59 + 53 60 static int savu_init_specials(struct hid_device *hdev) 54 61 { 55 62 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ··· 81 78 goto exit_free; 82 79 } 83 80 84 - retval = roccat_connect(savu_class, hdev, 81 + retval = roccat_connect(&savu_class, hdev, 85 82 sizeof(struct savu_roccat_report)); 86 83 if (retval < 0) { 87 84 hid_err(hdev, "couldn't init char dev\n"); ··· 207 204 { 208 205 int retval; 209 206 210 - savu_class = class_create("savu"); 211 - if (IS_ERR(savu_class)) 212 - return PTR_ERR(savu_class); 213 - savu_class->dev_groups = savu_groups; 207 + retval = class_register(&savu_class); 208 + if (retval) 209 + return retval; 214 210 215 211 retval = hid_register_driver(&savu_driver); 216 212 if (retval) 217 - class_destroy(savu_class); 213 + class_unregister(&savu_class); 218 214 return retval; 219 215 } 220 216 221 217 static void __exit savu_exit(void) 222 218 { 223 219 hid_unregister_driver(&savu_driver); 224 - class_destroy(savu_class); 220 + class_unregister(&savu_class); 225 221 } 226 222 227 223 module_init(savu_init);
+1 -1
drivers/hid/hid-roccat.c
··· 295 295 * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on 296 296 * success, a negative error code on failure. 297 297 */ 298 - int roccat_connect(struct class *klass, struct hid_device *hid, int report_size) 298 + int roccat_connect(const struct class *klass, struct hid_device *hid, int report_size) 299 299 { 300 300 unsigned int minor; 301 301 struct roccat_device *device;
+9 -9
drivers/hid/hidraw.c
··· 32 32 33 33 static int hidraw_major; 34 34 static struct cdev hidraw_cdev; 35 - static struct class *hidraw_class; 35 + static const struct class hidraw_class = { 36 + .name = "hidraw", 37 + }; 36 38 static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; 37 39 static DECLARE_RWSEM(minors_rwsem); 38 40 ··· 331 329 hid_hw_close(hidraw->hid); 332 330 wake_up_interruptible(&hidraw->wait); 333 331 } 334 - device_destroy(hidraw_class, 332 + device_destroy(&hidraw_class, 335 333 MKDEV(hidraw_major, hidraw->minor)); 336 334 } else { 337 335 --hidraw->open; ··· 571 569 goto out; 572 570 } 573 571 574 - dev->dev = device_create(hidraw_class, &hid->dev, MKDEV(hidraw_major, minor), 572 + dev->dev = device_create(&hidraw_class, &hid->dev, MKDEV(hidraw_major, minor), 575 573 NULL, "%s%d", "hidraw", minor); 576 574 577 575 if (IS_ERR(dev->dev)) { ··· 625 623 626 624 hidraw_major = MAJOR(dev_id); 627 625 628 - hidraw_class = class_create("hidraw"); 629 - if (IS_ERR(hidraw_class)) { 630 - result = PTR_ERR(hidraw_class); 626 + result = class_register(&hidraw_class); 627 + if (result) 631 628 goto error_cdev; 632 - } 633 629 634 630 cdev_init(&hidraw_cdev, &hidraw_ops); 635 631 result = cdev_add(&hidraw_cdev, dev_id, HIDRAW_MAX_DEVICES); ··· 639 639 return result; 640 640 641 641 error_class: 642 - class_destroy(hidraw_class); 642 + class_unregister(&hidraw_class); 643 643 error_cdev: 644 644 unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); 645 645 goto out; ··· 650 650 dev_t dev_id = MKDEV(hidraw_major, 0); 651 651 652 652 cdev_del(&hidraw_cdev); 653 - class_destroy(hidraw_class); 653 + class_unregister(&hidraw_class); 654 654 unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); 655 655 656 656 }
+1 -1
include/linux/hid-roccat.h
··· 16 16 17 17 #ifdef __KERNEL__ 18 18 19 - int roccat_connect(struct class *klass, struct hid_device *hid, 19 + int roccat_connect(const struct class *klass, struct hid_device *hid, 20 20 int report_size); 21 21 void roccat_disconnect(int minor); 22 22 int roccat_report_event(int minor, u8 const *data);