作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试处理 devm_regulator_get
找不到匹配调节器的情况。我在内核 4.9.30 上编程
从 linux 内核源代码中我们可以看到以下描述 [ drivers/regulator/devres.c/drivers/regulator/core.c ]
drivers/regulator/devres.c
/**
* devm_regulator_get - Resource managed regulator_get()
* @dev: device for regulator "consumer"
* @id: Supply name or regulator ID.
*
* Managed regulator_get(). Regulators returned from this function are
* automatically regulator_put() on driver detach. See regulator_get() for more
* information.
*/
struct regulator *devm_regulator_get(struct device *dev, const char *id)
{
return _devm_regulator_get(dev, id, NORMAL_GET);
}
EXPORT_SYMBOL_GPL(devm_regulator_get);
drivers/regulator/core.c
/**
* regulator_get - lookup and obtain a reference to a regulator.
* @dev: device for regulator "consumer"
* @id: Supply name or regulator ID.
*
* Returns a struct regulator corresponding to the regulator producer,
* or IS_ERR() condition containing errno.
*
* Use of supply names configured via regulator_set_device_supply() is
* strongly encouraged. It is recommended that the supply name used
* should match the name used for the supply and/or the relevant
* device pins in the datasheet.
*/
struct regulator *regulator_get(struct device *dev, const char *id)
{
return _regulator_get(dev, id, false, true);
}
EXPORT_SYMBOL_GPL(regulator_get);
这是我的代码
struct regulator *power_regulator = devm_regulator_get(&pdev->dev, "zdfhkfgv");
if(IS_ERR(power_regulator))
{
ERROR("Invalid power regulator\r\n");
return -EINVAL;
}
但是,即使找不到调节器,我也不会陷入错误情况。
这是内核输出:
# insmod mod.ko
module : Init driver
module : Device allocated and initialized
module supply zdfhkfgv not found, using dummy regulator
module : device is not powered
[...]
所以我可以看到 devm_regulator_get
未能找到监管机构,但我没有陷入错误情况。这很烦人,因为当调节器未设置时,我将返回。相反,代码会继续在未通电的设备上运行。
我在这里做错了什么?
最佳答案
如果您不想退回到虚拟调节器,您应该使用 devm_regulator_get_optional()。然后它将返回 -ENODEV。
关于linux - 如何使用 devm_regulator_get 处理错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50745249/
我正在尝试处理 devm_regulator_get 找不到匹配调节器的情况。我在内核 4.9.30 上编程 从 linux 内核源代码中我们可以看到以下描述 [ drivers/regulator/
我是一名优秀的程序员,十分优秀!