Re: Devices, IRQs and handlers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>         
>         Now my questions.
>          
>         Suppose two devices A ( IRQ1 ) and B ( IRQ2 ) share the same
>         handler handler1. 
>         Then according to the above description, handler1
>         distinguishes between the devices by the dev_id passed to it.
>         And also it is the same dev_id that was passed to
>         request_irq() when the handler was registered.
>          
>         1. But handler1 would have been registered by calling
>         request_irq() with dev_id as NULL ( because NULL would be
>         passed if the line is not shared with another handler ). So
>         how handler1 will differentiate between the devices if NULL
>         was passed to it ? 

don't do that. 

Usually what you pass is actually the device structure for your device,
not null. And you can use that to find the io addresses etc etc of the
exact device in question

>          
>         Or is it like handler1 should be registered twice ( one for
>         each device ) with the corresponding dev_id in each call to
>         request_irq() , and the kernel will call the handler with the
>         correct dev_id ?

yes you need to register twice

>          
>         2. Also as the dev_id is passed to the interrupt handler when
>         it is invoked , why should the kernel call all handlers on a
>         particular IRQ ? Rather, it can call the handler which has
>         registered for that device ?

you don't know which device generated the irq!
All the kernel knows is that "irq 11 triggered". Not which of the two
devices on irq 11 did that.

> 


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux