Skip to content

Commit

Permalink
console: rename acquire/release_console_sem() to console_lock/unlock()
Browse files Browse the repository at this point in the history
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.

[[email protected]: coding-style fixes]
[[email protected]: make console_trylock return 1 on success, per Geert]
Signed-off-by: Torben Hohn <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Greg KH <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torbenh3 authored and torvalds committed Jan 26, 2011
1 parent 3689456 commit ac751ef
Show file tree
Hide file tree
Showing 44 changed files with 336 additions and 328 deletions.
4 changes: 2 additions & 2 deletions arch/arm/mach-omap2/pm24xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void omap2_enter_full_retention(void)

/* Block console output in case it is on one of the OMAP UARTs */
if (!is_suspending())
if (try_acquire_console_sem())
if (!console_trylock())
goto no_sleep;

omap_uart_prepare_idle(0);
Expand All @@ -151,7 +151,7 @@ static void omap2_enter_full_retention(void)
omap_uart_resume_idle(0);

if (!is_suspending())
release_console_sem();
console_unlock();

no_sleep:
if (omap2_pm_debug) {
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-omap2/pm34xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void omap_sram_idle(void)
if (!is_suspending())
if (per_next_state < PWRDM_POWER_ON ||
core_next_state < PWRDM_POWER_ON)
if (try_acquire_console_sem())
if (!console_trylock())
goto console_still_active;

/* PER */
Expand Down Expand Up @@ -481,7 +481,7 @@ void omap_sram_idle(void)
}

if (!is_suspending())
release_console_sem();
console_unlock();

console_still_active:
/* Disable IO-PAD and IO-CHAIN wakeup */
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-omap2/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)

oh->dev_attr = uart;

acquire_console_sem(); /* in case the earlycon is on the UART */
console_lock(); /* in case the earlycon is on the UART */

/*
* Because of early UART probing, UART did not get idled
Expand All @@ -838,7 +838,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
omap_uart_block_sleep(uart);
uart->timeout = DEFAULT_TIMEOUT;

release_console_sem();
console_unlock();

if ((cpu_is_omap34xx() && uart->padconf) ||
(uart->wk_en && uart->wk_mask)) {
Expand Down
4 changes: 2 additions & 2 deletions arch/parisc/kernel/pdc_cons.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ static int __init pdc_console_tty_driver_init(void)

struct console *tmp;

acquire_console_sem();
console_lock();
for_each_console(tmp)
if (tmp == &pdc_cons)
break;
release_console_sem();
console_unlock();

if (!tmp) {
printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name);
Expand Down
8 changes: 4 additions & 4 deletions drivers/char/bfin_jtag_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ bfin_jc_circ_write(const unsigned char *buf, int count)
}

#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE
# define acquire_console_sem()
# define release_console_sem()
# define console_lock()
# define console_unlock()
#endif
static int
bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
int i;
acquire_console_sem();
console_lock();
i = bfin_jc_circ_write(buf, count);
release_console_sem();
console_unlock();
wake_up_process(bfin_jc_kthread);
return i;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/nouveau/nouveau_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
pci_set_power_state(pdev, PCI_D3hot);
}

acquire_console_sem();
console_lock();
nouveau_fbcon_set_suspend(dev, 1);
release_console_sem();
console_unlock();
nouveau_fbcon_restore_accel(dev);
return 0;

Expand Down Expand Up @@ -359,9 +359,9 @@ nouveau_pci_resume(struct pci_dev *pdev)
nv_crtc->lut.depth = 0;
}

acquire_console_sem();
console_lock();
nouveau_fbcon_set_suspend(dev, 0);
release_console_sem();
console_unlock();

nouveau_fbcon_zfill_all(dev);

Expand Down
10 changes: 5 additions & 5 deletions drivers/gpu/drm/radeon/radeon_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,9 +891,9 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
pci_disable_device(dev->pdev);
pci_set_power_state(dev->pdev, PCI_D3hot);
}
acquire_console_sem();
console_lock();
radeon_fbdev_set_suspend(rdev, 1);
release_console_sem();
console_unlock();
return 0;
}

Expand All @@ -905,11 +905,11 @@ int radeon_resume_kms(struct drm_device *dev)
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;

acquire_console_sem();
console_lock();
pci_set_power_state(dev->pdev, PCI_D0);
pci_restore_state(dev->pdev);
if (pci_enable_device(dev->pdev)) {
release_console_sem();
console_unlock();
return -1;
}
pci_set_master(dev->pdev);
Expand All @@ -920,7 +920,7 @@ int radeon_resume_kms(struct drm_device *dev)
radeon_restore_bios_scratch_regs(rdev);

radeon_fbdev_set_suspend(rdev, 0);
release_console_sem();
console_unlock();

/* reset hpd state */
radeon_hpd_init(rdev);
Expand Down
8 changes: 4 additions & 4 deletions drivers/staging/msm/msm_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
if ((!mfd) || (mfd->key != MFD_KEY))
return 0;

acquire_console_sem();
console_lock();
fb_set_suspend(mfd->fbi, 1);

