Access SPI within kernel space
I have spidev driver compiled, which i do have /dev/spidevx.x exist at my filesystem. Accessing through spi within userspace is working, but now I need to access spi from kernel space.
Upon machine_halt(), I need to access spi to write and read something. Within kernel space i found the function 'spi_write_then_read' which it ask for spi_device.
Where can I obtain the spi_device pointer from? Initially I try to get it from my platform_device, under platform_device i have .dev which is struct device.
Obtaining the device, i can convert it to spi_device by using to_spi_device(). Then I try to set the chipselect etc at spi_device.
After that, I try to spi_write_then_read() but i caught a kernel dump mention "Unable to handle kernel NULL pointer dereference"
My question is, is that a proper way to obtain spi_device? What should i do to access spi within kernel space?
|