至此,在probe函数中, 由spi_bitbang_start调用所引起的一系列函数调用都已讲解完毕。下面总结下整个调用过程:

可以看到,调用spi_bitbang_start以后,spi_master和spi_device都将被注册到内核中。
下面来看下platform driver的其他几个方法。
4.2.3 remove,suspend以及resume方法
- static int __exit s3c24xx_spi_remove(struct platform_device *dev)
- {
- struct s3c24xx_spi *hw = platform_get_drvdata(dev);
- platform_set_drvdata(dev, NULL);
- spi_unregister_master(hw->master); /*注销spi主控制器*/
- clk_disable(hw->clk); /*禁止时钟*/
- clk_put(hw->clk); /*释放CLK*/
- free_irq(hw->irq, hw); /*注销IRQ*/
- iounmap(hw->regs); /*解除映射*/
- if (hw->set_cs == s3c24xx_spi_gpiocs)
- gpio_free(hw->pdata->pin_cs); /*释放用于cs的gpio*/
- release_resource(hw->ioarea);
- kfree(hw->ioarea);
- spi_master_put(hw->master); /*减少master引用计数*/
- return 0;
- }
- #ifdef CONFIG_PM /*如果定义了电源管理*/
- static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg)
- {
- struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
- if (hw->pdata && hw->pdata->gpio_setup)
- hw->pdata->gpio_setup(hw->pdata, 0);
- clk_disable(hw->clk);
- return 0;
- }
- static int s3c24xx_spi_resume(struct platform_device *pdev)
- {
- struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
- s3c24xx_spi_initialsetup(hw);
- return 0;
- }
- #else
- #define s3c24xx_spi_suspend NULL
- #define s3c24xx_spi_resume NULL
- #endif
至此,master 驱动的大体结构都已分析完毕,随后第三篇文章将介绍spi设备驱动。
