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>

authored by Torben Hohn and committed by Linus Torvalds ac751efa 3689456b

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