* [PATCH] use mutex instead of semaphore in Sony PI driver
@ 2007-04-24 20:02 Matthias Kaehlcke
2007-04-25 0:22 ` Mattia Dongili
0 siblings, 1 reply; 3+ messages in thread
From: Matthias Kaehlcke @ 2007-04-24 20:02 UTC (permalink / raw)
To: malattia, linux-acpi; +Cc: linux-kernel
the Sony Programmable I/O Control 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/sonypi.c b/drivers/char/sonypi.c
index 7823757..878d8d0 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -477,7 +477,7 @@ static struct sonypi_device {
u16 evtype_offset;
int camera_power;
int bluetooth_power;
- struct semaphore lock;
+ struct mutex lock;
struct kfifo *fifo;
spinlock_t fifo_lock;
wait_queue_head_t fifo_proc_list;
@@ -884,7 +884,7 @@ int sonypi_camera_command(int command, u8 value)
if (!camera)
return -EIO;
- down(&sonypi_device.lock);
+ mutex_lock(&sonypi_device.lock);
switch (command) {
case SONYPI_COMMAND_SETCAMERA:
@@ -919,7 +919,7 @@ int sonypi_camera_command(int command, u8 value)
command);
break;
}
- up(&sonypi_device.lock);
+ mutex_unlock(&sonypi_device.lock);
return 0;
}
@@ -938,20 +938,20 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
static int sonypi_misc_release(struct inode *inode, struct file *file)
{
sonypi_misc_fasync(-1, file, 0);
- down(&sonypi_device.lock);
+ mutex_lock(&sonypi_device.lock);
sonypi_device.open_count--;
- up(&sonypi_device.lock);
+ mutex_unlock(&sonypi_device.lock);
return 0;
}
static int sonypi_misc_open(struct inode *inode, struct file *file)
{
- down(&sonypi_device.lock);
+ mutex_lock(&sonypi_device.lock);
/* Flush input queue on first open */
if (!sonypi_device.open_count)
kfifo_reset(sonypi_device.fifo);
sonypi_device.open_count++;
- up(&sonypi_device.lock);
+ mutex_unlock(&sonypi_device.lock);
return 0;
}
@@ -1001,7 +1001,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
u8 val8;
u16 val16;
- down(&sonypi_device.lock);
+ mutex_lock(&sonypi_device.lock);
switch (cmd) {
case SONYPI_IOCGBRT:
if (sonypi_ec_read(SONYPI_LCD_LIGHT, &val8)) {
@@ -1101,7 +1101,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
default:
ret = -EINVAL;
}
- up(&sonypi_device.lock);
+ mutex_unlock(&sonypi_device.lock);
return ret;
}
@@ -1330,7 +1330,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
}
init_waitqueue_head(&sonypi_device.fifo_proc_list);
- init_MUTEX(&sonypi_device.lock);
+ mutex_init(&sonypi_device.lock);
sonypi_device.bluetooth_power = -1;
if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
--
Matthias Kaehlcke
Linux Application Developer
Barcelona
If liberty means anything at all, it means the
right to tell people what they do not want to hear
(George Orwell)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] use mutex instead of semaphore in Sony PI driver
2007-04-24 20:02 [PATCH] use mutex instead of semaphore in Sony PI driver Matthias Kaehlcke
@ 2007-04-25 0:22 ` Mattia Dongili
2007-04-29 2:14 ` Len Brown
0 siblings, 1 reply; 3+ messages in thread
From: Mattia Dongili @ 2007-04-25 0:22 UTC (permalink / raw)
To: Matthias Kaehlcke, linux-acpi, linux-kernel
On Tue, Apr 24, 2007 at 10:02:35PM +0200, Matthias Kaehlcke wrote:
> the Sony Programmable I/O Control driver uses a semaphore as
> mutex. use the mutex API instead of the (binary) semaphore
>
> Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Acked-by: Mattia Dongili <malattia@linux.it>
> --
>
> diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
> index 7823757..878d8d0 100644
> --- a/drivers/char/sonypi.c
> +++ b/drivers/char/sonypi.c
> @@ -477,7 +477,7 @@ static struct sonypi_device {
> u16 evtype_offset;
> int camera_power;
> int bluetooth_power;
> - struct semaphore lock;
> + struct mutex lock;
> struct kfifo *fifo;
> spinlock_t fifo_lock;
> wait_queue_head_t fifo_proc_list;
> @@ -884,7 +884,7 @@ int sonypi_camera_command(int command, u8 value)
> if (!camera)
> return -EIO;
>
> - down(&sonypi_device.lock);
> + mutex_lock(&sonypi_device.lock);
>
> switch (command) {
> case SONYPI_COMMAND_SETCAMERA:
> @@ -919,7 +919,7 @@ int sonypi_camera_command(int command, u8 value)
> command);
> break;
> }
> - up(&sonypi_device.lock);
> + mutex_unlock(&sonypi_device.lock);
> return 0;
> }
>
> @@ -938,20 +938,20 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
> static int sonypi_misc_release(struct inode *inode, struct file *file)
> {
> sonypi_misc_fasync(-1, file, 0);
> - down(&sonypi_device.lock);
> + mutex_lock(&sonypi_device.lock);
> sonypi_device.open_count--;
> - up(&sonypi_device.lock);
> + mutex_unlock(&sonypi_device.lock);
> return 0;
> }
>
> static int sonypi_misc_open(struct inode *inode, struct file *file)
> {
> - down(&sonypi_device.lock);
> + mutex_lock(&sonypi_device.lock);
> /* Flush input queue on first open */
> if (!sonypi_device.open_count)
> kfifo_reset(sonypi_device.fifo);
> sonypi_device.open_count++;
> - up(&sonypi_device.lock);
> + mutex_unlock(&sonypi_device.lock);
> return 0;
> }
>
> @@ -1001,7 +1001,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
> u8 val8;
> u16 val16;
>
> - down(&sonypi_device.lock);
> + mutex_lock(&sonypi_device.lock);
> switch (cmd) {
> case SONYPI_IOCGBRT:
> if (sonypi_ec_read(SONYPI_LCD_LIGHT, &val8)) {
> @@ -1101,7 +1101,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
> default:
> ret = -EINVAL;
> }
> - up(&sonypi_device.lock);
> + mutex_unlock(&sonypi_device.lock);
> return ret;
> }
>
> @@ -1330,7 +1330,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
> }
>
> init_waitqueue_head(&sonypi_device.fifo_proc_list);
> - init_MUTEX(&sonypi_device.lock);
> + mutex_init(&sonypi_device.lock);
> sonypi_device.bluetooth_power = -1;
>
> if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
>
> --
> Matthias Kaehlcke
> Linux Application Developer
> Barcelona
>
> If liberty means anything at all, it means the
> right to tell people what they do not want to hear
> (George Orwell)
> .''`.
> using free software / Debian GNU/Linux | http://debian.org : :' :
> `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
>
--
mattia
:wq!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] use mutex instead of semaphore in Sony PI driver
2007-04-25 0:22 ` Mattia Dongili
@ 2007-04-29 2:14 ` Len Brown
0 siblings, 0 replies; 3+ messages in thread
From: Len Brown @ 2007-04-29 2:14 UTC (permalink / raw)
To: Mattia Dongili; +Cc: Matthias Kaehlcke, linux-acpi, linux-kernel
On Tuesday 24 April 2007 20:22, Mattia Dongili wrote:
> Acked-by: Mattia Dongili <malattia@linux.it>
applied.
thanks,
-Len
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-29 2:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-24 20:02 [PATCH] use mutex instead of semaphore in Sony PI driver Matthias Kaehlcke
2007-04-25 0:22 ` Mattia Dongili
2007-04-29 2:14 ` Len Brown
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).