Folks, i wrote a char driver for my i2c device. It is working on Android 4.0.3 using Linux kernel 3.0.8.
When I try to access the driver using ioctl()
with my native Android app. I get a permission denied error.
If I create the device file using the following command I don't get the permission error.
mknod /dev/barcodescan c 100 0
I don't want to have to manually issue this command all the time but instead that the module does it on startup. I wrote the following code but I get a permission denied error. How can I setup permission in this code?
ret= register_chrdev(MAJOR_NUMBER,"barcode",&fops );
if(ret) {
pr_info(KERN_ERR "%s:register chrdev failed\n",__FILE__);
return ret;
}
i2c_dev_class = class_create(THIS_MODULE,"barcode");
if (IS_ERR(i2c_dev_class)) {
ret = PTR_ERR(i2c_dev_class);
class_destroy(i2c_dev_class);
}