This one is okay.
> 2. The driver will create an entry in "sysfs" and a "corresponding" entry
> in /dev. Catting the device " /dev/mpu9250 " will return the device id.
>
> Then the driver will be a standard Linux kernel module with support for SPI
> ....
> #include <linux/module.h>
> #include <linux/spi/spi.h>
> ....
>
> struct spi_driver
> spi_register_driver (struct device dev; dictates the name of the device)
> spi_alloc_device
> spi_add_device
Not quite.
You should declare a struct spi_driver, register it using
spi_register_module, and in that structure, put the compatibles you
support. You'll also have to implement the probe and remove functions,
give in that spi_driver structure pointers to these functions, and
Linux will call probe whenever a device shows up, and call remove
whenever that device disappears.
Note that all this is covered in LDD3 and
http://free-electrons.com/doc/training/linux-kernel/slides.pdf, so I'd
suggest you go read these two, like I suggested you already (or should
have)
As for how to find simple SPI drivers, I don't really have an example
in mind, but you can search for spi_register_module, you should have a
huge number of hits.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com