From: Jiri Slaby <jirislaby@gmail.com>
To: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] use mutex instead of semaphore in RocketPort driver v2
Date: Wed, 25 Apr 2007 15:58:50 +0200 [thread overview]
Message-ID: <462F5E9A.4010009@gmail.com> (raw)
In-Reply-To: <20070425130843.GK6798@traven>
Matthias Kaehlcke napsal(a):
> the RocketPort driver uses a semaphore as mutex. use the mutex API
> instead of the (binary) semaphore
>
> Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
>
> --
>
> diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
> index 76357c8..7d23790 100644
> --- a/drivers/char/rocket.c
> +++ b/drivers/char/rocket.c
> @@ -702,7 +702,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
> }
> }
> spin_lock_init(&info->slock);
> - sema_init(&info->write_sem, 1);
> + mutex_init(&info->write_mtx);
> rp_table[line] = info;
> if (pci_dev)
> tty_register_device(rocket_driver, line, &pci_dev->dev);
> @@ -1662,7 +1662,7 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch)
> return;
>
> /* Grab the port write semaphore, locking out other processes that try to write to this port */
> - down(&info->write_sem);
> + mutex_lock(&info->write_mtx);
>
> #ifdef ROCKET_DEBUG_WRITE
> printk(KERN_INFO "rp_put_char %c...", ch);
> @@ -1684,7 +1684,7 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch)
> info->xmit_fifo_room--;
> }
> spin_unlock_irqrestore(&info->slock, flags);
> - up(&info->write_sem);
> + mutex_unlock(&info->write_mtx);
> }
>
> /*
> @@ -1706,7 +1706,8 @@ static int rp_write(struct tty_struct *tty,
> if (count <= 0 || rocket_paranoia_check(info, "rp_write"))
> return 0;
>
> - down_interruptible(&info->write_sem);
> + if(mutex_lock_interruptible(&info->write_mtx))
^
and put a space here "if (".
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
prev parent reply other threads:[~2007-04-25 13:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-25 13:08 [PATCH] use mutex instead of semaphore in RocketPort driver v2 Matthias Kaehlcke
2007-04-25 13:54 ` Jiri Slaby
2007-04-25 14:06 ` Matthias Kaehlcke
2007-04-25 13:58 ` Jiri Slaby [this message]
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=462F5E9A.4010009@gmail.com \
--to=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.kaehlcke@gmail.com \
/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