};
struct dt9812_private {
+ struct semaphore sem;
struct slot_dt9812 *slot;
};
struct slot_dt9812 {
- struct semaphore mutex;
struct usb_dt9812 *usb;
struct dt9812_private *devpriv;
};
struct slot_dt9812 *slot = devpriv->slot;
int ret = -ENODEV;
- down(&slot->mutex);
+ down(&devpriv->sem);
if (slot->usb) {
u8 reg[2] = { F020_SFR_P3, F020_SFR_P1 };
u8 value[2];
*bits = (value[0] & 0x7f) | ((value[1] & 0x08) << 4);
}
}
- up(&slot->mutex);
+ up(&devpriv->sem);
return ret;
}
struct slot_dt9812 *slot = devpriv->slot;
int ret = -ENODEV;
- down(&slot->mutex);
+ down(&devpriv->sem);
if (slot->usb) {
u8 reg[1] = { F020_SFR_P2 };
u8 value[1] = { bits };
ret = dt9812_write_multiple_registers(slot->usb, 1, reg, value);
slot->usb->digital_out_shadow = bits;
}
- up(&slot->mutex);
+ up(&devpriv->sem);
return ret;
}
struct slot_dt9812 *slot = devpriv->slot;
int ret = -ENODEV;
- down(&slot->mutex);
+ down(&devpriv->sem);
if (slot->usb) {
*bits = slot->usb->digital_out_shadow;
ret = 0;
}
- up(&slot->mutex);
+ up(&devpriv->sem);
return ret;
}
u8 val[3];
int ret = -ENODEV;
- down(&slot->mutex);
+ down(&devpriv->sem);
if (!slot->usb)
goto exit;
}
exit:
- up(&slot->mutex);
+ up(&devpriv->sem);
return ret;
}
struct slot_dt9812 *slot = devpriv->slot;
int ret = -ENODEV;
- down(&slot->mutex);
+ down(&devpriv->sem);
if (slot->usb) {
*value = slot->usb->analog_out_shadow[channel];
ret = 0;
}
- up(&slot->mutex);
+ up(&devpriv->sem);
return ret;
}
struct slot_dt9812 *slot = devpriv->slot;
int ret = -ENODEV;
- down(&slot->mutex);
+ down(&devpriv->sem);
if (slot->usb) {
struct dt9812_rmw_byte rmw[3];
ret = dt9812_rmw_multiple_registers(slot->usb, 3, rmw);
slot->usb->analog_out_shadow[channel] = value;
}
- up(&slot->mutex);
+ up(&devpriv->sem);
return ret;
}
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
+ sema_init(&devpriv->sem, 1);
down(&dt9812_mutex);
return -ENODEV;
}
- down(&slot->mutex);
slot->devpriv = devpriv;
devpriv->slot = slot;
range_2_5 = (slot->usb->device == DT9812_DEVID_DT9812_2PT5);
- up(&slot->mutex);
up(&dt9812_mutex);
goto error;
}
- down(&slot->mutex);
slot->usb = dev;
dev->slot = slot;
- up(&slot->mutex);
up(&dt9812_mutex);
down(&dt9812_mutex);
dev = usb_get_intfdata(interface);
if (dev->slot) {
- down(&dev->slot->mutex);
dev->slot->usb = NULL;
- up(&dev->slot->mutex);
dev->slot = NULL;
}
usb_set_intfdata(interface, NULL);
/* Initialize all driver slots */
for (i = 0; i < DT9812_NUM_SLOTS; i++) {
- sema_init(&dt9812[i].mutex, 1);
dt9812[i].usb = NULL;
dt9812[i].devpriv = NULL;
}