*参照元 [#l13893d2] #backlinks *説明 [#s2d2470f] -パス: [[linux-4.4.1/drivers/iommu/arm-smmu.c]] -FIXME: これは何? --説明 **引数 [#eb810a56] -struct platform_device *pdev -- --[[linux-4.4.1/platform_device]] **返り値 [#leffecc6] -int -- **参考 [#i4ffb69c] *実装 [#j085df4b] static int arm_smmu_device_dt_probe(struct platform_device *pdev) { const struct of_device_id *of_id; struct resource *res; struct arm_smmu_device *smmu; struct device *dev = &pdev->dev; struct rb_node *node; struct of_phandle_args masterspec; int num_irqs, i, err; - --[[linux-4.4.1/of_device_id]] --[[linux-4.4.1/resource]] --[[linux-4.4.1/arm_smmu_device]] --[[linux-4.4.1/device]] --[[linux-4.4.1/rb_node]] --[[linux-4.4.1/of_phandle_args]] smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL); if (!smmu) { dev_err(dev, "failed to allocate arm_smmu_device\n"); return -ENOMEM; } smmu->dev = dev; - --[[linux-4.4.1/devm_kzalloc()]] --[[linux-4.4.1/dev_err()]] of_id = of_match_node(arm_smmu_of_match, dev->of_node); smmu->version = (enum arm_smmu_arch_version)of_id->data; - --[[linux-4.4.1/of_match_node()]] --[[linux-4.4.1/arm_smmu_of_match(global)]] --[[linux-4.4.1/arm_smmu_arch_version]] res = platform_get_resource(pdev, IORESOURCE_MEM, 0); smmu->base = devm_ioremap_resource(dev, res); if (IS_ERR(smmu->base)) return PTR_ERR(smmu->base); smmu->size = resource_size(res); - --[[linux-4.4.1/platform_get_resource()]] --[[linux-4.4.1/devm_ioremap_resource()]] --[[linux-4.4.1/IS_ERR()]] --[[linux-4.4.1/PTR_ERR()]] --[[linux-4.4.1/resource_size()]] if (of_property_read_u32(dev->of_node, "#global-interrupts", &smmu->num_global_irqs)) { dev_err(dev, "missing #global-interrupts property\n"); return -ENODEV; } - --[[linux-4.4.1/of_property_read_u32()]] num_irqs = 0; while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) { num_irqs++; if (num_irqs > smmu->num_global_irqs) smmu->num_context_irqs++; } if (!smmu->num_context_irqs) { dev_err(dev, "found %d interrupts but expected at least %d\n", num_irqs, smmu->num_global_irqs + 1); return -ENODEV; } smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs, GFP_KERNEL); if (!smmu->irqs) { dev_err(dev, "failed to allocate %d irqs\n", num_irqs); return -ENOMEM; } for (i = 0; i < num_irqs; ++i) { int irq = platform_get_irq(pdev, i); if (irq < 0) { dev_err(dev, "failed to get irq index %d\n", i); return -ENODEV; } smmu->irqs[i] = irq; } - --[[linux-4.4.1/platform_get_irq()]] err = arm_smmu_device_cfg_probe(smmu); if (err) return err; - --[[linux-4.4.1/arm_smmu_device_cfg_probe()]] i = 0; smmu->masters = RB_ROOT; while (!of_parse_phandle_with_args(dev->of_node, "mmu-masters", "#stream-id-cells", i, &masterspec)) { err = register_smmu_master(smmu, dev, &masterspec); if (err) { dev_err(dev, "failed to add master %s\n", masterspec.np->name); goto out_put_masters; } i++; } dev_notice(dev, "registered %d master devices\n", i); - --[[linux-4.4.1/of_parse_phandle_with_args()]] --[[linux-4.4.1/masterspec(global)]] --[[linux-4.4.1/register_smmu_master()]] parse_driver_options(smmu); - --[[linux-4.4.1/parse_driver_options()]] if (smmu->version > ARM_SMMU_V1 && smmu->num_context_banks != smmu->num_context_irqs) { dev_err(dev, "found only %d context interrupt(s) but %d required\n", smmu->num_context_irqs, smmu->num_context_banks); err = -ENODEV; goto out_put_masters; } for (i = 0; i < smmu->num_global_irqs; ++i) { err = request_irq(smmu->irqs[i], arm_smmu_global_fault, IRQF_SHARED, "arm-smmu global fault", smmu); if (err) { dev_err(dev, "failed to request global IRQ %d (%u)\n", i, smmu->irqs[i]); goto out_free_irqs; } } - --[[linux-4.4.1/request_irq()]] INIT_LIST_HEAD(&smmu->list); spin_lock(&arm_smmu_devices_lock); list_add(&smmu->list, &arm_smmu_devices); spin_unlock(&arm_smmu_devices_lock); - --[[linux-4.4.1/INIT_LIST_HEAD()]] --[[linux-4.4.1/spin_lock()]] --[[linux-4.4.1/list_add()]] --[[linux-4.4.1/spin_unlock()]] arm_smmu_device_reset(smmu); - --[[linux-4.4.1/arm_smmu_device_reset()]] return 0; out_free_irqs: while (i--) free_irq(smmu->irqs[i], smmu); - --[[linux-4.4.1/free_irq()]] out_put_masters: for (node = rb_first(&smmu->masters); node; node = rb_next(node)) { struct arm_smmu_master *master = container_of(node, struct arm_smmu_master, node); of_node_put(master->of_node); } - --[[linux-4.4.1/rb_first()]] --[[linux-4.4.1/rb_next()]] --[[linux-4.4.1/container_of()]] --[[linux-4.4.1/of_node_put()]] return err; } *コメント [#z752bb9f]