ret = msm_fb_suspend_sub(mfd);
Expand All @@ -358,7 +358,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
pdev->dev.power.power_state = state;
}

release_console_sem();
console_unlock();
return ret;
}
#else
Expand Down Expand Up @@ -431,11 +431,11 @@ static int msm_fb_resume(struct platform_device *pdev)
if ((!mfd) || (mfd->key != MFD_KEY))
return 0;

acquire_console_sem();
console_lock();
ret = msm_fb_resume_sub(mfd);
pdev->dev.power.power_state = PMSG_ON;
fb_set_suspend(mfd->fbi, 1);
release_console_sem();
console_unlock();

return ret;
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/olpc_dcon/olpc_dcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,17 @@ static void dcon_source_switch(struct work_struct *work)
*
* For now, we just hope..
*/
acquire_console_sem();
console_lock();
ignore_fb_events = 1;
if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) {
ignore_fb_events = 0;
release_console_sem();
console_unlock();
printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n");
dcon_pending = DCON_SOURCE_DCON;
return;
}
ignore_fb_events = 0;
release_console_sem();
console_unlock();

/* And turn off the DCON */
pdata->set_dconload(1);
Expand Down Expand Up @@ -435,12 +435,12 @@ static void dcon_source_switch(struct work_struct *work)
}
}

acquire_console_sem();
console_lock();
ignore_fb_events = 1;
if (fb_blank(fbinfo, FB_BLANK_POWERDOWN))
printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n");
ignore_fb_events = 0;
release_console_sem();
console_unlock();

printk(KERN_INFO "olpc-dcon: The DCON has control\n");
break;
Expand Down
8 changes: 4 additions & 4 deletions drivers/staging/sm7xx/smtcfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,9 @@ static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)

/* when doing suspend, call fb apis and pci apis */
if (msg.event == PM_EVENT_SUSPEND) {
acquire_console_sem();
console_lock();
fb_set_suspend(&sfb->fb, 1);
release_console_sem();
console_unlock();
retv = pci_save_state(pdev);
pci_disable_device(pdev);
retv = pci_choose_state(pdev, msg);
Expand Down Expand Up @@ -1105,9 +1105,9 @@ static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)

smtcfb_setmode(sfb);

acquire_console_sem();
console_lock();
fb_set_suspend(&sfb->fb, 0);
release_console_sem();
console_unlock();

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/serial/sb1250-duart.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ static void __init sbd_probe_duarts(void)
#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE
/*
* Serial console stuff. Very basic, polling driver for doing serial
* console output. The console_sem is held by the caller, so we
* console output. The console_lock is held by the caller, so we
* shouldn't be interrupted for more console activity.
*/
static void sbd_console_putchar(struct uart_port *uport, int ch)
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3256,7 +3256,7 @@ static ssize_t show_cons_active(struct device *dev,
struct console *c;
ssize_t count = 0;

acquire_console_sem();
console_lock();
for (c = console_drivers; c; c = c->next) {
if (!c->device)
continue;
Expand All @@ -3271,7 +3271,7 @@ static ssize_t show_cons_active(struct device *dev,
while (i--)
count += sprintf(buf + count, "%s%d%c",
cs[i]->name, cs[i]->index, i ? ' ':'\n');
release_console_sem();
console_unlock();

return count;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/vt/selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ int paste_selection(struct tty_struct *tty)
/* always called with BTM from vt_ioctl */
WARN_ON(!tty_locked());

acquire_console_sem();
console_lock();
poke_blanked_console();
release_console_sem();
console_unlock();

ld = tty_ldisc_ref(tty);
if (!ld) {
Expand Down
16 changes: 8 additions & 8 deletions drivers/tty/vt/vc_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
/* Select the proper current console and verify
* sanity of the situation under the console lock.
*/
acquire_console_sem();
console_lock();

attr = (currcons & 128);
currcons = (currcons & 127);
Expand Down Expand Up @@ -336,9 +336,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
* the pagefault handling code may want to call printk().
*/

release_console_sem();
console_unlock();
ret = copy_to_user(buf, con_buf_start, orig_count);
acquire_console_sem();
console_lock();

if (ret) {
read += (orig_count - ret);
Expand All @@ -354,7 +354,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (read)
ret = read;
unlock_out:
release_console_sem();
console_unlock();
mutex_unlock(&con_buf_mtx);
return ret;
}
Expand All @@ -379,7 +379,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
/* Select the proper current console and verify
* sanity of the situation under the console lock.
*/
acquire_console_sem();
console_lock();

attr = (currcons & 128);
currcons = (currcons & 127);
Expand Down Expand Up @@ -414,9 +414,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
/* Temporarily drop the console lock so that we can read
* in the write data from userspace safely.
*/
release_console_sem();
console_unlock();
ret = copy_from_user(con_buf, buf, this_round);
acquire_console_sem();
console_lock();

if (ret) {
this_round -= ret;
Expand Down Expand Up @@ -542,7 +542,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
vcs_scr_updated(vc);

unlock_out:
release_console_sem();
console_unlock();

mutex_unlock(&con_buf_mtx);

Expand Down
Loading

0 comments on commit ac751ef

Please sign in to comment.