SDIO驱动(5)sdio总线上的probe

本文详细介绍了SDIO驱动中probe过程的工作原理,涉及电源管理、资源同步、等待队列、中断锁以及block size的设置。在probe期间,通过禁止电源管理、独占式占用host、设置block size并与设备通信确认,确保了SDIO设备的正确连接和初始化。
摘要由CSDN通过智能技术生成

Linux 2.6.38

sdio总线上driver和设备的match成功只是软件之间的”切口“,好比《还钱》:

刘金山:明月几时有?

冯巩:抬头自己瞅。

但是冯巩并没有马上把请给他吧?这里硬件的连通性、能不能工作还不知道,所以要probe探测一下。

static int sdio_bus_probe(struct device *dev)
{
	struct sdio_driver *drv = to_sdio_driver(dev->driver);
	struct sdio_func *func = dev_to_sdio_func(dev);
	const struct sdio_device_id *id;
	int ret;

	id = sdio_match_device(func, drv);
	if (!id)
		return -ENODEV;

	/* Unbound SDIO functions are always suspended.
	 * During probe, the function is set active and the usage count
	 * is incremented.  If the driver supports runtime PM,
	 * it should call pm_runtime_put_noidle() in its probe routine and
	 * pm_runtime_get_noresume() in its remove routine.
	 */
	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
		ret = pm_runtime_get_sync(dev);
		if (ret < 0)
			goto out;
	}

	/* Set the default block size so the driver is sure it's something
	 * sensible. */
	sdio_claim_host(func);
	ret = sdio_set_block_size(func, 0);
	sdio_release_host(func);
	if (ret)
		goto disable_runtimepm;

	ret = drv->probe(func, id);
	if (ret)
		goto disable_runtimepm;

	return 0;

disable_runtimepm:
	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
		pm_runtime_put_noidle(dev);
out:
	return ret;
}
3、4行不用说了。

第8~10行,之前的match操作也调用的sdio_match_device,不过当时仅仅关心是不是匹配,其他一概不管。这里需要用到它的sdio_device_id返回值。


第12~22行,sdio host的caps成员记录其特性(capability),MMC_CAP_POWER_OFF_CARD是电源管理(Power Manager)方面的选项,设置了这个标志的host在suspend的时候将把card的电关掉。很显然,在probe的过程中不允许这种情况发生,解决方式就是禁止MMC子系统进入suspend模式。pm_runtime_get_sync()调用后将增加sdio device的引用计数,系统suspend过程中检测这个引用计数,发现其不为零就会退出suspend流程。相应的,pm_runtime_put_noidle()降低引用计数,也即它们必须成对使用。


第26~28行,设置block siz

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值