From patchwork Sun Oct 22 20:00:04 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: 10021765 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 BE3BE60375 for ; Sun, 22 Oct 2017 20:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE56527FA5 for ; Sun, 22 Oct 2017 20:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F7BB286D7; Sun, 22 Oct 2017 20:00:24 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35D2027FA5 for ; Sun, 22 Oct 2017 20:00:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08DB16E1EA; Sun, 22 Oct 2017 20:00:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.web.de (mout.web.de [212.227.17.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F2AD6E1EA for ; Sun, 22 Oct 2017 20:00:20 +0000 (UTC) Received: from [192.168.1.2] ([77.182.45.221]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LgHLE-1dRThT1FIa-00njj9; Sun, 22 Oct 2017 22:00:07 +0200 Subject: [PATCH v2] gpu/drm/bridge/sii9234: Use common error handling code in sii9234_writebm() From: SF Markus Elfring To: dri-devel@lists.freedesktop.org, Andrzej Hajda , Archit Taneja , David Airlie , Laurent Pinchart , Maciej Purski , Rob Herring References: <8bb4a1d2-8876-731f-2938-8be075f4252c@users.sourceforge.net> Message-ID: <2ecf0bb7-7129-40e4-cefc-0bc2d0f7ee8b@users.sourceforge.net> Date: Sun, 22 Oct 2017 22:00:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <8bb4a1d2-8876-731f-2938-8be075f4252c@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:+VSxGeWBuAOAWelbJJPiupM30vvK1F8U+SgGWburxQH0rHKguq9 QM6C6ZGqQOfCg+xAlEj+pU3054XiBodbAxK46QpoDooqZYaCxMFn2uiOA2ViGM0/OyOXEw+ W5i6+IYSzBoiGg3tABqQtxR7cyS4wosdOVgQmeLX4Bc5dVwLtgv3blyWM92z9Q5412CmZmP 6uXLo3axfl7qJOjvA4WrQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:usE3nDW/0oY=:g5bvsix8q49JJ1wDZ22V3a k4CkQINCpNn1DRZSutHPxE7gdJ235y8+H8XWdqOZrNg6CmLh41TGbnr70qwJCcXxmkcAkfssZ yBqYbNPKKuSyj9LbbIimx6rrpMB9h/IJgfkMAzCzFrlK3R4/mOBu0Dr28RRkwfi4w7XLAPrIP FX+f0b+YA1U7/eJeFgGIWDnDtwfC3/BPgljCZ0/fpAiBhnp6BAemLukTYNcHWPu5jXNBz9djN uxKxBGxl0ygJ58SWDLmpcz+NIEGGtZVHOWqfCsURd1nSOdY9Fi+aW/6xeKKCp+8LSAsoKMAOc IIbCONLlMT3v0hUaez5GxL5pnaYgOvPbV0URZrDKYyVtvN0UlnbJ1/UMu87bi9FF4bkntPp9o KBdcRw8QDBaWHOe+1TxWQpDZZzwdcuLtiU/mp/pQPDZ7mJmAJ18Njh+g5d6kQxRp6pEj2GxPg E/41FLOSvcduJIjR18SSiR1Gmwj0d+EcmypJLYp2VKejCqFHx2pRF4jwa7XER8aSnMpkr590Z Y/6JF711uEPNo0kJ/FV3eTM4Y4Q6fnmxGXeQRjxZPH8HNFBRj1t+HoEJQ0S+QYCw44wZBAfzG 7IcVveMBM6BL9/NRSPLSIL8LBpNUAU5eE2xunLZb4mrz1zTKUqzxl3oToKU1JSCSYkhk23rDR d65+qnRKAcn0p3V+DiPVwP90FqC9ltT7fvunyo6QH43mDrm2542jLP9fOYdYgldk0my4JSsjI HsgWUsmZno5cJaLGDBjZgnmumQFKsFU/Qwktcvu76hHyI/kbup0156GDsAJMvS4TzIuHk1uiF gKjkINWzTM0O8xqn+SmTh4UwfuDuQwL8kWWQgNo0+bLH4umTQY= Cc: kernel-janitors@vger.kernel.org, LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 22 Oct 2017 21:50:51 +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. * Adjust condition checks. Signed-off-by: Markus Elfring --- v2: The check for a negative error code was preserved after a call of the function "i2c_smbus_read_byte". drivers/gpu/drm/bridge/sii9234.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii9234.c b/drivers/gpu/drm/bridge/sii9234.c index c77000626c22..4d8b2cc29378 100644 --- a/drivers/gpu/drm/bridge/sii9234.c +++ b/drivers/gpu/drm/bridge/sii9234.c @@ -231,30 +231,22 @@ static int sii9234_writebm(struct sii9234 *ctx, int id, int offset, return ctx->i2c_error; ret = i2c_smbus_write_byte(client, offset); - if (ret < 0) { - dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", - sii9234_client_name[id], offset, value); - ctx->i2c_error = ret; - return ret; - } + if (ret) + goto report_failure; ret = i2c_smbus_read_byte(client); - if (ret < 0) { - dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", - sii9234_client_name[id], offset, value); - ctx->i2c_error = ret; - return ret; - } + if (ret < 0) + goto report_failure; value = (value & mask) | (ret & ~mask); - ret = i2c_smbus_write_byte_data(client, offset, value); - if (ret < 0) { - dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", - sii9234_client_name[id], offset, value); - ctx->i2c_error = ret; - } + if (!ret) + return 0; +report_failure: + dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", + sii9234_client_name[id], offset, value); + ctx->i2c_error = ret; return ret; }