/* Allow user space to enable and disable the interrupt *intheinterruptcontroller,butkeeptrackofthe *statetopreventper-irqdepthdamage. * *Serializethisoperationtosupportmultipletasksandconcurrency *withirqhandleronSMPsystems.
*/
spin_lock_irqsave(&priv->lock, flags); if (irq_on) { if (__test_and_clear_bit(UIO_IRQ_DISABLED, &priv->flags))
enable_irq(dev_info->irq);
} else { if (!__test_and_set_bit(UIO_IRQ_DISABLED, &priv->flags))
disable_irq_nosync(dev_info->irq);
}
spin_unlock_irqrestore(&priv->lock, flags);
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) {
dev_err(&pdev->dev, "unable to kmalloc\n"); return -ENOMEM;
}
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (ret) {
dev_err(&pdev->dev, "DMA enable failed\n"); return ret;
}
priv->uioinfo = uioinfo;
spin_lock_init(&priv->lock);
priv->flags = 0; /* interrupt is enabled to begin with */
priv->pdev = pdev;
mutex_init(&priv->alloc_lock);
if (!uioinfo->irq) { /* Multiple IRQs are not supported */
ret = platform_get_irq(pdev, 0); if (ret == -ENXIO && pdev->dev.of_node)
ret = UIO_IRQ_NONE; elseif (ret < 0) return ret;
uioinfo->irq = ret;
}
for (i = 0; i < pdev->num_resources; ++i) { struct resource *r = &pdev->resource[i];
if (r->flags != IORESOURCE_MEM) continue;
if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) {
dev_warn(&pdev->dev, "device has more than "
__stringify(MAX_UIO_MAPS) " I/O memory resources.\n"); break;
}
for (i = 0; i < pdata->num_dynamic_regions; ++i) { if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) {
dev_warn(&pdev->dev, "device has more than "
__stringify(MAX_UIO_MAPS) " dynamic and fixed memory regions.\n"); break;
}
uiomem->memtype = UIO_MEM_DMA_COHERENT;
uiomem->dma_device = &pdev->dev;
uiomem->addr = DMEM_MAP_ERROR;
uiomem->size = pdata->dynamic_region_sizes[i];
++uiomem;
}
while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) {
uiomem->size = 0;
++uiomem;
}
/* This driver requires no hardware specific kernel code to handle *interrupts.Instead,theinterrupthandlersimplydisablesthe *interruptintheinterruptcontroller.Userspaceisresponsible *forperforminghardwarespecificacknowledgeandre-enablingof *theinterruptintheinterruptcontroller. * *Interruptsharingisnotsupported.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.