Programatorska konstrukce...
Jan Marek
jmarek na jcu.cz
Úterý Listopad 6 09:48:33 CET 2001
Dobry den,
tak se dale kvuli PCMCIA stouram v jadre a zatim jsem se zasekl
na studiu IRQ, kam me zavedly jiste stopy (vytuh nastava pri
volani funkce request_irq())
Nasel jsem tam takovouto zvlastnost:
--- part of arch/i386/kernel/irq.c
int request_irq(unsigned int irq,
void (*handler)(int, void *, struct pt_regs *),
unsigned long irqflags,
const char * devname,
void *dev_id)
{
int retval;
struct irqaction * action;
#if 1
/*
* Sanity-check: shared interrupts should REALLY pass in
* a real dev-ID, otherwise we'll have trouble later trying
* to figure out which interrupt is which (messes up the
* interrupt freeing logic etc).
*/
if (irqflags & SA_SHIRQ) {
if (!dev_id)
printk("Bad boy: %s (at 0x%x) called us without a dev_id!\n", devname, (&irq)[-1]);
}
#endif
if (irq >= NR_IRQS)
return -EINVAL;
if (!handler)
return -EINVAL;
action = (struct irqaction *)
kmalloc(sizeof(struct irqaction), GFP_KERNEL);
if (!action)
return -ENOMEM;
action->handler = handler;
action->flags = irqflags;
action->mask = 0;
action->name = devname;
action->next = NULL;
action->dev_id = dev_id;
retval = setup_irq(irq, action);
if (retval)
kfree(action);
return retval;
}
--- end part
Zajima me konstrukce ve funkci printk(), kokretne se mi jedna o
tento zapis:
(&irq)[-1]. Co to vlastne ma za vyznam, je-li promenna irq
unsigned int? Kdyby tam bylo pouze &irq, pak by to byla adresa te
promenne. Ale takhle? Proc tam vlastne neni proste a suse irq?
Dekuji za vysvetleni...
Zdravi
Honza Marek
--
Ing. Jan Marek
University of South Bohemia
Academic Computer Centre
Phone: +420-38-7772080
Další informace o konferenci Linux