From: "Richard B. Johnson" <root@chaos.analogic.com>
To: "Lee, Shuyu" <SLee@cognex.com>
Cc: linux-kernel@vger.kernel.org, "'Alan Cox'" <alan@lxorguk.ukuu.org.uk>
Subject: RE: How to notify a user process from within a driver
Date: Fri, 2 May 2003 07:53:51 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.53.0305020740180.6384@chaos> (raw)
In-Reply-To: <6AF24836F3EB074BA5C922466F9E92E10791B532@prince.pc.cognex.com>
On Thu, 1 May 2003, Lee, Shuyu wrote:
> Richard and Alan,
>
> Thank you for the info. Given the prototype for poll() is
> "int poll(struct pollfd *ufds, unsigned int nfds, int timeout);", and pollfd
> is struct pollfd {int fd; short events; short revents};, how do I
> communicate complex info to the driver?
>
> For example, assuming there are 8 input lines on my hardware, and the user
> wants to be notified in the following three cases:
> 1) input on Line 1 only,
> 2) input on either Line 2 or Line 3,
> 3) input on both Line 4 and Line 5,
> how do I pass that info to the driver? Also, other than POLLERR and POLLHUP,
> can I pass back to the user more descriptive error messages?
>
> Thanks,
> Shuyu
>
poll() tells you something happened, ioctl() tells you what. Poll
has some bits (POLLIN, POLLOUT, etc.) that can be used to tell
the user-mode task what information to actually request in the
ioctl() call. Your ioctl() can receive and send anything if you
use the third variable as a pointer to your stuff.
struct info {
int a;
int b;
...
...
} info;
int fd;
struct pollfd pfd;
fd = open("/dev/device", O_RDWR);
pfd.fd = fd;
pfd.events = POLLIN;
pfd.revents = 0;
if(poll(&pfd, 1, 0) <= 0)
handle_problem();
else if (pfd.revents & POLLIN)
ret = ioctl(fd, GET_MY_INFORMATION, &foo);
else if (pfd.revents & POLLOUT)
ret = ioctl(fd, CHANGE_CONFIGURATION, &how);
Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.
next prev parent reply other threads:[~2003-05-02 11:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-01 21:54 Lee, Shuyu
2003-05-01 22:29 ` Hua Zhong
2003-05-01 22:37 ` Chris Friesen
2003-05-02 11:53 ` Richard B. Johnson [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-05-01 19:23 Lee, Shuyu
2003-05-01 19:09 ` Alan Cox
2003-05-01 19:32 ` Richard B. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.53.0305020740180.6384@chaos \
--to=root@chaos.analogic.com \
--cc=SLee@cognex.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®