From patchwork Thu Sep 21 15:07:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9964097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6BE18600C5 for ; Thu, 21 Sep 2017 15:07:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 679AB2956E for ; Thu, 21 Sep 2017 15:07:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C76D2958B; Thu, 21 Sep 2017 15:07:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F7552956E for ; Thu, 21 Sep 2017 15:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751709AbdIUPHd (ORCPT ); Thu, 21 Sep 2017 11:07:33 -0400 Received: from mout.web.de ([212.227.17.12]:57418 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678AbdIUPHc (ORCPT ); Thu, 21 Sep 2017 11:07:32 -0400 Received: from [192.168.1.2] ([78.49.37.140]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Md4l4-1dcpj72D8k-00IH6q; Thu, 21 Sep 2017 17:07:07 +0200 Subject: [PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params() From: SF Markus Elfring To: linux-media@vger.kernel.org, Davidlohr Bueso , Hans Verkuil , Mauro Carvalho Chehab , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <52c09836-83d7-c509-6e85-c7af16160302@users.sourceforge.net> Date: Thu, 21 Sep 2017 17:07:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:CHN7sv9QmmjN8LZA9AmFfercpxE88v1sQ+Fu6dJlu+TfQk5Z//B pLdm+Eip4BA6dFkBWYyM34C3NIvOpE9cgDm1FS6yK+yPWa65XHoiEOON32XjFb3vROx3U4X afSWYJa6OUkRbknTxCaINPYJD/wMPoKqc/cCOt9yqRpisuScIKcHcTg3my/gdx3v4qMOSei hP+PMyY+Ya7u3QSAjKgRg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qiG2vh2XeBk=:NhqLKU2uoPhdirKuXp8Q5g uNe7KOi7gsHpF0d5jnRPaQzc6oK42t/baVgvDAuiZ2H23s04eiYGW+Hrs1ordGuVpyF9Xvrx6 2ZE+Kb6+bqy4E7VkWZwPyLL32d6qqjHH5uNKkOP/kOwfAXe9UZO8ltipTaZShOdfdCuL/u4ut o1f0bjkZbr86vHpSjmbswcabRdRMJWXSMNhn9PxdwsKQ4/7q5/lDPOfrgWaNOVca8hPgWUY0a 87np9xa4zMcV8NxS23c1QWFKFKvmn1FVpgqN0GDsyvzBgneCp6Elrk+JrkJOkOFT9Z+qcEQ1W QmjVDvyL7/0uHSx/hzQ3we2/1P1c8gvUg2g0omYqfTwIVYpS23/rOJgRURLJxXp0FlQyTgQ5u LWOIV0F3IzsnvFW+8yfIVARptIcLyvaIAjpoWpN5qRSjOBSrkvW/gCO/AxyIlIS/Y3bop8bYx Tg9WVtW87LfqvsB7pXB4lK/igOlKvfYSR/lg0/833eLVGkWROboNiNIfWKaxArZzj17mbg/yw J6iCod+Irx4airl5AVie8wSKHycRmJygXMOdb8tQZvTXSukzUMHwXtzgk/7iVt6G5jecrNAlP zsZY8lpfFlpBctRvWJ+p9RnC92Sklxt8G7mBjtrxkVxG1Dwqo+k5cNrKSDQq+m2SJ598LmLSN wqrl2sPhT3rs6eAG6XahCyF/lK5B497je3/AmMNfTEebN2OBzU2/TXZgUps3MfBnaxIRUikOV Z9ZD7OaN2lGyOA+FjhphOwcVJ7+eKGFjarvLxPIZjx4aO0HhqauZYshai3QRNAg9NOxtPV3dX sQ8JrTO3qrEhD2CUbwpvhs3L21lRqb2XL8mYZxpsyBtdEcH/t4= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 21 Sep 2017 12:45:49 +0200 * Add a jump target so that a bit of exception handling can be better reused at the end of this function. * Replace the local variable "proc" by the identifier "__func__". * Use the interface "dev_err" instead of "printk". Signed-off-by: Markus Elfring --- drivers/media/usb/usbvision/usbvision-core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c index 16b76c85eeec..bb6f4f69165f 100644 --- a/drivers/media/usb/usbvision/usbvision-core.c +++ b/drivers/media/usb/usbvision/usbvision-core.c @@ -1857,7 +1857,6 @@ int usbvision_stream_interrupt(struct usb_usbvision *usbvision) static int usbvision_set_compress_params(struct usb_usbvision *usbvision) { - static const char proc[] = "usbvision_set_compresion_params: "; int rc; unsigned char *value = usbvision->ctrl_urb_buffer; @@ -1882,12 +1881,8 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, 0, (__u16) USBVISION_INTRA_CYC, value, 5, HZ); - - if (rc < 0) { - printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n", - proc, rc); - return rc; - } + if (rc < 0) + goto report_failure; if (usbvision->bridge_type == BRIDGE_NT1004) { value[0] = 20; /* PCM Threshold 1 */ @@ -1913,11 +1908,12 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, 0, (__u16) USBVISION_PCM_THR1, value, 6, HZ); + if (rc < 0) +report_failure: + dev_err(&usbvision->dev->dev, + "%s: ERROR=%d. USBVISION stopped - reconnect or reload driver.\n", + __func__, rc); - if (rc < 0) { - printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n", - proc, rc); - } return rc; }