drivers/tty/tty_mutex.c
Source file repositories/reference/linux-study-clean/drivers/tty/tty_mutex.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/tty_mutex.c- Extension
.c- Size
- 994 bytes
- Lines
- 56
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/tty.hlinux/module.hlinux/kallsyms.hlinux/semaphore.hlinux/sched.htty.h
Detected Declarations
function tty_lockfunction tty_lock_interruptiblefunction tty_unlockfunction tty_lock_slavefunction tty_unlock_slavefunction tty_set_lock_subclassexport tty_lockexport tty_unlock
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#include <linux/semaphore.h>
#include <linux/sched.h>
#include "tty.h"
/* Legacy tty mutex glue */
/*
* Getting the big tty mutex.
*/
void tty_lock(struct tty_struct *tty)
{
tty_kref_get(tty);
mutex_lock(&tty->legacy_mutex);
}
EXPORT_SYMBOL(tty_lock);
int tty_lock_interruptible(struct tty_struct *tty)
{
int ret;
tty_kref_get(tty);
ret = mutex_lock_interruptible(&tty->legacy_mutex);
if (ret)
tty_kref_put(tty);
return ret;
}
void tty_unlock(struct tty_struct *tty)
{
mutex_unlock(&tty->legacy_mutex);
tty_kref_put(tty);
}
EXPORT_SYMBOL(tty_unlock);
void tty_lock_slave(struct tty_struct *tty)
{
if (tty && tty != tty->link)
tty_lock(tty);
}
void tty_unlock_slave(struct tty_struct *tty)
{
if (tty && tty != tty->link)
tty_unlock(tty);
}
void tty_set_lock_subclass(struct tty_struct *tty)
{
lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE);
}
Annotation
- Immediate include surface: `linux/tty.h`, `linux/module.h`, `linux/kallsyms.h`, `linux/semaphore.h`, `linux/sched.h`, `tty.h`.
- Detected declarations: `function tty_lock`, `function tty_lock_interruptible`, `function tty_unlock`, `function tty_lock_slave`, `function tty_unlock_slave`, `function tty_set_lock_subclass`, `export tty_lock`, `export tty_unlock`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.