1

What are the performance differences between attaching a hardware device and its driver to the HWMON subsystem vs. the INPUT subsystem?

I have an embedded board with an ADC that is connected via the SPI bus. It currently uses a simple vendor supplied device driver that lashes it up to the HWMON subsystem. When the ADC is read frequently it consumes a lot of CPU time. Would it be more efficient to create a driver that uses the INPUT subsystem vs. the HWMON subsystem?

1

It seems to me that the HWMON subsystem would be the best fit for devices that are relatively expensive to read, but only need to be read whenever an application asks for it.

In an INPUT subsystem driver, you would need to implement a mechanism that would allow an application to tell the driver how often the device should be read, or accept that the driver will be polling the device with on fixed intervals all the time, causing constant CPU consumption.

You should look at the vendor-supplied device driver code with a critical eye. Is it actually production quality, or is it just a simple example on how to read the ADC with no concern on performance at all?

If it does ADC-related timing by stupidly spinning in a loop, and your embedded platform can provide high resolution timers, replacing the loop with a clockevent handler or some other mechanism that allows the kernel to do other things until it needs to come back to read the ADC would be a good idea. It could greatly reduce the CPU time used by the driver, no matter which subsystem is used to interface with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.