All of lore.kernel.org
 help / color / mirror / Atom feed
* question in request_threaded_irq
@ 2011-08-13 19:25 radhika bhaskaran
  2011-08-14  1:01 ` Javier Martinez Canillas
  0 siblings, 1 reply; 5+ messages in thread
From: radhika bhaskaran @ 2011-08-13 19:25 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I have a question with respect to request_threaded_irq.

Assume that one driver has registered and ISR on some particular irq number.

Can i use the same irq number and register and isr in another driver.
Because that is my requirement.

when i try to do that is an error message with an error no as -19.

 err = request_threaded_irq(pdata->irq , NULL, testing_fucntion,
                            IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
"testing_function", dev);

Can some one please help me whether it is possible.

Regards,
RB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110814/76644a99/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* question in request_threaded_irq
  2011-08-13 19:25 question in request_threaded_irq radhika bhaskaran
@ 2011-08-14  1:01 ` Javier Martinez Canillas
  2011-08-15 11:03   ` radhika bhaskaran
  0 siblings, 1 reply; 5+ messages in thread
From: Javier Martinez Canillas @ 2011-08-14  1:01 UTC (permalink / raw)
  To: kernelnewbies

On Sat, Aug 13, 2011 at 9:25 PM, radhika bhaskaran <radhibhas@gmail.com> wrote:
> Hi,
> I have a question with respect to request_threaded_irq.
> Assume that one driver has registered and ISR on some particular irq number.
> Can i use the same irq number and register and isr in another driver.
> Because that is my requirement.
> when i try to do that is an error message with an error no as -19.
> ?err = request_threaded_irq(pdata->irq , NULL, testing_fucntion,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> "testing_function",?dev);
> Can some one please help me whether it is possible.
> Regards,
> RB

You have to use the IRQF_SHARED flag that specifies the IRQ will be
shared for two devices:

err = request_threaded_irq(pdata->irq , NULL, testing_fucntion, IRQF_SHARED |
                                      IRQF_TRIGGER_FALLING |
IRQF_TRIGGER_RISING,
                                      "testing_function", dev);

Have in mind that the kernel invokes every handler registered for that
IRQ every time an interrupt occurs on that line. So you have to check
in each ISR if the hardware raised the interrupt.

Hope it helps,

-- 
Javier Mart?nez Canillas
(+34) 682 39 81 69
Barcelona, Spain

^ permalink raw reply	[flat|nested] 5+ messages in thread

* question in request_threaded_irq
  2011-08-14  1:01 ` Javier Martinez Canillas
@ 2011-08-15 11:03   ` radhika bhaskaran
  2011-08-15 15:10     ` Javier Martinez Canillas
  2011-08-23  5:26     ` Haojian Zhuang
  0 siblings, 2 replies; 5+ messages in thread
From: radhika bhaskaran @ 2011-08-15 11:03 UTC (permalink / raw)
  To: kernelnewbies

Hi javier,

Thanks for the help.

I have tried the suggestion made by you. But unfortunately it did not work.

For my debugging purpose i tried to register two isr's on the same number
IRQ no in  the same driver. But the isr which is registerd first is being
hit.

The other isr funciton which is registered after the first isr is never
executed.

Any more suggestions?

Regards,
RB


On Sun, Aug 14, 2011 at 6:31 AM, Javier Martinez Canillas <
martinez.javier@gmail.com> wrote:

> On Sat, Aug 13, 2011 at 9:25 PM, radhika bhaskaran <radhibhas@gmail.com>
> wrote:
> > Hi,
> > I have a question with respect to request_threaded_irq.
> > Assume that one driver has registered and ISR on some particular irq
> number.
> > Can i use the same irq number and register and isr in another driver.
> > Because that is my requirement.
> > when i try to do that is an error message with an error no as -19.
> >  err = request_threaded_irq(pdata->irq , NULL, testing_fucntion,
> >                             IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> > "testing_function", dev);
> > Can some one please help me whether it is possible.
> > Regards,
> > RB
>
> You have to use the IRQF_SHARED flag that specifies the IRQ will be
> shared for two devices:
>
> err = request_threaded_irq(pdata->irq , NULL, testing_fucntion, IRQF_SHARED
> |
>                                       IRQF_TRIGGER_FALLING |
> IRQF_TRIGGER_RISING,
>                                      "testing_function", dev);
>
> Have in mind that the kernel invokes every handler registered for that
> IRQ every time an interrupt occurs on that line. So you have to check
> in each ISR if the hardware raised the interrupt.
>
> Hope it helps,
>
> --
> Javier Mart?nez Canillas
> (+34) 682 39 81 69
> Barcelona, Spain
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110815/b669c847/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* question in request_threaded_irq
  2011-08-15 11:03   ` radhika bhaskaran
