From patchwork Fri Sep 22 15:56:49 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: 9966461 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 EA259600C5 for ; Fri, 22 Sep 2017 15:57:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF7352979C for ; Fri, 22 Sep 2017 15:57:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4416297E5; Fri, 22 Sep 2017 15:57:11 +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 92B482979C for ; Fri, 22 Sep 2017 15:57:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbdIVP5B (ORCPT ); Fri, 22 Sep 2017 11:57:01 -0400 Received: from mout.web.de ([212.227.17.12]:56632 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752520AbdIVP46 (ORCPT ); Fri, 22 Sep 2017 11:56:58 -0400 Received: from [192.168.1.2] ([78.48.204.216]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MQ6H9-1e051V3C8B-005LWX; Fri, 22 Sep 2017 17:56:50 +0200 To: linux-media@vger.kernel.org, Brian Johnson , Hans Verkuil , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] [media] sn9c20x: Use common error handling code in sd_init() Message-ID: <6c54a84f-bf74-3e4f-eba4-6618dd9e388b@users.sourceforge.net> Date: Fri, 22 Sep 2017 17:56:49 +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:S2wnr3rLCeJbvAvmpu0W2uEgzgesJi/NFwb58KV6Ci2Qwqx7BEr BnBmBSVHiyyhVafr9+GdMaDQGCfmQ5FjPn54vwlJ5RPI4E8hNLVuen+kdT2jiR/1J6N5NvC nsGnkQClIFVeiyc+0SQWKuibwpyHxsLjjXWrfDjmgAVbn+oKEujDN5qpHOJpyvhGn6dUtXY KNBJ+hao/KGPxwxHE1Axw== X-UI-Out-Filterresults: notjunk:1; V01:K0:/HcAdo1dRP4=:saCkapGFdZ+WtHwsLUDznF zRrfHkmKupW/1TbEjQdfUEqu8ZvG1MUMGgv802vhNO9WEQRjNETUUZe/yz3uc/t2xT6Yl21Vw V2TLzwr4st8OCPLmQsflk9tpQOGGmkqwRQjoR7XPh4V6oywShaPsytthkpESKoOvay5rOw+gY nAAjdA/en6Qqfgcn82Tg6rwSNMPebCchN1XvJdNDuLncCpc/KcaBNGKNEJgbuF0rHt1kqlhXY pXVP0YfnhtB1dT/kfIhRQC+1SlP0uTc3ev1+TukvTEhRvseEcS9vJz7JWFzKGt4jprCPfqUic K7Hr/KSMTMCkBc4cvjVqWsAYW2JiZ++Gm/bVpXVGcX03uqQcz+EBjxd7BTTGoUlEsq64WQRxP i7pshPPfgZ+CeARN/UNRuZqKfR6O6MnLbe1mVVPmfJ62RiCpjLm5OxwBvhpcz3kUtC46n72ax 14IHs2MXkFUPchzUgkQ/zYn1yBQdNW0L+4l8yivsPkFQlQZKl8BnQFG950AU1vA5FTkkGNJX/ VVW5WwwltjgLZGF2cg/TnxzRSDq66+/jnGwSV6fLDLdk1fQftevZQgdGZiOOfFWlZEqzBOawk 11ciDTXRKwejcQFh0wxRKaeKNWi+W4n2EgmXlmRQOudXcaZPFReEGS8LG06bcqwNytcZHboN2 bTENOOgV2ZdhSF6p9Krt8oK2RC9BVWuq6kkxr8Pm5rQ1r0lGHXBuzKbHC7N8bOKK9LybajrCV V7rjXzLGrbBrBaVafN1IGBlGIcE746LnDCEBhz+Dg1uWWMkuj39IJD/bA8QDPb8V3KiYG9XrN XyzQNe/dkvrPsD+ZjEzLGne30ly63oNFa6RC64NSDGlEO4ZSd8= 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: Fri, 22 Sep 2017 17:45:33 +0200 Add jump targets 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. Signed-off-by: Markus Elfring --- drivers/media/usb/gspca/sn9c20x.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c index c605f78d6186..282bbd77d815 100644 --- a/drivers/media/usb/gspca/sn9c20x.c +++ b/drivers/media/usb/gspca/sn9c20x.c @@ -1788,10 +1788,8 @@ static int sd_init(struct gspca_dev *gspca_dev) for (i = 0; i < ARRAY_SIZE(bridge_init); i++) { value = bridge_init[i][1]; reg_w(gspca_dev, bridge_init[i][0], &value, 1); - if (gspca_dev->usb_err < 0) { - pr_err("Device initialization failed\n"); - return gspca_dev->usb_err; - } + if (gspca_dev->usb_err < 0) + goto report_failure; } if (sd->flags & LED_REVERSE) @@ -1800,10 +1798,8 @@ static int sd_init(struct gspca_dev *gspca_dev) reg_w1(gspca_dev, 0x1006, 0x20); reg_w(gspca_dev, 0x10c0, i2c_init, 9); - if (gspca_dev->usb_err < 0) { - pr_err("Device initialization failed\n"); - return gspca_dev->usb_err; - } + if (gspca_dev->usb_err < 0) + goto report_failure; switch (sd->sensor) { case SENSOR_OV9650: @@ -1869,6 +1865,11 @@ static int sd_init(struct gspca_dev *gspca_dev) pr_err("Unsupported sensor\n"); gspca_dev->usb_err = -ENODEV; } + goto exit; + +report_failure: + pr_err("Device initialization failed\n"); +exit: return gspca_dev->usb_err; }