linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Cox <alan@linux.intel.com>
To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	arnd@arndb.de
Subject: [PATCH 03/20] riscom8: kill use of lock_kernel
Date: Wed, 05 May 2010 11:01:57 +0100	[thread overview]
Message-ID: <20100505100156.3595.84007.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100505100144.3595.65633.stgit@localhost.localdomain>

The riscom8 board uses lock_kernel to protect bits of the port setting
ioctl logic. We can use the port mutex for this as the logic is internal
and will also lock set versus open (a locking property that has been lost
somewhere along the way)

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/char/riscom8.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)


diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index b02332a..af4de1f 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -47,7 +47,6 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/tty_flip.h>
-#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <linux/device.h>
 
@@ -1184,6 +1183,7 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
 	if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
 		return -EFAULT;
 
+	mutex_lock(&port->port.mutex);
 	change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
 			(tmp.flags & ASYNC_SPD_MASK));
 
@@ -1191,8 +1191,10 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
 		if ((tmp.close_delay != port->port.close_delay) ||
 		    (tmp.closing_wait != port->port.closing_wait) ||
 		    ((tmp.flags & ~ASYNC_USR_MASK) !=
-		     (port->port.flags & ~ASYNC_USR_MASK)))
+		     (port->port.flags & ~ASYNC_USR_MASK))) {
+			mutex_unlock(&port->port.mutex);
 			return -EPERM;
+		}
 		port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
 			       (tmp.flags & ASYNC_USR_MASK));
 	} else  {
@@ -1208,6 +1210,7 @@ static int rc_set_serial_info(struct tty_struct *tty, struct riscom_port *port,
 		rc_change_speed(tty, bp, port);
 		spin_unlock_irqrestore(&riscom_lock, flags);
 	}
+	mutex_unlock(&port->port.mutex);
 	return 0;
 }
 
@@ -1220,12 +1223,15 @@ static int rc_get_serial_info(struct riscom_port *port,
 	memset(&tmp, 0, sizeof(tmp));
 	tmp.type = PORT_CIRRUS;
 	tmp.line = port - rc_port;
+
+	mutex_lock(&port->port.mutex);
 	tmp.port = bp->base;
 	tmp.irq  = bp->irq;
 	tmp.flags = port->port.flags;
 	tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
 	tmp.close_delay = port->port.close_delay * HZ/100;
 	tmp.closing_wait = port->port.closing_wait * HZ/100;
+	mutex_unlock(&port->port.mutex);
 	tmp.xmit_fifo_size = CD180_NFIFO;
 	return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
 }
@@ -1242,14 +1248,10 @@ static int rc_ioctl(struct tty_struct *tty, struct file *filp,
 
 	switch (cmd) {
 	case TIOCGSERIAL:
-		lock_kernel();
 		retval = rc_get_serial_info(port, argp);
-		unlock_kernel();
 		break;
 	case TIOCSSERIAL:
-		lock_kernel();
 		retval = rc_set_serial_info(tty, port, argp);
-		unlock_kernel();
 		break;
 	default:
 		retval = -ENOIOCTLCMD;

  parent reply	other threads:[~2010-05-05 10:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-05 10:01 [PATCH 01/20] stallion: prune lock_kernel calls Alan Cox
2010-05-05 10:01 ` [PATCH 02/20] istallion: use bit ops for the board flags Alan Cox
2010-05-05 10:01 ` Alan Cox [this message]
2010-05-05 10:02 ` [PATCH 04/20] isicom: kill off the BKL Alan Cox
2010-05-05 10:02 ` [PATCH 05/20] rocket: kill BKL Alan Cox
2010-05-05 10:02 ` [PATCH 06/20] synclink: kill the big kernel lock Alan Cox
2010-05-05 10:02 ` [PATCH 07/20] cyclades: Kill off BKL usage Alan Cox
2010-05-05 10:02 ` [PATCH 08/20] epca: Kill the big kernel lock Alan Cox
2010-05-05 10:02 ` [PATCH 09/20] specialix; Kill the BKL Alan Cox
2010-05-05 10:02 ` [PATCH 10/20] synclink: reworking locking a bit Alan Cox
2010-05-05 10:02 ` [PATCH 11/20] tty: serial - fix various misuses/mishandlings of port->tty Alan Cox
2010-05-05 10:02 ` [PATCH 12/20] tty: serial - fix tty back references in termios Alan Cox
2010-05-05 10:02 ` [PATCH 13/20] tty: serial - fix tty referencing in set_ldisc Alan Cox
2010-05-05 10:02 ` [PATCH 14/20] vc: Locking clean up Alan Cox
2010-05-05 10:03 ` [PATCH 15/20] tty: Make vt's have a tty_port Alan Cox
2010-05-05 10:03 ` [PATCH 16/20] tty: Move the vt_tty field from the vc_data into the standard tty_port Alan Cox
2010-05-05 10:03 ` [PATCH 17/20] serial: Change the wait for carrier locking Alan Cox
2010-05-05 10:03 ` [PATCH 18/20] serial: add port helpers Alan Cox
2010-05-05 10:03 ` [PATCH 19/20] serial: trim locking on the helpers Alan Cox
2010-05-05 10:03 ` [PATCH 20/20] serial: Use block_til_ready helper Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100505100156.3595.84007.stgit@localhost.localdomain \
    --to=alan@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).