ARM-Linux s3c2440 之UART分析(四)
串口是一種platform設(shè)備,在體系框架setup_arch()中完成設(shè)備注冊,而且設(shè)備的注冊先于驅(qū)動注冊,最終串口設(shè)備與驅(qū)動的連接在driver_register() -->bus_add_driver()中完成。
本文引用地址:http://www.ex-cimer.com/article/201611/318134.htm- intbus_add_driver(structdevice_driver*drv)
- {
- intret;
- structdevice_driver*other;
- …
- if(drv->bus->p->drivers_autoprobe){//platfrom_but_type==1自動探測platfrom設(shè)備
- error=driver_attach(drv);
- if(error)
- gotoout_unregister;
- }
- ….
- }
最后driver_attach()-->bus_for_each_dev(),完成串口設(shè)備與驅(qū)動的連接
- intbus_for_each_dev(structbus_type*bus,structdevice*start,
- void*data,int(*fn)(structdevice*,void*))
- {
- structklist_iteri;
- structdevice*dev;
- interror=0;
- if(!bus)
- return-EINVAL;
- klist_iter_init_node(&bus->p->klist_devices,&i,
- (start?&start->p->knode_bus:NULL));
- while((dev=next_device(&i))&&!error)//遍歷所有對應(yīng)上的設(shè)備
- error=fn(dev,data);
- klist_iter_exit(&i);
- returnerror;
- }
評論