aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTorben Hohn <torbenh@gmx.de>2011-01-25 18:07:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-25 19:50:06 -0500
commitac751efa6a0d70f2c9daef5c7e3a92270f5c2dff (patch)
treee2d3f799e20e2cbca80891ea17af7484f21d628f
parent3689456b4bd36027022b3215eb2acba51cd0e6b5 (diff)
console: rename acquire/release_console_sem() to console_lock/unlock()
The -rt patches change the console_semaphore to console_mutex. As a result, a quite large chunk of the patches changes all acquire/release_console_sem() to acquire/release_console_mutex() This commit makes things use more neutral function names which dont make implications about the underlying lock. The only real change is the return value of console_trylock which is inverted from try_acquire_console_sem() This patch also paves the way to switching console_sem from a semaphore to a mutex. [akpm@linux-foundation.org: coding-style fixes] [akpm@linux-foundation.org: make console_trylock return 1 on success, per Geert] Signed-off-by: Torben Hohn <torbenh@gmx.de> Cc: Thomas Gleixner <tglx@tglx.de> Cc: Greg KH <gregkh@suse.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/arm/mach-omap2/pm24xx.c4
-rw-r--r--arch/arm/mach-omap2/pm34xx.c4
-rw-r--r--arch/arm/mach-omap2/serial.c4
-rw-r--r--arch/parisc/kernel/pdc_cons.c4
-rw-r--r--drivers/char/bfin_jtag_comm.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c10
-rw-r--r--drivers/staging/msm/msm_fb.c8
-rw-r--r--drivers/staging/olpc_dcon/olpc_dcon.c10
-rw-r--r--drivers/staging/sm7xx/smtcfb.c8
-rw-r--r--drivers/tty/serial/sb1250-duart.c2
-rw-r--r--drivers/tty/tty_io.c4
-rw-r--r--drivers/tty/vt/selection.c4
-rw-r--r--drivers/tty/vt/vc_screen.c16
-rw-r--r--drivers/tty/vt/vt.c124
-rw-r--r--drivers/tty/vt/vt_ioctl.c60
-rw-r--r--drivers/video/arkfb.c12
-rw-r--r--drivers/video/aty/aty128fb.c12
-rw-r--r--drivers/video/aty/atyfb_base.c10
-rw-r--r--drivers/video/aty/radeon_pm.c10
-rw-r--r--drivers/video/chipsfb.c8
-rw-r--r--drivers/video/console/fbcon.c42
-rw-r--r--drivers/video/da8xx-fb.c8
-rw-r--r--drivers/video/fbmem.c12
-rw-r--r--drivers/video/fbsysfs.c20
-rw-r--r--drivers/video/geode/gxfb_core.c8
-rw-r--r--drivers/video/geode/lxfb_core.c8
-rw-r--r--drivers/video/i810/i810_main.c8
-rw-r--r--drivers/video/jz4740_fb.c8
-rw-r--r--drivers/video/mx3fb.c8
-rw-r--r--drivers/video/nvidia/nvidia.c8
-rw-r--r--drivers/video/ps3fb.c16
-rw-r--r--drivers/video/s3fb.c16
-rw-r--r--drivers/video/savage/savagefb_driver.c8
-rw-r--r--drivers/video/sh_mobile_hdmi.c8
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c4
-rw-r--r--drivers/video/sm501fb.c8
-rw-r--r--drivers/video/tmiofb.c10
-rw-r--r--drivers/video/via/viafbdev.c8
-rw-r--r--drivers/video/vt8623fb.c12
-rw-r--r--drivers/video/xen-fbfront.c4
-rw-r--r--fs/proc/consoles.c4
-rw-r--r--include/linux/console.h6
-rw-r--r--kernel/printk.c100
44 files changed, 336 insertions, 328 deletions
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 9e5dc8ed51e9..97feb3ab6a69 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -134,7 +134,7 @@ static void omap2_enter_full_retention(void)
134 134
135 /* Block console output in case it is on one of the OMAP UARTs */ 135 /* Block console output in case it is on one of the OMAP UARTs */
136 if (!is_suspending()) 136 if (!is_suspending())
137 if (try_acquire_console_sem()) 137 if (!console_trylock())
138 goto no_sleep; 138 goto no_sleep;
139 139
140 omap_uart_prepare_idle(0); 140 omap_uart_prepare_idle(0);
@@ -151,7 +151,7 @@ static void omap2_enter_full_retention(void)
151 omap_uart_resume_idle(0); 151 omap_uart_resume_idle(0);
152 152
153 if (!is_suspending()) 153 if (!is_suspending())
154 release_console_sem(); 154 console_unlock();
155 155
156no_sleep: 156no_sleep:
157 if (omap2_pm_debug) { 157 if (omap2_pm_debug) {
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 8cbbeade4b8a..a4aa1920a75c 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -398,7 +398,7 @@ void omap_sram_idle(void)
398 if (!is_suspending()) 398 if (!is_suspending())
399 if (per_next_state < PWRDM_POWER_ON || 399 if (per_next_state < PWRDM_POWER_ON ||
400 core_next_state < PWRDM_POWER_ON) 400 core_next_state < PWRDM_POWER_ON)
401 if (try_acquire_console_sem()) 401 if (!console_trylock())
402 goto console_still_active; 402 goto console_still_active;
403 403
404 /* PER */ 404 /* PER */
@@ -481,7 +481,7 @@ void omap_sram_idle(void)
481 } 481 }
482 482
483 if (!is_suspending()) 483 if (!is_suspending())
484 release_console_sem(); 484 console_unlock();
485 485
486console_still_active: 486console_still_active:
487 /* Disable IO-PAD and IO-CHAIN wakeup */ 487 /* Disable IO-PAD and IO-CHAIN wakeup */
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 302da7403a10..32e91a9c8b6b 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -812,7 +812,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
812 812
813 oh->dev_attr = uart; 813 oh->dev_attr = uart;
814 814
815 acquire_console_sem(); /* in case the earlycon is on the UART */ 815 console_lock(); /* in case the earlycon is on the UART */
816 816
817 /* 817 /*
818 * Because of early UART probing, UART did not get idled 818 * Because of early UART probing, UART did not get idled
@@ -838,7 +838,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
838 omap_uart_block_sleep(uart); 838 omap_uart_block_sleep(uart);
839 uart->timeout = DEFAULT_TIMEOUT; 839 uart->timeout = DEFAULT_TIMEOUT;
840 840
841 release_console_sem(); 841 console_unlock();
842 842
843 if ((cpu_is_omap34xx() && uart->padconf) || 843 if ((cpu_is_omap34xx() && uart->padconf) ||
844 (uart->wk_en && uart->wk_mask)) { 844 (uart->wk_en && uart->wk_mask)) {
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 11bdd68e5762..fc770be465ff 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -169,11 +169,11 @@ static int __init pdc_console_tty_driver_init(void)
169 169
170 struct console *tmp; 170 struct console *tmp;
171 171
172 acquire_console_sem(); 172 console_lock();
173 for_each_console(tmp) 173 for_each_console(tmp)
174 if (tmp == &pdc_cons) 174 if (tmp == &pdc_cons)
175 break; 175 break;
176 release_console_sem(); 176 console_unlock();
177 177
178 if (!tmp) { 178 if (!tmp) {
179 printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name); 179 printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name);
diff --git a/drivers/char/bfin_jtag_comm.c b/drivers/char/bfin_jtag_comm.c
index e397df3ad98e..16402445f2b2 100644
--- a/drivers/char/bfin_jtag_comm.c
+++ b/drivers/char/bfin_jtag_comm.c
@@ -183,16 +183,16 @@ bfin_jc_circ_write(const unsigned char *buf, int count)
183} 183}
184 184
185#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE 185#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE
186# define acquire_console_sem() 186# define console_lock()
187# define release_console_sem() 187# define console_unlock()
188#endif 188#endif
189static int 189static int
190bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count) 190bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count)
191{ 191{
192 int i; 192 int i;
193 acquire_console_sem(); 193 console_lock();
194 i = bfin_jc_circ_write(buf, count); 194 i = bfin_jc_circ_write(buf, count);
195 release_console_sem(); 195 console_unlock();
196 wake_up_process(bfin_jc_kthread); 196 wake_up_process(bfin_jc_kthread);
197 return i; 197 return i;
198} 198}
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 13bb672a16f4..f658a04eecf9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -234,9 +234,9 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
234 pci_set_power_state(pdev, PCI_D3hot); 234 pci_set_power_state(pdev, PCI_D3hot);
235 } 235 }
236 236
237 acquire_console_sem(); 237 console_lock();
238 nouveau_fbcon_set_suspend(dev, 1); 238 nouveau_fbcon_set_suspend(dev, 1);
239 release_console_sem(); 239 console_unlock();
240 nouveau_fbcon_restore_accel(dev); 240 nouveau_fbcon_restore_accel(dev);
241 return 0; 241 return 0;
242 242
@@ -359,9 +359,9 @@ nouveau_pci_resume(struct pci_dev *pdev)
359 nv_crtc->lut.depth = 0; 359 nv_crtc->lut.depth = 0;
360 } 360 }
361 361
362 acquire_console_sem(); 362 console_lock();
363 nouveau_fbcon_set_suspend(dev, 0); 363 nouveau_fbcon_set_suspend(dev, 0);
364 release_console_sem(); 364 console_unlock();
365 365
366 nouveau_fbcon_zfill_all(dev); 366 nouveau_fbcon_zfill_all(dev);
367 367
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 26091d602b84..0d478932b1a9 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -891,9 +891,9 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
891 pci_disable_device(dev->pdev); 891 pci_disable_device(dev->pdev);
892 pci_set_power_state(dev->pdev, PCI_D3hot); 892 pci_set_power_state(dev->pdev, PCI_D3hot);
893 } 893 }
894 acquire_console_sem(); 894 console_lock();
895 radeon_fbdev_set_suspend(rdev, 1); 895 radeon_fbdev_set_suspend(rdev, 1);
896 release_console_sem(); 896 console_unlock();
897 return 0; 897 return 0;
898} 898}
899 899
@@ -905,11 +905,11 @@ int radeon_resume_kms(struct drm_device *dev)
905 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 905 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
906 return 0; 906 return 0;
907 907
908 acquire_console_sem(); 908 console_lock();
909 pci_set_power_state(dev->pdev, PCI_D0); 909 pci_set_power_state(dev->pdev, PCI_D0);
910 pci_restore_state(dev->pdev); 910 pci_restore_state(dev->pdev);
911 if (pci_enable_device(dev->pdev)) { 911 if (pci_enable_device(dev->pdev)) {
912 release_console_sem(); 912 console_unlock();
913 return -1; 913 return -1;
914 } 914 }
915 pci_set_master(dev->pdev); 915 pci_set_master(dev->pdev);
@@ -920,7 +920,7 @@ int radeon_resume_kms(struct drm_device *dev)
920 radeon_restore_bios_scratch_regs(rdev); 920 radeon_restore_bios_scratch_regs(rdev);
921 921
922 radeon_fbdev_set_suspend(rdev, 0); 922 radeon_fbdev_set_suspend(rdev, 0);
923 release_console_sem(); 923 console_unlock();
924 924
925 /* reset hpd state */ 925 /* reset hpd state */
926 radeon_hpd_init(rdev); 926 radeon_hpd_init(rdev);
diff --git a/drivers/staging/msm/msm_fb.c b/drivers/staging/msm/msm_fb.c
index 23fa049b51f2..a2f29d464051 100644
--- a/drivers/staging/msm/msm_fb.c
+++ b/drivers/staging/msm/msm_fb.c
@@ -347,7 +347,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
347 if ((!mfd) || (mfd->key != MFD_KEY)) 347 if ((!mfd) || (mfd->key != MFD_KEY))
348 return 0; 348 return 0;
349 349
350 acquire_console_sem(); 350 console_lock();
351 fb_set_suspend(mfd->fbi, 1); 351 fb_set_suspend(mfd->fbi, 1);
352 352
353 ret = msm_fb_suspend_sub(mfd); 353 ret = msm_fb_suspend_sub(mfd);
@@ -358,7 +358,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
358 pdev->dev.power.power_state = state; 358 pdev->dev.power.power_state = state;
359 } 359 }
360 360
361 release_console_sem(); 361 console_unlock();
362 return ret; 362 return ret;
363} 363}
364#else 364#else
@@ -431,11 +431,11 @@ static int msm_fb_resume(struct platform_device *pdev)
431 if ((!mfd) || (mfd->key != MFD_KEY)) 431 if ((!mfd) || (mfd->key != MFD_KEY))
432 return 0; 432 return 0;
433 433
434 acquire_console_sem(); 434 console_lock();
435 ret = msm_fb_resume_sub(mfd); 435 ret = msm_fb_resume_sub(mfd);
436 pdev->dev.power.power_state = PMSG_ON; 436 pdev->dev.power.power_state = PMSG_ON;
437 fb_set_suspend(mfd->fbi, 1); 437 fb_set_suspend(mfd->fbi, 1);
438 release_console_sem(); 438 console_unlock();
439 439
440 return ret; 440 return ret;
441} 441}
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index 9f26dc9408bb..56a283d1a74d 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -373,17 +373,17 @@ static void dcon_source_switch(struct work_struct *work)
373 * 373 *
374 * For now, we just hope.. 374 * For now, we just hope..
375 */ 375 */
376 acquire_console_sem(); 376 console_lock();
377 ignore_fb_events = 1; 377 ignore_fb_events = 1;
378 if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) { 378 if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) {
379 ignore_fb_events = 0; 379 ignore_fb_events = 0;
380 release_console_sem(); 380 console_unlock();
381 printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n"); 381 printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n");
382 dcon_pending = DCON_SOURCE_DCON; 382 dcon_pending = DCON_SOURCE_DCON;
383 return; 383 return;
384 } 384 }
385 ignore_fb_events = 0; 385 ignore_fb_events = 0;
386 release_console_sem(); 386 console_unlock();
387 387
388 /* And turn off the DCON */ 388 /* And turn off the DCON */
389 pdata->set_dconload(1); 389 pdata->set_dconload(1);
@@ -435,12 +435,12 @@ static void dcon_source_switch(struct work_struct *work)
435 } 435 }
436 } 436 }
437 437
438 acquire_console_sem(); 438 console_lock();
439 ignore_fb_events = 1; 439 ignore_fb_events = 1;
440 if (fb_blank(fbinfo, FB_BLANK_POWERDOWN)) 440 if (fb_blank(fbinfo, FB_BLANK_POWERDOWN))
441 printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n"); 441 printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n");
442 ignore_fb_events = 0; 442 ignore_fb_events = 0;
443 release_console_sem(); 443 console_unlock();
444 444
445 printk(KERN_INFO "olpc-dcon: The DCON has control\n"); 445 printk(KERN_INFO "olpc-dcon: The DCON has control\n");
446 break; 446 break;
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index 0bc113c44d39..d007e4a12c14 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -1044,9 +1044,9 @@ static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
1044 1044
1045 /* when doing suspend, call fb apis and pci apis */ 1045 /* when doing suspend, call fb apis and pci apis */
1046 if (msg.event == PM_EVENT_SUSPEND) { 1046 if (msg.event == PM_EVENT_SUSPEND) {
1047 acquire_console_sem(); 1047 console_lock();
1048 fb_set_suspend(&sfb->fb, 1); 1048 fb_set_suspend(&sfb->fb, 1);
1049 release_console_sem(); 1049 console_unlock();
1050 retv = pci_save_state(pdev); 1050 retv = pci_save_state(pdev);
1051 pci_disable_device(pdev); 1051 pci_disable_device(pdev);
1052 retv = pci_choose_state(pdev, msg); 1052 retv = pci_choose_state(pdev, msg);
@@ -1105,9 +1105,9 @@ static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)
1105 1105
1106 smtcfb_setmode(sfb); 1106 smtcfb_setmode(sfb);
1107 1107
1108 acquire_console_sem(); 1108 console_lock();
1109 fb_set_suspend(&sfb->fb, 0); 1109 fb_set_suspend(&sfb->fb, 0);
1110 release_console_sem(); 1110 console_unlock();
1111 1111
1112 return 0; 1112 return 0;
1113} 1113}
diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
index a2f2b3254499..602d9845c52f 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -829,7 +829,7 @@ static void __init sbd_probe_duarts(void)
829#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE 829#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE
830/* 830/*
831 * Serial console stuff. Very basic, polling driver for doing serial 831 * Serial console stuff. Very basic, polling driver for doing serial
832 * console output. The console_sem is held by the caller, so we 832 * console output. The console_lock is held by the caller, so we
833 * shouldn't be interrupted for more console activity. 833 * shouldn't be interrupted for more console activity.
834 */ 834 */
835static void sbd_console_putchar(struct uart_port *uport, int ch) 835static void sbd_console_putchar(struct uart_port *uport, int ch)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 464d09d97873..6158eae0f64a 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3256,7 +3256,7 @@ static ssize_t show_cons_active(struct device *dev,
3256 struct console *c; 3256 struct console *c;
3257 ssize_t count = 0; 3257 ssize_t count = 0;
3258 3258
3259 acquire_console_sem(); 3259 console_lock();
3260 for (c = console_drivers; c; c = c->next) { 3260 for (c = console_drivers; c; c = c->next) {
3261 if (!c->device) 3261 if (!c->device)
3262 continue; 3262 continue;
@@ -3271,7 +3271,7 @@ static ssize_t show_cons_active(struct device *dev,
3271 while (i--) 3271 while (i--)
3272 count += sprintf(buf + count, "%s%d%c", 3272 count += sprintf(buf + count, "%s%d%c",
3273 cs[i]->name, cs[i]->index, i ? ' ':'\n'); 3273 cs[i]->name, cs[i]->index, i ? ' ':'\n');
3274 release_console_sem(); 3274 console_unlock();
3275 3275
3276 return count; 3276 return count;
3277} 3277}
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index ebae344ce910..c956ed6c83a3 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -316,9 +316,9 @@ int paste_selection(struct tty_struct *tty)
316 /* always called with BTM from vt_ioctl */ 316 /* always called with BTM from vt_ioctl */
317 WARN_ON(!tty_locked()); 317 WARN_ON(!tty_locked());
318 318
319 acquire_console_sem(); 319 console_lock();
320 poke_blanked_console(); 320 poke_blanked_console();
321 release_console_sem(); 321 console_unlock();
322 322
323 ld = tty_ldisc_ref(tty); 323 ld = tty_ldisc_ref(tty);
324 if (!ld) { 324 if (!ld) {
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index eab3a1ff99e4..a672ed192d33 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -202,7 +202,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
202 /* Select the proper current console and verify 202 /* Select the proper current console and verify
203 * sanity of the situation under the console lock. 203 * sanity of the situation under the console lock.
204 */ 204 */
205 acquire_console_sem(); 205 console_lock();
206 206
207 attr = (currcons & 128); 207 attr = (currcons & 128);
208 currcons = (currcons & 127); 208 currcons = (currcons & 127);
@@ -336,9 +336,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
336 * the pagefault handling code may want to call printk(). 336 * the pagefault handling code may want to call printk().
337 */ 337 */
338 338
339 release_console_sem(); 339 console_unlock();
340 ret = copy_to_user(buf, con_buf_start, orig_count); 340 ret = copy_to_user(buf, con_buf_start, orig_count);
341 acquire_console_sem(); 341 console_lock();
342 342
343 if (ret) { 343 if (ret) {
344 read += (orig_count - ret); 344 read += (orig_count - ret);
@@ -354,7 +354,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
354 if (read) 354 if (read)
355 ret = read; 355 ret = read;
356unlock_out: 356unlock_out:
357 release_console_sem(); 357 console_unlock();
358 mutex_unlock(&con_buf_mtx); 358 mutex_unlock(&con_buf_mtx);
359 return ret; 359 return ret;
360} 360}
@@ -379,7 +379,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
379 /* Select the proper current console and verify 379 /* Select the proper current console and verify
380 * sanity of the situation under the console lock. 380 * sanity of the situation under the console lock.
381 */ 381 */
382 acquire_console_sem(); 382 console_lock();
383 383
384 attr = (currcons & 128); 384 attr = (currcons & 128);
385 currcons = (currcons & 127); 385 currcons = (currcons & 127);
@@ -414,9 +414,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
414 /* Temporarily drop the console lock so that we can read 414 /* Temporarily drop the console lock so that we can read
415 * in the write data from userspace safely. 415 * in the write data from userspace safely.
416 */ 416 */
417 release_console_sem(); 417 console_unlock();
418 ret = copy_from_user(con_buf, buf, this_round); 418 ret = copy_from_user(con_buf, buf, this_round);
419 acquire_console_sem(); 419 console_lock();
420 420
421 if (ret) { 421 if (ret) {
422 this_round -= ret; 422 this_round -= ret;
@@ -542,7 +542,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
542 vcs_scr_updated(vc); 542 vcs_scr_updated(vc);
543 543
544unlock_out: 544unlock_out:
545 release_console_sem(); 545 console_unlock();
546 546
547 mutex_unlock(&con_buf_mtx); 547 mutex_unlock(&con_buf_mtx);
548 548
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 76407eca9ab0..b230bd3f056f 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1003,9 +1003,9 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws)
1003 struct vc_data *vc = tty->driver_data; 1003 struct vc_data *vc = tty->driver_data;
1004 int ret; 1004 int ret;
1005 1005
1006 acquire_console_sem(); 1006 console_lock();
1007 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); 1007 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row);
1008 release_console_sem(); 1008 console_unlock();
1009 return ret; 1009 return ret;
1010} 1010}
1011 1011
@@ -1271,7 +1271,7 @@ static void default_attr(struct vc_data *vc)
1271 vc->vc_color = vc->vc_def_color; 1271 vc->vc_color = vc->vc_def_color;
1272} 1272}
1273 1273
1274/* console_sem is held */ 1274/* console_lock is held */
1275static void csi_m(struct vc_data *vc) 1275static void csi_m(struct vc_data *vc)
1276{ 1276{
1277 int i; 1277 int i;
@@ -1415,7 +1415,7 @@ int mouse_reporting(void)
1415 return vc_cons[fg_console].d->vc_report_mouse; 1415 return vc_cons[fg_console].d->vc_report_mouse;
1416} 1416}
1417 1417
1418/* console_sem is held */ 1418/* console_lock is held */
1419static void set_mode(struct vc_data *vc, int on_off) 1419static void set_mode(struct vc_data *vc, int on_off)
1420{ 1420{
1421 int i; 1421 int i;
@@ -1485,7 +1485,7 @@ static void set_mode(struct vc_data *vc, int on_off)
1485 } 1485 }
1486} 1486}
1487 1487
1488/* console_sem is held */ 1488/* console_lock is held */
1489static void setterm_command(struct vc_data *vc) 1489static void setterm_command(struct vc_data *vc)
1490{ 1490{
1491 switch(vc->vc_par[0]) { 1491 switch(vc->vc_par[0]) {
@@ -1545,7 +1545,7 @@ static void setterm_command(struct vc_data *vc)
1545 } 1545 }
1546} 1546}
1547 1547
1548/* console_sem is held */ 1548/* console_lock is held */
1549static void csi_at(struct vc_data *vc, unsigned int nr) 1549static void csi_at(struct vc_data *vc, unsigned int nr)
1550{ 1550{
1551 if (nr > vc->vc_cols - vc->vc_x) 1551 if (nr > vc->vc_cols - vc->vc_x)
@@ -1555,7 +1555,7 @@ static void csi_at(struct vc_data *vc, unsigned int nr)
1555 insert_char(vc, nr); 1555 insert_char(vc, nr);
1556} 1556}
1557 1557
1558/* console_sem is held */ 1558/* console_lock is held */
1559static void csi_L(struct vc_data *vc, unsigned int nr) 1559static void csi_L(struct vc_data *vc, unsigned int nr)
1560{ 1560{
1561 if (nr > vc->vc_rows - vc->vc_y) 1561 if (nr > vc->vc_rows - vc->vc_y)
@@ -1566,7 +1566,7 @@ static void csi_L(struct vc_data *vc, unsigned int nr)
1566 vc->vc_need_wrap = 0; 1566 vc->vc_need_wrap = 0;
1567} 1567}
1568 1568
1569/* console_sem is held */ 1569/* console_lock is held */
1570static void csi_P(struct vc_data *vc, unsigned int nr) 1570static void csi_P(struct vc_data *vc, unsigned int nr)
1571{ 1571{
1572 if (nr > vc->vc_cols - vc->vc_x) 1572 if (nr > vc->vc_cols - vc->vc_x)
@@ -1576,7 +1576,7 @@ static void csi_P(struct vc_data *vc, unsigned int nr)
1576 delete_char(vc, nr); 1576 delete_char(vc, nr);
1577} 1577}
1578 1578
1579/* console_sem is held */ 1579/* console_lock is held */
1580static void csi_M(struct vc_data *vc, unsigned int nr) 1580static void csi_M(struct vc_data *vc, unsigned int nr)
1581{ 1581{
1582 if (nr > vc->vc_rows - vc->vc_y) 1582 if (nr > vc->vc_rows - vc->vc_y)
@@ -1587,7 +1587,7 @@ static void csi_M(struct vc_data *vc, unsigned int nr)
1587 vc->vc_need_wrap = 0; 1587 vc->vc_need_wrap = 0;
1588} 1588}
1589 1589
1590/* console_sem is held (except via vc_init->reset_terminal */ 1590/* console_lock is held (except via vc_init->reset_terminal */
1591static void save_cur(struct vc_data *vc) 1591static void save_cur(struct vc_data *vc)
1592{ 1592{
1593 vc->vc_saved_x = vc->vc_x; 1593 vc->vc_saved_x = vc->vc_x;
@@ -1603,7 +1603,7 @@ static void save_cur(struct vc_data *vc)
1603 vc->vc_saved_G1 = vc->vc_G1_charset; 1603 vc->vc_saved_G1 = vc->vc_G1_charset;
1604} 1604}
1605 1605
1606/* console_sem is held */ 1606/* console_lock is held */
1607static void restore_cur(struct vc_data *vc) 1607static void restore_cur(struct vc_data *vc)
1608{ 1608{
1609 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); 1609 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
@@ -1625,7 +1625,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
1625 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd, 1625 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
1626 ESpalette }; 1626 ESpalette };
1627 1627
1628/* console_sem is held (except via vc_init()) */ 1628/* console_lock is held (except via vc_init()) */
1629static void reset_terminal(struct vc_data *vc, int do_clear) 1629static void reset_terminal(struct vc_data *vc, int do_clear)
1630{ 1630{
1631 vc->vc_top = 0; 1631 vc->vc_top = 0;
@@ -1685,7 +1685,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
1685 csi_J(vc, 2); 1685 csi_J(vc, 2);
1686} 1686}
1687 1687
1688/* console_sem is held */ 1688/* console_lock is held */
1689static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) 1689static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
1690{ 1690{
1691 /* 1691 /*
@@ -2119,7 +2119,7 @@ static int is_double_width(uint32_t ucs)
2119 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1); 2119 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1);
2120} 2120}
2121 2121
2122/* acquires console_sem */ 2122/* acquires console_lock */
2123static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2123static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
2124{ 2124{
2125#ifdef VT_BUF_VRAM_ONLY 2125#ifdef VT_BUF_VRAM_ONLY
@@ -2147,11 +2147,11 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2147 2147
2148 might_sleep(); 2148 might_sleep();
2149 2149
2150 acquire_console_sem(); 2150 console_lock();
2151 vc = tty->driver_data; 2151 vc = tty->driver_data;
2152 if (vc == NULL) { 2152 if (vc == NULL) {
2153 printk(KERN_ERR "vt: argh, driver_data is NULL !\n"); 2153 printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
2154 release_console_sem(); 2154 console_unlock();
2155 return 0; 2155 return 0;
2156 } 2156 }
2157 2157
@@ -2159,7 +2159,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2159 if (!vc_cons_allocated(currcons)) { 2159 if (!vc_cons_allocated(currcons)) {
2160 /* could this happen? */ 2160 /* could this happen? */
2161 printk_once("con_write: tty %d not allocated\n", currcons+1); 2161 printk_once("con_write: tty %d not allocated\n", currcons+1);
2162 release_console_sem(); 2162 console_unlock();
2163 return 0; 2163 return 0;
2164 } 2164 }
2165 2165
@@ -2375,7 +2375,7 @@ rescan_last_byte:
2375 } 2375 }
2376 FLUSH 2376 FLUSH
2377 console_conditional_schedule(); 2377 console_conditional_schedule();
2378 release_console_sem(); 2378 console_unlock();
2379 notify_update(vc); 2379 notify_update(vc);
2380 return n; 2380 return n;
2381#undef FLUSH 2381#undef FLUSH
@@ -2388,11 +2388,11 @@ rescan_last_byte:
2388 * us to do the switches asynchronously (needed when we want 2388 * us to do the switches asynchronously (needed when we want
2389 * to switch due to a keyboard interrupt). Synchronization 2389 * to switch due to a keyboard interrupt). Synchronization
2390 * with other console code and prevention of re-entrancy is 2390 * with other console code and prevention of re-entrancy is
2391 * ensured with console_sem. 2391 * ensured with console_lock.
2392 */ 2392 */
2393static void console_callback(struct work_struct *ignored) 2393static void console_callback(struct work_struct *ignored)
2394{ 2394{
2395 acquire_console_sem(); 2395 console_lock();
2396 2396
2397 if (want_console >= 0) { 2397 if (want_console >= 0) {
2398 if (want_console != fg_console && 2398 if (want_console != fg_console &&
@@ -2422,7 +2422,7 @@ static void console_callback(struct work_struct *ignored)
2422 } 2422 }
2423 notify_update(vc_cons[fg_console].d); 2423 notify_update(vc_cons[fg_console].d);
2424 2424
2425 release_console_sem(); 2425 console_unlock();
2426} 2426}
2427 2427
2428int set_console(int nr) 2428int set_console(int nr)
@@ -2603,7 +2603,7 @@ static struct console vt_console_driver = {
2603 */ 2603 */
2604 2604
2605/* 2605/*
2606 * Generally a bit racy with respect to console_sem(). 2606 * Generally a bit racy with respect to console_lock();.
2607 * 2607 *
2608 * There are some functions which don't need it. 2608 * There are some functions which don't need it.
2609 * 2609 *
@@ -2629,17 +2629,17 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2629 switch (type) 2629 switch (type)
2630 { 2630 {
2631 case TIOCL_SETSEL: 2631 case TIOCL_SETSEL:
2632 acquire_console_sem(); 2632 console_lock();
2633 ret = set_selection((struct tiocl_selection __user *)(p+1), tty); 2633 ret = set_selection((struct tiocl_selection __user *)(p+1), tty);
2634 release_console_sem(); 2634 console_unlock();
2635 break; 2635 break;
2636 case TIOCL_PASTESEL: 2636 case TIOCL_PASTESEL:
2637 ret = paste_selection(tty); 2637 ret = paste_selection(tty);
2638 break; 2638 break;
2639 case TIOCL_UNBLANKSCREEN: 2639 case TIOCL_UNBLANKSCREEN:
2640 acquire_console_sem(); 2640 console_lock();
2641 unblank_screen(); 2641 unblank_screen();
2642 release_console_sem(); 2642 console_unlock();
2643 break; 2643 break;
2644 case TIOCL_SELLOADLUT: 2644 case TIOCL_SELLOADLUT:
2645 ret = sel_loadlut(p); 2645 ret = sel_loadlut(p);
@@ -2688,10 +2688,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2688 } 2688 }
2689 break; 2689 break;
2690 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ 2690 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
2691 acquire_console_sem(); 2691 console_lock();
2692 ignore_poke = 1; 2692 ignore_poke = 1;
2693 do_blank_screen(0); 2693 do_blank_screen(0);
2694 release_console_sem(); 2694 console_unlock();
2695 break; 2695 break;
2696 case TIOCL_BLANKEDSCREEN: 2696 case TIOCL_BLANKEDSCREEN:
2697 ret = console_blanked; 2697 ret = console_blanked;
@@ -2790,11 +2790,11 @@ static void con_flush_chars(struct tty_struct *tty)
2790 return; 2790 return;
2791 2791
2792 /* if we race with con_close(), vt may be null */ 2792 /* if we race with con_close(), vt may be null */
2793 acquire_console_sem(); 2793 console_lock();
2794 vc = tty->driver_data; 2794 vc = tty->driver_data;
2795 if (vc) 2795 if (vc)
2796 set_cursor(vc); 2796 set_cursor(vc);
2797 release_console_sem(); 2797 console_unlock();
2798} 2798}
2799 2799
2800/* 2800/*
@@ -2805,7 +2805,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2805 unsigned int currcons = tty->index; 2805 unsigned int currcons = tty->index;
2806 int ret = 0; 2806 int ret = 0;
2807 2807
2808 acquire_console_sem(); 2808 console_lock();
2809 if (tty->driver_data == NULL) { 2809 if (tty->driver_data == NULL) {
2810 ret = vc_allocate(currcons); 2810 ret = vc_allocate(currcons);
2811 if (ret == 0) { 2811 if (ret == 0) {
@@ -2813,7 +2813,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2813 2813
2814 /* Still being freed */ 2814 /* Still being freed */
2815 if (vc->port.tty) { 2815 if (vc->port.tty) {
2816 release_console_sem(); 2816 console_unlock();
2817 return -ERESTARTSYS; 2817 return -ERESTARTSYS;
2818 } 2818 }
2819 tty->driver_data = vc; 2819 tty->driver_data = vc;
@@ -2827,11 +2827,11 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2827 tty->termios->c_iflag |= IUTF8; 2827 tty->termios->c_iflag |= IUTF8;
2828 else 2828 else
2829 tty->termios->c_iflag &= ~IUTF8; 2829 tty->termios->c_iflag &= ~IUTF8;
2830 release_console_sem(); 2830 console_unlock();
2831 return ret; 2831 return ret;
2832 } 2832 }
2833 } 2833 }
2834 release_console_sem(); 2834 console_unlock();
2835 return ret; 2835 return ret;
2836} 2836}
2837 2837
@@ -2844,9 +2844,9 @@ static void con_shutdown(struct tty_struct *tty)
2844{ 2844{
2845 struct vc_data *vc = tty->driver_data; 2845 struct vc_data *vc = tty->driver_data;
2846 BUG_ON(vc == NULL); 2846 BUG_ON(vc == NULL);
2847 acquire_console_sem(); 2847 console_lock();
2848 vc->port.tty = NULL; 2848 vc->port.tty = NULL;
2849 release_console_sem(); 2849 console_unlock();
2850 tty_shutdown(tty); 2850 tty_shutdown(tty);
2851} 2851}
2852 2852
@@ -2893,13 +2893,13 @@ static int __init con_init(void)
2893 struct vc_data *vc; 2893 struct vc_data *vc;
2894 unsigned int currcons = 0, i; 2894 unsigned int currcons = 0, i;
2895 2895
2896 acquire_console_sem(); 2896 console_lock();
2897 2897
2898 if (conswitchp) 2898 if (conswitchp)
2899 display_desc = conswitchp->con_startup(); 2899 display_desc = conswitchp->con_startup();
2900 if (!display_desc) { 2900 if (!display_desc) {
2901 fg_console = 0; 2901 fg_console = 0;
2902 release_console_sem(); 2902 console_unlock();
2903 return 0; 2903 return 0;
2904 } 2904 }
2905 2905
@@ -2946,7 +2946,7 @@ static int __init con_init(void)
2946 printable = 1; 2946 printable = 1;
2947 printk("\n"); 2947 printk("\n");
2948 2948
2949 release_console_sem(); 2949 console_unlock();
2950 2950
2951#ifdef CONFIG_VT_CONSOLE 2951#ifdef CONFIG_VT_CONSOLE
2952 register_console(&vt_console_driver); 2952 register_console(&vt_console_driver);
@@ -3037,7 +3037,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
3037 if (!try_module_get(owner)) 3037 if (!try_module_get(owner))
3038 return -ENODEV; 3038 return -ENODEV;
3039 3039
3040 acquire_console_sem(); 3040 console_lock();
3041 3041
3042 /* check if driver is registered */ 3042 /* check if driver is registered */
3043 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3043 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3122,7 +3122,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
3122 3122
3123 retval = 0; 3123 retval = 0;
3124err: 3124err:
3125 release_console_sem(); 3125 console_unlock();
3126 module_put(owner); 3126 module_put(owner);
3127 return retval; 3127 return retval;
3128}; 3128};
@@ -3171,7 +3171,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3171 if (!try_module_get(owner)) 3171 if (!try_module_get(owner))
3172 return -ENODEV; 3172 return -ENODEV;
3173 3173
3174 acquire_console_sem(); 3174 console_lock();
3175 3175
3176 /* check if driver is registered and if it is unbindable */ 3176 /* check if driver is registered and if it is unbindable */
3177 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3177 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3185,7 +3185,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3185 } 3185 }
3186 3186
3187 if (retval) { 3187 if (retval) {
3188 release_console_sem(); 3188 console_unlock();
3189 goto err; 3189 goto err;
3190 } 3190 }
3191 3191
@@ -3204,12 +3204,12 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3204 } 3204 }
3205 3205
3206 if (retval) { 3206 if (retval) {
3207 release_console_sem(); 3207 console_unlock();
3208 goto err; 3208 goto err;
3209 } 3209 }
3210 3210
3211 if (!con_is_bound(csw)) { 3211 if (!con_is_bound(csw)) {
3212 release_console_sem(); 3212 console_unlock();
3213 goto err; 3213 goto err;
3214 } 3214 }
3215 3215
@@ -3238,7 +3238,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3238 if (!con_is_bound(csw)) 3238 if (!con_is_bound(csw))
3239 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; 3239 con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
3240 3240
3241 release_console_sem(); 3241 console_unlock();
3242 /* ignore return value, binding should not fail */ 3242 /* ignore return value, binding should not fail */
3243 bind_con_driver(defcsw, first, last, deflt); 3243 bind_con_driver(defcsw, first, last, deflt);
3244err: 3244err:
@@ -3538,7 +3538,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
3538 if (!try_module_get(owner)) 3538 if (!try_module_get(owner))
3539 return -ENODEV; 3539 return -ENODEV;
3540 3540
3541 acquire_console_sem(); 3541 console_lock();
3542 3542
3543 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3543 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3544 con_driver = &registered_con_driver[i]; 3544 con_driver = &registered_con_driver[i];
@@ -3592,7 +3592,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
3592 } 3592 }
3593 3593
3594err: 3594err:
3595 release_console_sem(); 3595 console_unlock();
3596 module_put(owner); 3596 module_put(owner);
3597 return retval; 3597 return retval;
3598} 3598}
@@ -3613,7 +3613,7 @@ int unregister_con_driver(const struct consw *csw)
3613{ 3613{
3614 int i, retval = -ENODEV; 3614 int i, retval = -ENODEV;
3615 3615
3616 acquire_console_sem(); 3616 console_lock();
3617 3617
3618 /* cannot unregister a bound driver */ 3618 /* cannot unregister a bound driver */
3619 if (con_is_bound(csw)) 3619 if (con_is_bound(csw))
@@ -3639,7 +3639,7 @@ int unregister_con_driver(const struct consw *csw)
3639 } 3639 }
3640 } 3640 }
3641err: 3641err:
3642 release_console_sem(); 3642 console_unlock();
3643 return retval; 3643 return retval;
3644} 3644}
3645EXPORT_SYMBOL(unregister_con_driver); 3645EXPORT_SYMBOL(unregister_con_driver);
@@ -3934,9 +3934,9 @@ int con_set_cmap(unsigned char __user *arg)
3934{ 3934{
3935 int rc; 3935 int rc;
3936 3936
3937 acquire_console_sem(); 3937 console_lock();
3938 rc = set_get_cmap (arg,1); 3938 rc = set_get_cmap (arg,1);
3939 release_console_sem(); 3939 console_unlock();
3940 3940
3941 return rc; 3941 return rc;
3942} 3942}
@@ -3945,9 +3945,9 @@ int con_get_cmap(unsigned char __user *arg)
3945{ 3945{
3946 int rc; 3946 int rc;
3947 3947
3948 acquire_console_sem(); 3948 console_lock();
3949 rc = set_get_cmap (arg,0); 3949 rc = set_get_cmap (arg,0);
3950 release_console_sem(); 3950 console_unlock();
3951 3951
3952 return rc; 3952 return rc;
3953} 3953}
@@ -3994,12 +3994,12 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
3994 } else 3994 } else
3995 font.data = NULL; 3995 font.data = NULL;
3996 3996
3997 acquire_console_sem(); 3997 console_lock();
3998 if (vc->vc_sw->con_font_get) 3998 if (vc->vc_sw->con_font_get)
3999 rc = vc->vc_sw->con_font_get(vc, &font); 3999 rc = vc->vc_sw->con_font_get(vc, &font);
4000 else 4000 else
4001 rc = -ENOSYS; 4001 rc = -ENOSYS;
4002 release_console_sem(); 4002 console_unlock();
4003 4003
4004 if (rc) 4004 if (rc)
4005 goto out; 4005 goto out;
@@ -4076,12 +4076,12 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
4076 font.data = memdup_user(op->data, size); 4076 font.data = memdup_user(op->data, size);
4077 if (IS_ERR(font.data)) 4077 if (IS_ERR(font.data))
4078 return PTR_ERR(font.data); 4078 return PTR_ERR(font.data);
4079 acquire_console_sem(); 4079 console_lock();
4080 if (vc->vc_sw->con_font_set) 4080 if (vc->vc_sw->con_font_set)
4081 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); 4081 rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
4082 else 4082 else
4083 rc = -ENOSYS; 4083 rc = -ENOSYS;
4084 release_console_sem(); 4084 console_unlock();
4085 kfree(font.data); 4085 kfree(font.data);
4086 return rc; 4086 return rc;
4087} 4087}
@@ -4103,12 +4103,12 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
4103 else 4103 else
4104 name[MAX_FONT_NAME - 1] = 0; 4104 name[MAX_FONT_NAME - 1] = 0;
4105 4105
4106 acquire_console_sem(); 4106 console_lock();
4107 if (vc->vc_sw->con_font_default) 4107 if (vc->vc_sw->con_font_default)
4108 rc = vc->vc_sw->con_font_default(vc, &font, s); 4108 rc = vc->vc_sw->con_font_default(vc, &font, s);
4109 else 4109 else
4110 rc = -ENOSYS; 4110 rc = -ENOSYS;
4111 release_console_sem(); 4111 console_unlock();
4112 if (!rc) { 4112 if (!rc) {
4113 op->width = font.width; 4113 op->width = font.width;
4114 op->height = font.height; 4114 op->height = font.height;
@@ -4124,7 +4124,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
4124 if (vc->vc_mode != KD_TEXT) 4124 if (vc->vc_mode != KD_TEXT)
4125 return -EINVAL; 4125 return -EINVAL;
4126 4126
4127 acquire_console_sem(); 4127 console_lock();
4128 if (!vc->vc_sw->con_font_copy) 4128 if (!vc->vc_sw->con_font_copy)
4129 rc = -ENOSYS; 4129 rc = -ENOSYS;
4130 else if (con < 0 || !vc_cons_allocated(con)) 4130 else if (con < 0 || !vc_cons_allocated(con))
@@ -4133,7 +4133,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
4133 rc = 0; 4133 rc = 0;
4134 else 4134 else
4135 rc = vc->vc_sw->con_font_copy(vc, con); 4135 rc = vc->vc_sw->con_font_copy(vc, con);
4136 release_console_sem(); 4136 console_unlock();
4137 return rc; 4137 return rc;
4138} 4138}
4139 4139
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 6b68a0fb4611..1235ebda6e1c 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -649,12 +649,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
649 /* 649 /*
650 * explicitly blank/unblank the screen if switching modes 650 * explicitly blank/unblank the screen if switching modes
651 */ 651 */
652 acquire_console_sem(); 652 console_lock();
653 if (arg == KD_TEXT) 653 if (arg == KD_TEXT)
654 do_unblank_screen(1); 654 do_unblank_screen(1);
655 else 655 else
656 do_blank_screen(1); 656 do_blank_screen(1);
657 release_console_sem(); 657 console_unlock();
658 break; 658 break;
659 659
660 case KDGETMODE: 660 case KDGETMODE:
@@ -893,7 +893,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
893 ret = -EINVAL; 893 ret = -EINVAL;
894 goto out; 894 goto out;
895 } 895 }
896 acquire_console_sem(); 896 console_lock();
897 vc->vt_mode = tmp; 897 vc->vt_mode = tmp;
898 /* the frsig is ignored, so we set it to 0 */ 898 /* the frsig is ignored, so we set it to 0 */
899 vc->vt_mode.frsig = 0; 899 vc->vt_mode.frsig = 0;
@@ -901,7 +901,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
901 vc->vt_pid = get_pid(task_pid(current)); 901 vc->vt_pid = get_pid(task_pid(current));
902 /* no switch is required -- saw@shade.msu.ru */ 902 /* no switch is required -- saw@shade.msu.ru */
903 vc->vt_newvt = -1; 903 vc->vt_newvt = -1;
904 release_console_sem(); 904 console_unlock();
905 break; 905 break;
906 } 906 }
907 907
@@ -910,9 +910,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
910 struct vt_mode tmp; 910 struct vt_mode tmp;
911 int rc; 911 int rc;
912 912
913 acquire_console_sem(); 913 console_lock();
914 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode)); 914 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode));
915 release_console_sem(); 915 console_unlock();
916 916
917 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); 917 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
918 if (rc) 918 if (rc)
@@ -965,9 +965,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
965 ret = -ENXIO; 965 ret = -ENXIO;
966 else { 966 else {
967 arg--; 967 arg--;
968 acquire_console_sem(); 968 console_lock();
969 ret = vc_allocate(arg); 969 ret = vc_allocate(arg);
970 release_console_sem(); 970 console_unlock();
971 if (ret) 971 if (ret)
972 break; 972 break;
973 set_console(arg); 973 set_console(arg);
@@ -990,7 +990,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
990 ret = -ENXIO; 990 ret = -ENXIO;
991 else { 991 else {
992 vsa.console--; 992 vsa.console--;
993 acquire_console_sem(); 993 console_lock();
994 ret = vc_allocate(vsa.console); 994 ret = vc_allocate(vsa.console);
995 if (ret == 0) { 995 if (ret == 0) {
996 struct vc_data *nvc; 996 struct vc_data *nvc;
@@ -1003,7 +1003,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1003 put_pid(nvc->vt_pid); 1003 put_pid(nvc->vt_pid);
1004 nvc->vt_pid = get_pid(task_pid(current)); 1004 nvc->vt_pid = get_pid(task_pid(current));
1005 } 1005 }
1006 release_console_sem(); 1006 console_unlock();
1007 if (ret) 1007 if (ret)
1008 break; 1008 break;
1009 /* Commence switch and lock */ 1009 /* Commence switch and lock */
@@ -1044,7 +1044,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1044 /* 1044 /*
1045 * Switching-from response 1045 * Switching-from response
1046 */ 1046 */
1047 acquire_console_sem(); 1047 console_lock();
1048 if (vc->vt_newvt >= 0) { 1048 if (vc->vt_newvt >= 0) {
1049 if (arg == 0) 1049 if (arg == 0)
1050 /* 1050 /*
@@ -1063,7 +1063,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1063 vc->vt_newvt = -1; 1063 vc->vt_newvt = -1;
1064 ret = vc_allocate(newvt); 1064 ret = vc_allocate(newvt);
1065 if (ret) { 1065 if (ret) {
1066 release_console_sem(); 1066 console_unlock();
1067 break; 1067 break;
1068 } 1068 }
1069 /* 1069 /*
@@ -1083,7 +1083,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1083 if (arg != VT_ACKACQ) 1083 if (arg != VT_ACKACQ)
1084 ret = -EINVAL; 1084 ret = -EINVAL;
1085 } 1085 }
1086 release_console_sem(); 1086 console_unlock();
1087 break; 1087 break;
1088 1088
1089 /* 1089 /*
@@ -1096,20 +1096,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1096 } 1096 }
1097 if (arg == 0) { 1097 if (arg == 0) {
1098 /* deallocate all unused consoles, but leave 0 */ 1098 /* deallocate all unused consoles, but leave 0 */
1099 acquire_console_sem(); 1099 console_lock();
1100 for (i=1; i<MAX_NR_CONSOLES; i++) 1100 for (i=1; i<MAX_NR_CONSOLES; i++)
1101 if (! VT_BUSY(i)) 1101 if (! VT_BUSY(i))
1102 vc_deallocate(i); 1102 vc_deallocate(i);
1103 release_console_sem(); 1103 console_unlock();
1104 } else { 1104 } else {
1105 /* deallocate a single console, if possible */ 1105 /* deallocate a single console, if possible */
1106 arg--; 1106 arg--;
1107 if (VT_BUSY(arg)) 1107 if (VT_BUSY(arg))
1108 ret = -EBUSY; 1108 ret = -EBUSY;
1109 else if (arg) { /* leave 0 */ 1109 else if (arg) { /* leave 0 */
1110 acquire_console_sem(); 1110 console_lock();
1111 vc_deallocate(arg); 1111 vc_deallocate(arg);
1112 release_console_sem(); 1112 console_unlock();
1113 } 1113 }
1114 } 1114 }
1115 break; 1115 break;
@@ -1126,7 +1126,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1126 get_user(cc, &vtsizes->v_cols)) 1126 get_user(cc, &vtsizes->v_cols))
1127 ret = -EFAULT; 1127 ret = -EFAULT;
1128 else { 1128 else {
1129 acquire_console_sem(); 1129 console_lock();
1130 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1130 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1131 vc = vc_cons[i].d; 1131 vc = vc_cons[i].d;
1132 1132
@@ -1135,7 +1135,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1135 vc_resize(vc_cons[i].d, cc, ll); 1135 vc_resize(vc_cons[i].d, cc, ll);
1136 } 1136 }
1137 } 1137 }
1138 release_console_sem(); 1138 console_unlock();
1139 } 1139 }
1140 break; 1140 break;
1141 } 1141 }
@@ -1187,14 +1187,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1187 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1187 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1188 if (!vc_cons[i].d) 1188 if (!vc_cons[i].d)
1189 continue; 1189 continue;
1190 acquire_console_sem(); 1190 console_lock();
1191 if (vlin) 1191 if (vlin)
1192 vc_cons[i].d->vc_scan_lines = vlin; 1192 vc_cons[i].d->vc_scan_lines = vlin;
1193 if (clin) 1193 if (clin)
1194 vc_cons[i].d->vc_font.height = clin; 1194 vc_cons[i].d->vc_font.height = clin;
1195 vc_cons[i].d->vc_resize_user = 1; 1195 vc_cons[i].d->vc_resize_user = 1;
1196 vc_resize(vc_cons[i].d, cc, ll); 1196 vc_resize(vc_cons[i].d, cc, ll);
1197 release_console_sem(); 1197 console_unlock();
1198 } 1198 }
1199 break; 1199 break;
1200 } 1200 }
@@ -1367,7 +1367,7 @@ void vc_SAK(struct work_struct *work)
1367 struct vc_data *vc; 1367 struct vc_data *vc;
1368 struct tty_struct *tty; 1368 struct tty_struct *tty;
1369 1369
1370 acquire_console_sem(); 1370 console_lock();
1371 vc = vc_con->d; 1371 vc = vc_con->d;
1372 if (vc) { 1372 if (vc) {
1373 tty = vc->port.tty; 1373 tty = vc->port.tty;
@@ -1379,7 +1379,7 @@ void vc_SAK(struct work_struct *work)
1379 __do_SAK(tty); 1379 __do_SAK(tty);
1380 reset_vc(vc); 1380 reset_vc(vc);
1381 } 1381 }
1382 release_console_sem(); 1382 console_unlock();
1383} 1383}
1384 1384
1385#ifdef CONFIG_COMPAT 1385#ifdef CONFIG_COMPAT
@@ -1737,10 +1737,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
1737{ 1737{
1738 int prev; 1738 int prev;
1739 1739
1740 acquire_console_sem(); 1740 console_lock();
1741 /* Graphics mode - up to X */ 1741 /* Graphics mode - up to X */
1742 if (disable_vt_switch) { 1742 if (disable_vt_switch) {
1743 release_console_sem(); 1743 console_unlock();
1744 return 0; 1744 return 0;
1745 } 1745 }
1746 prev = fg_console; 1746 prev = fg_console;
@@ -1748,7 +1748,7 @@ int vt_move_to_console(unsigned int vt, int alloc)
1748 if (alloc && vc_allocate(vt)) { 1748 if (alloc && vc_allocate(vt)) {
1749 /* we can't have a free VC for now. Too bad, 1749 /* we can't have a free VC for now. Too bad,
1750 * we don't want to mess the screen for now. */ 1750 * we don't want to mess the screen for now. */
1751 release_console_sem(); 1751 console_unlock();
1752 return -ENOSPC; 1752 return -ENOSPC;
1753 } 1753 }
1754 1754
@@ -1758,10 +1758,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
1758 * Let the calling function know so it can decide 1758 * Let the calling function know so it can decide
1759 * what to do. 1759 * what to do.
1760 */ 1760 */
1761 release_console_sem(); 1761 console_unlock();
1762 return -EIO; 1762 return -EIO;
1763 } 1763 }
1764 release_console_sem(); 1764 console_unlock();
1765 tty_lock(); 1765 tty_lock();
1766 if (vt_waitactive(vt + 1)) { 1766 if (vt_waitactive(vt + 1)) {
1767 pr_debug("Suspend: Can't switch VCs."); 1767 pr_debug("Suspend: Can't switch VCs.");
@@ -1781,8 +1781,8 @@ int vt_move_to_console(unsigned int vt, int alloc)
1781 */ 1781 */
1782void pm_set_vt_switch(int do_switch) 1782void pm_set_vt_switch(int do_switch)
1783{ 1783{
1784 acquire_console_sem(); 1784 console_lock();
1785 disable_vt_switch = !do_switch; 1785 disable_vt_switch = !do_switch;
1786 release_console_sem(); 1786 console_unlock();
1787} 1787}
1788EXPORT_SYMBOL(pm_set_vt_switch); 1788EXPORT_SYMBOL(pm_set_vt_switch);
diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c
index d583bea608fd..391ac939f011 100644
--- a/drivers/video/arkfb.c
+++ b/drivers/video/arkfb.c
@@ -23,7 +23,7 @@
23#include <linux/svga.h> 23#include <linux/svga.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 26#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
27#include <video/vga.h> 27#include <video/vga.h>
28 28
29#ifdef CONFIG_MTRR 29#ifdef CONFIG_MTRR
@@ -1091,12 +1091,12 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1091 1091
1092 dev_info(info->device, "suspend\n"); 1092 dev_info(info->device, "suspend\n");
1093 1093
1094 acquire_console_sem(); 1094 console_lock();
1095 mutex_lock(&(par->open_lock)); 1095 mutex_lock(&(par->open_lock));
1096 1096
1097 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 1097 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1098 mutex_unlock(&(par->open_lock)); 1098 mutex_unlock(&(par->open_lock));
1099 release_console_sem(); 1099 console_unlock();
1100 return 0; 1100 return 0;
1101 } 1101 }
1102 1102
@@ -1107,7 +1107,7 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1107 pci_set_power_state(dev, pci_choose_state(dev, state)); 1107 pci_set_power_state(dev, pci_choose_state(dev, state));
1108 1108
1109 mutex_unlock(&(par->open_lock)); 1109 mutex_unlock(&(par->open_lock));
1110 release_console_sem(); 1110 console_unlock();
1111 1111
1112 return 0; 1112 return 0;
1113} 1113}
@@ -1122,7 +1122,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1122 1122
1123 dev_info(info->device, "resume\n"); 1123 dev_info(info->device, "resume\n");
1124 1124
1125 acquire_console_sem(); 1125 console_lock();
1126 mutex_lock(&(par->open_lock)); 1126 mutex_lock(&(par->open_lock));
1127 1127
1128 if (par->ref_count == 0) 1128 if (par->ref_count == 0)
@@ -1141,7 +1141,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1141 1141
1142fail: 1142fail:
1143 mutex_unlock(&(par->open_lock)); 1143 mutex_unlock(&(par->open_lock));
1144 release_console_sem(); 1144 console_unlock();
1145 return 0; 1145 return 0;
1146} 1146}
1147#else 1147#else
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index dd9de2e80580..4cb6a576c567 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1860,11 +1860,11 @@ static void aty128_early_resume(void *data)
1860{ 1860{
1861 struct aty128fb_par *par = data; 1861 struct aty128fb_par *par = data;
1862 1862
1863 if (try_acquire_console_sem()) 1863 if (!console_trylock())
1864 return; 1864 return;
1865 pci_restore_state(par->pdev); 1865 pci_restore_state(par->pdev);
1866 aty128_do_resume(par->pdev); 1866 aty128_do_resume(par->pdev);
1867 release_console_sem(); 1867 console_unlock();
1868} 1868}
1869#endif /* CONFIG_PPC_PMAC */ 1869#endif /* CONFIG_PPC_PMAC */
1870 1870
@@ -2438,7 +2438,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2438 2438
2439 printk(KERN_DEBUG "aty128fb: suspending...\n"); 2439 printk(KERN_DEBUG "aty128fb: suspending...\n");
2440 2440
2441 acquire_console_sem(); 2441 console_lock();
2442 2442
2443 fb_set_suspend(info, 1); 2443 fb_set_suspend(info, 1);
2444 2444
@@ -2470,7 +2470,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2470 if (state.event != PM_EVENT_ON) 2470 if (state.event != PM_EVENT_ON)
2471 aty128_set_suspend(par, 1); 2471 aty128_set_suspend(par, 1);
2472 2472
2473 release_console_sem(); 2473 console_unlock();
2474 2474
2475 pdev->dev.power.power_state = state; 2475 pdev->dev.power.power_state = state;
2476 2476
@@ -2527,9 +2527,9 @@ static int aty128_pci_resume(struct pci_dev *pdev)
2527{ 2527{
2528 int rc; 2528 int rc;
2529 2529
2530 acquire_console_sem(); 2530 console_lock();
2531 rc = aty128_do_resume(pdev); 2531 rc = aty128_do_resume(pdev);
2532 release_console_sem(); 2532 console_unlock();
2533 2533
2534 return rc; 2534 return rc;
2535} 2535}
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 767ab4fb1a05..94e293fce1d2 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2069,7 +2069,7 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2069 if (state.event == pdev->dev.power.power_state.event) 2069 if (state.event == pdev->dev.power.power_state.event)
2070 return 0; 2070 return 0;
2071 2071
2072 acquire_console_sem(); 2072 console_lock();
2073 2073
2074 fb_set_suspend(info, 1); 2074 fb_set_suspend(info, 1);
2075 2075
@@ -2097,14 +2097,14 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2097 par->lock_blank = 0; 2097 par->lock_blank = 0;
2098 atyfb_blank(FB_BLANK_UNBLANK, info); 2098 atyfb_blank(FB_BLANK_UNBLANK, info);
2099 fb_set_suspend(info, 0); 2099 fb_set_suspend(info, 0);
2100 release_console_sem(); 2100 console_unlock();
2101 return -EIO; 2101 return -EIO;
2102 } 2102 }
2103#else 2103#else
2104 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2104 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2105#endif 2105#endif
2106 2106
2107 release_console_sem(); 2107 console_unlock();
2108 2108
2109 pdev->dev.power.power_state = state; 2109 pdev->dev.power.power_state = state;
2110 2110
@@ -2133,7 +2133,7 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2133 if (pdev->dev.power.power_state.event == PM_EVENT_ON) 2133 if (pdev->dev.power.power_state.event == PM_EVENT_ON)
2134 return 0; 2134 return 0;
2135 2135
2136 acquire_console_sem(); 2136 console_lock();
2137 2137
2138 /* 2138 /*
2139 * PCI state will have been restored by the core, so 2139 * PCI state will have been restored by the core, so
@@ -2161,7 +2161,7 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2161 par->lock_blank = 0; 2161 par->lock_blank = 0;
2162 atyfb_blank(FB_BLANK_UNBLANK, info); 2162 atyfb_blank(FB_BLANK_UNBLANK, info);
2163 2163
2164 release_console_sem(); 2164 console_unlock();
2165 2165
2166 pdev->dev.power.power_state = PMSG_ON; 2166 pdev->dev.power.power_state = PMSG_ON;
2167 2167
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index c4e17642d9c5..92bda5848516 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2626,7 +2626,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2626 goto done; 2626 goto done;
2627 } 2627 }
2628 2628
2629 acquire_console_sem(); 2629 console_lock();
2630 2630
2631 fb_set_suspend(info, 1); 2631 fb_set_suspend(info, 1);
2632 2632
@@ -2690,7 +2690,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2690 if (rinfo->pm_mode & radeon_pm_d2) 2690 if (rinfo->pm_mode & radeon_pm_d2)
2691 radeon_set_suspend(rinfo, 1); 2691 radeon_set_suspend(rinfo, 1);
2692 2692
2693 release_console_sem(); 2693 console_unlock();
2694 2694
2695 done: 2695 done:
2696 pdev->dev.power.power_state = mesg; 2696 pdev->dev.power.power_state = mesg;
@@ -2715,10 +2715,10 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2715 return 0; 2715 return 0;
2716 2716
2717 if (rinfo->no_schedule) { 2717 if (rinfo->no_schedule) {
2718 if (try_acquire_console_sem()) 2718 if (!console_trylock())
2719 return 0; 2719 return 0;
2720 } else 2720 } else
2721 acquire_console_sem(); 2721 console_lock();
2722 2722
2723 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n", 2723 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
2724 pci_name(pdev), pdev->dev.power.power_state.event); 2724 pci_name(pdev), pdev->dev.power.power_state.event);
@@ -2783,7 +2783,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2783 pdev->dev.power.power_state = PMSG_ON; 2783 pdev->dev.power.power_state = PMSG_ON;
2784 2784
2785 bail: 2785 bail:
2786 release_console_sem(); 2786 console_unlock();
2787 2787
2788 return rc; 2788 return rc;
2789} 2789}
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index d637e1f53172..cff742abdc5d 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -460,10 +460,10 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
460 if (!(state.event & PM_EVENT_SLEEP)) 460 if (!(state.event & PM_EVENT_SLEEP))
461 goto done; 461 goto done;
462 462
463 acquire_console_sem(); 463 console_lock();
464 chipsfb_blank(1, p); 464 chipsfb_blank(1, p);
465 fb_set_suspend(p, 1); 465 fb_set_suspend(p, 1);
466 release_console_sem(); 466 console_unlock();
467 done: 467 done:
468 pdev->dev.power.power_state = state; 468 pdev->dev.power.power_state = state;
469 return 0; 469 return 0;
@@ -473,10 +473,10 @@ static int chipsfb_pci_resume(struct pci_dev *pdev)
473{ 473{
474 struct fb_info *p = pci_get_drvdata(pdev); 474 struct fb_info *p = pci_get_drvdata(pdev);
475 475
476 acquire_console_sem(); 476 console_lock();
477 fb_set_suspend(p, 0); 477 fb_set_suspend(p, 0);
478 chipsfb_blank(0, p); 478 chipsfb_blank(0, p);
479 release_console_sem(); 479 console_unlock();
480 480
481 pdev->dev.power.power_state = PMSG_ON; 481 pdev->dev.power.power_state = PMSG_ON;
482 return 0; 482 return 0;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 7ccc967831f0..9c092b8d64e6 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -375,14 +375,14 @@ static void fb_flashcursor(struct work_struct *work)
375 int c; 375 int c;
376 int mode; 376 int mode;
377 377
378 acquire_console_sem(); 378 console_lock();
379 if (ops && ops->currcon != -1) 379 if (ops && ops->currcon != -1)
380 vc = vc_cons[ops->currcon].d; 380 vc = vc_cons[ops->currcon].d;
381 381
382 if (!vc || !CON_IS_VISIBLE(vc) || 382 if (!vc || !CON_IS_VISIBLE(vc) ||
383 registered_fb[con2fb_map[vc->vc_num]] != info || 383 registered_fb[con2fb_map[vc->vc_num]] != info ||
384 vc->vc_deccm != 1) { 384 vc->vc_deccm != 1) {
385 release_console_sem(); 385 console_unlock();
386 return; 386 return;
387 } 387 }
388 388
@@ -392,7 +392,7 @@ static void fb_flashcursor(struct work_struct *work)
392 CM_ERASE : CM_DRAW; 392 CM_ERASE : CM_DRAW;
393 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), 393 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
394 get_color(vc, info, c, 0)); 394 get_color(vc, info, c, 0));
395 release_console_sem(); 395 console_unlock();
396} 396}
397 397
398static void cursor_timer_handler(unsigned long dev_addr) 398static void cursor_timer_handler(unsigned long dev_addr)
@@ -836,7 +836,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
836 836
837 found = search_fb_in_map(newidx); 837 found = search_fb_in_map(newidx);
838 838
839 acquire_console_sem(); 839 console_lock();
840 con2fb_map[unit] = newidx; 840 con2fb_map[unit] = newidx;
841 if (!err && !found) 841 if (!err && !found)
842 err = con2fb_acquire_newinfo(vc, info, unit, oldidx); 842 err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
@@ -863,7 +863,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
863 if (!search_fb_in_map(info_idx)) 863 if (!search_fb_in_map(info_idx))
864 info_idx = newidx; 864 info_idx = newidx;
865 865
866 release_console_sem(); 866 console_unlock();
867 return err; 867 return err;
868} 868}
869 869
@@ -3321,7 +3321,7 @@ static ssize_t store_rotate(struct device *device,
3321 if (fbcon_has_exited) 3321 if (fbcon_has_exited)
3322 return count; 3322 return count;
3323 3323
3324 acquire_console_sem(); 3324 console_lock();
3325 idx = con2fb_map[fg_console]; 3325 idx = con2fb_map[fg_console];
3326 3326
3327 if (idx == -1 || registered_fb[idx] == NULL) 3327 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3331,7 +3331,7 @@ static ssize_t store_rotate(struct device *device,
3331 rotate = simple_strtoul(buf, last, 0); 3331 rotate = simple_strtoul(buf, last, 0);
3332 fbcon_rotate(info, rotate); 3332 fbcon_rotate(info, rotate);
3333err: 3333err:
3334 release_console_sem(); 3334 console_unlock();
3335 return count; 3335 return count;
3336} 3336}
3337 3337
@@ -3346,7 +3346,7 @@ static ssize_t store_rotate_all(struct device *device,
3346 if (fbcon_has_exited) 3346 if (fbcon_has_exited)
3347 return count; 3347 return count;
3348 3348
3349 acquire_console_sem(); 3349 console_lock();
3350 idx = con2fb_map[fg_console]; 3350 idx = con2fb_map[fg_console];
3351 3351
3352 if (idx == -1 || registered_fb[idx] == NULL) 3352 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3356,7 +3356,7 @@ static ssize_t store_rotate_all(struct device *device,
3356 rotate = simple_strtoul(buf, last, 0); 3356 rotate = simple_strtoul(buf, last, 0);
3357 fbcon_rotate_all(info, rotate); 3357 fbcon_rotate_all(info, rotate);
3358err: 3358err:
3359 release_console_sem(); 3359 console_unlock();
3360 return count; 3360 return count;
3361} 3361}
3362 3362
@@ -3369,7 +3369,7 @@ static ssize_t show_rotate(struct device *device,
3369 if (fbcon_has_exited) 3369 if (fbcon_has_exited)
3370 return 0; 3370 return 0;
3371 3371
3372 acquire_console_sem(); 3372 console_lock();
3373 idx = con2fb_map[fg_console]; 3373 idx = con2fb_map[fg_console];
3374 3374
3375 if (idx == -1 || registered_fb[idx] == NULL) 3375 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3378,7 +3378,7 @@ static ssize_t show_rotate(struct device *device,
3378 info = registered_fb[idx]; 3378 info = registered_fb[idx];
3379 rotate = fbcon_get_rotate(info); 3379 rotate = fbcon_get_rotate(info);
3380err: 3380err:
3381 release_console_sem(); 3381 console_unlock();
3382 return snprintf(buf, PAGE_SIZE, "%d\n", rotate); 3382 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3383} 3383}
3384 3384
@@ -3392,7 +3392,7 @@ static ssize_t show_cursor_blink(struct device *device,
3392 if (fbcon_has_exited) 3392 if (fbcon_has_exited)
3393 return 0; 3393 return 0;
3394 3394
3395 acquire_console_sem(); 3395 console_lock();
3396 idx = con2fb_map[fg_console]; 3396 idx = con2fb_map[fg_console];
3397 3397
3398 if (idx == -1 || registered_fb[idx] == NULL) 3398 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3406,7 +3406,7 @@ static ssize_t show_cursor_blink(struct device *device,
3406 3406
3407 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0; 3407 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3408err: 3408err:
3409 release_console_sem(); 3409 console_unlock();
3410 return snprintf(buf, PAGE_SIZE, "%d\n", blink); 3410 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3411} 3411}
3412 3412
@@ -3421,7 +3421,7 @@ static ssize_t store_cursor_blink(struct device *device,
3421 if (fbcon_has_exited) 3421 if (fbcon_has_exited)
3422 return count; 3422 return count;
3423 3423
3424 acquire_console_sem(); 3424 console_lock();
3425 idx = con2fb_map[fg_console]; 3425 idx = con2fb_map[fg_console];
3426 3426
3427 if (idx == -1 || registered_fb[idx] == NULL) 3427 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3443,7 +3443,7 @@ static ssize_t store_cursor_blink(struct device *device,
3443 } 3443 }
3444 3444
3445err: 3445err:
3446 release_console_sem(); 3446 console_unlock();
3447 return count; 3447 return count;
3448} 3448}
3449 3449
@@ -3482,7 +3482,7 @@ static void fbcon_start(void)
3482 if (num_registered_fb) { 3482 if (num_registered_fb) {
3483 int i; 3483 int i;
3484 3484
3485 acquire_console_sem(); 3485 console_lock();
3486 3486
3487 for (i = 0; i < FB_MAX; i++) { 3487 for (i = 0; i < FB_MAX; i++) {
3488 if (registered_fb[i] != NULL) { 3488 if (registered_fb[i] != NULL) {
@@ -3491,7 +3491,7 @@ static void fbcon_start(void)
3491 } 3491 }
3492 } 3492 }
3493 3493
3494 release_console_sem(); 3494 console_unlock();
3495 fbcon_takeover(0); 3495 fbcon_takeover(0);
3496 } 3496 }
3497} 3497}
@@ -3552,7 +3552,7 @@ static int __init fb_console_init(void)
3552{ 3552{
3553 int i; 3553 int i;
3554 3554
3555 acquire_console_sem(); 3555 console_lock();
3556 fb_register_client(&fbcon_event_notifier); 3556 fb_register_client(&fbcon_event_notifier);
3557 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, 3557 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3558 "fbcon"); 3558 "fbcon");
@@ -3568,7 +3568,7 @@ static int __init fb_console_init(void)
3568 for (i = 0; i < MAX_NR_CONSOLES; i++) 3568 for (i = 0; i < MAX_NR_CONSOLES; i++)
3569 con2fb_map[i] = -1; 3569 con2fb_map[i] = -1;
3570 3570
3571 release_console_sem(); 3571 console_unlock();
3572 fbcon_start(); 3572 fbcon_start();
3573 return 0; 3573 return 0;
3574} 3574}
@@ -3591,12 +3591,12 @@ static void __exit fbcon_deinit_device(void)
3591 3591
3592static void __exit fb_console_exit(void) 3592static void __exit fb_console_exit(void)
3593{ 3593{
3594 acquire_console_sem(); 3594 console_lock();
3595 fb_unregister_client(&fbcon_event_notifier); 3595 fb_unregister_client(&fbcon_event_notifier);
3596 fbcon_deinit_device(); 3596 fbcon_deinit_device();
3597 device_destroy(fb_class, MKDEV(0, 0)); 3597 device_destroy(fb_class, MKDEV(0, 0));
3598 fbcon_exit(); 3598 fbcon_exit();
3599 release_console_sem(); 3599 console_unlock();
3600 unregister_con_driver(&fb_con); 3600 unregister_con_driver(&fb_con);
3601} 3601}
3602 3602
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 520047ac6e3e..8d61ef96eedd 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -1131,14 +1131,14 @@ static int fb_suspend(struct platform_device *dev, pm_message_t state)
1131 struct fb_info *info = platform_get_drvdata(dev); 1131 struct fb_info *info = platform_get_drvdata(dev);
1132 struct da8xx_fb_par *par = info->par; 1132 struct da8xx_fb_par *par = info->par;
1133 1133
1134 acquire_console_sem(); 1134 console_lock();
1135 if (par->panel_power_ctrl) 1135 if (par->panel_power_ctrl)
1136 par->panel_power_ctrl(0); 1136 par->panel_power_ctrl(0);
1137 1137
1138 fb_set_suspend(info, 1); 1138 fb_set_suspend(info, 1);
1139 lcd_disable_raster(); 1139 lcd_disable_raster();
1140 clk_disable(par->lcdc_clk); 1140 clk_disable(par->lcdc_clk);
1141 release_console_sem(); 1141 console_unlock();
1142 1142
1143 return 0; 1143 return 0;
1144} 1144}
@@ -1147,14 +1147,14 @@ static int fb_resume(struct platform_device *dev)
1147 struct fb_info *info = platform_get_drvdata(dev); 1147 struct fb_info *info = platform_get_drvdata(dev);
1148 struct da8xx_fb_par *par = info->par; 1148 struct da8xx_fb_par *par = info->par;
1149 1149
1150 acquire_console_sem(); 1150 console_lock();
1151 if (par->panel_power_ctrl) 1151 if (par->panel_power_ctrl)
1152 par->panel_power_ctrl(1); 1152 par->panel_power_ctrl(1);
1153 1153
1154 clk_enable(par->lcdc_clk); 1154 clk_enable(par->lcdc_clk);
1155 lcd_enable_raster(); 1155 lcd_enable_raster();
1156 fb_set_suspend(info, 0); 1156 fb_set_suspend(info, 0);
1157 release_console_sem(); 1157 console_unlock();
1158 1158
1159 return 0; 1159 return 0;
1160} 1160}
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 4ac1201ad6c2..e2bf95370e40 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1036,11 +1036,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1036 return -EFAULT; 1036 return -EFAULT;
1037 if (!lock_fb_info(info)) 1037 if (!lock_fb_info(info))
1038 return -ENODEV; 1038 return -ENODEV;
1039 acquire_console_sem(); 1039 console_lock();
1040 info->flags |= FBINFO_MISC_USEREVENT; 1040 info->flags |= FBINFO_MISC_USEREVENT;
1041 ret = fb_set_var(info, &var); 1041 ret = fb_set_var(info, &var);
1042 info->flags &= ~FBINFO_MISC_USEREVENT; 1042 info->flags &= ~FBINFO_MISC_USEREVENT;
1043 release_console_sem(); 1043 console_unlock();
1044 unlock_fb_info(info); 1044 unlock_fb_info(info);
1045 if (!ret && copy_to_user(argp, &var, sizeof(var))) 1045 if (!ret && copy_to_user(argp, &var, sizeof(var)))
1046 ret = -EFAULT; 1046 ret = -EFAULT;
@@ -1072,9 +1072,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1072 return -EFAULT; 1072 return -EFAULT;
1073 if (!lock_fb_info(info)) 1073 if (!lock_fb_info(info))
1074 return -ENODEV; 1074 return -ENODEV;
1075 acquire_console_sem(); 1075 console_lock();
1076 ret = fb_pan_display(info, &var); 1076 ret = fb_pan_display(info, &var);
1077 release_console_sem(); 1077 console_unlock();
1078 unlock_fb_info(info); 1078 unlock_fb_info(info);
1079 if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) 1079 if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
1080 return -EFAULT; 1080 return -EFAULT;
@@ -1119,11 +1119,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1119 case FBIOBLANK: 1119 case FBIOBLANK:
1120 if (!lock_fb_info(info)) 1120 if (!lock_fb_info(info))
1121 return -ENODEV; 1121 return -ENODEV;
1122 acquire_console_sem(); 1122 console_lock();
1123 info->flags |= FBINFO_MISC_USEREVENT; 1123 info->flags |= FBINFO_MISC_USEREVENT;
1124 ret = fb_blank(info, arg); 1124 ret = fb_blank(info, arg);
1125 info->flags &= ~FBINFO_MISC_USEREVENT; 1125 info->flags &= ~FBINFO_MISC_USEREVENT;
1126 release_console_sem(); 1126 console_unlock();
1127 unlock_fb_info(info); 1127 unlock_fb_info(info);
1128 break; 1128 break;
1129 default: 1129 default:
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 0a08f1341227..f4a32779168b 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -90,11 +90,11 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var)
90 int err; 90 int err;
91 91
92 var->activate |= FB_ACTIVATE_FORCE; 92 var->activate |= FB_ACTIVATE_FORCE;
93 acquire_console_sem(); 93 console_lock();
94 fb_info->flags |= FBINFO_MISC_USEREVENT; 94 fb_info->flags |= FBINFO_MISC_USEREVENT;
95 err = fb_set_var(fb_info, var); 95 err = fb_set_var(fb_info, var);
96 fb_info->flags &= ~FBINFO_MISC_USEREVENT; 96 fb_info->flags &= ~FBINFO_MISC_USEREVENT;
97 release_console_sem(); 97 console_unlock();
98 if (err) 98 if (err)
99 return err; 99 return err;
100 return 0; 100 return 0;
@@ -175,7 +175,7 @@ static ssize_t store_modes(struct device *device,
175 if (i * sizeof(struct fb_videomode) != count) 175 if (i * sizeof(struct fb_videomode) != count)
176 return -EINVAL; 176 return -EINVAL;
177 177
178 acquire_console_sem(); 178 console_lock();
179 list_splice(&fb_info->modelist, &old_list); 179 list_splice(&fb_info->modelist, &old_list);
180 fb_videomode_to_modelist((const struct fb_videomode *)buf, i, 180 fb_videomode_to_modelist((const struct fb_videomode *)buf, i,
181 &fb_info->modelist); 181 &fb_info->modelist);
@@ -185,7 +185,7 @@ static ssize_t store_modes(struct device *device,
185 } else 185 } else
186 fb_destroy_modelist(&old_list); 186 fb_destroy_modelist(&old_list);
187 187
188 release_console_sem(); 188 console_unlock();
189 189
190 return 0; 190 return 0;
191} 191}
@@ -301,11 +301,11 @@ static ssize_t store_blank(struct device *device,
301 char *last = NULL; 301 char *last = NULL;
302 int err; 302 int err;
303 303
304 acquire_console_sem(); 304 console_lock();
305 fb_info->flags |= FBINFO_MISC_USEREVENT; 305 fb_info->flags |= FBINFO_MISC_USEREVENT;
306 err = fb_blank(fb_info, simple_strtoul(buf, &last, 0)); 306 err = fb_blank(fb_info, simple_strtoul(buf, &last, 0));
307 fb_info->flags &= ~FBINFO_MISC_USEREVENT; 307 fb_info->flags &= ~FBINFO_MISC_USEREVENT;
308 release_console_sem(); 308 console_unlock();
309 if (err < 0) 309 if (err < 0)
310 return err; 310 return err;
311 return count; 311 return count;
@@ -364,9 +364,9 @@ static ssize_t store_pan(struct device *device,
364 return -EINVAL; 364 return -EINVAL;
365 var.yoffset = simple_strtoul(last, &last, 0); 365 var.yoffset = simple_strtoul(last, &last, 0);
366 366
367 acquire_console_sem(); 367 console_lock();
368 err = fb_pan_display(fb_info, &var); 368 err = fb_pan_display(fb_info, &var);
369 release_console_sem(); 369 console_unlock();
370 370
371 if (err < 0) 371 if (err < 0)
372 return err; 372 return err;
@@ -399,9 +399,9 @@ static ssize_t store_fbstate(struct device *device,
399 399
400 state = simple_strtoul(buf, &last, 0); 400 state = simple_strtoul(buf, &last, 0);
401 401
402 acquire_console_sem(); 402 console_lock();
403 fb_set_suspend(fb_info, (int)state); 403 fb_set_suspend(fb_info, (int)state);
404 release_console_sem(); 404 console_unlock();
405 405
406 return count; 406 return count;
407} 407}
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 70b1d9d51c96..b4f19db9bb54 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -344,10 +344,10 @@ static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state)
344 struct fb_info *info = pci_get_drvdata(pdev); 344 struct fb_info *info = pci_get_drvdata(pdev);
345 345
346 if (state.event == PM_EVENT_SUSPEND) { 346 if (state.event == PM_EVENT_SUSPEND) {
347 acquire_console_sem(); 347 console_lock();
348 gx_powerdown(info); 348 gx_powerdown(info);
349 fb_set_suspend(info, 1); 349 fb_set_suspend(info, 1);
350 release_console_sem(); 350 console_unlock();
351 } 351 }
352 352
353 /* there's no point in setting PCI states; we emulate PCI, so 353 /* there's no point in setting PCI states; we emulate PCI, so
@@ -361,7 +361,7 @@ static int gxfb_resume(struct pci_dev *pdev)
361 struct fb_info *info = pci_get_drvdata(pdev); 361 struct fb_info *info = pci_get_drvdata(pdev);
362 int ret; 362 int ret;
363 363
364 acquire_console_sem(); 364 console_lock();
365 ret = gx_powerup(info); 365 ret = gx_powerup(info);
366 if (ret) { 366 if (ret) {
367 printk(KERN_ERR "gxfb: power up failed!\n"); 367 printk(KERN_ERR "gxfb: power up failed!\n");
@@ -369,7 +369,7 @@ static int gxfb_resume(struct pci_dev *pdev)
369 } 369 }
370 370
371 fb_set_suspend(info, 0); 371 fb_set_suspend(info, 0);
372 release_console_sem(); 372 console_unlock();
373 return 0; 373 return 0;
374} 374}
375#endif 375#endif
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index 39bdbedf43b4..416851ca8754 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -465,10 +465,10 @@ static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state)
465 struct fb_info *info = pci_get_drvdata(pdev); 465 struct fb_info *info = pci_get_drvdata(pdev);
466 466
467 if (state.event == PM_EVENT_SUSPEND) { 467 if (state.event == PM_EVENT_SUSPEND) {
468 acquire_console_sem(); 468 console_lock();
469 lx_powerdown(info); 469 lx_powerdown(info);
470 fb_set_suspend(info, 1); 470 fb_set_suspend(info, 1);
471 release_console_sem(); 471 console_unlock();
472 } 472 }
473 473
474 /* there's no point in setting PCI states; we emulate PCI, so 474 /* there's no point in setting PCI states; we emulate PCI, so
@@ -482,7 +482,7 @@ static int lxfb_resume(struct pci_dev *pdev)
482 struct fb_info *info = pci_get_drvdata(pdev); 482 struct fb_info *info = pci_get_drvdata(pdev);
483 int ret; 483 int ret;
484 484
485 acquire_console_sem(); 485 console_lock();
486 ret = lx_powerup(info); 486 ret = lx_powerup(info);
487 if (ret) { 487 if (ret) {
488 printk(KERN_ERR "lxfb: power up failed!\n"); 488 printk(KERN_ERR "lxfb: power up failed!\n");
@@ -490,7 +490,7 @@ static int lxfb_resume(struct pci_dev *pdev)
490 } 490 }
491 491
492 fb_set_suspend(info, 0); 492 fb_set_suspend(info, 0);
493 release_console_sem(); 493 console_unlock();
494 return 0; 494 return 0;
495} 495}
496#else 496#else
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 5743ea25e818..318f6fb895b2 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1574,7 +1574,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1574 return 0; 1574 return 0;
1575 } 1575 }
1576 1576
1577 acquire_console_sem(); 1577 console_lock();
1578 fb_set_suspend(info, 1); 1578 fb_set_suspend(info, 1);
1579 1579
1580 if (info->fbops->fb_sync) 1580 if (info->fbops->fb_sync)
@@ -1587,7 +1587,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1587 pci_save_state(dev); 1587 pci_save_state(dev);
1588 pci_disable_device(dev); 1588 pci_disable_device(dev);
1589 pci_set_power_state(dev, pci_choose_state(dev, mesg)); 1589 pci_set_power_state(dev, pci_choose_state(dev, mesg));
1590 release_console_sem(); 1590 console_unlock();
1591 1591
1592 return 0; 1592 return 0;
1593} 1593}
@@ -1605,7 +1605,7 @@ static int i810fb_resume(struct pci_dev *dev)
1605 return 0; 1605 return 0;
1606 } 1606 }
1607 1607
1608 acquire_console_sem(); 1608 console_lock();
1609 pci_set_power_state(dev, PCI_D0); 1609 pci_set_power_state(dev, PCI_D0);
1610 pci_restore_state(dev); 1610 pci_restore_state(dev);
1611 1611
@@ -1621,7 +1621,7 @@ static int i810fb_resume(struct pci_dev *dev)
1621 fb_set_suspend (info, 0); 1621 fb_set_suspend (info, 0);
1622 info->fbops->fb_blank(VESA_NO_BLANKING, info); 1622 info->fbops->fb_blank(VESA_NO_BLANKING, info);
1623fail: 1623fail:
1624 release_console_sem(); 1624 console_unlock();
1625 return 0; 1625 return 0;
1626} 1626}
1627/*********************************************************************** 1627/***********************************************************************
diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c
index 670ecaa0385a..de366937c933 100644
--- a/drivers/video/jz4740_fb.c
+++ b/drivers/video/jz4740_fb.c
@@ -778,9 +778,9 @@ static int jzfb_suspend(struct device *dev)
778{ 778{
779 struct jzfb *jzfb = dev_get_drvdata(dev); 779 struct jzfb *jzfb = dev_get_drvdata(dev);
780 780
781 acquire_console_sem(); 781 console_lock();
782 fb_set_suspend(jzfb->fb, 1); 782 fb_set_suspend(jzfb->fb, 1);
783 release_console_sem(); 783 console_unlock();
784 784
785 mutex_lock(&jzfb->lock); 785 mutex_lock(&jzfb->lock);
786 if (jzfb->is_enabled) 786 if (jzfb->is_enabled)
@@ -800,9 +800,9 @@ static int jzfb_resume(struct device *dev)
800 jzfb_enable(jzfb); 800 jzfb_enable(jzfb);
801 mutex_unlock(&jzfb->lock); 801 mutex_unlock(&jzfb->lock);
802 802
803 acquire_console_sem(); 803 console_lock();
804 fb_set_suspend(jzfb->fb, 0); 804 fb_set_suspend(jzfb->fb, 0);
805 release_console_sem(); 805 console_unlock();
806 806
807 return 0; 807 return 0;
808} 808}
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index cb013919e9ce..7e3a490e8d76 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -1177,9 +1177,9 @@ static int mx3fb_suspend(struct platform_device *pdev, pm_message_t state)
1177 struct mx3fb_data *mx3fb = platform_get_drvdata(pdev); 1177 struct mx3fb_data *mx3fb = platform_get_drvdata(pdev);
1178 struct mx3fb_info *mx3_fbi = mx3fb->fbi->par; 1178 struct mx3fb_info *mx3_fbi = mx3fb->fbi->par;
1179 1179
1180 acquire_console_sem(); 1180 console_lock();
1181 fb_set_suspend(mx3fb->fbi, 1); 1181 fb_set_suspend(mx3fb->fbi, 1);
1182 release_console_sem(); 1182 console_unlock();
1183 1183
1184 if (mx3_fbi->blank == FB_BLANK_UNBLANK) { 1184 if (mx3_fbi->blank == FB_BLANK_UNBLANK) {
1185 sdc_disable_channel(mx3_fbi); 1185 sdc_disable_channel(mx3_fbi);
@@ -1202,9 +1202,9 @@ static int mx3fb_resume(struct platform_device *pdev)
1202 sdc_set_brightness(mx3fb, mx3fb->backlight_level); 1202 sdc_set_brightness(mx3fb, mx3fb->backlight_level);
1203 } 1203 }
1204 1204
1205 acquire_console_sem(); 1205 console_lock();
1206 fb_set_suspend(mx3fb->fbi, 0); 1206 fb_set_suspend(mx3fb->fbi, 0);
1207 release_console_sem(); 1207 console_unlock();
1208 1208
1209 return 0; 1209 return 0;
1210} 1210}
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index efe10ff86d63..081dc4745274 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1057,7 +1057,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1057 1057
1058 if (mesg.event == PM_EVENT_PRETHAW) 1058 if (mesg.event == PM_EVENT_PRETHAW)
1059 mesg.event = PM_EVENT_FREEZE; 1059 mesg.event = PM_EVENT_FREEZE;
1060 acquire_console_sem(); 1060 console_lock();
1061 par->pm_state = mesg.event; 1061 par->pm_state = mesg.event;
1062 1062
1063 if (mesg.event & PM_EVENT_SLEEP) { 1063 if (mesg.event & PM_EVENT_SLEEP) {
@@ -1070,7 +1070,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1070 } 1070 }
1071 dev->dev.power.power_state = mesg; 1071 dev->dev.power.power_state = mesg;
1072 1072
1073 release_console_sem(); 1073 console_unlock();
1074 return 0; 1074 return 0;
1075} 1075}
1076 1076
@@ -1079,7 +1079,7 @@ static int nvidiafb_resume(struct pci_dev *dev)
1079 struct fb_info *info = pci_get_drvdata(dev); 1079 struct fb_info *info = pci_get_drvdata(dev);
1080 struct nvidia_par *par = info->par; 1080 struct nvidia_par *par = info->par;
1081 1081
1082 acquire_console_sem(); 1082 console_lock();
1083 pci_set_power_state(dev, PCI_D0); 1083 pci_set_power_state(dev, PCI_D0);
1084 1084
1085 if (par->pm_state != PM_EVENT_FREEZE) { 1085 if (par->pm_state != PM_EVENT_FREEZE) {
@@ -1097,7 +1097,7 @@ static int nvidiafb_resume(struct pci_dev *dev)
1097 nvidiafb_blank(FB_BLANK_UNBLANK, info); 1097 nvidiafb_blank(FB_BLANK_UNBLANK, info);
1098 1098
1099fail: 1099fail:
1100 release_console_sem(); 1100 console_unlock();
1101 return 0; 1101 return 0;
1102} 1102}
1103#else 1103#else
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 9c0144ee7ae5..65560a1a0439 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -513,9 +513,9 @@ static int ps3fb_release(struct fb_info *info, int user)
513 if (atomic_dec_and_test(&ps3fb.f_count)) { 513 if (atomic_dec_and_test(&ps3fb.f_count)) {
514 if (atomic_read(&ps3fb.ext_flip)) { 514 if (atomic_read(&ps3fb.ext_flip)) {
515 atomic_set(&ps3fb.ext_flip, 0); 515 atomic_set(&ps3fb.ext_flip, 0);
516 if (!try_acquire_console_sem()) { 516 if (console_trylock()) {
517 ps3fb_sync(info, 0); /* single buffer */ 517 ps3fb_sync(info, 0); /* single buffer */
518 release_console_sem(); 518 console_unlock();
519 } 519 }
520 } 520 }
521 } 521 }
@@ -830,14 +830,14 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
830 if (vmode) { 830 if (vmode) {
831 var = info->var; 831 var = info->var;
832 fb_videomode_to_var(&var, vmode); 832 fb_videomode_to_var(&var, vmode);
833 acquire_console_sem(); 833 console_lock();
834 info->flags |= FBINFO_MISC_USEREVENT; 834 info->flags |= FBINFO_MISC_USEREVENT;
835 /* Force, in case only special bits changed */ 835 /* Force, in case only special bits changed */
836 var.activate |= FB_ACTIVATE_FORCE; 836 var.activate |= FB_ACTIVATE_FORCE;
837 par->new_mode_id = val; 837 par->new_mode_id = val;
838 retval = fb_set_var(info, &var); 838 retval = fb_set_var(info, &var);
839 info->flags &= ~FBINFO_MISC_USEREVENT; 839 info->flags &= ~FBINFO_MISC_USEREVENT;
840 release_console_sem(); 840 console_unlock();
841 } 841 }
842 break; 842 break;
843 } 843 }
@@ -881,9 +881,9 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
881 break; 881 break;
882 882
883 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val); 883 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val);
884 acquire_console_sem(); 884 console_lock();
885 retval = ps3fb_sync(info, val); 885 retval = ps3fb_sync(info, val);
886 release_console_sem(); 886 console_unlock();
887 break; 887 break;
888 888
889 default: 889 default:
@@ -903,9 +903,9 @@ static int ps3fbd(void *arg)
903 set_current_state(TASK_INTERRUPTIBLE); 903 set_current_state(TASK_INTERRUPTIBLE);
904 if (ps3fb.is_kicked) { 904 if (ps3fb.is_kicked) {
905 ps3fb.is_kicked = 0; 905 ps3fb.is_kicked = 0;
906 acquire_console_sem(); 906 console_lock();
907 ps3fb_sync(info, 0); /* single buffer */ 907 ps3fb_sync(info, 0); /* single buffer */
908 release_console_sem(); 908 console_unlock();
909 } 909 }
910 schedule(); 910 schedule();
911 } 911 }
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index dce8c97b4333..75738a928610 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -22,7 +22,7 @@
22#include <linux/svga.h> 22#include <linux/svga.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 25#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
26#include <video/vga.h> 26#include <video/vga.h>
27 27
28#ifdef CONFIG_MTRR 28#ifdef CONFIG_MTRR
@@ -1113,12 +1113,12 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1113 1113
1114 dev_info(info->device, "suspend\n"); 1114 dev_info(info->device, "suspend\n");
1115 1115
1116 acquire_console_sem(); 1116 console_lock();
1117 mutex_lock(&(par->open_lock)); 1117 mutex_lock(&(par->open_lock));
1118 1118
1119 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 1119 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1120 mutex_unlock(&(par->open_lock)); 1120 mutex_unlock(&(par->open_lock));
1121 release_console_sem(); 1121 console_unlock();
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 1124
@@ -1129,7 +1129,7 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1129 pci_set_power_state(dev, pci_choose_state(dev, state)); 1129 pci_set_power_state(dev, pci_choose_state(dev, state));
1130 1130
1131 mutex_unlock(&(par->open_lock)); 1131 mutex_unlock(&(par->open_lock));
1132 release_console_sem(); 1132 console_unlock();
1133 1133
1134 return 0; 1134 return 0;
1135} 1135}
@@ -1145,12 +1145,12 @@ static int s3_pci_resume(struct pci_dev* dev)
1145 1145
1146 dev_info(info->device, "resume\n"); 1146 dev_info(info->device, "resume\n");
1147 1147
1148 acquire_console_sem(); 1148 console_lock();
1149 mutex_lock(&(par->open_lock)); 1149 mutex_lock(&(par->open_lock));
1150 1150
1151 if (par->ref_count == 0) { 1151 if (par->ref_count == 0) {
1152 mutex_unlock(&(par->open_lock)); 1152 mutex_unlock(&(par->open_lock));
1153 release_console_sem(); 1153 console_unlock();
1154 return 0; 1154 return 0;
1155 } 1155 }
1156 1156
@@ -1159,7 +1159,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1159 err = pci_enable_device(dev); 1159 err = pci_enable_device(dev);
1160 if (err) { 1160 if (err) {
1161 mutex_unlock(&(par->open_lock)); 1161 mutex_unlock(&(par->open_lock));
1162 release_console_sem(); 1162 console_unlock();
1163 dev_err(info->device, "error %d enabling device for resume\n", err); 1163 dev_err(info->device, "error %d enabling device for resume\n", err);
1164 return err; 1164 return err;
1165 } 1165 }
@@ -1169,7 +1169,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1169 fb_set_suspend(info, 0); 1169 fb_set_suspend(info, 0);
1170 1170
1171 mutex_unlock(&(par->open_lock)); 1171 mutex_unlock(&(par->open_lock));
1172 release_console_sem(); 1172 console_unlock();
1173 1173
1174 return 0; 1174 return 0;
1175} 1175}
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 842d157e1025..487911e2926c 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -2373,7 +2373,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2373 if (mesg.event == PM_EVENT_FREEZE) 2373 if (mesg.event == PM_EVENT_FREEZE)
2374 return 0; 2374 return 0;
2375 2375
2376 acquire_console_sem(); 2376 console_lock();
2377 fb_set_suspend(info, 1); 2377 fb_set_suspend(info, 1);
2378 2378
2379 if (info->fbops->fb_sync) 2379 if (info->fbops->fb_sync)
@@ -2385,7 +2385,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2385 pci_save_state(dev); 2385 pci_save_state(dev);
2386 pci_disable_device(dev); 2386 pci_disable_device(dev);
2387 pci_set_power_state(dev, pci_choose_state(dev, mesg)); 2387 pci_set_power_state(dev, pci_choose_state(dev, mesg));
2388 release_console_sem(); 2388 console_unlock();
2389 2389
2390 return 0; 2390 return 0;
2391} 2391}
@@ -2409,7 +2409,7 @@ static int savagefb_resume(struct pci_dev* dev)
2409 return 0; 2409 return 0;
2410 } 2410 }
2411 2411
2412 acquire_console_sem(); 2412 console_lock();
2413 2413
2414 pci_set_power_state(dev, PCI_D0); 2414 pci_set_power_state(dev, PCI_D0);
2415 pci_restore_state(dev); 2415 pci_restore_state(dev);
@@ -2423,7 +2423,7 @@ static int savagefb_resume(struct pci_dev* dev)
2423 savagefb_set_par(info); 2423 savagefb_set_par(info);
2424 fb_set_suspend(info, 0); 2424 fb_set_suspend(info, 0);
2425 savagefb_blank(FB_BLANK_UNBLANK, info); 2425 savagefb_blank(FB_BLANK_UNBLANK, info);
2426 release_console_sem(); 2426 console_unlock();
2427 2427
2428 return 0; 2428 return 0;
2429} 2429}
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 74d9f546a2e8..2b9e56a6bde4 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1151,7 +1151,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1151 1151
1152 ch = info->par; 1152 ch = info->par;
1153 1153
1154 acquire_console_sem(); 1154 console_lock();
1155 1155
1156 /* HDMI plug in */ 1156 /* HDMI plug in */
1157 if (!sh_hdmi_must_reconfigure(hdmi) && 1157 if (!sh_hdmi_must_reconfigure(hdmi) &&
@@ -1171,7 +1171,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1171 fb_set_suspend(info, 0); 1171 fb_set_suspend(info, 0);
1172 } 1172 }
1173 1173
1174 release_console_sem(); 1174 console_unlock();
1175 } else { 1175 } else {
1176 ret = 0; 1176 ret = 0;
1177 if (!hdmi->info) 1177 if (!hdmi->info)
@@ -1181,12 +1181,12 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1181 fb_destroy_modedb(hdmi->monspec.modedb); 1181 fb_destroy_modedb(hdmi->monspec.modedb);
1182 hdmi->monspec.modedb = NULL; 1182 hdmi->monspec.modedb = NULL;
1183 1183
1184 acquire_console_sem(); 1184 console_lock();
1185 1185
1186 /* HDMI disconnect */ 1186 /* HDMI disconnect */
1187 fb_set_suspend(hdmi->info, 1); 1187 fb_set_suspend(hdmi->info, 1);
1188 1188
1189 release_console_sem(); 1189 console_unlock();
1190 pm_runtime_put(hdmi->dev); 1190 pm_runtime_put(hdmi->dev);
1191 } 1191 }
1192 1192
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index bd4840a8a6b7..bf12e53aed5c 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -912,9 +912,9 @@ static int sh_mobile_release(struct fb_info *info, int user)
912 912
913 /* Nothing to reconfigure, when called from fbcon */ 913 /* Nothing to reconfigure, when called from fbcon */
914 if (user) { 914 if (user) {
915 acquire_console_sem(); 915 console_lock();
916 sh_mobile_fb_reconfig(info); 916 sh_mobile_fb_reconfig(info);
917 release_console_sem(); 917 console_unlock();
918 } 918 }
919 919
920 mutex_unlock(&ch->open_lock); 920 mutex_unlock(&ch->open_lock);
diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
index b7dc1800efa9..bcb44a594ebc 100644
--- a/drivers/video/sm501fb.c
+++ b/drivers/video/sm501fb.c
@@ -2010,9 +2010,9 @@ static int sm501fb_suspend_fb(struct sm501fb_info *info,
2010 2010
2011 /* tell console/fb driver we are suspending */ 2011 /* tell console/fb driver we are suspending */
2012 2012
2013 acquire_console_sem(); 2013 console_lock();
2014 fb_set_suspend(fbi, 1); 2014 fb_set_suspend(fbi, 1);
2015 release_console_sem(); 2015 console_unlock();
2016 2016
2017 /* backup copies in case chip is powered down over suspend */ 2017 /* backup copies in case chip is powered down over suspend */
2018 2018
@@ -2069,9 +2069,9 @@ static void sm501fb_resume_fb(struct sm501fb_info *info,
2069 memcpy_toio(par->cursor.k_addr, par->store_cursor, 2069 memcpy_toio(par->cursor.k_addr, par->store_cursor,
2070 par->cursor.size); 2070 par->cursor.size);
2071 2071
2072 acquire_console_sem(); 2072 console_lock();
2073 fb_set_suspend(fbi, 0); 2073 fb_set_suspend(fbi, 0);
2074 release_console_sem(); 2074 console_unlock();
2075 2075
2076 vfree(par->store_fb); 2076 vfree(par->store_fb);
2077 vfree(par->store_cursor); 2077 vfree(par->store_cursor);
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
index 6913fe168c25..dfef88c803d4 100644
--- a/drivers/video/tmiofb.c
+++ b/drivers/video/tmiofb.c
@@ -25,7 +25,7 @@
25#include <linux/fb.h> 25#include <linux/fb.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28/* Why should fb driver call console functions? because acquire_console_sem() */ 28/* Why should fb driver call console functions? because console_lock() */
29#include <linux/console.h> 29#include <linux/console.h>
30#include <linux/mfd/core.h> 30#include <linux/mfd/core.h>
31#include <linux/mfd/tmio.h> 31#include <linux/mfd/tmio.h>
@@ -944,7 +944,7 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
944 struct mfd_cell *cell = dev->dev.platform_data; 944 struct mfd_cell *cell = dev->dev.platform_data;
945 int retval = 0; 945 int retval = 0;
946 946
947 acquire_console_sem(); 947 console_lock();
948 948
949 fb_set_suspend(info, 1); 949 fb_set_suspend(info, 1);
950 950
@@ -965,7 +965,7 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
965 if (cell->suspend) 965 if (cell->suspend)
966 retval = cell->suspend(dev); 966 retval = cell->suspend(dev);
967 967
968 release_console_sem(); 968 console_unlock();
969 969
970 return retval; 970 return retval;
971} 971}
@@ -976,7 +976,7 @@ static int tmiofb_resume(struct platform_device *dev)
976 struct mfd_cell *cell = dev->dev.platform_data; 976 struct mfd_cell *cell = dev->dev.platform_data;
977 int retval = 0; 977 int retval = 0;
978 978
979 acquire_console_sem(); 979 console_lock();
980 980
981 if (cell->resume) { 981 if (cell->resume) {
982 retval = cell->resume(dev); 982 retval = cell->resume(dev);
@@ -992,7 +992,7 @@ static int tmiofb_resume(struct platform_device *dev)
992 992
993 fb_set_suspend(info, 0); 993 fb_set_suspend(info, 0);
994out: 994out:
995 release_console_sem(); 995 console_unlock();
996 return retval; 996 return retval;
997} 997}
998#else 998#else
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 289edd519527..4e66349e4366 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1674,17 +1674,17 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
1674#ifdef CONFIG_PM 1674#ifdef CONFIG_PM
1675static int viafb_suspend(void *unused) 1675static int viafb_suspend(void *unused)
1676{ 1676{
1677 acquire_console_sem(); 1677 console_lock();
1678 fb_set_suspend(viafbinfo, 1); 1678 fb_set_suspend(viafbinfo, 1);
1679 viafb_sync(viafbinfo); 1679 viafb_sync(viafbinfo);
1680 release_console_sem(); 1680 console_unlock();
1681 1681
1682 return 0; 1682 return 0;
1683} 1683}
1684 1684
1685static int viafb_resume(void *unused) 1685static int viafb_resume(void *unused)
1686{ 1686{
1687 acquire_console_sem(); 1687 console_lock();
1688 if (viaparinfo->shared->vdev->engine_mmio) 1688 if (viaparinfo->shared->vdev->engine_mmio)
1689 viafb_reset_engine(viaparinfo); 1689 viafb_reset_engine(viaparinfo);
1690 viafb_set_par(viafbinfo); 1690 viafb_set_par(viafbinfo);
@@ -1692,7 +1692,7 @@ static int viafb_resume(void *unused)
1692 viafb_set_par(viafbinfo1); 1692 viafb_set_par(viafbinfo1);
1693 fb_set_suspend(viafbinfo, 0); 1693 fb_set_suspend(viafbinfo, 0);
1694 1694
1695 release_console_sem(); 1695 console_unlock();
1696 return 0; 1696 return 0;
1697} 1697}
1698 1698
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
index 85d76ec4c63e..a2965ab92cfb 100644
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -23,7 +23,7 @@
23#include <linux/svga.h> 23#include <linux/svga.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 26#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
27#include <video/vga.h> 27#include <video/vga.h>
28 28
29#ifdef CONFIG_MTRR 29#ifdef CONFIG_MTRR
@@ -819,12 +819,12 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
819 819
820 dev_info(info->device, "suspend\n"); 820 dev_info(info->device, "suspend\n");
821 821
822 acquire_console_sem(); 822 console_lock();
823 mutex_lock(&(par->open_lock)); 823 mutex_lock(&(par->open_lock));
824 824
825 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 825 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
826 mutex_unlock(&(par->open_lock)); 826 mutex_unlock(&(par->open_lock));
827 release_console_sem(); 827 console_unlock();
828 return 0; 828 return 0;
829 } 829 }
830 830
@@ -835,7 +835,7 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
835 pci_set_power_state(dev, pci_choose_state(dev, state)); 835 pci_set_power_state(dev, pci_choose_state(dev, state));
836 836
837 mutex_unlock(&(par->open_lock)); 837 mutex_unlock(&(par->open_lock));
838 release_console_sem(); 838 console_unlock();
839 839
840 return 0; 840 return 0;
841} 841}
@@ -850,7 +850,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
850 850
851 dev_info(info->device, "resume\n"); 851 dev_info(info->device, "resume\n");
852 852
853 acquire_console_sem(); 853 console_lock();
854 mutex_lock(&(par->open_lock)); 854 mutex_lock(&(par->open_lock));
855 855
856 if (par->ref_count == 0) 856 if (par->ref_count == 0)
@@ -869,7 +869,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
869 869
870fail: 870fail:
871 mutex_unlock(&(par->open_lock)); 871 mutex_unlock(&(par->open_lock));
872 release_console_sem(); 872 console_unlock();
873 873
874 return 0; 874 return 0;
875} 875}
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 3e6934d4bea8..a20218c2fda8 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -491,12 +491,12 @@ xenfb_make_preferred_console(void)
491 if (console_set_on_cmdline) 491 if (console_set_on_cmdline)
492 return; 492 return;
493 493
494 acquire_console_sem(); 494 console_lock();
495 for_each_console(c) { 495 for_each_console(c) {
496 if (!strcmp(c->name, "tty") && c->index == 0) 496 if (!strcmp(c->name, "tty") && c->index == 0)
497 break; 497 break;
498 } 498 }
499 release_console_sem(); 499 console_unlock();
500 if (c) { 500 if (c) {
501 unregister_console(c); 501 unregister_console(c);
502 c->flags |= CON_CONSDEV; 502 c->flags |= CON_CONSDEV;
diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index eafc22ab1fdd..b701eaa482bf 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -67,7 +67,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
67 struct console *con; 67 struct console *con;
68 loff_t off = 0; 68 loff_t off = 0;
69 69
70 acquire_console_sem(); 70 console_lock();
71 for_each_console(con) 71 for_each_console(con)
72 if (off++ == *pos) 72 if (off++ == *pos)
73 break; 73 break;
@@ -84,7 +84,7 @@ static void *c_next(struct seq_file *m, void *v, loff_t *pos)
84 84
85static void c_stop(struct seq_file *m, void *v) 85static void c_stop(struct seq_file *m, void *v)
86{ 86{
87 release_console_sem(); 87 console_unlock();
88} 88}
89 89
90static const struct seq_operations consoles_op = { 90static const struct seq_operations consoles_op = {
diff --git a/include/linux/console.h b/include/linux/console.h
index 9774fe6a1a97..7453cfd593c8 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -139,9 +139,9 @@ extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_n
139extern void register_console(struct console *); 139extern void register_console(struct console *);
140extern int unregister_console(struct console *); 140extern int unregister_console(struct console *);
141extern struct console *console_drivers; 141extern struct console *console_drivers;
142extern void acquire_console_sem(void); 142extern void console_lock(void);
143extern int try_acquire_console_sem(void); 143extern int console_trylock(void);
144extern void release_console_sem(void); 144extern void console_unlock(void);
145extern void console_conditional_schedule(void); 145extern void console_conditional_schedule(void);
146extern void console_unblank(void); 146extern void console_unblank(void);
147extern struct tty_driver *console_device(int *); 147extern struct tty_driver *console_device(int *);
diff --git a/kernel/printk.c b/kernel/printk.c
index 53d9a9ec88e6..2ddbdc73aade 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -97,7 +97,7 @@ static int console_locked, console_suspended;
97/* 97/*
98 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars 98 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars
99 * It is also used in interesting ways to provide interlocking in 99 * It is also used in interesting ways to provide interlocking in
100 * release_console_sem(). 100 * console_unlock();.
101 */ 101 */
102static DEFINE_SPINLOCK(logbuf_lock); 102static DEFINE_SPINLOCK(logbuf_lock);
103 103
@@ -501,7 +501,7 @@ static void _call_console_drivers(unsigned start,
501/* 501/*
502 * Call the console drivers, asking them to write out 502 * Call the console drivers, asking them to write out
503 * log_buf[start] to log_buf[end - 1]. 503 * log_buf[start] to log_buf[end - 1].
504 * The console_sem must be held. 504 * The console_lock must be held.
505 */ 505 */
506static void call_console_drivers(unsigned start, unsigned end) 506static void call_console_drivers(unsigned start, unsigned end)
507{ 507{
@@ -604,11 +604,11 @@ static int have_callable_console(void)
604 * 604 *
605 * This is printk(). It can be called from any context. We want it to work. 605 * This is printk(). It can be called from any context. We want it to work.
606 * 606 *
607 * We try to grab the console_sem. If we succeed, it's easy - we log the output and 607 * We try to grab the console_lock. If we succeed, it's easy - we log the output and
608 * call the console drivers. If we fail to get the semaphore we place the output 608 * call the console drivers. If we fail to get the semaphore we place the output
609 * into the log buffer and return. The current holder of the console_sem will 609 * into the log buffer and return. The current holder of the console_sem will
610 * notice the new output in release_console_sem() and will send it to the 610 * notice the new output in console_unlock(); and will send it to the
611 * consoles before releasing the semaphore. 611 * consoles before releasing the lock.
612 * 612 *
613 * One effect of this deferred printing is that code which calls printk() and 613 * One effect of this deferred printing is that code which calls printk() and
614 * then changes console_loglevel may break. This is because console_loglevel 614 * then changes console_loglevel may break. This is because console_loglevel
@@ -659,19 +659,19 @@ static inline int can_use_console(unsigned int cpu)
659/* 659/*
660 * Try to get console ownership to actually show the kernel 660 * Try to get console ownership to actually show the kernel
661 * messages from a 'printk'. Return true (and with the 661 * messages from a 'printk'. Return true (and with the
662 * console_semaphore held, and 'console_locked' set) if it 662 * console_lock held, and 'console_locked' set) if it
663 * is successful, false otherwise. 663 * is successful, false otherwise.
664 * 664 *
665 * This gets called with the 'logbuf_lock' spinlock held and 665 * This gets called with the 'logbuf_lock' spinlock held and
666 * interrupts disabled. It should return with 'lockbuf_lock' 666 * interrupts disabled. It should return with 'lockbuf_lock'
667 * released but interrupts still disabled. 667 * released but interrupts still disabled.
668 */ 668 */
669static int acquire_console_semaphore_for_printk(unsigned int cpu) 669static int console_trylock_for_printk(unsigned int cpu)
670 __releases(&logbuf_lock) 670 __releases(&logbuf_lock)
671{ 671{
672 int retval = 0; 672 int retval = 0;
673 673
674 if (!try_acquire_console_sem()) { 674 if (console_trylock()) {
675 retval = 1; 675 retval = 1;
676 676
677 /* 677 /*
@@ -827,12 +827,12 @@ asmlinkage int vprintk(const char *fmt, va_list args)
827 * actual magic (print out buffers, wake up klogd, 827 * actual magic (print out buffers, wake up klogd,
828 * etc). 828 * etc).
829 * 829 *
830 * The acquire_console_semaphore_for_printk() function 830 * The console_trylock_for_printk() function
831 * will release 'logbuf_lock' regardless of whether it 831 * will release 'logbuf_lock' regardless of whether it
832 * actually gets the semaphore or not. 832 * actually gets the semaphore or not.
833 */ 833 */
834 if (acquire_console_semaphore_for_printk(this_cpu)) 834 if (console_trylock_for_printk(this_cpu))
835 release_console_sem(); 835 console_unlock();
836 836
837 lockdep_on(); 837 lockdep_on();
838out_restore_irqs: 838out_restore_irqs:
@@ -993,7 +993,7 @@ void suspend_console(void)
993 if (!console_suspend_enabled) 993 if (!console_suspend_enabled)
994 return; 994 return;
995 printk("Suspending console(s) (use no_console_suspend to debug)\n"); 995 printk("Suspending console(s) (use no_console_suspend to debug)\n");
996 acquire_console_sem(); 996 console_lock();
997 console_suspended = 1; 997 console_suspended = 1;
998 up(&console_sem); 998 up(&console_sem);
999} 999}
@@ -1004,7 +1004,7 @@ void resume_console(void)
1004 return; 1004 return;
1005 down(&console_sem); 1005 down(&console_sem);
1006 console_suspended = 0; 1006 console_suspended = 0;
1007 release_console_sem(); 1007 console_unlock();
1008} 1008}
1009 1009
1010/** 1010/**
@@ -1027,21 +1027,21 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self,
1027 case CPU_DYING: 1027 case CPU_DYING:
1028 case CPU_DOWN_FAILED: 1028 case CPU_DOWN_FAILED:
1029 case CPU_UP_CANCELED: 1029 case CPU_UP_CANCELED:
1030 acquire_console_sem(); 1030 console_lock();
1031 release_console_sem(); 1031 console_unlock();
1032 } 1032 }
1033 return NOTIFY_OK; 1033 return NOTIFY_OK;
1034} 1034}
1035 1035
1036/** 1036/**
1037 * acquire_console_sem - lock the console system for exclusive use. 1037 * console_lock - lock the console system for exclusive use.
1038 * 1038 *
1039 * Acquires a semaphore which guarantees that the caller has 1039 * Acquires a lock which guarantees that the caller has
1040 * exclusive access to the console system and the console_drivers list. 1040 * exclusive access to the console system and the console_drivers list.
1041 * 1041 *
1042 * Can sleep, returns nothing. 1042 * Can sleep, returns nothing.
1043 */ 1043 */
1044void acquire_console_sem(void) 1044void console_lock(void)
1045{ 1045{
1046 BUG_ON(in_interrupt()); 1046 BUG_ON(in_interrupt());
1047 down(&console_sem); 1047 down(&console_sem);
@@ -1050,21 +1050,29 @@ void acquire_console_sem(void)
1050 console_locked = 1; 1050 console_locked = 1;
1051 console_may_schedule = 1; 1051 console_may_schedule = 1;
1052} 1052}
1053EXPORT_SYMBOL(acquire_console_sem); 1053EXPORT_SYMBOL(console_lock);
1054 1054
1055int try_acquire_console_sem(void) 1055/**
1056 * console_trylock - try to lock the console system for exclusive use.
1057 *
1058 * Tried to acquire a lock which guarantees that the caller has
1059 * exclusive access to the console system and the console_drivers list.
1060 *
1061 * returns 1 on success, and 0 on failure to acquire the lock.
1062 */
1063int console_trylock(void)
1056{ 1064{
1057 if (down_trylock(&console_sem)) 1065 if (down_trylock(&console_sem))
1058 return -1; 1066 return 0;
1059 if (console_suspended) { 1067 if (console_suspended) {
1060 up(&console_sem); 1068 up(&console_sem);
1061 return -1; 1069 return 0;
1062 } 1070 }
1063 console_locked = 1; 1071 console_locked = 1;
1064 console_may_schedule = 0; 1072 console_may_schedule = 0;
1065 return 0; 1073 return 1;
1066} 1074}
1067EXPORT_SYMBOL(try_acquire_console_sem); 1075EXPORT_SYMBOL(console_trylock);
1068 1076
1069int is_console_locked(void) 1077int is_console_locked(void)
1070{ 1078{
@@ -1095,20 +1103,20 @@ void wake_up_klogd(void)
1095} 1103}
1096 1104
1097/** 1105/**
1098 * release_console_sem - unlock the console system 1106 * console_unlock - unlock the console system
1099 * 1107 *
1100 * Releases the semaphore which the caller holds on the console system 1108 * Releases the console_lock which the caller holds on the console system
1101 * and the console driver list. 1109 * and the console driver list.
1102 * 1110 *
1103 * While the semaphore was held, console output may have been buffered 1111 * While the console_lock was held, console output may have been buffered
1104 * by printk(). If this is the case, release_console_sem() emits 1112 * by printk(). If this is the case, console_unlock(); emits
1105 * the output prior to releasing the semaphore. 1113 * the output prior to releasing the lock.
1106 * 1114 *
1107 * If there is output waiting for klogd, we wake it up. 1115 * If there is output waiting for klogd, we wake it up.
1108 * 1116 *
1109 * release_console_sem() may be called from any context. 1117 * console_unlock(); may be called from any context.
1110 */ 1118 */
1111void release_console_sem(void) 1119void console_unlock(void)
1112{ 1120{
1113 unsigned long flags; 1121 unsigned long flags;
1114 unsigned _con_start, _log_end; 1122 unsigned _con_start, _log_end;
@@ -1141,7 +1149,7 @@ void release_console_sem(void)
1141 if (wake_klogd) 1149 if (wake_klogd)
1142 wake_up_klogd(); 1150 wake_up_klogd();
1143} 1151}
1144EXPORT_SYMBOL(release_console_sem); 1152EXPORT_SYMBOL(console_unlock);
1145 1153
1146/** 1154/**
1147 * console_conditional_schedule - yield the CPU if required 1155 * console_conditional_schedule - yield the CPU if required
@@ -1150,7 +1158,7 @@ EXPORT_SYMBOL(release_console_sem);
1150 * if this CPU should yield the CPU to another task, do 1158 * if this CPU should yield the CPU to another task, do
1151 * so here. 1159 * so here.
1152 * 1160 *
1153 * Must be called within acquire_console_sem(). 1161 * Must be called within console_lock();.
1154 */ 1162 */
1155void __sched console_conditional_schedule(void) 1163void __sched console_conditional_schedule(void)
1156{ 1164{
@@ -1171,14 +1179,14 @@ void console_unblank(void)
1171 if (down_trylock(&console_sem) != 0) 1179 if (down_trylock(&console_sem) != 0)
1172 return; 1180 return;
1173 } else 1181 } else
1174 acquire_console_sem(); 1182 console_lock();
1175 1183
1176 console_locked = 1; 1184 console_locked = 1;
1177 console_may_schedule = 0; 1185 console_may_schedule = 0;
1178 for_each_console(c) 1186 for_each_console(c)
1179 if ((c->flags & CON_ENABLED) && c->unblank) 1187 if ((c->flags & CON_ENABLED) && c->unblank)
1180 c->unblank(); 1188 c->unblank();
1181 release_console_sem(); 1189 console_unlock();
1182} 1190}
1183 1191
1184/* 1192/*
@@ -1189,7 +1197,7 @@ struct tty_driver *console_device(int *index)
1189 struct console *c; 1197 struct console *c;
1190 struct tty_driver *driver = NULL; 1198 struct tty_driver *driver = NULL;
1191 1199
1192 acquire_console_sem(); 1200 console_lock();
1193 for_each_console(c) { 1201 for_each_console(c) {
1194 if (!c->device) 1202 if (!c->device)
1195 continue; 1203 continue;
@@ -1197,7 +1205,7 @@ struct tty_driver *console_device(int *index)
1197 if (driver) 1205 if (driver)
1198 break; 1206 break;
1199 } 1207 }
1200 release_console_sem(); 1208 console_unlock();
1201 return driver; 1209 return driver;
1202} 1210}
1203 1211
@@ -1208,17 +1216,17 @@ struct tty_driver *console_device(int *index)
1208 */ 1216 */
1209void console_stop(struct console *console) 1217void console_stop(struct console *console)
1210{ 1218{
1211 acquire_console_sem(); 1219 console_lock();
1212 console->flags &= ~CON_ENABLED; 1220 console->flags &= ~CON_ENABLED;
1213 release_console_sem(); 1221 console_unlock();
1214} 1222}
1215EXPORT_SYMBOL(console_stop); 1223EXPORT_SYMBOL(console_stop);
1216 1224
1217void console_start(struct console *console) 1225void console_start(struct console *console)
1218{ 1226{
1219 acquire_console_sem(); 1227 console_lock();
1220 console->flags |= CON_ENABLED; 1228 console->flags |= CON_ENABLED;
1221 release_console_sem(); 1229 console_unlock();
1222} 1230}
1223EXPORT_SYMBOL(console_start); 1231EXPORT_SYMBOL(console_start);
1224 1232
@@ -1340,7 +1348,7 @@ void register_console(struct console *newcon)
1340 * Put this console in the list - keep the 1348 * Put this console in the list - keep the
1341 * preferred driver at the head of the list. 1349 * preferred driver at the head of the list.
1342 */ 1350 */
1343 acquire_console_sem(); 1351 console_lock();
1344 if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) { 1352 if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) {
1345 newcon->next = console_drivers; 1353 newcon->next = console_drivers;
1346 console_drivers = newcon; 1354 console_drivers = newcon;
@@ -1352,14 +1360,14 @@ void register_console(struct console *newcon)
1352 } 1360 }
1353 if (newcon->flags & CON_PRINTBUFFER) { 1361 if (newcon->flags & CON_PRINTBUFFER) {
1354 /* 1362 /*
1355 * release_console_sem() will print out the buffered messages 1363 * console_unlock(); will print out the buffered messages
1356 * for us. 1364 * for us.
1357 */ 1365 */
1358 spin_lock_irqsave(&logbuf_lock, flags); 1366 spin_lock_irqsave(&logbuf_lock, flags);
1359 con_start = log_start; 1367 con_start = log_start;
1360 spin_unlock_irqrestore(&logbuf_lock, flags); 1368 spin_unlock_irqrestore(&logbuf_lock, flags);
1361 } 1369 }
1362 release_console_sem(); 1370 console_unlock();
1363 console_sysfs_notify(); 1371 console_sysfs_notify();
1364 1372
1365 /* 1373 /*
@@ -1396,7 +1404,7 @@ int unregister_console(struct console *console)
1396 return braille_unregister_console(console); 1404 return braille_unregister_console(console);
1397#endif 1405#endif
1398 1406
1399 acquire_console_sem(); 1407 console_lock();
1400 if (console_drivers == console) { 1408 if (console_drivers == console) {
1401 console_drivers=console->next; 1409 console_drivers=console->next;
1402 res = 0; 1410 res = 0;
@@ -1418,7 +1426,7 @@ int unregister_console(struct console *console)
1418 if (console_drivers != NULL && console->flags & CON_CONSDEV) 1426 if (console_drivers != NULL && console->flags & CON_CONSDEV)
1419 console_drivers->flags |= CON_CONSDEV; 1427 console_drivers->flags |= CON_CONSDEV;
1420 1428
1421 release_console_sem(); 1429 console_unlock();
1422 console_sysfs_notify(); 1430 console_sysfs_notify();
1423 return res; 1431 return res;
1424} 1432}