From patchwork Sun Oct 22 19:32:46 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: 10021763 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 C68AD60381 for ; Sun, 22 Oct 2017 19:46:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B629628497 for ; Sun, 22 Oct 2017 19:46:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A81BB28714; Sun, 22 Oct 2017 19:46:18 +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 429F928497 for ; Sun, 22 Oct 2017 19:46:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 939936E035; Sun, 22 Oct 2017 19:46:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 793 seconds by postgrey-1.35 at gabe; Sun, 22 Oct 2017 19:46:14 UTC Received: from mout.web.de (mout.web.de [212.227.17.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2640C6E16C for ; Sun, 22 Oct 2017 19:46:13 +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 0LvBIk-1d745a2Mlu-010LIp; Sun, 22 Oct 2017 21:32:49 +0200 To: dri-devel@lists.freedesktop.org, Andrzej Hajda , Archit Taneja , David Airlie , Laurent Pinchart , Maciej Purski , Rob Herring From: SF Markus Elfring Subject: [PATCH] gpu/drm/bridge/sii9234: Use common error handling code in sii9234_writebm() Message-ID: <8bb4a1d2-8876-731f-2938-8be075f4252c@users.sourceforge.net> Date: Sun, 22 Oct 2017 21:32:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:/KwrHVmwrpMOucwp1Clx6fStnJuoVrIBied8XNZFKaSbS3J+wTe QKxFa22MsyeXHr5DDy9PrswG+M7BLoP7SCKIMcl9H8vMmRVcDQltF/LgC90ZmZeWJdoaqJl NoBxCFSTi63B0JEvmoksCrNVpgWxJ9vrOMzVj4EZs3pdmYYymWaHWdcpCgFDHQ+1fWTkxGs X7sXMVBbdqezY5DSRjzTA== X-UI-Out-Filterresults: notjunk:1; V01:K0:wE10gmLxIe0=:oVfXg7TJ1jm0IBO2qVGMie f/rLkp4miGIvI1FXs7AsHx1t5ENyjEiEJpsXhEe3l/d2RzUsHcQXlHPHCNXzqxahJRAuDb7km wVl74lsUh7BPqdmP7CcpEFsyUUa119bdW1KbPWUh8q2iyctf9qUh2FAPQ11CbjMsCg7UIIYsD S1HNdzz6pi0YPy6H95bqIOSwqSQkv/rpG3kyyp5JIixN6Z5h3WG2/fjl0Rm2Zbr7rhKF7OVKQ BuaV4P0IWcwhlHo2zabN7hTYzoF5ABs2J1DiWNZtIqivB6Ab8SdMw+djaUOHqj/JDCfuQacLB /yFSsUCCBCBxeLrAI+xueTOu+hv4igd503HO2dHh5tdxD9w4w97pUwHKnJNWNqZQuzvq4o6m2 pzLP30UF99M6h3XkyLt561Pqlf3O+nbvfdNVaiP6x7CzUZ6CzAdB2ig32HzdaRPJMagKYFNPW r6AnolXPIEY3Kb+IMU1DJKuTGRlp6EDist7NaMMwc8bzAAhYOSWYWFt/EdDDkYO9fzSOdX3fw 9ZdvxoTJQ1dqCZgmsz6jMNlH7aaZ6yJU+g+YmmIGZlHkhgZrFDepnAPXnM63UL++gVuFGSu2A 1CF4nw/wkVw+0THduW68/EVPJVzDxNs79eRLQuYRrVBIkJAx82l+rayn4GNcAzZRMi9T6FOZf eR4dTdcjJk+FoL3UOQAMn6PF7fAFa+LoWtlR6qW7i9hpilEf71ani7eLanrLMkr4jRsq/fvL5 47EZYiadEOvPjaXr5WxVnxkGdFHVZDZUsnJa8kjkwD2Kerv3tVNDgvqvAywRT/KIQKj6LBHuP eGfjG0yMe2o/vRRQ0n0xDTUoK5fUOJ8bMszOSN9d/8VYmPpewU= 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:21:44 +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 --- 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..fbdacdaf485c 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) + 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; }