2026/4/6 14:27:59
网站建设
项目流程
接前一篇文章:Linux网络驱动之Fixed-Link(24)三、深入了解上一回开始解析platform_device_add函数,讲了前边两段,本回继续。为了便于理解和回顾,再次贴出其源码,在drivers/base/platform.c中,如下:/** * 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) { u32 i; int ret; if (!pdev) return -EINVAL; if (!pdev-dev.parent) pdev-dev.parent = platform_bus; pdev-dev.bus = platform_bus_type; switch (pdev-id) { default: dev_set_name(pdev-dev, "%s.%d", pdev-name, pdev-id); break; case PLATFORM_DEVID_NONE: dev_set_name(pdev-dev, "%s", pdev-name); break; case PLATFORM_D