LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-30-2011, 12:17 AM   #1
haribabu1836
LQ Newbie
 
Registered: Apr 2010
Posts: 16

Rep: Reputation: 0
How the Linux device driver can inform the applications when some events occurs


Hi all,

I have a question like is there any way in Linux such that device driver can inform to the applications when ever driver wants?
I have a device which will receive many interrupts and i need to inform application when ever interrupts received.

Thanks in advance.
 
Old 12-01-2011, 10:18 AM   #2
RudyMartin
LQ Newbie
 
Registered: Nov 2011
Location: Argentina
Distribution: Slackware
Posts: 25

Rep: Reputation: Disabled
is the application a program made by yourself? whats the name of the device in question?
 
Old 12-05-2011, 05:22 AM   #3
haribabu1836
LQ Newbie
 
Registered: Apr 2010
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by RudyMartin View Post
is the application a program made by yourself? whats the name of the device in question?
Thanks Martin.
Yes, I written a sample program which communicates to the driver through IOCTL's. My physical device is a FPGA.
 
Old 12-05-2011, 06:32 AM   #4
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Your driver could provide a character device, which provides a stream of event descriptors, one for each event. Personally, I'd use a binary structure similar to various interchange formats, i.e. something like
Code:
struct event {
    uint32_t  identifier;
    uint32_t  length;
    /* Optional data, if length > 0 */
};
If none of your interrupts have any associated data, and you know you'll need much less than 257 of them ever, then you could just make it a byte stream. An extensible event structure lets you extend the events without confusing existing clients.

When a client application is interested in those interrupts, it opens the device, and starts reading. Using the standard file semantics, O_NONBLOCK flag indicates that a reader wants to receive EWOULDBLOCK/EAGAIN when there is no data; without the flag the reader is blocked. O_ASYNC flag semantics are also useful to implement: whenever an event occurs, the reader is sent a signal (SIGIO by default, settable to eg. a realtime signal using fcntl()).

Note that my viewpoint here is from the userspace application; what is best for userspace applications and userspace programmers, not what is easiest to implement in a kernel module. Still, all of this is described in various tutorials, and is bog-standard stuff anyway; used by practically all sane char device drivers you'll ever see in Linux.

For example, see Linux Device Drivers, 3rd edition. Chapter 3 describes the basics of a char driver, Chapter 6 describes how to block and make the userspace application sleep (O_NONBLOCK) or signal asynchronous readers (O_ASYNC). Signal details are explained near the end of chapter 5.
 
  


Reply

Tags
devicedrivers, linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] USB device is not claimed by any active driver for every device in Linux 2.4 jacquesdirac Linux - Hardware 3 11-12-2010 08:35 AM
how to create a device driver for user applications trkecea Programming 3 02-07-2010 09:12 AM
Hang on triggering udev events- is there a buildup of events? sonichedgehog Slackware 20 07-11-2008 02:49 AM
Multiple Device driver from single device driver???? rickhg12hs Linux - Kernel 3 05-25-2008 12:11 AM
Leaving Linux for a while... again... please inform when it is ready Teddy_Horse Linux - General 16 10-13-2004 05:41 PM


All times are GMT -5. The time now is 08:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration