From 80fb91b164f3fdc7b2c54198d5fa7757b084c466 Mon Sep 17 00:00:00 2001 From: W_Y_CPP <383152993@qq.com> Date: Wed, 9 Mar 2022 01:45:44 -0500 Subject: [PATCH] add tty driver missing function --- drivers/tty/tty_io.c | 13 +++++++++++++ include/linux/tty_driver.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 6616d4a0d..79c6cc39e 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3438,6 +3438,12 @@ void tty_driver_kref_put(struct tty_driver *driver) } EXPORT_SYMBOL(tty_driver_kref_put); +void put_tty_driver(struct tty_driver *d) +{ + tty_driver_kref_put(d); +} +EXPORT_SYMBOL(put_tty_driver); + /* * Called by a tty driver to register itself. */ diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index c20431d8d..cc404cfdc 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -329,6 +329,7 @@ extern struct list_head tty_drivers; extern struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner, unsigned long flags); +extern void put_tty_driver(struct tty_driver *driver); extern struct tty_driver *tty_find_polling_driver(char *name, int *line); extern void tty_driver_kref_put(struct tty_driver *driver); @@ -337,6 +340,18 @@ extern void tty_driver_kref_put(struct tty_driver *driver); #define tty_alloc_driver(lines, flags) \ __tty_alloc_driver(lines, THIS_MODULE, flags) +/* + * DEPRECATED Do not use this in new code, use tty_alloc_driver instead. + * (And change the return value checks.) + */ +static inline struct tty_driver *alloc_tty_driver(unsigned int lines) +{ + struct tty_driver *ret = tty_alloc_driver(lines, 0); + if (IS_ERR(ret)) + return NULL; + return ret; +} + static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) { kref_get(&d->kref); -- 2.17.1