I am trying to install a dummy thermal zone device in sys/class/thermal using a kernel module. Doing an insmod to register the device works perfectly..
struct thermal_zone_device *tz_dev; //declared globally...
...
//in the init function
tz_dev = thermal_zone_device_register("tsensor", 2,NULL,&tsensor_ops, 0,0, 0,0);
where tsensor_ops points to a struct thermal_zone_device_ops with a bunch of dummy callback functions.
However, when I do an rmmod with the following code,
thermal_zone_device_unregister(tz_dev);
I get a message saying Killed! reply and dmesg gives me some error about NULL pointers. The only way for me to recover is to reboot the machine. Is there any way to avoid this?
Ok I fixed it. My specific version of linux, the thermal_sys framework requires us to have a function declared for get_crit_temp. If you don't define this, it will try to remove this device file upon unregistering the device and it will end up with a NULL reference error. Note that this does not apply to linux versions above 3.0