以此範例來說如果直接make是看不出記指標任何錯誤 ex: http://kingofsdtw.blogspot.tw/2015/02/blog-post.html#links
\> make
if do make ,can't find any pointer error
安裝 sparse,並用 __iomem 監視你要的pointer
after install sparse and use __iomem monitor your pointer
( __iomem only useful when install sparse )
\> make C=2
他會幫助你發現錯誤
It will help you find some error
BUG:
////-------------------------------------------// // FUNCTION : MMIO_TEST // INPUT : // OUTPUT : // DESCRIPTION: // // #include // size : byte // ioremap(unsigned long phy_addr , unsigned int size) // ioremap_nocache(unsigned long phy_addr , unsigned int size) // iounmap() // release_mem_regin( start , size); //-------------------------------------------// // void MMIO_TEST(void){ char __iomem *reg; reg = ioremap_nocache(0xFEC00000 , 4 ); if(reg != NULL) { printk("Get mmio ,data = 0x%x\n",*reg); //free iounmap(reg); } }
Fix:
////-------------------------------------------// // FUNCTION : MMIO_TEST // INPUT : // OUTPUT : // DESCRIPTION: // // #include // size : byte // ioremap(unsigned long phy_addr , unsigned int size) // ioremap_nocache(unsigned long phy_addr , unsigned int size) // iounmap() // release_mem_regin( start , size); //-------------------------------------------// // void MMIO_TEST(void){ char __iomem *reg; reg = ioremap_nocache(0xFEC00000 , 4 ); if(reg != NULL) { printk("Get mmio ,data = 0x%x\n",ioread8(reg)); //free iounmap(reg); } }
沒有留言:
張貼留言