From: Jonathan Corbet <corbet@lwn.net>
To: "Marcos Lois Bermúdez" <marcos.discalis@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question about using new request_threaded_irq
Date: Mon, 17 Dec 2012 08:37:59 -0700 [thread overview]
Message-ID: <20121217083759.0cbed418@lwn.net> (raw)
In-Reply-To: <50CF361A.1030203@gmail.com>
On Mon, 17 Dec 2012 16:11:22 +0100
Marcos Lois Bermúdez <marcos.discalis@gmail.com> wrote:
> For my understand if i call for example:
>
> request_threaded_irq(irqmum, NULL, irq_handle, IRQF_TRIGGER_FALLING,
> DEVICE_NAME, priv);
>
> This seem to make a old Hard IRQ handler, and inside of this handler
> sleep APIs can't be used, but i see some SPI drivers that seem to
> register a IRQ of this form and make API calls that can sleep in the
> handler.
Not quite. The prototype for request_threaded_irq() is:
int request_threaded_irq(unsigned int irq, irq_handler_t handler,
irq_handler_t thread_fn, unsigned long irqflags,
const char *devname, void *dev_id)
Note the presents of *two* handlers, called "handler" and "thread_fn".
The first, "handler", is called in interrupt context; it's job is usually
to quiet the device and return; it cannot sleep. If it's return value is
IRQ_WAKE_THREAD, the thread_fn() will be called in process context; it
*can* sleep. In the example you cite, there is no immediate handler, only
the thread_fn(); the call to a blocking function from within the
thread_fn() is correct.
Hope that helps,
jon
Jonathan Corbet / LWN.net / corbet@lwn.net
next prev parent reply other threads:[~2012-12-17 15:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-17 15:11 Question about using new request_threaded_irq Marcos Lois Bermúdez
2012-12-17 15:37 ` Jonathan Corbet [this message]
2012-12-17 16:06 ` Marcos Lois Bermúdez
2012-12-17 17:14 ` Jonathan Corbet
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=20121217083759.0cbed418@lwn.net \
--to=corbet@lwn.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marcos.discalis@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.