2

I opened a device file in Linux kernel space using struct file *filp->f_op->open.

Now I want to poll the opened device file before doing a read using struct file *filp->f_op->read or I want to read the device file once the data has arrived.

When I went through the Internet, I found a kernel function to poll called poll_wait(). Can any one provide example how to use poll_wait() to function ?

Below is my pseudo code in kernel implementation :

struct file *filp;
filp->f_op->sys_open("/dev/ttySX") ---> Non blocking mode 
filp->f_op->read() --> Before reading i need to poll the opened device file .

Is the polling only way to find the data has arrived?

Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33
kar
  • 2,505
  • 9
  • 30
  • 32
  • Not sure of what you really want to achieve, anyway if the file you opened is a char device, you will know when someone write to it in the write callback of the device structure I suggest you reading Chap. 3 of [Linux Device Drivers] http://lwn.net/Kernel/LDD3/ – sergico Feb 01 '14 at 15:43

0 Answers0