linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 2.5.31-serport
@ 2002-08-30 21:39 Russell King
  2002-08-30 22:03 ` David S. Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Russell King @ 2002-08-30 21:39 UTC (permalink / raw)
  To: Vojtech Pavlik, James Simmons; +Cc: LKML

This patch appears not to be in 2.5.32, but applies cleanly.

serport/serio presently has several problems.  This is by no means a
definitive list (for example, the locking problems that hch reported
back in 2.4.0-test time):

1. Insomnia.  When someone closes the serport device, it wakes up a
   thread in serport_ldisc_read().  Unfortunately, if serport->serio.type
   is non-zero and we haven't received a signal, we re-call schedule()
   without changing current->state.  So schedule returns, and repeat
   for ever.
 
   A better sleep solution would be:
   
        wait_event_interruptible((&serport->wait, serport->serio.type); 

   which contains all the knoweldge of handling sleeping.

   Someone might also think about what serport_serio_close() is actually
   trying to do.  If its intended to cause the thread in ldisc_read exit,
   it should set serport->serio.type to 0.

2. What happens if I open and try to read from this port while something
   has the serport_ldisc attached?  I suspect that you'll create nice
   loop of serio devices in serio.c and an infinite loop when you try to
   traverse the list to remove a different serio device.
   
3. Naming:

#ifdef CONFIG_DEVFS_FS
        sprintf(name, tty->driver.name, minor(tty->device) - tty->driver.minor_start);
#else
        sprintf(name, "%s%d", tty->driver.name, minor(tty->device) - tty->driver.minor_start);
#endif
   
   should probably be using tty_name(), rather than trying to construct
   the name itself.

4. Stack overflows.  There seems to be confusion about how long a tty name
   can be, and we seem to add characters to the name ("/serio0") and then
   squash it into a smaller buffer.

        char ttyname[64];
...     
        strcpy(ttyname, tty->driver.name);
...     
        sprintf(serport->phys, "%s%d/serio0", ttyname, minor(tty->device) - tty$   
   However, serport->phys is declared as:

struct serport {
        char phys[32];
};
   
   I'd suggest using strncpy() and snprintf() here, and adjusting the size of
   those strings so they're sensible.

This patch fixes (1) and (3) completey.  (4) needs the sizes reviewed and fixed.
(2) is NOT fixed by this patch.

 drivers/input/serio/serio.c   |    8 ++++++++
 drivers/input/serio/serport.c |   26 ++++++++------------------
 2 files changed, 16 insertions, 18 deletions

diff -ur orig/drivers/input/serio/serio.c linux/drivers/input/serio/serio.c
--- orig/drivers/input/serio/serio.c	Fri Aug  2 21:13:28 2002
+++ linux/drivers/input/serio/serio.c	Sun Aug 11 16:15:00 2002
@@ -122,6 +122,8 @@
 
 void serio_register_port(struct serio *serio)
 {
+	BUG_ON(serio->next);
+
 	serio->next = serio_list;	
 	serio_list = serio;
 	serio_find_dev(serio);
@@ -134,6 +136,8 @@
         while (*serioptr && (*serioptr != serio)) serioptr = &((*serioptr)->next);
         *serioptr = (*serioptr)->next;
 
+	serio->next = NULL;
+
 	if (serio->dev && serio->dev->disconnect)
 		serio->dev->disconnect(serio);
 }
@@ -142,6 +146,8 @@
 {
 	struct serio *serio = serio_list;
 
+	BUG_ON(dev->next);
+
 	dev->next = serio_dev;	
 	serio_dev = dev;
 
@@ -159,6 +165,8 @@
 
         while (*devptr && (*devptr != dev)) devptr = &((*devptr)->next);
         *devptr = (*devptr)->next;
+
+	dev->next = NULL;
 
 	while (serio) {
 		if (serio->dev == dev && dev->disconnect)
diff -ur orig/drivers/input/serio/serport.c linux/drivers/input/serio/serport.c
--- orig/drivers/input/serio/serport.c	Sat Jul 27 13:55:18 2002
+++ linux/drivers/input/serio/serport.c	Sun Aug 11 16:33:59 2002
@@ -96,11 +96,14 @@
 	serport->tty = tty;
 	tty->disc_data = serport;
 
-	strcpy(ttyname, tty->driver.name);
-	for (i = 0; ttyname[i] != 0 && ttyname[i] != '/'; i++);
+	strncpy(ttyname, tty->driver.name, sizeof(ttyname) - 1);
+
+	for (i = 0; ttyname[i] != 0 && ttyname[i] != '/' &&
+		    i < sizeof(ttyname) - 1; i++);
 	ttyname[i] = 0;
 
-	sprintf(serport->phys, "%s%d/serio0", ttyname, minor(tty->device) - tty->driver.minor_start);
+	snprintf(serport->phys, sizeof(serport->phys), "%s%d/serio0",
+		ttyname, minor(tty->device) - tty->driver.minor_start);
 
 	serport->serio.name = serport_name;
 	serport->serio.phys = serport->phys;
@@ -161,26 +164,13 @@
 static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char * buf, size_t nr)
 {
 	struct serport *serport = (struct serport*) tty->disc_data;
-	DECLARE_WAITQUEUE(wait, current);
 	char name[32];
 
-#ifdef CONFIG_DEVFS_FS
-	sprintf(name, tty->driver.name, minor(tty->device) - tty->driver.minor_start);
-#else
-	sprintf(name, "%s%d", tty->driver.name, minor(tty->device) - tty->driver.minor_start);
-#endif
-
 	serio_register_port(&serport->serio);
 
-	printk(KERN_INFO "serio: Serial port %s\n", name);
-
-	add_wait_queue(&serport->wait, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
-
-	while(serport->serio.type && !signal_pending(current)) schedule();
+	printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
 
-	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&serport->wait, &wait);
+	wait_event_interruptible(serport->wait, serport->serio.type != 0);
 
 	serio_unregister_port(&serport->serio);
 

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

* Re: [PATCH] 2.5.31-serport
  2002-08-30 21:39 [PATCH] 2.5.31-serport Russell King
@ 2002-08-30 22:03 ` David S. Miller
  2002-08-30 22:36   ` Vojtech Pavlik
  2002-08-30 22:40 ` Vojtech Pavlik
  2002-08-31 14:16 ` [patch] Fixes in serport.c Vojtech Pavlik
  2 siblings, 1 reply; 7+ messages in thread
From: David S. Miller @ 2002-08-30 22:03 UTC (permalink / raw)
  To: rmk; +Cc: vojtech, jsimmons, linux-kernel

   From: Russell King <rmk@arm.linux.org.uk>
   Date: Fri, 30 Aug 2002 22:39:11 +0100

   2. What happens if I open and try to read from this port while something
      has the serport_ldisc attached?  I suspect that you'll create nice
      loop of serio devices in serio.c and an infinite loop when you try to
      traverse the list to remove a different serio device.
      
SERIO devices are not meant to be registered as normal TTYs.
At least I don't do this for any of the Sparc serial ports
when they are the keyboard/mouse serio device.

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

* Re: [PATCH] 2.5.31-serport
  2002-08-30 22:03 ` David S. Miller
