diff options
author | Jiri Slaby <jslaby@suse.cz> | 2021-05-05 12:19:09 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-05-13 17:57:16 +0300 |
commit | f81ee8b8b8421dc06d13f197bb53191559cc51da (patch) | |
tree | 1034c668915cd8a499a186e25197783ff5f9b983 /drivers/tty | |
parent | 839e0f226d1c1d216ac3841b4710810080392c16 (diff) | |
download | linux-f81ee8b8b8421dc06d13f197bb53191559cc51da.tar.xz |
tty: make tty_ldisc_ops a param in tty_unregister_ldisc
Make tty_unregister_ldisc symmetric to tty_register_ldisc by accepting
struct tty_ldisc_ops as a parameter instead of ldisc number. This avoids
checking of the ldisc number bounds in tty_unregister_ldisc.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Rodolfo Giometti <giometti@enneenne.com>
Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Link: https://lore.kernel.org/r/20210505091928.22010-17-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/n_gsm.c | 4 | ||||
-rw-r--r-- | drivers/tty/n_hdlc.c | 3 | ||||
-rw-r--r-- | drivers/tty/n_null.c | 2 | ||||
-rw-r--r-- | drivers/tty/tty_ldisc.c | 9 |
4 files changed, 7 insertions, 11 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index cce2ef04caeb..db7d4a30af91 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3280,13 +3280,13 @@ static int __init gsm_init(void) err_put_driver: put_tty_driver(gsm_tty_driver); err_unreg_ldisc: - tty_unregister_ldisc(N_GSM0710); + tty_unregister_ldisc(&tty_ldisc_packet); return status; } static void __exit gsm_exit(void) { - int status = tty_unregister_ldisc(N_GSM0710); + int status = tty_unregister_ldisc(&tty_ldisc_packet); if (status != 0) pr_err("n_gsm: can't unregister line discipline (err = %d)\n", status); diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c index 2256039911f5..c2afbfe0a1d5 100644 --- a/drivers/tty/n_hdlc.c +++ b/drivers/tty/n_hdlc.c @@ -822,8 +822,7 @@ static int __init n_hdlc_init(void) static void __exit n_hdlc_exit(void) { - /* Release tty registration of line discipline */ - int status = tty_unregister_ldisc(N_HDLC); + int status = tty_unregister_ldisc(&n_hdlc_ldisc); if (status) pr_err("N_HDLC: can't unregister line discipline (err = %d)\n", diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c index ee229c812dce..f913b665af72 100644 --- a/drivers/tty/n_null.c +++ b/drivers/tty/n_null.c @@ -57,7 +57,7 @@ static int __init n_null_init(void) static void __exit n_null_exit(void) { - tty_unregister_ldisc(N_NULL); + tty_unregister_ldisc(&null_ldisc); } module_init(n_null_init); diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index 9aff04bee4cd..d02deeb5e584 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -87,19 +87,16 @@ EXPORT_SYMBOL(tty_register_ldisc); * takes tty_ldiscs_lock to guard against ldisc races */ -int tty_unregister_ldisc(int disc) +int tty_unregister_ldisc(struct tty_ldisc_ops *ldisc) { unsigned long flags; int ret = 0; - if (disc < N_TTY || disc >= NR_LDISCS) - return -EINVAL; - raw_spin_lock_irqsave(&tty_ldiscs_lock, flags); - if (tty_ldiscs[disc]->refcount) + if (tty_ldiscs[ldisc->num]->refcount) ret = -EBUSY; else - tty_ldiscs[disc] = NULL; + tty_ldiscs[ldisc->num] = NULL; raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags); return ret; |