@@ -37,7 +37,9 @@ MODULE_PARM_DESC(nirqs, "number of interrupts to allocate (more may be useful fo
3737static dev_t switchtec_devt ;
3838static DEFINE_IDA (switchtec_minor_ida );
3939
40- struct class * switchtec_class ;
40+ const struct class switchtec_class = {
41+ .name = "switchtec" ,
42+ };
4143EXPORT_SYMBOL_GPL (switchtec_class );
4244
4345enum mrpc_state {
@@ -1363,7 +1365,7 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
13631365
13641366 dev = & stdev -> dev ;
13651367 device_initialize (dev );
1366- dev -> class = switchtec_class ;
1368+ dev -> class = & switchtec_class ;
13671369 dev -> parent = & pdev -> dev ;
13681370 dev -> groups = switchtec_device_groups ;
13691371 dev -> release = stdev_release ;
@@ -1851,11 +1853,9 @@ static int __init switchtec_init(void)
18511853 if (rc )
18521854 return rc ;
18531855
1854- switchtec_class = class_create ("switchtec" );
1855- if (IS_ERR (switchtec_class )) {
1856- rc = PTR_ERR (switchtec_class );
1856+ rc = class_register (& switchtec_class );
1857+ if (rc )
18571858 goto err_create_class ;
1858- }
18591859
18601860 rc = pci_register_driver (& switchtec_pci_driver );
18611861 if (rc )
@@ -1866,7 +1866,7 @@ static int __init switchtec_init(void)
18661866 return 0 ;
18671867
18681868err_pci_register :
1869- class_destroy ( switchtec_class );
1869+ class_unregister ( & switchtec_class );
18701870
18711871err_create_class :
18721872 unregister_chrdev_region (switchtec_devt , max_devices );
@@ -1878,7 +1878,7 @@ module_init(switchtec_init);
18781878static void __exit switchtec_exit (void )
18791879{
18801880 pci_unregister_driver (& switchtec_pci_driver );
1881- class_destroy ( switchtec_class );
1881+ class_unregister ( & switchtec_class );
18821882 unregister_chrdev_region (switchtec_devt , max_devices );
18831883 ida_destroy (& switchtec_minor_ida );
18841884
0 commit comments