Problems with dynamic registration of SPI protocol slave devices
I am trying to write a loadable kernel module that dynamically registers a slave SPI protocol device driver on a SPI bus.
I am using the Embest SBC6000x board with AT91SAM9261S. I note that the board has two SPI buses, Bus 0 and Bus 1, and both use the SPI master controller driver in /driver/atmel_spi.c. In my case, I would like my device registered on bus 1.
The problem I encounter is that when I try to get the spi master associated with Bus 1 in the init functions of my LKM by using the spi.c function, spi_busnum_to_master(1), the function returns NULL during insmod. (i.e. no master was found associated with bus 1, spi_busnum_to_master(1) returns NULL).
How can this be? In atmel_spi.c, the master seems to be registered with the SPI framework at the end of its probe function using the spi.c function spi_register_master(). I confirmed this in my kernel init.
Everything seems to work fine if I were to use spidev instead, and statically register my spidev slave device driver during kernel startup.