public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Introduce tty_unregister_ldisc()
@ 2005-05-31 19:56 Alexey Dobriyan
  2005-05-31 22:28 ` Paul Fulghum
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey Dobriyan @ 2005-05-31 19:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

It's a bit strange to see tty_register_ldisc() call in modules' exit functions.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 Documentation/tty.txt |    2 +-
 drivers/char/tty_io.c |   35 ++++++++++++++++++++++++-----------
 include/linux/tty.h   |    1 +
 3 files changed, 26 insertions(+), 12 deletions(-)

diff -uprN linux-tty_register_ldisc_000/Documentation/tty.txt linux-tty_register_ldisc_001/Documentation/tty.txt
--- linux-tty_register_ldisc_000/Documentation/tty.txt	2005-05-31 20:12:47.000000000 +0400
+++ linux-tty_register_ldisc_001/Documentation/tty.txt	2005-05-31 23:19:32.000000000 +0400
@@ -22,7 +22,7 @@ copy of the structure. You must not re-r
 discipline even with the same data or your computer again will be eaten by
 demons.
 
-In order to remove a line discipline call tty_register_ldisc passing NULL.
+In order to remove a line discipline call tty_unregister_ldisc().
 In ancient times this always worked. In modern times the function will
 return -EBUSY if the ldisc is currently in use. Since the ldisc referencing
 code manages the module counts this should not usually be a concern.
diff -uprN linux-tty_register_ldisc_000/drivers/char/tty_io.c linux-tty_register_ldisc_001/drivers/char/tty_io.c
--- linux-tty_register_ldisc_000/drivers/char/tty_io.c	2005-05-31 20:13:34.000000000 +0400
+++ linux-tty_register_ldisc_001/drivers/char/tty_io.c	2005-05-31 23:17:40.000000000 +0400
@@ -262,17 +262,10 @@ int tty_register_ldisc(int disc, struct 
 		return -EINVAL;
 	
 	spin_lock_irqsave(&tty_ldisc_lock, flags);
-	if (new_ldisc) {
-		tty_ldiscs[disc] = *new_ldisc;
-		tty_ldiscs[disc].num = disc;
-		tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
-		tty_ldiscs[disc].refcount = 0;
-	} else {
-		if(tty_ldiscs[disc].refcount)
-			ret = -EBUSY;
-		else
-			tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
-	}
+	tty_ldiscs[disc] = *new_ldisc;
+	tty_ldiscs[disc].num = disc;
+	tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
+	tty_ldiscs[disc].refcount = 0;
 	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
 	
 	return ret;
@@ -280,6 +273,26 @@ int tty_register_ldisc(int disc, struct 
 
 EXPORT_SYMBOL(tty_register_ldisc);
 
+int tty_unregister_ldisc(int disc)
+{
+	unsigned long flags;
+	int ret = 0;
+
+	if (disc < N_TTY || disc >= NR_LDISCS)
+		return -EINVAL;
+
+	spin_lock_irqsave(&tty_ldisc_lock, flags);
+	if (tty_ldiscs[disc].refcount)
+		ret = -EBUSY;
+	else
+		tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
+	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+
+	return ret;
+}
+
+EXPORT_SYMBOL(tty_unregister_ldisc);
+
 struct tty_ldisc *tty_ldisc_get(int disc)
 {
 	unsigned long flags;
diff -uprN linux-tty_register_ldisc_000/include/linux/tty.h linux-tty_register_ldisc_001/include/linux/tty.h
--- linux-tty_register_ldisc_000/include/linux/tty.h	2005-05-31 20:15:51.000000000 +0400
+++ linux-tty_register_ldisc_001/include/linux/tty.h	2005-05-31 23:18:23.000000000 +0400
@@ -345,6 +345,7 @@ extern int tty_check_change(struct tty_s
 extern void stop_tty(struct tty_struct * tty);
 extern void start_tty(struct tty_struct * tty);
 extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
+extern int tty_unregister_ldisc(int disc);
 extern int tty_register_driver(struct tty_driver *driver);
 extern int tty_unregister_driver(struct tty_driver *driver);
 extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev);

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 1/2] Introduce tty_unregister_ldisc()
@ 2005-06-15 21:40 Alexey Dobriyan
  0 siblings, 0 replies; 8+ messages in thread
From: Alexey Dobriyan @ 2005-06-15 21:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

It's a bit strange to see tty_register_ldisc call in modules' exit functions.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 Documentation/tty.txt |    2 +-
 drivers/char/tty_io.c |   35 ++++++++++++++++++++++++-----------
 include/linux/tty.h   |    1 +
 3 files changed, 26 insertions(+), 12 deletions(-)

diff -uprN linux-tty_register_ldisc_000/Documentation/tty.txt linux-tty_register_ldisc_001/Documentation/tty.txt
--- linux-tty_register_ldisc_000/Documentation/tty.txt	2005-05-31 20:12:47.000000000 +0400
+++ linux-tty_register_ldisc_001/Documentation/tty.txt	2005-05-31 23:19:32.000000000 +0400
@@ -22,7 +22,7 @@ copy of the structure. You must not re-r
 discipline even with the same data or your computer again will be eaten by
 demons.
 
-In order to remove a line discipline call tty_register_ldisc passing NULL.
+In order to remove a line discipline call tty_unregister_ldisc().
 In ancient times this always worked. In modern times the function will
 return -EBUSY if the ldisc is currently in use. Since the ldisc referencing
 code manages the module counts this should not usually be a concern.
diff -uprN linux-tty_register_ldisc_000/drivers/char/tty_io.c linux-tty_register_ldisc_001/drivers/char/tty_io.c
--- linux-tty_register_ldisc_000/drivers/char/tty_io.c	2005-05-31 20:13:34.000000000 +0400
+++ linux-tty_register_ldisc_001/drivers/char/tty_io.c	2005-05-31 23:17:40.000000000 +0400
@@ -262,17 +262,10 @@ int tty_register_ldisc(int disc, struct 
 		return -EINVAL;
 	
 	spin_lock_irqsave(&tty_ldisc_lock, flags);
-	if (new_ldisc) {
-		tty_ldiscs[disc] = *new_ldisc;
-		tty_ldiscs[disc].num = disc;
-		tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
-		tty_ldiscs[disc].refcount = 0;
-	} else {
-		if(tty_ldiscs[disc].refcount)
-			ret = -EBUSY;
-		else
-			tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
-	}
+	tty_ldiscs[disc] = *new_ldisc;
+	tty_ldiscs[disc].num = disc;
+	tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
+	tty_ldiscs[disc].refcount = 0;
 	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
 	
 	return ret;
@@ -280,6 +273,26 @@ int tty_register_ldisc(int disc, struct 
 
 EXPORT_SYMBOL(tty_register_ldisc);
 
+int tty_unregister_ldisc(int disc)
+{
+	unsigned long flags;
+	int ret = 0;
+
+	if (disc < N_TTY || disc >= NR_LDISCS)
+		return -EINVAL;
+
+	spin_lock_irqsave(&tty_ldisc_lock, flags);
+	if (tty_ldiscs[disc].refcount)
+		ret = -EBUSY;
+	else
+		tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
+	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+
+	return ret;
+}
+
+EXPORT_SYMBOL(tty_unregister_ldisc);
+
 struct tty_ldisc *tty_ldisc_get(int disc)
 {
 	unsigned long flags;
diff -uprN linux-tty_register_ldisc_000/include/linux/tty.h linux-tty_register_ldisc_001/include/linux/tty.h
--- linux-tty_register_ldisc_000/include/linux/tty.h	2005-05-31 20:15:51.000000000 +0400
+++ linux-tty_register_ldisc_001/include/linux/tty.h	2005-05-31 23:18:23.000000000 +0400
@@ -345,6 +345,7 @@ extern int tty_check_change(struct tty_s
 extern void stop_tty(struct tty_struct * tty);
 extern void start_tty(struct tty_struct * tty);
 extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
+extern int tty_unregister_ldisc(int disc);
 extern int tty_register_driver(struct tty_driver *driver);
 extern int tty_unregister_driver(struct tty_driver *driver);
 extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-06-15 21:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-31 19:56 [PATCH 1/2] Introduce tty_unregister_ldisc() Alexey Dobriyan
2005-05-31 22:28 ` Paul Fulghum
2005-06-01  3:38   ` Paul Fulghum
2005-06-01 13:51     ` Paul Fulghum
2005-06-01  4:39   ` Greg KH
2005-06-01  5:42   ` Christoph Hellwig
2005-06-01 15:22     ` Alexey Dobriyan
  -- strict thread matches above, loose matches on Subject: below --
2005-06-15 21:40 Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox