aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2009-09-22 19:47:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 10:39:53 -0400
commit5ff32f69e75deca5ee1a2f421ca8a3e43cfaa339 (patch)
treece934068e33d0053eb85992316bbf942215e6984 /drivers/video
parent837b0abba19a0ac7840f41debe267da2e2add6a7 (diff)
viafb: use read-only mode parsing
viafb: use read-only mode parsing The previous method of mode parsing wrote to the strings resulting in truncated mode strings in the sysfs. Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Scott Fang <ScottFang@viatech.com.cn> Cc: Joseph Chan <JosephChan@via.com.tw> Cc: Harald Welte <laforge@gnumonks.org> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/via/viafbdev.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 94ade1f9ff72..61e652cb2138 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1821,11 +1821,29 @@ static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
1821 remove_proc_entry("viafb", NULL); 1821 remove_proc_entry("viafb", NULL);
1822} 1822}
1823 1823
1824static void parse_mode(const char *str, u32 *xres, u32 *yres)
1825{
1826 char *ptr;
1827
1828 *xres = simple_strtoul(str, &ptr, 10);
1829 if (ptr[0] != 'x')
1830 goto out_default;
1831
1832 *yres = simple_strtoul(&ptr[1], &ptr, 10);
1833 if (ptr[0])
1834 goto out_default;
1835
1836 return;
1837
1838out_default:
1839 printk(KERN_WARNING "viafb received invalid mode string: %s\n", str);
1840 *xres = 640;
1841 *yres = 480;
1842}
1843
1824static int __devinit via_pci_probe(void) 1844static int __devinit via_pci_probe(void)
1825{ 1845{
1826 unsigned long default_xres, default_yres; 1846 u32 default_xres, default_yres;
1827 char *tmpc, *tmpm;
1828 char *tmpc_sec, *tmpm_sec;
1829 int vmode_index; 1847 int vmode_index;
1830 u32 viafb_par_length; 1848 u32 viafb_par_length;
1831 1849
@@ -1902,26 +1920,14 @@ static int __devinit via_pci_probe(void)
1902 viafb_second_size * 1024 * 1024; 1920 viafb_second_size * 1024 * 1024;
1903 } 1921 }
1904 1922
1905 tmpm = viafb_mode; 1923 parse_mode(viafb_mode, &default_xres, &default_yres);
1906 tmpc = strsep(&tmpm, "x");
1907 strict_strtoul(tmpc, 0, &default_xres);
1908 strict_strtoul(tmpm, 0, &default_yres);
1909
1910 vmode_index = viafb_get_mode_index(default_xres, default_yres); 1924 vmode_index = viafb_get_mode_index(default_xres, default_yres);
1911 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index); 1925 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
1912 1926
1913 if (viafb_SAMM_ON == 1) { 1927 if (viafb_SAMM_ON == 1) {
1914 if (strcmp(viafb_mode, viafb_mode1)) { 1928 parse_mode(viafb_mode1, &viafb_second_xres,
1915 tmpm_sec = viafb_mode1; 1929 &viafb_second_yres);
1916 tmpc_sec = strsep(&tmpm_sec, "x"); 1930
1917 strict_strtoul(tmpc_sec, 0,
1918 (unsigned long *)&viafb_second_xres);
1919 strict_strtoul(tmpm_sec, 0,
1920 (unsigned long *)&viafb_second_yres);
1921 } else {
1922 viafb_second_xres = default_xres;
1923 viafb_second_yres = default_yres;
1924 }
1925 if (0 == viafb_second_virtual_xres) { 1931 if (0 == viafb_second_virtual_xres) {
1926 switch (viafb_second_xres) { 1932 switch (viafb_second_xres) {
1927 case 1400: 1933 case 1400: