I'm trying to write a simple mouse driver (as part of a project to use my phone as a mouse for linux). If I understand correctly: 1) I should use misc_register() in the init() for the module 2) the file_operations' poll() will be called periodically to determine if the mouse should move? 3) open() and read() get called to determine how it should move?
Am I misunderstanding something? Is there another step to ensure that the poll() gets called?
struct file_operations mousey_fops = {
...
poll: mousey_poll
};
static struct miscdevice mousey = {
minor:MISC_DYNAMIC_MINOR,
...
fops:&mousey_fops
};
...
int mousey_init(void){
// This gets executed, result == 0
printk (KERN_ALERT "mousey_init called\n");
result = misc_register(&mousey);
...
}
...
... mousey_poll(...){
// this never gets executed
printk (KERN_ALERT "mousey_poll called\n");
return POLLIN | POLLRDNORM;
}
full code is here in case it's needed: https://github.com/jeremydeanlakey/linuxdriverexperiment/blob/master/mousey.c