> 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. I believe the general idea is that each device will register its own handler. I do not think the code specifically check for this but you can assume that handlers are not shared.Only the interrupts are. > > 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 ? > It is perfectly okay to pass NULL as the dev_id if interrupts are not shared. If they are shared (flags has SA_SHIRQ set), then it is better for dev_id to be not null. It should be unique and the device id is used for this purpose. If the dev_id is not null, it is not a fatal error. The handler will still be registered with a warning. > 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 ? > When handlers are registered, they are stored in a list for that particular irq. Once an interrupt fires, the kernel calls all the handlers that are on the list. (do_irq->handle_IRQ_event->handler). The handler is passed the dev_id. It will check if the hardware had an interrupt pending. If yes, service it. Then walk down the list and repeat. The dev_id is used to verify that the handler is servicing the correct device. So, 2 handlers are registered with different dev_ids (unless both are NULL). > 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 ? > As I said, even when sharing, dev_id could be NULL. If we had 2 such beasts, the only way to perform correctly is to test the interrupt pending flag on all devices. Also, it could just be that it is quicker to just call all handlers instead of testing each device.(To test we still have to walk and test the pending bit which the handler does anyway). SInce usually, we have just 1 handler per interrupt, this may be faster. This is just my conjecture. Maybe someone knowledgable could pitch in. vijay. > Please explain. > > Thanks. > > <Raja> > > > > > > > > > > > > > > > > > > > > > > > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > > > > ________________________________ > Yahoo! DSL Something to write home about. Just $16.99/mo. or less > > -- Networks Lab, RPI http://poisson.ecse.rpi.edu/~vijay -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/