In the device_read function,
len — ;
should be len --; len — ;
should be len --;Also for anyone writing kernel code, this is indispensable: http://elixir.free-electrons.com/linux/latest/source
Nowadays, lots of code could be using devm_kmalloc, devm_ioremap, etc which will release the resources automatically when the driver detaches from the device.