module_param_named(devices, wwan_hwsim_devsnum, int, 0444);
 MODULE_PARM_DESC(devices, "Number of simulated devices");
 
-static struct class *wwan_hwsim_class;
+static const struct class wwan_hwsim_class = {
+       .name = "wwan_hwsim",
+};
 
 static struct dentry *wwan_hwsim_debugfs_topdir;
 static struct dentry *wwan_hwsim_debugfs_devcreate;
        spin_unlock(&wwan_hwsim_devs_lock);
 
        dev->dev.release = wwan_hwsim_dev_release;
-       dev->dev.class = wwan_hwsim_class;
+       dev->dev.class = &wwan_hwsim_class;
        dev_set_name(&dev->dev, "hwsim%u", dev->id);
 
        spin_lock_init(&dev->ports_lock);
        if (!wwan_wq)
                return -ENOMEM;
 
-       wwan_hwsim_class = class_create("wwan_hwsim");
-       if (IS_ERR(wwan_hwsim_class)) {
-               err = PTR_ERR(wwan_hwsim_class);
+       err = class_register(&wwan_hwsim_class);
+       if (err)
                goto err_wq_destroy;
-       }
 
        wwan_hwsim_debugfs_topdir = debugfs_create_dir("wwan_hwsim", NULL);
        wwan_hwsim_debugfs_devcreate =
        wwan_hwsim_free_devs();
        flush_workqueue(wwan_wq);       /* Wait deletion works completion */
        debugfs_remove(wwan_hwsim_debugfs_topdir);
-       class_destroy(wwan_hwsim_class);
+       class_unregister(&wwan_hwsim_class);
 err_wq_destroy:
        destroy_workqueue(wwan_wq);
 
        wwan_hwsim_free_devs();
        flush_workqueue(wwan_wq);       /* Wait deletion works completion */
        debugfs_remove(wwan_hwsim_debugfs_topdir);
-       class_destroy(wwan_hwsim_class);
+       class_unregister(&wwan_hwsim_class);
        destroy_workqueue(wwan_wq);
 }