Re: [PATCH 06/41] IB/hfi1: add char device instantiation code

Or Gerlitz
2015-06-14T20:58:00Z

On Fri, Jun 12, 2015 at 2:09 AM, Mike Marciniszyn
<mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> +++ b/drivers/infiniband/hw/hfi1/device.c

> +int __init dev_init(void)
> +{
> + int ret;
> +
> + ret = alloc_chrdev_region(&hfi1_dev, 0, HFI1_NMINORS, DRIVER_NAME);
> + if (ret < 0) {
> + pr_err("Could not allocate chrdev region (err %d)\n", -ret);
> + goto done;
> + }
> +
> + class = class_create(THIS_MODULE, class_name());
> + if (IS_ERR(class)) {
> + ret = PTR_ERR(class);
> + pr_err("Could not create device class (err %d)\n", -ret);
> + unregister_chrdev_region(hfi1_dev, HFI1_NMINORS);
> + }
> +
> +done:
> + return ret;
> +}

so what's the role of the char-device? why should a low-level driver
which is part of the upstream RDMA stack contain a char-device?

Or.

> +
> +void dev_cleanup(void)
> +{
> + if (class) {
> + class_destroy(class);
> + class = NULL;
> + }
> +
> + unregister_chrdev_region(hfi1_dev, HFI1_NMINORS);
> +}