From patchwork Thu Sep 21 15:06:02 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: 9964093 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 840A5600C5 for ; Thu, 21 Sep 2017 15:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ED4C2958B for ; Thu, 21 Sep 2017 15:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7293929593; Thu, 21 Sep 2017 15:06:50 +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 27A722958B for ; Thu, 21 Sep 2017 15:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768AbdIUPGd (ORCPT ); Thu, 21 Sep 2017 11:06:33 -0400 Received: from mout.web.de ([212.227.17.12]:65334 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751387AbdIUPGb (ORCPT ); Thu, 21 Sep 2017 11:06:31 -0400 Received: from [192.168.1.2] ([78.49.37.140]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MHGaV-1e7ROB0gV9-00E74t; Thu, 21 Sep 2017 17:06:04 +0200 Subject: [PATCH 1/4] [media] usbvision-core: Use common error handling code in usbvision_set_input() 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: Date: Thu, 21 Sep 2017 17:06:02 +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:zw7779C9NM/U9M53fR0L6vCZcCMua+OFfoYkV6jptvkDP/EcF6+ eaMzmohBLWGvbm0EWvQSdpCq+TMOsUIAPcwt49XXnBHC3+Cc75sKH61UdtJ+/XnzI41NZil 5eYOmQqVgnyGBY6XS3Q/cgeuC7GoGNdW6w3cQ3hNJEwQgX8NFha5o9PNtn+RNJwpwSgYZ5/ qHHCdH4Is/Kp9FrVSVY5Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:qxl7u/oxDzo=:/jv/Kj9Kpv8t53NvztFCkD AW/JtvwpbgKYT1T9zgmqr178xf4B4suAEQniTYViNK67uOgyFFZxKLvEp2/TAuT6JxACvzb5u I1NXAJckHw9E5voo/isVwKNknQLRhxEdPbSc2pMPTTw1eQfzq6wYdFPG3ukNJFU3lHeSp1S8l y3h1P8hR4PRYl3yqimvIO8pV+bsiWPIECmt25qeHdyGsvm4PqlE0mL4XRFYDFkjWDRk1nwKji mq84Z/T+RQemIzIeyRyMhjz8Un9RyJDP4LJZmRggxMJQLUcpriEHcjzQbcXy7lWz//7rcLoSU m2U3QKcNviCr6PSLHAk/ArJShFfBh9haKFzz6IbGo0qf35vrJutPwMn6a1bQNBS6opZdCR0Mr X+Lyo/vFJ0XAlmCs6J/YH5LQrJxYU9Z3gKcQU6f3x4Z6uLgPY7sNZzOAePEu5jyoIDCUIBFDo OEW3HZoivzlvfsLnJMc/e2qJ2cnj8qNsR5D/fQHEsQErgav8qMdoNNoJpghBaAV4BJaMzQVqT HoLnbWU6anpM51fhrdqsv3FBDPvSLvN4KlmR26XW7Hc5/aLpoMd33WIAD1j14hbHjyhvcnBJd FZNVLShXNNkdj/YZSASTSho5B1l1HC0BhrLwvaCdOhSApJwRfFeH/KGagrYeV0OD5e5Br6orU DF37Tx0ljqMOHSNI/+3YFDDEn81L3srE5Z5L2h1hDaIcQ9tYkideaQv3YNpHIp+DwRVUy9Es9 Kj3w8cTBbaM2+MEfhglB8u5ADyGABqyR8zwFAAf9b5VdI/cqC8y0m9iBwUiN4c+rIer+fPdG6 gAbQAhXTsoHdYfVYCSCKYVkbE2P2zh3R0ciMZ4iLD2Nb07ddnw= 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 11:50:54 +0200 * Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. * 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 | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c index 3f87fbc80be2..16b76c85eeec 100644 --- a/drivers/media/usb/usbvision/usbvision-core.c +++ b/drivers/media/usb/usbvision/usbvision-core.c @@ -1931,7 +1931,6 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision) */ int usbvision_set_input(struct usb_usbvision *usbvision) { - static const char proc[] = "usbvision_set_input: "; int rc; unsigned char *value = usbvision->ctrl_urb_buffer; unsigned char dvi_yuv_value; @@ -1953,12 +1952,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision) } rc = usbvision_write_reg(usbvision, USBVISION_VIN_REG1, value[0]); - 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->tvnorm_id & V4L2_STD_PAL) { value[0] = 0xC0; @@ -2019,12 +2014,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision) USBVISION_OP_CODE, /* USBVISION specific code */ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, 0, (__u16) USBVISION_LXSIZE_I, value, 8, 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; dvi_yuv_value = 0x00; /* U comes after V, Ya comes after U/V, Yb comes after Yb */ @@ -2036,6 +2027,12 @@ int usbvision_set_input(struct usb_usbvision *usbvision) } return usbvision_write_reg(usbvision, USBVISION_DVI_YUV, dvi_yuv_value); + +report_failure: + dev_err(&usbvision->dev->dev, + "%s: ERROR=%d. USBVISION stopped - reconnect or reload driver.\n", + __func__, rc); + return rc; }