From: Kumar Gaurav <kumargauravgupta3@gmail.com>
Cc: gregkh@linuxfoundation.org, lidza.louina@gmail.com,
driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
Date: Sun, 20 Apr 2014 04:50:25 +0000 [thread overview]
Message-ID: <535351CA.8000201@gmail.com> (raw)
In-Reply-To: <1397750132-21296-1-git-send-email-kumargauravgupta3@gmail.com>
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);
WARNING: multiple messages have this Message-ID (diff)
From: Kumar Gaurav <kumargauravgupta3@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: gregkh@linuxfoundation.org, lidza.louina@gmail.com,
driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
Date: Sun, 20 Apr 2014 10:19:14 +0530 [thread overview]
Message-ID: <535351CA.8000201@gmail.com> (raw)
In-Reply-To: <1397750132-21296-1-git-send-email-kumargauravgupta3@gmail.com>
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);
next prev parent reply other threads:[~2014-04-20 4:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-17 15:55 [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore Kumar Gaurav
2014-04-17 15:55 ` Kumar Gaurav
2014-04-20 4:49 ` Kumar Gaurav [this message]
2014-04-20 4:50 ` Kumar Gaurav
2014-04-20 15:28 ` Greg KH
2014-04-20 15:28 ` Greg KH
2014-04-22 9:45 ` Dan Carpenter
2014-04-22 9:45 ` Dan Carpenter
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=535351CA.8000201@gmail.com \
--to=kumargauravgupta3@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lidza.louina@gmail.com \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.