New driver model in 2.6

Laurent Pinchart laurent.pinchart at technotrade.biz
Wed Feb 14 20:32:27 EST 2007


Hi,
> Anyone knows how, where, when the match device of spi_bus_type structure
> is called? I put a printk in spi_match_device function and registered an
> spi device in this way:
>
> static struct spi_board_info spi_board_info[] __initdata = {
>         {
>                 .modalias       = "m25p80",
>                 .max_speed_hz   = 16000000,
>                 .bus_num        = 0,
>                 .chip_select    = 0,
>         },
> };
>
> static int board_init_spi(void)
> {
>         printk("%s\n", __FUNCTION__);
>         spi_register_board_info(spi_board_info,
> ARRAY_SIZE(spi_board_info));
>         return 0;
> }
>
> But spi_match_device is not called and consequently the _probe function
> of m25p80 driver is never called.

spi_register_board_info() will add the board information structure to 
board_list in drivers/spi/spi.c. The list is walked from scan_boardinfo() in 
the same file when a SPI master is registered by spi_register_master(). The 
first step would be to check if spi_register_master() is called, and if it 
fails before calling scan_boardinfo(). Add a few printk's there.

If a master is correctly registered, scan_boardinfo() will call 
spi_new_device(), which in turn calls device_register(). That's where the 
spi_match_device() function should be called, using the function pointer 
stored in proxy->dev.bus.match.

Hope this helps.

Best regards,

Laurent Pinchart



More information about the Linuxppc-embedded mailing list