浅析wlan驱动和sd卡硬件绑定的简单流程
struct mmc_card *mmc_alloc_card(struct mmc_host *host) { struct mmc_card *card;
card = kzalloc(sizeof(struct mmc_card), GFP_KERNEL); if (!card) return ERR_PTR(-ENOMEM);
card->host = host;
device_initialize(&card->dev);
card->dev.parent = mmc_classdev(host);//该card对应parent为arm平台的SD控制器 card->dev.bus = &mmc_bus_type;//总线为mmc_bus_type,对应mmc_bus_match和mmc_bus_probe card->dev.release = mmc_release_card;
return card; }
static int mmc_bus_match(struct device *dev, struct device_driver *drv) { return 1;//始终返回1,所以mmc总线上设备匹配工作完全交由设备的驱动probe完成 }
static int mmc_bus_probe(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); struct mmc_card *card = dev_to_mmc_card(dev);
return drv->probe(card); //对于sd卡drivers/mmc/card/block.c->module_init(mmc_blk_init)这是内核注册到mmc_bus上的驱动,也是这里调用的drv->probe驱动 //mmc_blk_probe //感觉对于wlan来说,card并没有在总线上取得到驱动,仅仅func所在的sdio_bus_type总线上注册了wlan驱动 }
struct sdio_func *sdio_alloc_func(struct mmc_card *card) { struct sdio_func *func;
func = kzalloc(sizeof(struct sdio_func), GFP_KERNEL); if (!func) return ERR_PTR(-ENOMEM);
func->card = card;
device_initialize(&func->dev);
func->dev.parent = &card->dev;//设置sysfs系统视图中的parent func->dev.bus = &sdio_bus_type;//设置所在bus总线,对应总线mach和probe分别为sdio_bus_match和sdio_bus_probe func->dev.release = sdio_release_func;
return func; }
sbi_register()->sdio_register_driver(&wlan_sdio);这样将wlan_sdio驱动注册到sdio_bus_type总线,当sd接口检测到sd设备插入, 之后,mmc_rescan()函数会生成插入设备的sdio_func结构体,并这些结构体填充成sysfs文件系统目录和文件,最后当调用sdio_add_func() 的device_add()的时候,会在device_attach()时,通过sdio_bus_match()调用和sdio_bus_probe()调用之后调用wlan_probe()函数,最后 将wlan驱动和插入到sd口的sdio网卡硬件绑定[gliethttp_20080626]!
|
转载于:https://blog.51cto.com/prothesman/1411545