Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: fbdev: savage: Replace mdelay with usleep_range in savage_init_hw

savage_init_hw() is never called in atomic context.

The call chains ending up at savage_init_hw() are:
[1] savage_init_hw() <- savagefb_probe()
[2] savage_init_hw() <- savagefb_resume()

savagefb_probe() is only set as ".probe" in struct pci_driver.
savagefb_resume) is only set as ".resume" in struct pci_driver.
These functions are not called in atomic context.

Despite never getting called from atomic context, savage_init_hw()
calls mdelay() to busily wait.
This is not necessary and can be replaced with usleep_range to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Jia-Ju Bai and committed by
Bartlomiej Zolnierkiewicz
12f3ac2f 8cad95f5

+4 -4
+4 -4
drivers/video/fbdev/savage/savagefb_driver.c
··· 1892 1892 vga_out8(0x3d4, 0x66, par); 1893 1893 cr66 = vga_in8(0x3d5, par); 1894 1894 vga_out8(0x3d5, cr66 | 0x02, par); 1895 - mdelay(10); 1895 + usleep_range(10000, 11000); 1896 1896 1897 1897 vga_out8(0x3d4, 0x66, par); 1898 1898 vga_out8(0x3d5, cr66 & ~0x02, par); /* clear reset flag */ 1899 - mdelay(10); 1899 + usleep_range(10000, 11000); 1900 1900 1901 1901 1902 1902 /* ··· 1906 1906 vga_out8(0x3d4, 0x3f, par); 1907 1907 cr3f = vga_in8(0x3d5, par); 1908 1908 vga_out8(0x3d5, cr3f | 0x08, par); 1909 - mdelay(10); 1909 + usleep_range(10000, 11000); 1910 1910 1911 1911 vga_out8(0x3d4, 0x3f, par); 1912 1912 vga_out8(0x3d5, cr3f & ~0x08, par); /* clear reset flags */ 1913 - mdelay(10); 1913 + usleep_range(10000, 11000); 1914 1914 1915 1915 /* Savage ramdac speeds */ 1916 1916 par->numClocks = 4;