aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2011-11-09 15:33:22 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-15 18:52:46 -0500
commit2cd0050cf3ec4da847c3a2f7d95cffd548aef39d (patch)
tree3a9fb2454f7365a3c11c69ddd7f2231e14271596 /drivers/tty
parentba5db44895ec3abc5317a9af86001e688a72185c (diff)
TTY: move tty_lookup_driver to switch-cases
The labels express more the nature of the decision tree. We returned from each if with a driver. Now we do this at the end of the function and the code flow is clear. While at it, remove an obsolete comment (we already take the reference). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/tty_io.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index ba9194e7b9c8..76e66ff5e65d 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1841,16 +1841,17 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,
1841{ 1841{
1842 struct tty_driver *driver; 1842 struct tty_driver *driver;
1843 1843
1844 switch (device) {
1844#ifdef CONFIG_VT 1845#ifdef CONFIG_VT
1845 if (device == MKDEV(TTY_MAJOR, 0)) { 1846 case MKDEV(TTY_MAJOR, 0): {
1846 extern struct tty_driver *console_driver; 1847 extern struct tty_driver *console_driver;
1847 driver = tty_driver_kref_get(console_driver); 1848 driver = tty_driver_kref_get(console_driver);
1848 *index = fg_console; 1849 *index = fg_console;
1849 *noctty = 1; 1850 *noctty = 1;
1850 return driver; 1851 break;
1851 } 1852 }
1852#endif 1853#endif
1853 if (device == MKDEV(TTYAUX_MAJOR, 1)) { 1854 case MKDEV(TTYAUX_MAJOR, 1): {
1854 struct tty_driver *console_driver = console_device(index); 1855 struct tty_driver *console_driver = console_device(index);
1855 if (console_driver) { 1856 if (console_driver) {
1856 driver = tty_driver_kref_get(console_driver); 1857 driver = tty_driver_kref_get(console_driver);
@@ -1858,15 +1859,17 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,
1858 /* Don't let /dev/console block */ 1859 /* Don't let /dev/console block */
1859 filp->f_flags |= O_NONBLOCK; 1860 filp->f_flags |= O_NONBLOCK;
1860 *noctty = 1; 1861 *noctty = 1;
1861 return driver; 1862 break;
1862 } 1863 }
1863 } 1864 }
1864 return ERR_PTR(-ENODEV); 1865 return ERR_PTR(-ENODEV);
1865 } 1866 }
1866 1867 default:
1867 driver = get_tty_driver(device, index); 1868 driver = get_tty_driver(device, index);
1868 if (!driver) 1869 if (!driver)
1869 return ERR_PTR(-ENODEV); 1870 return ERR_PTR(-ENODEV);
1871 break;
1872 }
1870 return driver; 1873 return driver;
1871} 1874}
1872 1875