@ 2002-08-30 22:36   ` Vojtech Pavlik
  2002-08-30 22:43     ` David S. Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Vojtech Pavlik @ 2002-08-30 22:36 UTC (permalink / raw)
  To: David S. Miller; +Cc: rmk, jsimmons, linux-kernel

On Fri, Aug 30, 2002 at 03:03:59PM -0700, David S. Miller wrote:
>    From: Russell King <rmk@arm.linux.org.uk>
>    Date: Fri, 30 Aug 2002 22:39:11 +0100
> 
>    2. What happens if I open and try to read from this port while something
>       has the serport_ldisc attached?  I suspect that you'll create nice
>       loop of serio devices in serio.c and an infinite loop when you try to
>       traverse the list to remove a different serio device.
>       
> SERIO devices are not meant to be registered as normal TTYs.
> At least I don't do this for any of the Sparc serial ports
> when they are the keyboard/mouse serio device.

No, but using serport.c, you can bind a serio to a tty via a line
discipline, for example if you want a PC serial mouse on /dev/ttyS0 to
talk to sermouse.c via serio. I don't like the approach much, I hope(d) we
could switch somewhere below the tty layer, but it sort of works, and
maybe will have the bugs fixed sooner or later.

-- 
Vojtech Pavlik
SuSE Labs

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

