Commit 9faa310f authored by Ksenija Stanojevic's avatar Ksenija Stanojevic Committed by Greg Kroah-Hartman

Staging: comedi: dt9812: Use mutex instead of semaphore

Replace binary semaphore with mutex. Mutex also gives better performance
than semaphore.
Signed-off-by: default avatarKsenija Stanojevic <ksenija.stanojevic@gmail.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c2972215
...@@ -233,7 +233,7 @@ struct dt9812_usb_cmd { ...@@ -233,7 +233,7 @@ struct dt9812_usb_cmd {
}; };
struct dt9812_private { struct dt9812_private {
struct semaphore sem; struct mutex mut;
struct { struct {
__u8 addr; __u8 addr;
size_t size; size_t size;
...@@ -335,7 +335,7 @@ static int dt9812_digital_in(struct comedi_device *dev, u8 *bits) ...@@ -335,7 +335,7 @@ static int dt9812_digital_in(struct comedi_device *dev, u8 *bits)
u8 value[2]; u8 value[2];
int ret; int ret;
down(&devpriv->sem); mutex_lock(&devpriv->mut);
ret = dt9812_read_multiple_registers(dev, 2, reg, value); ret = dt9812_read_multiple_registers(dev, 2, reg, value);
if (ret == 0) { if (ret == 0) {
/* /*
...@@ -345,7 +345,7 @@ static int dt9812_digital_in(struct comedi_device *dev, u8 *bits) ...@@ -345,7 +345,7 @@ static int dt9812_digital_in(struct comedi_device *dev, u8 *bits)
*/ */
*bits = (value[0] & 0x7f) | ((value[1] & 0x08) << 4); *bits = (value[0] & 0x7f) | ((value[1] & 0x08) << 4);
} }
up(&devpriv->sem); mutex_unlock(&devpriv->mut);
return ret; return ret;
} }
...@@ -357,9 +357,9 @@ static int dt9812_digital_out(struct comedi_device *dev, u8 bits) ...@@ -357,9 +357,9 @@ static int dt9812_digital_out(struct comedi_device *dev, u8 bits)
u8 value[1] = { bits }; u8 value[1] = { bits };
int ret; int ret;
down(&devpriv->sem); mutex_lock(&devpriv->mut);
ret = dt9812_write_multiple_registers(dev, 1, reg, value); ret = dt9812_write_multiple_registers(dev, 1, reg, value);
up(&devpriv->sem); mutex_unlock(&devpriv->mut);
return ret; return ret;
} }
...@@ -444,7 +444,7 @@ static int dt9812_analog_in(struct comedi_device *dev, ...@@ -444,7 +444,7 @@ static int dt9812_analog_in(struct comedi_device *dev,
u8 val[3]; u8 val[3];
int ret; int ret;
down(&devpriv->sem); mutex_lock(&devpriv->mut);
/* 1 select the gain */ /* 1 select the gain */
dt9812_configure_gain(dev, &rmw[0], gain); dt9812_configure_gain(dev, &rmw[0], gain);
...@@ -493,7 +493,7 @@ static int dt9812_analog_in(struct comedi_device *dev, ...@@ -493,7 +493,7 @@ static int dt9812_analog_in(struct comedi_device *dev,
} }
exit: exit:
up(&devpriv->sem); mutex_unlock(&devpriv->mut);
return ret; return ret;
} }
...@@ -504,7 +504,7 @@ static int dt9812_analog_out(struct comedi_device *dev, int channel, u16 value) ...@@ -504,7 +504,7 @@ static int dt9812_analog_out(struct comedi_device *dev, int channel, u16 value)
struct dt9812_rmw_byte rmw[3]; struct dt9812_rmw_byte rmw[3];
int ret; int ret;
down(&devpriv->sem); mutex_lock(&devpriv->mut);
switch (channel) { switch (channel) {
case 0: case 0:
...@@ -543,7 +543,7 @@ static int dt9812_analog_out(struct comedi_device *dev, int channel, u16 value) ...@@ -543,7 +543,7 @@ static int dt9812_analog_out(struct comedi_device *dev, int channel, u16 value)
} }
ret = dt9812_rmw_multiple_registers(dev, 3, rmw); ret = dt9812_rmw_multiple_registers(dev, 3, rmw);
up(&devpriv->sem); mutex_unlock(&devpriv->mut);
return ret; return ret;
} }
...@@ -606,9 +606,9 @@ static int dt9812_ao_insn_read(struct comedi_device *dev, ...@@ -606,9 +606,9 @@ static int dt9812_ao_insn_read(struct comedi_device *dev,
struct dt9812_private *devpriv = dev->private; struct dt9812_private *devpriv = dev->private;
int ret; int ret;
down(&devpriv->sem); mutex_lock(&devpriv->mut);
ret = comedi_readback_insn_read(dev, s, insn, data); ret = comedi_readback_insn_read(dev, s, insn, data);
up(&devpriv->sem); mutex_unlock(&devpriv->mut);
return ret; return ret;
} }
...@@ -772,7 +772,7 @@ static int dt9812_auto_attach(struct comedi_device *dev, ...@@ -772,7 +772,7 @@ static int dt9812_auto_attach(struct comedi_device *dev,
if (!devpriv) if (!devpriv)
return -ENOMEM; return -ENOMEM;
sema_init(&devpriv->sem, 1); mutex_init(&devpriv->mut);
usb_set_intfdata(intf, devpriv); usb_set_intfdata(intf, devpriv);
ret = dt9812_find_endpoints(dev); ret = dt9812_find_endpoints(dev);
...@@ -844,11 +844,11 @@ static void dt9812_detach(struct comedi_device *dev) ...@@ -844,11 +844,11 @@ static void dt9812_detach(struct comedi_device *dev)
if (!devpriv) if (!devpriv)
return; return;
down(&devpriv->sem); mutex_lock(&devpriv->mut);
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
up(&devpriv->sem); mutex_unlock(&devpriv->mut);
} }
static struct comedi_driver dt9812_driver = { static struct comedi_driver dt9812_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment