0

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

jeremydeanlakey
  • 133
  • 2
  • 7
  • Hmm… Interesting structure initialization via colon. Should not it be like `.minor = MISC_DYNAMIC_MINOR,` or what did I miss? – 0andriy Mar 01 '15 at 19:00
  • I saw it in a tutorial. I had never seem it before. I tried it and it compiled. After your comment, I googled it. It may be obsolete.http://stackoverflow.com/questions/1601201/c-struct-initialization-using-labels-it-works-but-how-documentation – jeremydeanlakey Mar 01 '15 at 19:15
  • I tried the more regular syntax just in case. It did not appear to make any difference. Thanks for the idea though. – jeremydeanlakey Mar 01 '15 at 21:24

0 Answers0