I am somewhat new to raspberry pi, and kernel building, and device drivers, but not programming in general, so I will be using the wrong words.
I have an SD card, which was prepared using the instructions on this page: http://elinux.org/RPi_CANBus, and then doing insmod on the modules can.ko, can-bcm.ko, can-dev.ko, can-raw.ko, mcp251x.ko, mcp2515.ko and spi-cm2708.ko, finally doing "ip link set can0". The kernel is 3.6. This setup works (except for the latency problems that apparently a lot of people are having).
Now I want to use kernel 4.2, because a more recent kernel than 3.6 is needed for some camera that we want to use. The instructions on the page I mentioned don't fit completely anymore, but I think I could adapt all steps appropriately. When I run this kernel and do this command:
ip link set can0 up type can bitrate 500000
I get the error message "Invalid argument", and in /var/log/messages, it says
"A link change request failed with some changes committed already. Interface can0 may have been left with an inconsistent configuration, please check."
I have read at some place (maybe this forum) that people do use the CAN bus with kernel 4.2. They were asking whether the alternative 2515 module (described at the end of the instruction page) can be made to run there, and I'd like to know that too, since it has better latency, but to begin with I can't get CAN to work at all. Perhaps 4.1 will be sufficient for me, but I tried that too, with the same result.
Once having a 4.2 that didn't work, I went through the instructions for 3.6 and got back a 3.6 that worked, and then I went to 4.2 again.
What could be wrong?