Re: [PATCH v5 07/28] fpga: dfl: add chardev support for feature devices
From: Alan Tull
Date: Thu Jun 07 2018 - 14:04:06 EST
On Wed, Jun 6, 2018 at 7:24 AM, Wu Hao <hao.wu@xxxxxxxxx> wrote:
Hi Hao,
One more...
>> > +static dev_t dfl_get_devt(enum dfl_fpga_devt_type type, int id)
>> > +{
>> > + WARN_ON(type >= DFL_FPGA_DEVT_MAX);
>> > +
>> > + return MKDEV(MAJOR(dfl_chrdevs[type].devt), id);
>> > +}
>> > +
>> > +/**
>> > + * dfl_fpga_register_dev_ops - register cdev ops for feature dev
>> > + *
>> > + * @pdev: feature dev.
>> > + * @fops: file operations for feature dev's cdev.
>> > + * @owner: owning module/driver.
>> > + *
>> > + * Return: 0 on success, negative error code otherwise.
>> > + */
>> > +int dfl_fpga_register_dev_ops(struct platform_device *pdev,
>> > + const struct file_operations *fops,
>> > + struct module *owner)
>> > +{
>> > + struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
>> > +
>> > + cdev_init(&pdata->cdev, fops);
>> > + pdata->cdev.owner = owner;
>> > +
>> > + /*
>> > + * set parent to the feature device so that its refcount is
>> > + * decreased after the last refcount of cdev is gone, that
>> > + * makes sure the feature device is valid during device
>> > + * file's life-cycle.
>> > + */
>> > + pdata->cdev.kobj.parent = &pdev->dev.kobj;
>> > +
>> > + return cdev_add(&pdata->cdev, pdev->dev.devt, 1);
>> > +}
>> > +EXPORT_SYMBOL_GPL(dfl_fpga_register_dev_ops);
>> > +
>> > +/**
>> > + * dfl_fpga_unregister_dev_ops - unregister cdev ops for feature dev
>> > + * @pdev: feature dev.
>> > + */
>> > +void dfl_fpga_unregister_dev_ops(struct platform_device *pdev)
>> > +{
>> > + struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
>> > +
>> > + cdev_del(&pdata->cdev);
>> > +}
>> > +EXPORT_SYMBOL_GPL(dfl_fpga_unregister_dev_ops);
How about dfl_fpga_dev_ops_register/unregister?
Thanks,
Alan