1

I wrote a driver for ADC module which is the part of IIO subsystem. It read voltages of various hardware peripherals connected to specific channel, and these voltages can be read only from 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).

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. It fetches device details(driver_find_device), can call the handler function for read operation.

Thanks in advance.

Sam Protsenko
  • 14,045
  • 4
  • 59
  • 75
Rahul Khandelwal
  • 149
  • 1
  • 12
  • A scheme that is extensible and portable is preferable to one that is not. What you propose is not portable. Use each driver to isolate its HW requirements. Have a userspace application to perform the interactions between the drivers. Use a realtime priority if necessary. – sawdust Oct 06 '15 at 04:58
  • Can charger work without ADC driver loaded? Does the hardware you are talking about is in SoC or it's totally separate stuff? P.S. Your proposal is not okay, though something similar might be done inside kernel. – 0andriy Oct 06 '15 at 07:00

1 Answers1

3

That is not true, there is a consumer API for in-kernel user. It is defined in linux/iio/consumer.h. Have a look at drivers/hwmon/ii_hwmon.c or drivers/power/axp288_fuel_gauge.cfor a usage exemple. You can also search for iio_read_channel_raw but I would suggest using the processed version that will definitively more portable.

Alexandre Belloni
  • 2,244
  • 13
  • 12