Re: [PATCH v5 07/28] fpga: dfl: add chardev support for feature devices
From: Wu Hao <hidden>
Date: 2018-06-08 00:22:19
Also in:
linux-fpga, lkml
On Thu, Jun 07, 2018 at 01:03:18PM -0500, Alan Tull wrote:
On Wed, Jun 6, 2018 at 7:24 AM, Wu Hao [off-list ref] wrote: Hi Hao, One more...quoted
quoted
quoted
+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?
Sure, will fix this in the v6. Thanks. Hao
Thanks, Alan -- To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html