staging: comedi: usbduxsigma: cleanup the unlink urb functions
These functions always return success. Change them to just return void. The 'usbduxsub_tmp', which is actually the comedi_device private data, is already validated by the callers. Remove the unnecessary validation and rename the 'usbduxsub_tmp' parameter to 'devpriv' which is more common in comedi drivers. Remove the unnecessary comments. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
956ddbcd89
commit
1c3032a4e9
1 changed files with 20 additions and 62 deletions
|
@ -252,49 +252,29 @@ static struct usbduxsub usbduxsub[NUMUSBDUX];
|
||||||
|
|
||||||
static DEFINE_SEMAPHORE(start_stop_sem);
|
static DEFINE_SEMAPHORE(start_stop_sem);
|
||||||
|
|
||||||
/*
|
static void usbduxsub_unlink_InURBs(struct usbduxsub *devpriv)
|
||||||
* Stops the data acquision
|
|
||||||
* It should be safe to call this function from any context
|
|
||||||
*/
|
|
||||||
static int usbduxsub_unlink_InURBs(struct usbduxsub *usbduxsub_tmp)
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if (usbduxsub_tmp && usbduxsub_tmp->urbIn) {
|
for (i = 0; i < devpriv->numOfInBuffers; i++) {
|
||||||
for (i = 0; i < usbduxsub_tmp->numOfInBuffers; i++) {
|
if (devpriv->urbIn[i])
|
||||||
if (usbduxsub_tmp->urbIn[i]) {
|
usb_kill_urb(devpriv->urbIn[i]);
|
||||||
/* We wait here until all transfers have been
|
|
||||||
* cancelled. */
|
|
||||||
usb_kill_urb(usbduxsub_tmp->urbIn[i]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This will stop a running acquisition operation
|
|
||||||
* Is called from within this driver from both the
|
|
||||||
* interrupt context and from comedi
|
|
||||||
*/
|
|
||||||
static int usbdux_ai_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
|
static int usbdux_ai_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!this_usbduxsub) {
|
if (!this_usbduxsub) {
|
||||||
pr_err("comedi?: usbdux_ai_stop: this_usbduxsub=NULL!\n");
|
pr_err("comedi?: usbdux_ai_stop: this_usbduxsub=NULL!\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_unlink) {
|
if (do_unlink)
|
||||||
/* stop aquistion */
|
usbduxsub_unlink_InURBs(this_usbduxsub);
|
||||||
ret = usbduxsub_unlink_InURBs(this_usbduxsub);
|
|
||||||
}
|
|
||||||
|
|
||||||
this_usbduxsub->ai_cmd_running = 0;
|
this_usbduxsub->ai_cmd_running = 0;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -469,36 +449,27 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
|
||||||
comedi_event(this_usbduxsub->comedidev, s);
|
comedi_event(this_usbduxsub->comedidev, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usbduxsub_unlink_OutURBs(struct usbduxsub *usbduxsub_tmp)
|
static void usbduxsub_unlink_OutURBs(struct usbduxsub *devpriv)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if (usbduxsub_tmp && usbduxsub_tmp->urbOut) {
|
for (i = 0; i < devpriv->numOfOutBuffers; i++) {
|
||||||
for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) {
|
if (devpriv->urbOut[i])
|
||||||
if (usbduxsub_tmp->urbOut[i])
|
usb_kill_urb(devpriv->urbOut[i]);
|
||||||
usb_kill_urb(usbduxsub_tmp->urbOut[i]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This will cancel a running acquisition operation
|
|
||||||
* in any context.
|
|
||||||
*/
|
|
||||||
static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
|
static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!this_usbduxsub)
|
if (!this_usbduxsub)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (do_unlink)
|
if (do_unlink)
|
||||||
ret = usbduxsub_unlink_OutURBs(this_usbduxsub);
|
usbduxsub_unlink_OutURBs(this_usbduxsub);
|
||||||
|
|
||||||
this_usbduxsub->ao_cmd_running = 0;
|
this_usbduxsub->ao_cmd_running = 0;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force unlink, is called by comedi */
|
/* force unlink, is called by comedi */
|
||||||
|
@ -1662,36 +1633,23 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
|
||||||
return insn->n;
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************/
|
static void usbduxsub_unlink_PwmURBs(struct usbduxsub *devpriv)
|
||||||
/* PWM */
|
|
||||||
|
|
||||||
static int usbduxsub_unlink_PwmURBs(struct usbduxsub *usbduxsub_tmp)
|
|
||||||
{
|
{
|
||||||
int err = 0;
|
if (devpriv->urbPwm)
|
||||||
|
usb_kill_urb(devpriv->urbPwm);
|
||||||
if (usbduxsub_tmp && usbduxsub_tmp->urbPwm) {
|
|
||||||
if (usbduxsub_tmp->urbPwm)
|
|
||||||
usb_kill_urb(usbduxsub_tmp->urbPwm);
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This cancels a running acquisition operation
|
|
||||||
* in any context.
|
|
||||||
*/
|
|
||||||
static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
|
static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!this_usbduxsub)
|
if (!this_usbduxsub)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (do_unlink)
|
if (do_unlink)
|
||||||
ret = usbduxsub_unlink_PwmURBs(this_usbduxsub);
|
usbduxsub_unlink_PwmURBs(this_usbduxsub);
|
||||||
|
|
||||||
this_usbduxsub->pwm_cmd_running = 0;
|
this_usbduxsub->pwm_cmd_running = 0;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force unlink - is called by comedi */
|
/* force unlink - is called by comedi */
|
||||||
|
|
Loading…
Add table
Reference in a new issue