*参照元 [#t61ff8c1] #backlinks *説明 [#wef299df] -パス: [[linux-2.6.33/drivers/base/platform.c]] -FIXME: これは何? --説明 --platform_device_alloc() で確保したデバイスを登録できる。 **引数 [#a2b626ef] -struct platform_device *pdev -- --[[linux-2.6.33/platform_device]] **返り値 [#z9148ac3] -int --0: 成功、0 以外: 失敗 --失敗時はエラー番号(errno.h を参照)を 負の値で返すのが通例(-EINVAL など)である。 --[[linux-2.6.33/include/linux/errno.h]] **参考 [#iad047f9] *実装 [#u98e21e8] /** * platform_device_add - add a platform device to device hierarchy * @pdev: platform device we're adding * * This is part 2 of platform_device_register(), though may be called * separately _iff_ pdev was allocated by platform_device_alloc(). */ int platform_device_add(struct platform_device *pdev) { int i, ret = 0; if (!pdev) return -EINVAL; if (!pdev->dev.parent) pdev->dev.parent = &platform_bus; - --[[linux-2.6.33/platform_bus(global)]] pdev->dev.bus = &platform_bus_type; - --[[linux-2.6.33/platform_bus_type(global)]] if (pdev->id != -1) dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); else dev_set_name(&pdev->dev, "%s", pdev->name); - --[[linux-2.6.33/dev_set_name()]] for (i = 0; i < pdev->num_resources; i++) { struct resource *p, *r = &pdev->resource[i]; - --[[linux-2.6.33/resource]] if (r->name == NULL) r->name = dev_name(&pdev->dev); - --[[linux-2.6.33/dev_name()]] p = r->parent; if (!p) { if (resource_type(r) == IORESOURCE_MEM) p = &iomem_resource; else if (resource_type(r) == IORESOURCE_IO) p = &ioport_resource; } - --[[linux-2.6.33/resource_type()]] - --[[linux-2.6.33/iomem_resource(global)]] - --[[linux-2.6.33/ioport_resource(global)]] if (p && insert_resource(p, r)) { printk(KERN_ERR "%s: failed to claim resource %d\n", dev_name(&pdev->dev), i); ret = -EBUSY; goto failed; } - --[[linux-2.6.33/insert_resource()]] --[[linux-2.6.33/printk()]] } pr_debug("Registering platform device '%s'. Parent at %s\n", dev_name(&pdev->dev), dev_name(pdev->dev.parent)); - --[[linux-2.6.33/pr_debug()]] ret = device_add(&pdev->dev); if (ret == 0) return ret; - --[[linux-2.6.33/device_add()]] failed: while (--i >= 0) { struct resource *r = &pdev->resource[i]; unsigned long type = resource_type(r); if (type == IORESOURCE_MEM || type == IORESOURCE_IO) release_resource(r); } - --[[linux-2.6.33/release_resource()]] return ret; } EXPORT_SYMBOL_GPL(platform_device_add); -GPL のモジュールにのみシンボルを公開する。 --[[linux-2.6.33/EXPORT_SYMBOL_GPL()]] *コメント [#o80b27e9]