devm_regulator_bulk_get
时间: 2023-10-03 07:05:01 浏览: 71
`devm_regulator_bulk_get`是一个函数,用于在设备驱动程序中获取一组相关的稳压器。这个函数使用设备管理器(devm)机制,因此可以确保在设备被释放时自动注销稳压器。这个函数需要传入一个指向设备结构体的指针、一个指向稳压器结构体数组的指针、以及数组中稳压器的数量。函数返回一个整数值,表示成功获取的稳压器数量。如果返回的值与期望值不同,则表示出现了错误。
相关问题
devm_regulator_get
devm_regulator_get is a function provided by the Linux kernel API that allows a device driver to obtain a reference to a regulator device. This function is a managed version of the regulator_get function, which means that it automatically handles the deallocation of the regulator device when the driver is unloaded from the system.
The devm_regulator_get function takes two arguments: a pointer to the device structure of the device that requires the regulator, and a string that specifies the name of the regulator device. The function returns a pointer to the regulator device structure if successful, or an error code if it fails.
Once a driver obtains a reference to a regulator device using devm_regulator_get, it can use the regulator API functions to control the voltage or current supplied to the device. The driver should release the reference to the regulator device when it is no longer needed, but this is handled automatically by devm_regulator_get.
devm_regulator_get()函数理解
在 Linux 内核中,devm_regulator_get() 函数用于获取一个设备的电压调节器(regulator)。
在嵌入式系统中,一些外围设备需要使用不同的电压供电,这就需要使用电压调节器来调节电压。而我们在驱动程序中需要操作这些电压调节器,就需要使用 devm_regulator_get() 函数获取对应的 regulator 对象。
devm_regulator_get() 函数的参数包括设备对象和电压调节器的名称,它会根据名称查找对应的电压调节器,如果找到了就返回一个 regulator 对象,否则返回一个错误指针。
需要注意的是,devm_regulator_get() 函数获取到的 regulator 对象是一种资源,使用完毕后需要及时释放,否则会导致资源泄露。为了方便资源管理,devm_regulator_get() 函数会自动将获取到的 regulator 对象与设备对象进行关联,当设备对象被释放时,相应的 regulator 对象也会被自动释放。