struct dummy_drvdata {
struct cdev dummy_cdev;
struct device *dev;
};
static size_t dummy_read(struct file *file, char _user *data, size_t len, lofft *ppos)
{
struct dummy_drvdata = file->private_data;
.......
}
static int dummy_open(struct inode *inode, struct file *file)
{
struct dummy_drvdata *drvdata = container_of(inode->i_cdev,
file->private_data = drvdata;
return 0;
}
struct file_operations dummy_fops = {
.open = dummy_open,
.read = dummy_read,
};
static int dummy_devices_register(struct dummy_drvdata *drvdata)
{
dev_id dev;
alloc_chrdev_region(&dev, 0, 1, "dummy-devices");
cdev_init(&drv_data->dummy_cdev, dummy_fops);
cdev_add(&drvdata->dummy_cdev, dev, 1);
}
static int dummy_probe(struct platform_device *pdev)
{
struct dummy_drvdata *drvdata = kmalloc();
drvdata->dev = &pdev->dev;
platform_set_drvdata(pdev, drvdata); //needed in dummy_remove function
dummy_devices_register(drvdata);
}
const struct of_device_id dummy_device_id = {
{.compactible = "qcom,dummy-driver"},
{}
}
static struct platform_driver dummy_platform_driver = {
.probe = dummy_probe,
.remove = dummy_remove,
.device_driver = {
.name = "dummy-driver",
.of_match_table = dummy_match_table,
},
};
static int my_module_init(void)
{
platform_driver_register(
}
module_init(dummy_module_init);
module_exit(dummy_module_exit);