* Re: [PATCH] 2.5.31-serport
  2002-08-30 21:39 [PATCH] 2.5.31-serport Russell King
  2002-08-30 22:03 ` David S. Miller
@ 2002-08-30 22:40 ` Vojtech Pavlik
  2002-08-31 14:16 ` [patch] Fixes in serport.c Vojtech Pavlik
  2 siblings, 0 replies; 7+ messages in thread
From: Vojtech Pavlik @ 2002-08-30 22:40 UTC (permalink / raw)
  To: Russell King; +Cc: James Simmons, LKML

On Fri, Aug 30, 2002 at 10:39:11PM +0100, Russell King wrote:
> This patch appears not to be in 2.5.32, but applies cleanly.
> 
> serport/serio presently has several problems.  This is by no means a
> definitive list (for example, the locking problems that hch reported
> back in 2.4.0-test time):
> 
> 1. Insomnia.  When someone closes the serport device, it wakes up a
>    thread in serport_ldisc_read().  Unfortunately, if serport->serio.type
>    is non-zero and we haven't received a signal, we re-call schedule()
>    without changing current->state.  So schedule returns, and repeat
>    for ever.
>  
>    A better sleep solution would be:
>    
>         wait_event_interruptible((&serport->wait, serport->serio.type); 
> 
>    which contains all the knoweldge of handling sleeping.
> 
>    Someone might also think about what serport_serio_close() is actually
>    trying to do.  If its intended to cause the thread in ldisc_read exit,
>    it should set serport->serio.type to 0.

I'll answer to this as soon as I get some sleep. No pun originally
intended.

> 2. What happens if I open and try to read from this port while something
>    has the serport_ldisc attached?  I suspect that you'll create nice
>    loop of serio devices in serio.c and an infinite loop when you try to
>    traverse the list to remove a different serio device.

Just to make sure - the scenario would be: inputattach opening
/dev/ttyS0, setting N_MOUSE ldisc. Mouse driver opening that serio, etc,
etc. Then I run minicom on /dev/ttyS0?

> 3. Naming:
> 
> #ifdef CONFIG_DEVFS_FS
>         sprintf(name, tty->driver.name, minor(tty->device) - tty->driver.minor_start);
> #else
>         sprintf(name, "%s%d", tty->driver.name, minor(tty->device) - tty->driver.minor_start);
> #endif
>    
>    should probably be using tty_name(), rather than trying to construct
>    the name itself.

Definitely. Not sure if that existed at the time this was written.
Probably yes, though.

> 4. Stack overflows.  There seems to be confusion about how long a tty name
>    can be, and we seem to add characters to the name ("/serio0") and then
>    squash it into a smaller buffer.
> 
>         char ttyname[64];
> ...     
>         strcpy(ttyname, tty->driver.name);
> ...     
>         sprintf(serport->phys, "%s%d/serio0", ttyname, minor(tty->device) - tty$   
>    However, serport->phys is declared as:
> 
> struct serport {
>         char phys[32];
> };
>    
>    I'd suggest using strncpy() and snprintf() here, and adjusting the size of
>    those strings so they're sensible.

Indeed.

> This patch fixes (1) and (3) completey.  (4) needs the sizes reviewed and fixed.
> (2) is NOT fixed by this patch.
> 
>  drivers/input/serio/serio.c   |    8 ++++++++
>  drivers/input/serio/serport.c |   26 ++++++++------------------
>  2 files changed, 16 insertions, 18 deletions
> 
> diff -ur orig/drivers/input/serio/serio.c linux/drivers/input/serio/serio.c
> --- orig/drivers/input/serio/serio.c	Fri Aug  2 21:13:28 2002
> +++ linux/drivers/input/serio/serio.c	Sun Aug 11 16:15:00 2002
> @@ -122,6 +122,8 @@
>  
>  void serio_register_port(struct serio *serio)
>  {
> +	BUG_ON(serio->next);
> +
>  	serio->next = serio_list;	
>  	serio_list = serio;
>  	serio_find_dev(serio);
> @@ -134,6 +136,8 @@
>          while (*serioptr && (*serioptr != serio)) serioptr = &((*serioptr)->next);
>          *serioptr = (*serioptr)->next;
>  
> +	serio->next = NULL;
> +
>  	if (serio->dev && serio->dev->disconnect)
>  		serio->dev->disconnect(serio);
>  }
> @@ -142,6 +146,8 @@
>  {
>  	struct serio *serio = serio_list;
>  
> +	BUG_ON(dev->next);
> +
>  	dev->next = serio_dev;	
>  	serio_dev = dev;
>  
> @@ -159,6 +165,8 @@
>  
>          while (*devptr && (*devptr != dev)) devptr = &((*devptr)->next);
>          *devptr = (*devptr)->next;
> +
> +	dev->next = NULL;
>  
>  	while (serio) {
>  		if (serio->dev == dev && dev->disconnect)

This should better be fixed by switching to <linux/list.h> for the
linked lists.

> diff -ur orig/drivers/input/serio/serport.c linux/drivers/input/serio/serport.c
> --- orig/drivers/input/serio/serport.c	Sat Jul 27 13:55:18 2002
> +++ linux/drivers/input/serio/serport.c	Sun Aug 11 16:33:59 2002
> @@ -96,11 +96,14 @@
>  	serport->tty = tty;
>  	tty->disc_data = serport;
>  
> -	strcpy(ttyname, tty->driver.name);
> -	for (i = 0; ttyname[i] != 0 && ttyname[i] != '/'; i++);
> +	strncpy(ttyname, tty->driver.name, sizeof(ttyname) - 1);
> +
> +	for (i = 0; ttyname[i] != 0 && ttyname[i] != '/' &&
> +		    i < sizeof(ttyname) - 1; i++);
>  	ttyname[i] = 0;
>  
> -	sprintf(serport->phys, "%s%d/serio0", ttyname, minor(tty->device) - tty->driver.minor_start);
> +	snprintf(serport->phys, sizeof(serport->phys), "%s%d/serio0",
> +		ttyname, minor(tty->device) - tty->driver.minor_start);
>  
>  	serport->serio.name = serport_name;
>  	serport->serio.phys = serport->phys;
> @@ -161,26 +164,13 @@
>  static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char * buf, size_t nr)
>  {
>  	struct serport *serport = (struct serport*) tty->disc_data;
> -	DECLARE_WAITQUEUE(wait, current);
>  	char name[32];
>  
> -#ifdef CONFIG_DEVFS_FS
> -	sprintf(name, tty->driver.name, minor(tty->device) - tty->driver.minor_start);
> -#else
> -	sprintf(name, "%s%d", tty->driver.name, minor(tty->device) - tty->driver.minor_start);
> -#endif
> -
>  	serio_register_port(&serport->serio);
>  
> -	printk(KERN_INFO "serio: Serial port %s\n", name);
> -
> -	add_wait_queue(&serport->wait, &wait);
> -	set_current_state(TASK_INTERRUPTIBLE);
> -
> -	while(serport->serio.type && !signal_pending(current)) schedule();
> +	printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
>  
> -	set_current_state(TASK_RUNNING);
> -	remove_wait_queue(&serport->wait, &wait);
> +	wait_event_interruptible(serport->wait, serport->serio.type != 0);
>  
>  	serio_unregister_port(&serport->serio);
>  

-- 
Vojtech Pavlik
SuSE Labs

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

* Re: [PATCH] 2.5.31-serport
  2002-08-30 22:36   ` Vojtech Pavlik
