linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
@ 2014-04-17 15:55 Kumar Gaurav
  2014-04-20  4:49 ` Kumar Gaurav
  2014-04-22  9:45 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Kumar Gaurav @ 2014-04-17 15:55 UTC (permalink / raw)
  To: gregkh, lidza.louina
  Cc: driverdev-devel, devel, linux-kernel, kernel-janitors,
	Kumar Gaurav

dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX.

Signed-off-by: Kumar Gaurav <kumargauravgupta3@gmail.com>
---
 drivers/staging/dgap/dgap_tty.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 2a7a372..0ca72a2 100755
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -52,7 +52,7 @@
 #include <asm/uaccess.h>	/* For copy_from_user/copy_to_user */
 #include <asm/io.h>		/* For read[bwl]/write[bwl] */
 #include <linux/pci.h>
-
+#include<linux/mutex.h>
 #include "dgap_driver.h"
 #include "dgap_tty.h"
 #include "dgap_types.h"
@@ -61,18 +61,12 @@
 #include "dgap_conf.h"
 #include "dgap_sysfs.h"
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
-#define init_MUTEX(sem)         sema_init(sem, 1)
-#define DECLARE_MUTEX(name)     \
-        struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#endif
-
 /*
  * internal variables
  */
 static struct board_t	*dgap_BoardsByMajor[256];
 static uchar		*dgap_TmpWriteBuf = NULL;
-static DECLARE_MUTEX(dgap_TmpWriteSem);
+static DEFINE_MUTEX(dgap_TmpWriteSem);
 
 /*
  * Default transparent print information.
@@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int
 		 * the board.
 		 */
 		/* we're allowed to block if it's from_user */
-		if (down_interruptible(&dgap_TmpWriteSem)) {
+		if (mutex_lock_interruptible(&dgap_TmpWriteSem))
 			return (-EINTR);
-		}
 
 		if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) {
-			up(&dgap_TmpWriteSem);
+			mutex_unlock(&dgap_TmpWriteSem);
 			printk("Write: Copy from user failed!\n");
 			return -EFAULT;
 		}
@@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int
 
 	if (from_user) {
 		DGAP_UNLOCK(ch->ch_lock, lock_flags);
-		up(&dgap_TmpWriteSem);
+		mutex_unlock(&dgap_TmpWriteSem);
 	} 
 	else {
 		DGAP_UNLOCK(ch->ch_lock, lock_flags);
-- 
1.7.9.5


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

* Re: [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
  2014-04-17 15:55 [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore Kumar Gaurav
@ 2014-04-20  4:49 ` Kumar Gaurav
  2014-04-20 15:28   ` Greg KH
  2014-04-22  9:45 ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Kumar Gaurav @ 2014-04-20  4:49 UTC (permalink / raw)
  Cc: gregkh, lidza.louina, driverdev-devel, devel, linux-kernel,
	kernel-janitors

Hi All,

Any update on below patch. Do i need to make any modification?

On Thursday 17 April 2014 09:25 PM, Kumar Gaurav wrote:
> dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX.
>
> Signed-off-by: Kumar Gaurav <kumargauravgupta3@gmail.com>
> ---
>   drivers/staging/dgap/dgap_tty.c |   17 +++++------------
>   1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
> index 2a7a372..0ca72a2 100755
> --- a/drivers/staging/dgap/dgap_tty.c
> +++ b/drivers/staging/dgap/dgap_tty.c
> @@ -52,7 +52,7 @@
>   #include <asm/uaccess.h>	/* For copy_from_user/copy_to_user */
>   #include <asm/io.h>		/* For read[bwl]/write[bwl] */
>   #include <linux/pci.h>
> -
> +#include<linux/mutex.h>
>   #include "dgap_driver.h"
>   #include "dgap_tty.h"
>   #include "dgap_types.h"
> @@ -61,18 +61,12 @@
>   #include "dgap_conf.h"
>   #include "dgap_sysfs.h"
>   
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
> -#define init_MUTEX(sem)         sema_init(sem, 1)
> -#define DECLARE_MUTEX(name)     \
> -        struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
> -#endif
> -
>   /*
>    * internal variables
>    */
>   static struct board_t	*dgap_BoardsByMajor[256];
>   static uchar		*dgap_TmpWriteBuf = NULL;
> -static DECLARE_MUTEX(dgap_TmpWriteSem);
> +static DEFINE_MUTEX(dgap_TmpWriteSem);
>   
>   /*
>    * Default transparent print information.
> @@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int
>   		 * the board.
>   		 */
>   		/* we're allowed to block if it's from_user */
> -		if (down_interruptible(&dgap_TmpWriteSem)) {
> +		if (mutex_lock_interruptible(&dgap_TmpWriteSem))
>   			return (-EINTR);
> -		}
>   
>   		if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) {
> -			up(&dgap_TmpWriteSem);
> +			mutex_unlock(&dgap_TmpWriteSem);
>   			printk("Write: Copy from user failed!\n");
>   			return -EFAULT;
>   		}
> @@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int
>   
>   	if (from_user) {
>   		DGAP_UNLOCK(ch->ch_lock, lock_flags);
> -		up(&dgap_TmpWriteSem);
> +		mutex_unlock(&dgap_TmpWriteSem);
>   	}
>   	else {
>   		DGAP_UNLOCK(ch->ch_lock, lock_flags);


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

* Re: [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
  2014-04-20  4:49 ` Kumar Gaurav
@ 2014-04-20 15:28   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2014-04-20 15:28 UTC (permalink / raw)
  To: Kumar Gaurav
  Cc: lidza.louina, driverdev-devel, devel, linux-kernel,
	kernel-janitors

On Sun, Apr 20, 2014 at 10:19:14AM +0530, Kumar Gaurav wrote:
> Hi All,
> 
> Any update on below patch. Do i need to make any modification?

Please give an overworked maintainer a chance to catch up on his email.
If after a week you haven't heard anything, then ask again.

thanks,

greg k-h

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

* Re: [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
  2014-04-17 15:55 [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore Kumar Gaurav
  2014-04-20  4:49 ` Kumar Gaurav
@ 2014-04-22  9:45 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-04-22  9:45 UTC (permalink / raw)
  To: Kumar Gaurav
  Cc: gregkh, lidza.louina, devel, driverdev-devel, kernel-janitors,
	linux-kernel

On Thu, Apr 17, 2014 at 09:25:32PM +0530, Kumar Gaurav wrote:
> dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX.
> 

You are patching ancient code that doesn't exist.  Work against
linux-next.

regards,
dan carpenter


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

end of thread, other threads:[~2014-04-22  9:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 15:55 [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore Kumar Gaurav
2014-04-20  4:49 ` Kumar Gaurav
2014-04-20 15:28   ` Greg KH
2014-04-22  9:45 ` Dan Carpenter

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).