0

I have a driver for the LSM6DSOX provided by ST which can be configured to use hardware interrupts and read data. I see that IIO interface is exposed to the user space but I need this data in the another driver. I think that implementation of the hwmon may be quite good and shows what I wanted to achieve, the example code I found is here https://github.com/torvalds/linux/blob/master/drivers/hwmon/iio_hwmon.c so I can find a GYRO channels and read samples but in this case hwmon needs to call "iio_read_channel_processed" to get sample.

My problem is that I don't know when I should call "iio_read_channel_processed" because I wanted to be notified by the IIO that the sample is ready to read. I expected that I could pass some callback function that will be called each time IIO buffer will receive new sample from another driver. Is that possible?

0andriy
  • 4,183
  • 1
  • 24
  • 37
  • 1
    inter module communication - there is a lot of help on internet – 0___________ Jul 12 '22 at 19:44
  • 1
    but in that case I will need to modify driver provided by manufacturer which reads data from gyro and put them into IIO. I don't want to modify that driver I just want to create my driver that can read samples from a gyro installed in the system. If I will need to use another chip in the future I just wanted to replace gyro driver only without code modifications. – grzesiekrc Jul 12 '22 at 20:03
  • Why not to ask in linux-iio@ mailing list? Jonathan is a kind guy, he helps newbies. – 0andriy Jul 30 '22 at 08:59
  • It seems what you are looking for is **IIO_BUFFER_CB** (https://elixir.bootlin.com/linux/latest/source/drivers/iio/buffer/Kconfig#L7): "IIO callback buffer used for push in-kernel interfaces" Should be selected by any drivers that do in-kernel push usage. That is, those where the data is pushed to the consumer. – 0andriy Jul 30 '22 at 12:58

0 Answers0