struct ib_user_mad mad;
};
-static struct class *umad_class;
-
static const dev_t base_umad_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE);
static const dev_t base_issm_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE) +
IB_UMAD_NUM_FIXED_MINOR;
static CLASS_ATTR_STRING(abi_version, S_IRUGO,
__stringify(IB_USER_MAD_ABI_VERSION));
+static char *umad_devnode(struct device *dev, umode_t *mode)
+{
+ return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
+}
+
+static struct class umad_class = {
+ .name = "infiniband_mad",
+ .devnode = umad_devnode,
+};
+
static int ib_umad_init_port(struct ib_device *device, int port_num,
struct ib_umad_device *umad_dev,
struct ib_umad_port *port)
if (cdev_add(&port->cdev, base_umad, 1))
goto err_cdev;
- port->dev = device_create(umad_class, device->dev.parent,
+ port->dev = device_create(&umad_class, device->dev.parent,
port->cdev.dev, port,
"umad%d", port->dev_num);
if (IS_ERR(port->dev))
if (cdev_add(&port->sm_cdev, base_issm, 1))
goto err_sm_cdev;
- port->sm_dev = device_create(umad_class, device->dev.parent,
+ port->sm_dev = device_create(&umad_class, device->dev.parent,
port->sm_cdev.dev, port,
"issm%d", port->dev_num);
if (IS_ERR(port->sm_dev))
return 0;
err_sm_dev:
- device_destroy(umad_class, port->sm_cdev.dev);
+ device_destroy(&umad_class, port->sm_cdev.dev);
err_sm_cdev:
cdev_del(&port->sm_cdev);
err_dev:
- device_destroy(umad_class, port->cdev.dev);
+ device_destroy(&umad_class, port->cdev.dev);
err_cdev:
cdev_del(&port->cdev);
dev_set_drvdata(port->dev, NULL);
dev_set_drvdata(port->sm_dev, NULL);
- device_destroy(umad_class, port->cdev.dev);
- device_destroy(umad_class, port->sm_cdev.dev);
+ device_destroy(&umad_class, port->cdev.dev);
+ device_destroy(&umad_class, port->sm_cdev.dev);
cdev_del(&port->cdev);
cdev_del(&port->sm_cdev);
kobject_put(&umad_dev->kobj);
}
-static char *umad_devnode(struct device *dev, umode_t *mode)
-{
- return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
-}
-
static int __init ib_umad_init(void)
{
int ret;
}
dynamic_issm_dev = dynamic_umad_dev + IB_UMAD_NUM_DYNAMIC_MINOR;
- umad_class = class_create(THIS_MODULE, "infiniband_mad");
- if (IS_ERR(umad_class)) {
- ret = PTR_ERR(umad_class);
+ ret = class_register(&umad_class);
+ if (ret) {
pr_err("couldn't create class infiniband_mad\n");
goto out_chrdev;
}
- umad_class->devnode = umad_devnode;
-
- ret = class_create_file(umad_class, &class_attr_abi_version.attr);
+ ret = class_create_file(&umad_class, &class_attr_abi_version.attr);
if (ret) {
pr_err("couldn't create abi_version attribute\n");
goto out_class;
return 0;
out_class:
- class_destroy(umad_class);
+ class_unregister(&umad_class);
out_chrdev:
unregister_chrdev_region(dynamic_umad_dev,
static void __exit ib_umad_cleanup(void)
{
ib_unregister_client(&umad_client);
- class_destroy(umad_class);
+ class_unregister(&umad_class);
unregister_chrdev_region(base_umad_dev,
IB_UMAD_NUM_FIXED_MINOR * 2);
unregister_chrdev_region(dynamic_umad_dev,