简体   繁体   English

不同子系统驱动程序之间的通信(例如:IIO和充电驱动程序)

[英]Communication between different subsystem drivers(For ex: IIO and Charging driver)

I wrote a driver for ADC module which is the part of IIO subsystem. 我为ADC模块编写了一个驱动程序,它是IIO子系统的一部分。 It read voltages of various hardware peripherals connected to specific channel, and these voltages can be read only from sysfs. 它读取连接到特定通道的各种硬件外设的电压,这些电压只能从sysfs读取。

My problem is that, my charging driver also want to read data from ADC, but there are no such API exposed so that Charging driver can communicate with the IIO subsystem driver(Driver-Driver communication). 我的问题是,我的充电驱动程序也想从ADC读取数据,但是没有暴露这样的API,因此充电驱动程序可以与IIO子系统驱动程序通信(驱动程序 - 驱动程序通信)。

My solution - Is it ok to write a function which will in itself calculate the ADC voltage of specific channel, send the voltage to charging driver. 我的解决方案 - 可以编写一个本身可以计算特定通道的ADC电压的功能,将电压发送给充电驱动器。 It fetches device details(driver_find_device), can call the handler function for read operation. 它获取设备细节(driver_find_device),可以调用处理函数进行读操作。

Thanks in advance. 提前致谢。

That is not true, there is a consumer API for in-kernel user. 事实并非如此,内核用户有一个消费者API。 It is defined in linux/iio/consumer.h . 它在linux / iio / consumer.h中定义。 Have a look at drivers/hwmon/ii_hwmon.c or drivers/power/axp288_fuel_gauge.c for a usage exemple. 有关用法示例 ,请查看drivers / hwmon / ii_hwmon.cdrivers / power / axp288_fuel_gauge.c You can also search for iio_read_channel_raw but I would suggest using the processed version that will definitively more portable. 您也可以搜索iio_read_channel_raw,但我建议使用最终可移植的处理版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM