static void macio_setup_interrupts(struct macio_dev *dev) { struct device_node *np = dev->ofdev.dev.of_node; unsigned int irq; int i = 0, j = 0; for (;;) { struct resource *res; if (j >= MACIO_DEV_COUNT_IRQS) break; res = &dev->interrupt[j]; irq = irq_of_parse_and_map(np, i++); if (irq == NO_IRQ) break; res->start = irq; res->flags = IORESOURCE_IRQ; res->name = dev_name(&dev->ofdev.dev); if (macio_resource_quirks(np, res, i - 1)) { memset(res, 0, sizeof(struct resource)); continue; } else j++; } dev->n_interrupts = j; }
static void macio_setup_resources(struct macio_dev *dev, struct resource *parent_res) { struct device_node *np = dev->ofdev.dev.of_node; struct resource r; int index; for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) { struct resource *res; if (index >= MACIO_DEV_COUNT_RESOURCES) break; res = &dev->resource[index]; *res = r; res->name = dev_name(&dev->ofdev.dev); if (macio_resource_quirks(np, res, index)) { memset(res, 0, sizeof(struct resource)); continue; } /* Currently, we consider failure as harmless, this may * change in the future, once I've found all the device * tree bugs in older machines & worked around them */ if (insert_resource(parent_res, res)) { printk(KERN_WARNING "Can't request resource " "%d for MacIO device %s\n", index, dev_name(&dev->ofdev.dev)); } } dev->n_resources = index; }
static void macio_setup_interrupts(struct macio_dev *dev) { struct device_node *np = dev->ofdev.node; int i,j; /* For now, we use pre-parsed entries in the device-tree for * interrupt routing and addresses, but we should change that * to dynamically parsed entries and so get rid of most of the * clutter in struct device_node */ for (i = j = 0; i < np->n_intrs; i++) { struct resource *res = &dev->interrupt[j]; if (j >= MACIO_DEV_COUNT_IRQS) break; res->start = np->intrs[i].line; res->flags = IORESOURCE_IO; if (np->intrs[j].sense) res->flags |= IORESOURCE_IRQ_LOWLEVEL; else res->flags |= IORESOURCE_IRQ_HIGHEDGE; res->name = dev->ofdev.dev.bus_id; if (macio_resource_quirks(np, res, i)) memset(res, 0, sizeof(struct resource)); else j++; } dev->n_interrupts = j; }