@ 2002-08-30 22:43     ` David S. Miller
  2002-08-31  0:34       ` Alan Cox
  0 siblings, 1 reply; 7+ messages in thread
From: David S. Miller @ 2002-08-30 22:43 UTC (permalink / raw)
  To: vojtech; +Cc: rmk, jsimmons, linux-kernel

   From: Vojtech Pavlik <vojtech@suse.cz>
   Date: Sat, 31 Aug 2002 00:36:18 +0200
   
   No, but using serport.c, you can bind a serio to a tty via a line
   discipline, for example if you want a PC serial mouse on /dev/ttyS0 to
   talk to sermouse.c via serio. I don't like the approach much, I hope(d) we
   could switch somewhere below the tty layer, but it sort of works, and
   maybe will have the bugs fixed sooner or later.

So how about this:

1) When SERIO device is claimed, we fail of TTY copy is opened
   by any user.

2) Once we allow SERIO device to be claimed, we prevent opens
   of TTY copy.

I guess this is sort of what Russell is recommending.

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

* Re: [PATCH] 2.5.31-serport
  2002-08-30 22:43     ` David S. Miller
@ 2002-08-31  0:34       ` Alan Cox
  0 siblings, 0 replies; 7+ messages in thread
From: Alan Cox @ 2002-08-31  0:34 UTC (permalink / raw)
  To: David S. Miller; +Cc: vojtech, rmk, jsimmons, linux-kernel

