tty_port_put(9)
β¨ tty_port_put(9) β the kernel API manual, but make it a group chat π
okay so bestie, we're in the kernel API manual (section 9, the fun one) and today's main character is tty_port_put π
πΈ NAME πΈ
tty_port_put β drop a reference to tty_port
π¦ SYNOPSIS π¦
void tty_port_put (struct tty_port *port );
π ARGUMENTS π
portβ the port you're dropping a reference of (and yes bestie, it can beNULLπ«Ά)
β¨ DESCRIPTION β¨
So here's the tea π: that final put is the one that actually destroys and frees up the port. Not me being dramatic, that's just literally what it does π
And how does it do the freeing? Two paths, iykyk:
- it uses the
port->ops->destructhook, or - it just uses
kfreeif that hook isn't provided.
Either way, the last reference walking out the door is the one that cleans up. Iconic behavior honestly π
π SEE ALSO π
Kernel file ./drivers/tty/tty_port.c and the whole tty_port squad, all linked up:
tty_port_init(9)tty_port_link_wq(9)tty_port_link_device(9)tty_port_register_device(9)tty_port_register_device_attr(9)tty_port_register_device_attr_serdev(9)tty_port_unregister_device(9)tty_port_destroy(9)tty_port_tty_get(9)tty_port_tty_set(9)tty_port_shutdown(9)tty_port_hangup(9)tty_port_tty_hangup(9)tty_port_tty_vhangup(9)tty_port_tty_wakeup(9)tty_port_carrier_raised(9)tty_port_raise_dtr_rts(9)tty_port_lower_dtr_rts(9)tty_port_block_til_ready(9)tty_port_close_start(9)tty_port_close_end(9)tty_port_close(9)tty_port_install(9)tty_port_open(9)
ngl, when that final put lands you better not be holding any other references, because this is the one that actually frees the port π theport->ops->destructhook is your moment to shine, otherwise it's plain oldkfreedoing the honors π
and that's a wrap bestie π§ this page lives in ./drivers/tty, dated October 2026, and it's part of the kernel API manual β slay, go free some ports responsibly ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms