mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Hua Zhong" <hzhong@cisco.com>
To: "Lee, Shuyu" <SLee@cognex.com>, <linux-kernel@vger.kernel.org>
Cc: <root@chaos.analogic.com>, "'Alan Cox'" <alan@lxorguk.ukuu.org.uk>
Subject: RE: How to notify a user process from within a driver
Date: Thu, 1 May 2003 15:29:33 -0700	[thread overview]
Message-ID: <CDEDIMAGFBEBKHDJPCLDIEKADNAA.hzhong@cisco.com> (raw)
In-Reply-To: <6AF24836F3EB074BA5C922466F9E92E10791B532@prince.pc.cognex.com>

You could have one fd for each line. Create multiple nodes in /dev with
different minor numbers. User space listens to the file(s) it is interested
in.

> 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
>
>
>  -----Original Message-----
> From: 	Richard B. Johnson [mailto:root@chaos.analogic.com]
> Sent:	Thursday, May 01, 2003 3:32 PM
> To:	Lee, Shuyu
> Cc:	linux-kernel@vger.kernel.org
> Subject:	Re: How to notify a user process from within a driver
>
> On Thu, 1 May 2003, Lee, Shuyu wrote:
>
> > Hello, All.
> >
> > I am working on a device driver. One of the features of the hardware is
> > multi-channel I/O control. In order for a user process to
> communicate with
> > the hardware, my design is for the user process to call the
> driver's ioctl
> > to register a semaphore for each I/O channel, then wait on
> them. When the
> > hardware detects an input, the ISR then BH will wake up the
> user process.
> > This sounds straightforward in principle. Because there are two types of
> > semaphores in Linux (one for kernel, and one for user), I am
> not sure how
> > this can be accomplished. Any help would be greatly appreciated.
> >
> > My development environment is:
> > 1) OS:  RedHat 7.2 (Linux 2.4.7),
> > 2) gcc: 3.2.1,
> > 3) PC:  one P-III (HP kayak) with 128Mbyte of memory,
> > 4) Bus: PCI.
> >
> > Shuyu
> >
>
> You normally use poll() or select() for this. It's called poll()
> inside the driver.
>
> The user-mode code sleeps in poll() or select(). When your
> driver ISR wants to wake up the process, it calls
> wake_up_interruptible() from within the ISR.
>
> 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.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  reply	other threads:[~2003-05-01 22:18 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 [this message]
2003-05-01 22:37 ` Chris Friesen
2003-05-02 11:53 ` Richard B. Johnson
  -- 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=CDEDIMAGFBEBKHDJPCLDIEKADNAA.hzhong@cisco.com \
    --to=hzhong@cisco.com \
    --cc=SLee@cognex.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /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®