From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 13 Sep 2002 05:00:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 13 Sep 2002 05:00:38 -0400 Received: from twilight.ucw.cz ([195.39.74.230]:60048 "EHLO twilight.ucw.cz") by vger.kernel.org with ESMTP id ; Fri, 13 Sep 2002 05:00:36 -0400 Date: Fri, 13 Sep 2002 11:04:53 +0200 From: Vojtech Pavlik To: vojtech@suse.cz Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org Subject: Minor input fixes [1/7] Message-ID: <20020913110453.A28145@ucw.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hi! 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.568.2.2, 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 Thu Sep 12 23:37:14 2002 +++ b/drivers/char/tty_io.c Thu Sep 12 23:37:14 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 Thu Sep 12 23:37:14 2002 +++ b/drivers/input/serio/serport.c Thu Sep 12 23:37:14 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 , 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 @@ -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: 1.568.2.2 ## Wrapped with gzip_uu ## begin 664 bkpatch25155 M'XL(``H)@3T``\U7;8_:1A#^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