On Fri, 2002-08-30 at 23:43, David S. Miller wrote:
> 1) When SERIO device is claimed, we fail of TTY copy is opened
>    by any user.
> 
> 2) Once we allow SERIO device to be claimed, we prevent opens
>    of TTY copy.

Should it not be a line discipline question ?


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

* [patch] Fixes in serport.c
  2002-08-30 21:39 [PATCH] 2.5.31-serport Russell King
  2002-08-30 22:03 ` David S. Miller
  2002-08-30 22:40 ` Vojtech Pavlik
@ 2002-08-31 14:16 ` Vojtech Pavlik
  2 siblings, 0 replies; 7+ messages in thread
From: Vojtech Pavlik @ 2002-08-31 14:16 UTC (permalink / raw)
  To: Russell King, torvalds; +Cc: James Simmons, LKML

On Fri, Aug 30, 2002 at 10:39:11PM +0100, Russell King wrote:

> This patch appears not to be in 2.5.32, but applies cleanly.
> 
> serport/serio presently has several problems.  This is by no means a
> definitive list (for example, the locking problems that hch reported
> back in 2.4.0-test time):

This patch should fix all four of them:

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.
'bk pull bk://linux-input.bkbits.net/linux-input' should work as well.

===================================================================

ChangeSet@1.570, 2002-08-31 16:15:03+02:00, vojtech@suse.cz
  This fixes problems in serport.c found by Russell King:
      	1) Problem with current->state in serport_ldisc_read.
      	   Solved by using wait_event_interruptible()
      	2) Problem when serport_ldisc_read() is entered twice.
      	   Solved using set_bit et al.
      	3) Complex naming of the serio ports.
      	   Using tty_name() instead.
      	4) Possible stack overflows in name generations.
      	   Using tty_name() instead. 


 char/tty_io.c         |    2 +
 input/serio/serport.c |   77 ++++++++++++++------------------------------------
 2 files changed, 25 insertions(+), 54 deletions(-)

===================================================================

diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
--- a/drivers/char/tty_io.c	Sat Aug 31 16:15:18 2002
+++ b/drivers/char/tty_io.c	Sat Aug 31 16:15:18 2002
@@ -204,6 +204,8 @@
 	return _tty_make_name(tty, (tty)?tty->driver.name:NULL, buf);
 }
 
+EXPORT_SYMBOL(tty_name);
+
 inline int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
 			      const char *routine)
 {
diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c	Sat Aug 31 16:15:18 2002
+++ b/drivers/input/serio/serport.c	Sat Aug 31 16:15:18 2002
@@ -1,32 +1,16 @@
 /*
- * $Id: serport_old.c,v 1.10 2002/01/24 19:52:57 vojtech Exp $
+ * Input device TTY line discipline
+ *
+ * Copyright (c) 1999-2002 Vojtech Pavlik
  *
- *  Copyright (c) 1999-2001 Vojtech Pavlik
- */
-
-/*
  * This is a module that converts a tty line into a much simpler
  * 'serial io port' abstraction that the input device drivers use.
  */
 
 /*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or 
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * 
- *  Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
  */
 
 #include <asm/uaccess.h>
@@ -41,10 +25,13 @@
 MODULE_DESCRIPTION("Input device TTY line discipline");
 MODULE_LICENSE("GPL");
 
+#define SERPORT_BUSY	1
+
 struct serport {
 	struct tty_struct *tty;
 	wait_queue_head_t wait;
 	struct serio serio;
+	unsigned long flags;
 	char phys[32];
 };
 
@@ -68,20 +55,20 @@
 static void serport_serio_close(struct serio *serio)
 {
 	struct serport *serport = serio->driver;
+
+	serport->serio.type = 0;
 	wake_up_interruptible(&serport->wait);
 }
 
 /*
  * serport_ldisc_open() is the routine that is called upon setting our line
- * discipline on a tty. It looks for the Mag, and if found, registers
- * it as a joystick device.
+ * discipline on a tty. It prepares the serio struct.
  */
 
 static int serport_ldisc_open(struct tty_struct *tty)
 {
 	struct serport *serport;
-	char ttyname[64];
-	int i;
+	char name[64];
 
 	MOD_INC_USE_COUNT;
 
@@ -96,11 +83,7 @@
 	serport->tty = tty;
 	tty->disc_data = serport;
 
-	strcpy(ttyname, tty->driver.name);
-	for (i = 0; ttyname[i] != 0 && ttyname[i] != '/'; i++);
-	ttyname[i] = 0;
-
-	sprintf(serport->phys, "%s%d/serio0", ttyname, minor(tty->device) - tty->driver.minor_start);
+	snprintf(serport->phys, sizeof(serport->phys), "%s/serio0", tty_name(tty, name));
 
 	serport->serio.name = serport_name;
 	serport->serio.phys = serport->phys;
@@ -161,29 +144,18 @@
 static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char * buf, size_t nr)
 {
 	struct serport *serport = (struct serport*) tty->disc_data;
-	DECLARE_WAITQUEUE(wait, current);
-	char name[32];
+	char name[64];
 
-#ifdef CONFIG_DEVFS_FS
-	sprintf(name, tty->driver.name, minor(tty->device) - tty->driver.minor_start);
-#else
-	sprintf(name, "%s%d", tty->driver.name, minor(tty->device) - tty->driver.minor_start);
-#endif
+	if (test_and_set_bit(SERPORT_BUSY, &serport->flags))
+		return -EBUSY;
 
 	serio_register_port(&serport->serio);
-
-	printk(KERN_INFO "serio: Serial port %s\n", name);
-
-	add_wait_queue(&serport->wait, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
-
-	while(serport->serio.type && !signal_pending(current)) schedule();
-
-	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&serport->wait, &wait);
-
+	printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
+	wait_event_interruptible(serport->wait, !serport->serio.type);
 	serio_unregister_port(&serport->serio);
 
+	clear_bit(SERPORT_BUSY, &serport->flags);
+
 	return 0;
 }
 
@@ -195,10 +167,8 @@
 {
 	struct serport *serport = (struct serport*) tty->disc_data;
 	
-	switch (cmd) {
-		case SPIOCSTYPE:
-			return get_user(serport->serio.type, (unsigned long *) arg);
-	}
+	if (cmd == SPIOCSTYPE)
+		return get_user(serport->serio.type, (unsigned long *) arg);
 
 	return -EINVAL;
 }
@@ -208,7 +178,6 @@
 	struct serport *sp = (struct serport *) tty->disc_data;
 
 	serio_dev_write_wakeup(&sp->serio);
-
 }
 
 /*

===================================================================

This BitKeeper patch contains the following changesets:
+
## Wrapped with gzip_uu ##


begin 664 bkpatch64481
M'XL(`';/<#T``\U7^X_:1A#^V?M73!.E@H2'UT_,Z:HT!TE1TAR"NZJGID+&
MK+&#\:+=-82(/[ZSAN.XZ[V52N6AP_;LS#<SWWR[]Q+.)1-M8\F_*A8EY"7\
MQJ5J&[*0K!%]Q^L!YWC=3/B<-7=6S?&LF>:+0A%\W@]5E,"2"=DV:,/>WU'K
M!6L;@^Z'\T^_#@@Y/H:3),RG;,@4'!\3Q<4RS";R;:B2C.<-)<)<SID*&Q&?
M;_:F&\LT+7R[U+=-U]M0SW3\340GE(8.91/3<EJ>0Z:"3=_.!`^3VY:W;&JZ
MMFWZ&]>AMDDZ0!NN;X)I-<U6TZ9`O39UVZ;]QK3:I@F[--_NB@!O+*B;Y!W\
M6,PG)(*S))40I]^8A(7@XXS-):0Y8$L67*A&!#$O\@F,US`HI&19!A_3?-K&
ME?IET"KTM\M@E:H$HD((EJOZ+U*%BAUX&F635$8CP<))XW(Q?H<\6[+2?2'1
M+ZS"5(W8$EV,TEPQ(8J%2M%]I7JYR#J(F+#;_%>J@#DQO1Q=JU4:L5M";N-)
MID;C5`%2(LSV5G853OA\D;%OD(=S;<=C4`G3P5(..IX\='E>^E)J/4)SIN/G
M4AUFZB!H+J7.!+`RT0PX\C7.^*JLMEX%4Y8S$:J4YX_S#>0CN+;C!*1_16Q2
M?^*+$#,TR2\/,&LB4CU?S2@)15-C27DC.F"98YK.QFVU/&_#&$6NCZ,@CN(P
M&,<WN7R?+QP3ZE#7-#>6Y=+@:;"^\K54:31K[KE[':"[P1%TK`V-[(GGA5'+
M'<<3FWEW`BP%IEFV_*;/*Z">37V_%)=[ESTL.#\D%W*9"[(^2Z>):A31ZI$Y
M^99CV8Y/Z<;R`C\H-2KXET*9=RJ4#777^9]IU+/UZ<G:]'Q=>EB3'JU'#VG1
M<W3H00W:3L`IU,6J_*"F].\?AF>(5,<"2GH6V`1>0T\[A0E;8@7A[.P"LC1G
MH.N<+O1/M-%F)WRQ%GH(H!)5@09!4-><@S^VU,53PC)+9Z3C@$,ZU`;J8X1@
M&Z*D'))M*L*Y[EHL&%:,QVH5"G8$:UY`%.:`C4RE$NFXT&3"?N63)A<PYY,T
M7N,-[0JIR439+6P\,G?7N@^?S^%#6>H,^L4X2R/XA/GDDI5'&2P_6!`B"/U,
M)B41M3N]]KU&,]RA@?>:_67#&J3GV&"1EQ,6ZY(,NX/^Z>!L].Y\>&%0\@4?
M^UA'H\AE.LW1)<[G%.(LG,HCTL/SB(4VQJY/.".Z;0U]C()C,(](Q_?0HN=K
M'XCDJN"`8$/-CP;T%):-+1"7/&`HUJB(5(-T6AI>K^5H%%KI2LK]Y3E_H_<@
M`)?TJ&GKAS)?")RRN+)'LTC6L@8R_<[XC;O5&KQX);<L,U_4KHB*/VIEA&H5
M_5//T<&IY]X6G7I^&=ZG:&2D,504DVJ$'1WM!K)R6,X:_+S'4!:P6B6&(9@J
M1`[UKC;13GW,%(E+6SJT4:8TJWSL#CZ/>I_?G\*+$G,;AO@'>:#=P2OY);\S
M">-.$=JCT18U^.F6+N)Z1*)[:$09"\4CDCI"0G1HT,(1Z5GFOC31?(([&@S[
MO=.3X=E%OWN0_!2KA9N"J-R"H`:5Z]Q[78503'5W+(I[S+6-]-H!X8D;Z-/.
M*#=/[_>XPLW*HK;K>'CI.'ZY2]K^$[;)_^H@W_U6LN>2-C@I'`<P5%J,B@RG
M4>L5HD!5:J!J;P]8=ZCVM;R?H=9(%<VR[I\ELX87O[\[_52Y1%9R:O]/6I2P
5:":+^;$3L-CQ&"/_`/9DR!D1#@``
`
end

-- 
Vojtech Pavlik
SuSE Labs

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

end of thread, other threads:[~2002-08-31 14:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-30 21:39 [PATCH] 2.5.31-serport Russell King
2002-08-30 22:03 ` David S. Miller
2002-08-30 22:36   ` Vojtech Pavlik
2002-08-30 22:43     ` David S. Miller
2002-08-31  0:34       ` Alan Cox
2002-08-30 22:40 ` Vojtech Pavlik
2002-08-31 14:16 ` [patch] Fixes in serport.c Vojtech Pavlik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).