Call driver functions from terminal

I’m trying to debug a sensor driver. By now, I already modified the device tree, and after flashing the kernel dtb, I just include the module via .ko file with insmod. The probe function is successfully executed, as I can see there is no error printed in the kernel messages. As I want to go further and test other functions (as open, board_setup, …), I’d like to know how can I call those functions from terminal after including the module. Would it be possible to do something like this in the terminal?

sudo insmod test123.ko //probe() successfully executed
//call test123_open() function (e.g. open test123)
sudo rmmod test123.ko //remove() successfully executed

Unless the module exports an interface into “/sys” for that purpose, then you won’t be able to do so. The “/sys” content is 100% custom to the particular driver…if this exists, then you can do it, but if it does not exist, then you cannot do this. Other than running the kernel itself in a debugger (definitely not simple…there is a steep learning curve) your best tool is to add printk statements inside the driver and monitor the logs.

We created files under /sys/device/ourdevice for this sort of testing.

Then when those files are read from or written to you can trigger some
sort of action. We’ve implemented 15 or 20 commands that way (with a
single file).

This is not all that difficult, but does require typically exacting kernel
code syntax.

Here is one short reference: