From patchwork Sun Sep 17 20:22:12 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: 9955079 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 B046B6028A for ; Sun, 17 Sep 2017 20:22:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A73F828969 for ; Sun, 17 Sep 2017 20:22:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C0CF289AA; Sun, 17 Sep 2017 20:22:54 +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 5CE8E28969 for ; Sun, 17 Sep 2017 20:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751860AbdIQUWl (ORCPT ); Sun, 17 Sep 2017 16:22:41 -0400 Received: from mout.web.de ([217.72.192.78]:54931 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbdIQUWk (ORCPT ); Sun, 17 Sep 2017 16:22:40 -0400 Received: from [192.168.1.2] ([77.181.201.34]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LoHcD-1dDzXI40yn-00gL1X; Sun, 17 Sep 2017 22:22:14 +0200 Subject: [PATCH 6/8] [media] cx231xx: Use common error handling code in read_eeprom() From: SF Markus Elfring To: linux-media@vger.kernel.org, Bhumika Goyal , Hans Verkuil , Johan Hovold , Julia Lawall , Matthias Schwarzott , Mauro Carvalho Chehab , Oleh Kravchenko , Peter Rosin , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <8971b7e5-87ca-a1d5-f23d-64ed05c788b7@users.sourceforge.net> Date: Sun, 17 Sep 2017 22:22:12 +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:SaUKwQA7Nxr1CQTbegACVQZVIf1dM6h12lH6tlt4NLucncST76Z mhjL9AwNj9ZAQ3C7DvHRDIphxpwqS3PS0XuQz3RHEvLGWMjFi+rt5Ki0OqyJBcyQkgh4wvx UaANLW2q9iEpXR1QgTkxSp31VjdAHIlwlsvTkdrXA89U/92coZIw7xxnp8g5RneSriZd0bq 7CkqixuWv6RzmV5kHBgbg== X-UI-Out-Filterresults: notjunk:1; V01:K0:b3tktO7bakA=:Pe0EzrXKeAnt3QAbhp4qVB xcHdoYMxsAoJ0wQC79e/k9ltaUlgcY1oV5vEq/Lm/YCtFYRqioHuw8sOLSKvDx99QA3tI45jn tAdeUYNnWiv7qd5dPatWz/G24hb6TmbRb7Z5d+xPDNdGH2d5XzzRPkvvQcjmRFQuFhwz/hEuc QRzpFHq8WV2f3U9raYonU0DIe7UN2c4mUGZ1cthW4YDAK5/tvBarDaFK8Vm8PoUsFWMFRMXN4 RSOHFZWDy0igg41dJQpld8fMh5ECLrHVzvEpxcHQxR0jzuEvaZMKcfHldQAQMxng+9jDhlRS/ KzGqjduNh7CNsjoR5D2M73lgxLDGSQN4dopAQhkUByWltpNTo/4FdUA2Ej6cnMs8jYnvu1s2v h2oc4Y7IQJgyeZR7wgkb6obQjScqpRe5CY7+flhWcjV4qWwY7umh34jy+wdKFhfdRCeEPguPU Wf3KF3quJyCOv1qyBMUBK9SRy3FrEWPhQd5m9zCa8CyXXEYxKlajfEptrW4hIqQNVR5I1beua 68CfJVq6IFeS/VgfehHzGTwC0qwh+e2HfFVPvdm2jePIs7H3alfl2dBjPJz1hxoYaN3Jp0U3h vfHgkpsxXBtQllRQ0u8PNNitRhafCTUXcMUzjNkuswuwTHK8YBQXufHBWUq3tixzvENHFa1Rq WQ/CfSM7ZS7zDOARh4Xi0Q8ExB1UdlH80J0wmwOF8yg+ZjnIlVuCFhv66UtONBYhznAYAULzK 8kYt0DJgTh/N8J6FHSejwMkx9m2/mVEXrMWKGSTLc+EBktg+hr0lfnft0gAk5orfC+f5EBxqy QqhZVUQtdcn0cfgFTYCrMegFnNv8MHVlVEwQwUiinKBJtvVwIw= 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: Sun, 17 Sep 2017 20:22:15 +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. Signed-off-by: Markus Elfring --- drivers/media/usb/cx231xx/cx231xx-cards.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index d204f220dfe5..04c0734aee79 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1117,20 +1117,17 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, /* start reading at offset 0 */ ret = i2c_transfer(client->adapter, &msg_write, 1); - if (ret < 0) { - dev_err(dev->dev, "Can't read eeprom\n"); - return ret; - } + if (ret < 0) + goto report_failure; while (len_todo > 0) { msg_read.len = (len_todo > 64) ? 64 : len_todo; msg_read.buf = eedata_cur; ret = i2c_transfer(client->adapter, &msg_read, 1); - if (ret < 0) { - dev_err(dev->dev, "Can't read eeprom\n"); - return ret; - } + if (ret < 0) + goto report_failure; + eedata_cur += msg_read.len; len_todo -= msg_read.len; } @@ -1140,6 +1137,10 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, i, 16, &eedata[i]); return 0; + +report_failure: + dev_err(dev->dev, "Can't read eeprom\n"); + return ret; } void cx231xx_card_setup(struct cx231xx *dev)