platform_device_register和platform_device_register_full的区别

platform_device_register和platform_device_register_full都是用于在Linux内核中注册平台设备的函数,但是它们之间存在一些区别。

  1. platform_device_register

platform_device_register函数用于注册一个平台设备。它接受一个指向platform_device结构体的指针作为参数,该结构体表示要注册的平台设备。该函数会将设备添加到平台设备列表中,以便与驱动程序进行匹配和加载。

原型:
int platform_device_register(struct platform_device *pdev);

返回值:
成功返回0,失败返回负值错误码。

  1. platform_device_register_full

platform_device_register_full函数也用于注册一个平台设备,但是它接受更多的参数,并且提供了更多的功能。它接受一个指向platform_device结构体的指针、一个设备初始化函数指针和一个资源结构体列表作为参数。

与platform_device_register相比,platform_device_register_full提供了更多的选项,例如可以指定设备的资源、设置设备的驱动程序信息和回调函数等。因此,它可以更灵活地注册设备并支持更多的功能。

原型:
int platform_device_register_full(struct platform_device *pdev, struct device_initdata *initdata, void *data);

返回值:
成功返回0,失败返回负值错误码。

总的来说,platform_device_register是更简单的注册函数,适用于基本的设备注册场景。而platform_device_register_full提供了更多的选项和功能,适用于需要更多定制的设备注册场景。

posted @ 2023-08-23 20:23  burlingame  阅读(72)  评论(0编辑  收藏  举报