poll() returns both, POLLPRI & POLLERR

前端 未结 1 1461
情歌与酒
情歌与酒 2021-01-13 13:52

I started to get in C programming with Linux and embedded systems (router hardware and openwrt). I have got interupts on GPIOs enabled, using poll works ... nearly.

相关标签:
1条回答
  • 2021-01-13 14:20

    I've found some answer alluding to your question at: http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/716/t/182883

    I just ran into the POLLERR thing you're seeing too. Turns out this is how all sysfs files work, and you're using gpio through the sysfs interface.

    From the sysfs GPIO kernel document: If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. Also, if you look take a look at the kernel code in fs/sysfs/file.c, you'll see that sysfs_poll returns DEFAULT_POLLMASK | POLLERR | POLLPRI.

    All that said, it does seem strange that sysfs files return POLLERR, I'm not sure why they chose to do that.

    0 讨论(0)
提交回复
热议问题