On 2/4/19 8:22 AM, Roger Quadros wrote:
> From: Jason Reeder <jree...@ti.com>
> 

[...]

> +/* .name matches on RPMsg Channels and causes a probe */
> +static const struct rpmsg_device_id rpmsg_driver_pru_id_table[] = {
> +     { .name = "rpmsg-pru" },
> +     { },
> +};
> +MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_pru_id_table);
> +
> +static struct rpmsg_driver rpmsg_pru_driver = {
> +     .drv.name       = KBUILD_MODNAME,
> +     .id_table       = rpmsg_driver_pru_id_table,
> +     .probe          = rpmsg_pru_probe,
> +     .callback       = rpmsg_pru_cb,
> +     .remove         = rpmsg_pru_remove,
> +};
> +
> +static int __init rpmsg_pru_init(void)
> +{
> +     int ret;
> +
> +     rpmsg_pru_class = class_create(THIS_MODULE, "rpmsg_pru");
> +     if (IS_ERR(rpmsg_pru_class)) {
> +             pr_err("Unable to create class\n");
> +             ret = PTR_ERR(rpmsg_pru_class);
> +             goto fail_create_class;
> +     }
> +
> +     ret = alloc_chrdev_region(&rpmsg_pru_devt, 0, PRU_MAX_DEVICES,
> +                               "rpmsg_pru");
> +     if (ret) {
> +             pr_err("Unable to allocate chrdev region\n");
> +             goto fail_alloc_region;
> +     }
> +
> +     ret = register_rpmsg_driver(&rpmsg_pru_driver);
> +     if (ret) {
> +             pr_err("Unable to register rpmsg driver");
> +             goto fail_register_rpmsg_driver;
> +     }
> +
> +     return 0;
> +
> +fail_register_rpmsg_driver:
> +     unregister_chrdev_region(rpmsg_pru_devt, PRU_MAX_DEVICES);
> +fail_alloc_region:
> +     class_destroy(rpmsg_pru_class);
> +fail_create_class:
> +     return ret;
> +}
> +
> +static void __exit rpmsg_pru_exit(void)
> +{
> +     unregister_rpmsg_driver(&rpmsg_pru_driver);
> +     idr_destroy(&rpmsg_pru_minors);
> +     mutex_destroy(&rpmsg_pru_lock);
> +     class_destroy(rpmsg_pru_class);
> +     unregister_chrdev_region(rpmsg_pru_devt, PRU_MAX_DEVICES);
> +}
> +
> +module_init(rpmsg_pru_init);
> +module_exit(rpmsg_pru_exit);
> +
> +MODULE_AUTHOR("Jason Reeder <jree...@ti.com>");
> +MODULE_ALIAS("rpmsg:rpmsg-pru");

MODULE_ALIAS not needed, MODULE_DEVICE_TABLE will generate the alias.

Andrew

> +MODULE_DESCRIPTION("PRU Remote Processor Messaging Driver");
> +MODULE_LICENSE("GPL v2");
> 

Reply via email to