media: ttusb-dec: cleanup an error handling logic
Simplify the logic at ttusb_dec_send_command(). Besides avoiding some code duplication, as a side effect, this could remove this false positive return with spatch: drivers/media/usb/ttusb-dec/ttusb_dec.c:380 ttusb_dec_send_command() warn: inconsistent returns '&dec->usb_mutex'. Locked on : 330 Unlocked on: 354,365,380 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
5368b1ee29
commit
dba328bab4
1 changed files with 11 additions and 14 deletions
|
@ -324,10 +324,10 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
|
||||||
if (!b)
|
if (!b)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if ((result = mutex_lock_interruptible(&dec->usb_mutex))) {
|
result = mutex_lock_interruptible(&dec->usb_mutex);
|
||||||
kfree(b);
|
if (result) {
|
||||||
printk("%s: Failed to lock usb mutex.\n", __func__);
|
printk("%s: Failed to lock usb mutex.\n", __func__);
|
||||||
return result;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
b[0] = 0xaa;
|
b[0] = 0xaa;
|
||||||
|
@ -349,9 +349,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
|
||||||
if (result) {
|
if (result) {
|
||||||
printk("%s: command bulk message failed: error %d\n",
|
printk("%s: command bulk message failed: error %d\n",
|
||||||
__func__, result);
|
__func__, result);
|
||||||
mutex_unlock(&dec->usb_mutex);
|
goto err;
|
||||||
kfree(b);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = usb_bulk_msg(dec->udev, dec->result_pipe, b,
|
result = usb_bulk_msg(dec->udev, dec->result_pipe, b,
|
||||||
|
@ -360,9 +358,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
|
||||||
if (result) {
|
if (result) {
|
||||||
printk("%s: result bulk message failed: error %d\n",
|
printk("%s: result bulk message failed: error %d\n",
|
||||||
__func__, result);
|
__func__, result);
|
||||||
mutex_unlock(&dec->usb_mutex);
|
goto err;
|
||||||
kfree(b);
|
|
||||||
return result;
|
|
||||||
} else {
|
} else {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printk(KERN_DEBUG "%s: result: %*ph\n",
|
printk(KERN_DEBUG "%s: result: %*ph\n",
|
||||||
|
@ -373,12 +369,13 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
|
||||||
*result_length = b[3];
|
*result_length = b[3];
|
||||||
if (cmd_result && b[3] > 0)
|
if (cmd_result && b[3] > 0)
|
||||||
memcpy(cmd_result, &b[4], b[3]);
|
memcpy(cmd_result, &b[4], b[3]);
|
||||||
|
|
||||||
mutex_unlock(&dec->usb_mutex);
|
|
||||||
|
|
||||||
kfree(b);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
|
mutex_unlock(&dec->usb_mutex);
|
||||||
|
|
||||||
|
kfree(b);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode,
|
static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode,
|
||||||
|
|
Loading…
Add table
Reference in a new issue