[lkml]   [2003]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRE: How to notify a user process from within a driver
    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; = POLLIN;
    pfd.revents = 0;
    if(poll(&pfd, 1, 0) <= 0)
    else if (pfd.revents & POLLIN)
    ret = ioctl(fd, GET_MY_INFORMATION, &foo);
    else if (pfd.revents & POLLOUT)
    ret = ioctl(fd, CHANGE_CONFIGURATION, &how);

    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.

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:35    [W:0.023 / U:15.848 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site