Kernel Module print messages

I am adding a module, I am able to compile the module with the kernel source code.
Also I am able to load the file_module.ko with “modprobe”. I can see that it loaded it with “lsmod”.

When I check to see the print statements I added to verify that the function executed, I don’t see any of the messages.
I use " dmesg | tail" to see if any message were capture, but I don’t see any of the messages.

I checked:
the priority level of logging located in /proc/sys/kernel/printk
and by default it is set to 8 7 1 7.
It should show me all levels.

in the module, I am initializing the module with “module_i2c_driver(name_of_conf_function)”
and the name_of_conf_function { .probe = name_init_funt, };

in the name_init_funt, I am printing the messages with printk, dev_info, dev_dbg.

Also the kernel configuration has the CONFIG_PRINTK variable enable.

Does any one has an idea why I can’t print the messages? Is there a kernel configuration that needs to be added to the default nvidia kernel image?

If I use

instead of

I can see messages of printk but only in the init and exit function. Not on the probe function or remove function

Did you have declare this i2c device in device tree? Otherwise please reference to below link to know more information.

The probe function is called when an entry in the id_table name field
matches the device’s name. It is passed the entry that was matched so
the driver knows which one in the table matched.

Device Creation

If you know for a fact that an I2C device is connected to a given I2C bus,
you can instantiate that device by simply filling an i2c_board_info
structure with the device address and driver name, and calling
i2c_new_device(). This will create the device, then the driver core will
take care of finding the right driver and will call its probe() method.
If a driver supports different device types, you can specify the type you
want using the type field. You can also specify an IRQ and platform data
if needed.

that makes a lot of sense why the probe functions was not being called.
Since I am trying to above to use the device tree, Is this device creation a work around to by pass the device tree?

I used the i2c_board_info but I did not where to call the i2c_new_device() from . I thought I could call it from the __init function but I would have to instantiate the parameter i2c_adapter.
i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)

Is it Okay to instantiate the i2c_adapter and call it from the __Init function?


found a good link thats describes how to do it. Ended declaring it over the device tree.