platform 平台总线驱动

本文主要探讨了platform平台总线驱动的设计理念,旨在将稳定代码与易变的硬件相关代码分离。介绍了关键的两个组件:platform_driver_register和platform_device_register,并分别在platform.c和device部分进行了阐述。
摘要由CSDN通过智能技术生成

platform平台总线是为了将较为稳定的代码与具体的硬件 相关的会变得代码分开

其下有两个部分platform_driver_register与platform_device_register

1.platform.c

int platform_driver_register(struct platform_driver *drv)
{
	drv->driver.bus = &platform_bus_type;
	if (drv->probe)
		drv->driver.probe = platform_drv_probe;  //将driver的probe函数赋给总线的probe函数
	if (drv->remove)
		drv->driver.remove = platform_drv_remove;
	if (drv->shutdown)
		drv->driver.shutdown = platform_drv_shutdown;
	if (drv->suspend)
		drv->driver.suspend = platform_drv_suspend;
	if (drv->resume)
		drv->driver.resume = platform_drv_resume;
	return driver_register(&drv->driver);    
}
int driver_register(struct device_driver * drv)
{
	if ((drv->bus->probe && drv->probe) ||
	    (drv->bus->remove && drv->remove) ||
	    (drv->bus->shutdown && drv->s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值