@ 2011-08-15 15:10     ` Javier Martinez Canillas
  2011-08-23  5:26     ` Haojian Zhuang
  1 sibling, 0 replies; 5+ messages in thread
From: Javier Martinez Canillas @ 2011-08-15 15:10 UTC (permalink / raw)
  To: kernelnewbies

On Mon, 2011-08-15 at 16:33 +0530, radhika bhaskaran wrote:

> 
> For my debugging purpose i tried to register two isr's on the same
> number IRQ no in  the same driver. But the isr which is registerd
> first is being hit.
> 

Since the kernel is monolithic is doesn't really matter where your ISR
functions are defined and where these handlers are assigned an IRQ line.

> 
> The other isr funciton which is registered after the first isr is
> never executed.
> 
> 
> Any more suggestions?
> 

Yes, does yours ISR function handlers look if they generated the interrupt and 
if not respond accordingly?
If your device didn't raised the interrupt then they have to return IRQ_NONE. 
If your hardware raised the interrupt then you have to do the processing and 
return IRQ_HANDLED.

So you have to do something like this:

static irqreturn_t my_interrupt(int irq, void *data)
{
        int result;
        struct my_device *my_dev = data;

        result = check_interrupt_raised(my_dev);

        if (!result)
           return IRQ_NONE;

	process_interrupt(my_dev);
        return IRQ_HANDLED;
}

Hope it helps,
Javier Martinez Canillas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* question in request_threaded_irq
  2011-08-15 11:03   ` radhika bhaskaran
  2011-08-15 15:10     ` Javier Martinez Canillas
@ 2011-08-23  5:26     ` Haojian Zhuang
  1 sibling, 0 replies; 5+ messages in thread
From: Haojian Zhuang @ 2011-08-23  5:26 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Aug 15, 2011 at 7:03 PM, radhika bhaskaran <radhibhas@gmail.com>wrote:

> Hi javier,
>
> Thanks for the help.
>
> I have tried the suggestion made by you. But unfortunately it did not work.
>
> For my debugging purpose i tried to register two isr's on the same number
> IRQ no in  the same driver. But the isr which is registerd first is being
> hit.
>
> The other isr funciton which is registered after the first isr is never
> executed.
>
> Any more suggestions?
>
>
IRQ_SHARED flag could work if IRQ_ONESHOT isn't enabled.

In your request_threaded_irq(), you assigned thread_func() and NULL for
handler_func(). It means that IRQ_ONESHOT is enabled. You either registered
it to handler_func(), or abandon irq handler sharing between multiple
drivers.


>
> On Sun, Aug 14, 2011 at 6:31 AM, Javier Martinez Canillas <
> martinez.javier at gmail.com> wrote:
>
>> On Sat, Aug 13, 2011 at 9:25 PM, radhika bhaskaran <radhibhas@gmail.com>
>> wrote:
>> > Hi,
>> > I have a question with respect to request_threaded_irq.
>> > Assume that one driver has registered and ISR on some particular irq
>> number.
>> > Can i use the same irq number and register and isr in another driver.
>> > Because that is my requirement.
>> > when i try to do that is an error message with an error no as -19.
>> >  err = request_threaded_irq(pdata->irq , NULL, testing_fucntion,
>> >                             IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
>> > "testing_function", dev);
>> > Can some one please help me whether it is possible.
>> > Regards,
>> > RB
>>
>> You have to use the IRQF_SHARED flag that specifies the IRQ will be
>> shared for two devices:
>>
>> err = request_threaded_irq(pdata->irq , NULL, testing_fucntion,
>> IRQF_SHARED |
>>                                       IRQF_TRIGGER_FALLING |
>> IRQF_TRIGGER_RISING,
>>                                      "testing_function", dev);
>>
>> Have in mind that the kernel invokes every handler registered for that
>> IRQ every time an interrupt occurs on that line. So you have to check
>> in each ISR if the hardware raised the interrupt.
>>
>> Hope it helps,
>>
>> --
>> Javier Mart?nez Canillas
>> (+34) 682 39 81 69
>> Barcelona, Spain
>>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110823/b6d31fc3/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-23  5:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-13 19:25 question in request_threaded_irq radhika bhaskaran
2011-08-14  1:01 ` Javier Martinez Canillas
2011-08-15 11:03   ` radhika bhaskaran
2011-08-15 15:10     ` Javier Martinez Canillas
2011-08-23  5:26     ` Haojian Zhuang

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.