mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
put_tty_driver() is an alias for tty_driver_kref_put(). There is no need for two exported identical functions, therefore switch all users of old put_tty_driver() to new tty_driver_kref_put() and remove the former for good. Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Anton Ivanov <[email protected]> Cc: Chris Zankel <[email protected]> Cc: Max Filippov <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Samuel Iglesias Gonsalvez <[email protected]> Cc: Jens Taprogge <[email protected]> Cc: Karsten Keil <[email protected]> Cc: Scott Branden <[email protected]> Cc: Ulf Hansson <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: David Lin <[email protected]> Cc: Johan Hovold <[email protected]> Cc: Alex Elder <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Laurentiu Tudor <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: David Sterba <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Pengutronix Kernel Team <[email protected]> Cc: Fabio Estevam <[email protected]> Cc: NXP Linux Team <[email protected]> Cc: Oliver Neukum <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Mathias Nyman <[email protected]> Cc: Marcel Holtmann <[email protected]> Cc: Johan Hedberg <[email protected]> Cc: Luiz Augusto von Dentz <[email protected]> Acked-by: Alex Elder <[email protected]> Acked-by: Christian Borntraeger <[email protected]> Acked-by: Max Filippov <[email protected]> Acked-by: David Sterba <[email protected]> Acked-by: Samuel Iglesias Gonsálvez <[email protected]> Signed-off-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
110 lines
2.3 KiB
C
110 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2019 Axis Communications AB
|
|
*
|
|
* Based on ttyprintk.c:
|
|
* Copyright (C) 2010 Samo Pogacnik
|
|
*/
|
|
|
|
#include <linux/console.h>
|
|
#include <linux/module.h>
|
|
#include <linux/tty.h>
|
|
|
|
static const struct tty_port_operations ttynull_port_ops;
|
|
static struct tty_driver *ttynull_driver;
|
|
static struct tty_port ttynull_port;
|
|
|
|
static int ttynull_open(struct tty_struct *tty, struct file *filp)
|
|
{
|
|
return tty_port_open(&ttynull_port, tty, filp);
|
|
}
|
|
|
|
static void ttynull_close(struct tty_struct *tty, struct file *filp)
|
|
{
|
|
tty_port_close(&ttynull_port, tty, filp);
|
|
}
|
|
|
|
static void ttynull_hangup(struct tty_struct *tty)
|
|
{
|
|
tty_port_hangup(&ttynull_port);
|
|
}
|
|
|
|
static int ttynull_write(struct tty_struct *tty, const unsigned char *buf,
|
|
int count)
|
|
{
|
|
return count;
|
|
}
|
|
|
|
static unsigned int ttynull_write_room(struct tty_struct *tty)
|
|
{
|
|
return 65536;
|
|
}
|
|
|
|
static const struct tty_operations ttynull_ops = {
|
|
.open = ttynull_open,
|
|
.close = ttynull_close,
|
|
.hangup = ttynull_hangup,
|
|
.write = ttynull_write,
|
|
.write_room = ttynull_write_room,
|
|
};
|
|
|
|
static struct tty_driver *ttynull_device(struct console *c, int *index)
|
|
{
|
|
*index = 0;
|
|
return ttynull_driver;
|
|
}
|
|
|
|
static struct console ttynull_console = {
|
|
.name = "ttynull",
|
|
.device = ttynull_device,
|
|
};
|
|
|
|
static int __init ttynull_init(void)
|
|
{
|
|
struct tty_driver *driver;
|
|
int ret;
|
|
|
|
driver = tty_alloc_driver(1,
|
|
TTY_DRIVER_RESET_TERMIOS |
|
|
TTY_DRIVER_REAL_RAW |
|
|
TTY_DRIVER_UNNUMBERED_NODE);
|
|
if (IS_ERR(driver))
|
|
return PTR_ERR(driver);
|
|
|
|
tty_port_init(&ttynull_port);
|
|
ttynull_port.ops = &ttynull_port_ops;
|
|
|
|
driver->driver_name = "ttynull";
|
|
driver->name = "ttynull";
|
|
driver->type = TTY_DRIVER_TYPE_CONSOLE;
|
|
driver->init_termios = tty_std_termios;
|
|
driver->init_termios.c_oflag = OPOST | OCRNL | ONOCR | ONLRET;
|
|
tty_set_operations(driver, &ttynull_ops);
|
|
tty_port_link_device(&ttynull_port, driver, 0);
|
|
|
|
ret = tty_register_driver(driver);
|
|
if (ret < 0) {
|
|
tty_driver_kref_put(driver);
|
|
tty_port_destroy(&ttynull_port);
|
|
return ret;
|
|
}
|
|
|
|
ttynull_driver = driver;
|
|
register_console(&ttynull_console);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void __exit ttynull_exit(void)
|
|
{
|
|
unregister_console(&ttynull_console);
|
|
tty_unregister_driver(ttynull_driver);
|
|
tty_driver_kref_put(ttynull_driver);
|
|
tty_port_destroy(&ttynull_port);
|
|
}
|
|
|
|
module_init(ttynull_init);
|
|
module_exit(ttynull_exit);
|
|
|
|
MODULE_LICENSE("GPL v2");
|