public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Walker <dwalker@mvista.com>
To: akpm@linux-foundation.org
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org, linux@bohmer.net,
	jonathan@jonmasters.org, matthias.kaehlcke@gmail.com
Subject: [PATCH 3/3] printer port driver: semaphore to mutex
Date: Wed, 05 Dec 2007 00:00:03 -0800	[thread overview]
Message-ID: <20071206021909.131993721@mvista.com> (raw)
In-Reply-To: 20071206021857.826386004@mvista.com

[-- Attachment #1: lp-semaphore-to-mutex.patch --]
[-- Type: text/plain, Size: 2401 bytes --]

The port_mutex is actually a semaphore, so easily converted to
a struct mutex.

Signed-off-by: Daniel Walker <dwalker@mvista.com>

---
 drivers/char/lp.c  |   11 ++++++-----
 include/linux/lp.h |    2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

Index: linux-2.6.23/drivers/char/lp.c
===================================================================
--- linux-2.6.23.orig/drivers/char/lp.c
+++ linux-2.6.23/drivers/char/lp.c
@@ -126,6 +126,7 @@
 #include <linux/device.h>
 #include <linux/wait.h>
 #include <linux/jiffies.h>
+#include <linux/mutex.h>
 
 #include <linux/parport.h>
 #undef LP_STATS
@@ -312,7 +313,7 @@ static ssize_t lp_write(struct file * fi
 	if (copy_size > LP_BUFFER_SIZE)
 		copy_size = LP_BUFFER_SIZE;
 
-	if (down_interruptible (&lp_table[minor].port_mutex))
+	if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
 		return -EINTR;
 
 	if (copy_from_user (kbuf, buf, copy_size)) {
@@ -399,7 +400,7 @@ static ssize_t lp_write(struct file * fi
 		lp_release_parport (&lp_table[minor]);
 	}
 out_unlock:
-	up (&lp_table[minor].port_mutex);
+	mutex_unlock(&lp_table[minor].port_mutex);
 
  	return retv;
 }
@@ -421,7 +422,7 @@ static ssize_t lp_read(struct file * fil
 	if (count > LP_BUFFER_SIZE)
 		count = LP_BUFFER_SIZE;
 
-	if (down_interruptible (&lp_table[minor].port_mutex))
+	if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
 		return -EINTR;
 
 	lp_claim_parport_or_block (&lp_table[minor]);
@@ -479,7 +480,7 @@ static ssize_t lp_read(struct file * fil
 	if (retval > 0 && copy_to_user (buf, kbuf, retval))
 		retval = -EFAULT;
 
-	up (&lp_table[minor].port_mutex);
+	mutex_unlock(&lp_table[minor].port_mutex);
 
 	return retval;
 }
@@ -888,7 +889,7 @@ static int __init lp_init (void)
 		lp_table[i].last_error = 0;
 		init_waitqueue_head (&lp_table[i].waitq);
 		init_waitqueue_head (&lp_table[i].dataq);
-		init_MUTEX (&lp_table[i].port_mutex);
+		mutex_init(&lp_table[i].port_mutex);
 		lp_table[i].timeout = 10 * HZ;
 	}
 
Index: linux-2.6.23/include/linux/lp.h
===================================================================
--- linux-2.6.23.orig/include/linux/lp.h
+++ linux-2.6.23/include/linux/lp.h
@@ -145,7 +145,7 @@ struct lp_struct {
 #endif
 	wait_queue_head_t waitq;
 	unsigned int last_error;
-	struct semaphore port_mutex;
+	struct mutex port_mutex;
 	wait_queue_head_t dataq;
 	long timeout;
 	unsigned int best_mode;

-- 

  parent reply	other threads:[~2007-12-06  2:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071206021857.826386004@mvista.com>
2007-12-05  8:00 ` [PATCH 1/3] stopmachine semaphore to mutex Daniel Walker
2007-12-05  8:00 ` [PATCH 2/3] Amiga serial driver: port_write_mutex fixup Daniel Walker
2007-12-05  8:00 ` Daniel Walker [this message]
2007-12-06 10:23   ` [PATCH 3/3] printer port driver: semaphore to mutex Ingo Molnar
2007-12-06 16:34     ` Daniel Walker
2007-12-06 20:01       ` Remy Bohmer
2007-12-06 20:12         ` Daniel Walker
2007-12-06 20:40           ` Remy Bohmer
2007-12-06 20:05       ` Matthias Kaehlcke
2007-12-06 20:12         ` Remy Bohmer
2007-12-06 20:23           ` Daniel Walker
2007-12-07  7:40           ` Matthias Kaehlcke
2007-12-06 20:44       ` Ingo Molnar
2007-12-06 23:30       ` Kevin Winchester
2007-12-07  1:05         ` Daniel Walker
2007-12-07  1:29           ` Possible locking issue in viotape.c Kevin Winchester
2007-12-07  1:40             ` Daniel Walker
2007-12-08 18:17               ` Kevin Winchester
2007-12-08 18:22                 ` Daniel Walker
2007-12-08 19:19                   ` Kevin Winchester
2007-12-08 19:45                     ` Daniel Walker
2007-12-06 10:22 ` [PATCH 1/3] stopmachine semaphore to mutex Ingo Molnar

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=20071206021909.131993721@mvista.com \
    --to=dwalker@mvista.com \
    --cc=akpm@linux-foundation.org \
    --cc=jonathan@jonmasters.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@bohmer.net \
    --cc=matthias.kaehlcke@gmail.com \
    --cc=mingo@elte.hu \
    /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