From patchwork Mon Sep 25 19:15: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: 9970383 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 64242602D8 for ; Mon, 25 Sep 2017 19:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5388828CC0 for ; Mon, 25 Sep 2017 19:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 488CB28CC2; Mon, 25 Sep 2017 19:15: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 05BB228CC0 for ; Mon, 25 Sep 2017 19:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936418AbdIYTPi (ORCPT ); Mon, 25 Sep 2017 15:15:38 -0400 Received: from mout.web.de ([212.227.17.12]:58360 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934555AbdIYTPh (ORCPT ); Mon, 25 Sep 2017 15:15:37 -0400 Received: from [192.168.1.2] ([78.48.115.31]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LZedc-1dVEr21pC0-00lWGL; Mon, 25 Sep 2017 21:15:16 +0200 To: linux-media@vger.kernel.org, Andi Shyti , Andrey Utkin , Mauro Carvalho Chehab , Sean Young , Thomas Gleixner From: SF Markus Elfring Subject: [PATCH] [media] cx88: Use common error handling code in get_key_pvr2000() Cc: LKML , kernel-janitors@vger.kernel.org Message-ID: <962b8373-ca02-b27a-cc25-eb9b4ac16e05@users.sourceforge.net> Date: Mon, 25 Sep 2017 21:15:06 +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:qcau4lOZiFwKZtBXWk3vFKHVyq7FVkaxkDmtnJa1lFXjNaYgKA+ UQR+2xYDIAwd1Sls3OrEKV/pbVN9w5MvLau1v2xlOQUnzc6VM5qcy6ZhyYN6cwW1hvDA4Wg 4ioxTpiwHTqtTrVbsfXT3KFQWKTym/c9+GIGEymrqI3cEF8eT5LmpzFTk1C0Q1Em/oPfopF QCg10/KRIy1zBQhnANOQw== X-UI-Out-Filterresults: notjunk:1; V01:K0:Zydk/npQiO0=:GWaMFcdTsx50Rj1j2zDzoH VC+c01mzMNyKBPMbbZqgxXQENy2vqRWR0WqRyw+VjU051c4+XDNRVribPwvY283OW65Rmvxv7 I0mqRdkJnIfc7yKVnoaBozO94znnVd9UtYQRvYfWKuVApt436s1lcvsK3WbNeVE9kGJ1NAXkY lqHBBv/fdMZiI4mJBzjRk7olB+QeB47856/YLki+p9g/FSW/T9l/iAvDqWxL5dvA8c1jHty0v ZMYbN4/QG0mObi/8iYJ2FIvBH0+DtSRdgO7GIso6uHSrGK6bj/+u4z6/XL7CgX9AfPEOLyDdH Wy3GHl33gOS98dd0jRIx7BLsUkLV/ZCvv5x5j2ivjmyllPq4pjKu1WaOGZUtlQTu8wT0ynLyN kAASTtJAjqcisdNULPVVXAu4bBiUU5g+rKW79q3nwcFmiXg6jURB5XeAwmqyZpO1YVcG4fXFU LkUfpIqD0JlPGsQkpz7znur34W+F4Or3ydxcN7uIdlly3x18mQc0vVuFvCZxIs1LR25/EAEeq 3JUFrZJ8Ln86v9bqnu+vhTVlcQTL/d3J79Qsi55gL3iKutbTZQleU5935h3/nR8lgDKgtEwCR y2qqPowLMa7DjhSTtayx7F1eqARVYdvBQud1hrNQoRrSIjK8RXb++kiwf1Ms7oLx94EDBu082 rIrVRJBms9g57HSme50IXQ2w3+Mros1F1mbQVQEOTP6e74T/37RIsIO1oZzPbU9P0MXuW4i7T CON+DjMadjYByTFVktRH6L1KXmgnDsYx92DIM5KvtM/5qj4BKMLnSroV9S5TJkreHXFfbr3i6 JGCcHOoAhRmu2vSzU9ZK925TsHc/0tQnSHHvOBSY6B3AdXs8Cw= 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 21:03:57 +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/pci/cx88/cx88-input.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c index e02449bf2041..001fbb97bcdf 100644 --- a/drivers/media/pci/cx88/cx88-input.c +++ b/drivers/media/pci/cx88/cx88-input.c @@ -566,20 +566,17 @@ static int get_key_pvr2000(struct IR_i2c *ir, enum rc_proto *protocol, /* poll IR chip */ flags = i2c_smbus_read_byte_data(ir->c, 0x10); - if (flags < 0) { - dprintk("read error\n"); - return 0; - } + if (flags < 0) + goto report_read_failure; + /* key pressed ? */ if (0 == (flags & 0x80)) return 0; /* read actual key code */ code = i2c_smbus_read_byte_data(ir->c, 0x00); - if (code < 0) { - dprintk("read error\n"); - return 0; - } + if (code < 0) + goto report_read_failure; dprintk("IR Key/Flags: (0x%02x/0x%02x)\n", code & 0xff, flags & 0xff); @@ -588,6 +585,10 @@ static int get_key_pvr2000(struct IR_i2c *ir, enum rc_proto *protocol, *scancode = code & 0xff; *toggle = 0; return 1; + +report_read_failure: + dprintk("read error\n"); + return 0; } void cx88_i2c_init_ir(struct cx88_core *core)