From patchwork Mon Sep 25 20:18:29 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: 9970447 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 3E5FC60365 for ; Mon, 25 Sep 2017 20:18:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 310432870E for ; Mon, 25 Sep 2017 20:18:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25D0A28813; Mon, 25 Sep 2017 20:18:56 +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 24EA82870E for ; Mon, 25 Sep 2017 20:18:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966075AbdIYUSn (ORCPT ); Mon, 25 Sep 2017 16:18:43 -0400 Received: from mout.web.de ([212.227.17.11]:57099 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966053AbdIYUSm (ORCPT ); Mon, 25 Sep 2017 16:18:42 -0400 Received: from [192.168.1.2] ([78.48.115.31]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LrJse-1dDWCb0tP2-0137kK; Mon, 25 Sep 2017 22:18:33 +0200 To: linux-media@vger.kernel.org, Daniele Nicolodi , Mauro Carvalho Chehab , Max Kellermann From: SF Markus Elfring Subject: [PATCH] [media] bt8xx: Use common error handling code in two functions Cc: LKML , kernel-janitors@vger.kernel.org Message-ID: <7ad78087-fdd4-b76b-d770-81b9a55aaabd@users.sourceforge.net> Date: Mon, 25 Sep 2017 22:18:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:RnLTrbXK4qU4VfTSRPKVyMBCLYJxPIM86/h2+SnMXMkPfZ9FEhk iKqQ1L8rPGUlx4rRm22HmArWa2rdM4V1vo5RSt2XrIp8X7t/H+6sM4BEZSc6GTrSoI2hJUS MXlqgTGfF/cLJX4wMmot/GiNX1KaS2wEQ6UPdtQ+bqn52tVDLtVI3a1sANKZ/gJjSssnwdd o0GWevAYRCUaZHmOXG+TA== X-UI-Out-Filterresults: notjunk:1; V01:K0:t8Ryx9+Kh20=:grLi1Fcv2G/1M9URpYUiMS 6gMEMYAiFU3xDZyM6tgrj49TtFEHYyspMAZa5uM+REBR8wZnMUiFs3EXY/nn7vPfb0MlvJjmN UV84snbcufK5+JEXQGfkrD52cxLJZUnMjOM0esPGFKx34tb4rEJfpvZKtmuLpUpG3OtOoVF+T dZ7uBW+6VD3bLII6P6F/HaBma+nuhoof52AsJlJQJD1BXlesDu3QECaK2WZlhVwkMStF6f2Ub 52pa9ewC94jjqI+gkegpQAVQ5AQZ94zAJdvtCJb9e8TkA94OS8yv3P6yq17C5h+NANunr5kQ0 oOEoRuZbA02bxmuPly2PIGVsxXoTJv+shI2QbVebKMAUZcyWHNJnw/xGEYq5NJ2U+3XZCW80Z 8mLCbuazVah6Ebq8HJLz9grc2eCQSpq/TKWQLh2UEqO2mLzT27m0ro2xIi9G0ryJevhCCO2H+ YV0z6AV/4v2sg4ud7JfWaL/fa+rAPFldGk7xL5rPfZ/XW09saGlrTIMSdge/gXgBwpalSUptv 3/MZxRW3TcQktLxjaHHXIMiHCLSFKAwGXzn15AMqZ7BJ+lRYxCRhSnQqEDwZi1Q03K8Dgz1Lg pMBdaUMEH5b528qgyxOfvmEN6pEIfk5PS7m/HPzTaX+0ojSK4IbH7YYTzTShh5zu843fPiLW1 fSkGRugpTAOMrwHb/AbaeS1aWbzUgk7s93XtR1O4yK4YZI5zUuOGWiwPdDHL0G90xMu9RkTof YPQghu+kwhNdrh+L/W1evgljpkunkik0hZvxterdpzk1nkWJl5lfOBEuhOzvgZNIPS3DJ1mvX jHeXaYOe5btzn5GrdRoipJyohe5Qa6ELqWpjtmlLl6IFb5ex3M= 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: Mon, 25 Sep 2017 22:10:17 +0200 Adjust jump targets so that a bit of exception handling can be better reused at the end of these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/media/pci/bt8xx/dst.c | 19 +++++++++++-------- drivers/media/pci/bt8xx/dst_ca.c | 30 +++++++++++++++--------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/drivers/media/pci/bt8xx/dst.c b/drivers/media/pci/bt8xx/dst.c index 7166d2279465..1290419aca0b 100644 --- a/drivers/media/pci/bt8xx/dst.c +++ b/drivers/media/pci/bt8xx/dst.c @@ -134,17 +134,20 @@ EXPORT_SYMBOL(rdc_reset_state); static int rdc_8820_reset(struct dst_state *state) { dprintk(3, "Resetting DST\n"); - if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { - pr_err("dst_gpio_outb ERROR !\n"); - return -1; - } + if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) + < 0) + goto report_failure; + udelay(1000); - if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { - pr_err("dst_gpio_outb ERROR !\n"); - return -1; - } + if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, + RDC_8820_RESET, DELAY) < 0) + goto report_failure; return 0; + +report_failure: + pr_err("dst_gpio_outb ERROR !\n"); + return -1; } static int dst_pio_enable(struct dst_state *state) diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c index 90f4263452d3..5ea0a9c9a590 100644 --- a/drivers/media/pci/bt8xx/dst_ca.c +++ b/drivers/media/pci/bt8xx/dst_ca.c @@ -97,33 +97,33 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 if (write_dst(state, data, len)) { dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover"); - dst_error_recovery(state); - goto error; + goto error_recovery; } if ((dst_pio_disable(state)) < 0) { dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed."); - goto error; - } - if (read_dst(state, &reply, GET_ACK) < 0) { - dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); - dst_error_recovery(state); - goto error; + goto unlock; } + if (read_dst(state, &reply, GET_ACK) < 0) + goto report_read_failure; + if (read) { if (! dst_wait_dst_ready(state, LONG_DELAY)) { dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready"); - goto error; - } - if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ - dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); - dst_error_recovery(state); - goto error; + goto unlock; } + /* Try to make this dynamic */ + if (read_dst(state, ca_string, 128) < 0) + goto report_read_failure; } mutex_unlock(&state->dst_mutex); return 0; -error: +report_read_failure: + dprintk(verbose, DST_CA_INFO, 1, + " Read not successful, trying to recover"); +error_recovery: + dst_error_recovery(state); +unlock: mutex_unlock(&state->dst_mutex); return -EIO; }