日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

bbb mmc_blk_probe 分析

發布時間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 bbb mmc_blk_probe 分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

bbb 的 emmc驅動在drivers\mmc\card\block.c,其mmc_dirver結構體如下,

根據以往平臺總線驅動模型的經驗來看的話,內核里應該有mmc_devices結構體,并且

其name也為"mmcblk",這樣其probe函數將被調用,但是搜索整個內核文件并沒有發現mmc_devices。

現在我們分析一下mmc_blk_probe什么時候被調用。

static struct mmc_driver mmc_driver = {

.drv= {
.name = "mmcblk",
},
.probe = mmc_blk_probe,
.remove = mmc_blk_remove,
.suspend = mmc_blk_suspend,
.resume = mmc_blk_resume,

};


static int __init mmc_blk_init(void) ? ? ? ? ? ? //drivers\mmc\card\block.c
{
? ? ?res = mmc_register_driver(&mmc_driver); ? ? //注冊mmc_driver
}


int mmc_register_driver(struct mmc_driver *drv) ? ? ?//drivers\mmc\core\bus.c
{
? ? ?drv->drv.bus = &mmc_bus_type; ? ? ? ? ? ? ? ? ? ? ? ? //mmc設備是掛載在mmc總線上的
? ? ?return driver_register(&drv->drv); ? ? ? ? ? ? ? ? ? ? ? ?//注冊mmc驅動
}


int driver_register(struct device_driver *drv) ? ? ? ?//drivers\base\driver.c
{
? ? ?other = driver_find(drv->name, drv->bus); ? ? ?//在總線上查找是否已經注冊過此驅動
? ? ?if (other) {
? ? ? ? ? put_driver(other);
? ? ? ? ? printk(KERN_ERR "Error: Driver '%s' is already registered, "
? ? ? ? ? ? ? ?"aborting...\n", drv->name);
? ? ? ? ? return -EBUSY;
? ? ?}

? ? ?ret = bus_add_driver(drv); ? ? ? ? ? ? ? ? ? ? ? ? ? ?//如果沒有注冊過,則注冊此驅動
}


int bus_add_driver(struct device_driver *drv) ? ? ? ?//drivers\base\bus.c
{
? ? ?error = driver_attach(drv); ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ?error = driver_create_file(drv, &driver_attr_uevent);
}


//try to bind driver to devices

int driver_attach(struct device_driver *drv) ? ? ? ??//drivers/base/dd.c
{
? ? ?return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); ?

? ? //__driver_attach的里面device的查找還沒搞清楚
}


static int __driver_attach(struct device *dev, void *data) ? ??//drivers/base/dd.c

{

? ? ?if (!driver_match_device(drv, dev))
return 0;

? ? ?driver_probe_device(drv, dev);

}


static inline int driver_match_device(struct device_driver *drv, ? ? ?//drivers/base/base.h
? ? ?struct device *dev)
{

? ? ?//這里調用了mmc總線的match函數
? ? ?return drv->bus->match ? drv->bus->match(dev, drv) : 1;
}


static int mmc_bus_match(struct device *dev, struct device_driver *drv) ? ? ??//drivers\mmc\core\bus.c
{

? ? ? //mmc總線的match直接返回了1
? ? ? return 1;
}


int driver_probe_device(struct device_driver *drv, struct device *dev) ? ? ?//drivers/base/dd.c
{
? ? ?really_probe(dev, drv);
}


static int really_probe(struct device *dev, struct device_driver *drv) ? ? ?//drivers/base/dd.c
{
? ? ?dev->bus->probe(dev); ? ? ? //這里調用總線的probe函數
}


static int mmc_bus_probe(struct device *dev) ? ? ?//drivers\mmc\core\bus.c
{
return drv->probe(card); ? ? ?//最終mmc總線的probe函數調用mmc_driver的probe函數
}

總結

以上是生活随笔為你收集整理的bbb mmc_blk_probe 分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。