From patchwork Wed Jan 18 20:36:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9524725 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 8629C60113 for ; Wed, 18 Jan 2017 20:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 757F12861F for ; Wed, 18 Jan 2017 20:37:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69D3D28637; Wed, 18 Jan 2017 20:37:19 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 F40B8285F0 for ; Wed, 18 Jan 2017 20:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753079AbdARUhL (ORCPT ); Wed, 18 Jan 2017 15:37:11 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:59438 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862AbdARUhK (ORCPT ); Wed, 18 Jan 2017 15:37:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=3ws30e0WUPtb2knfH67FLKNo1AASje0Eb+j4yQRAROw=; b=tN5V8QNQ/1HszJ DrCmAEM4OGs86MiU1eUIlC5DjbW/baPm2s9FXQYhSK4wja/NR5NGOqxq84ld3CH3hKv6X0ZY1A1WT yvBxgRLVFGtiYFI0qprGiQhZXc/G/ZSaMEtDe6nI9dXjFCegVJZ77lPqk63UM+zTLbJq2yzAXMb8O ZNhE/RrJHMl7Qa18YcMhbGKTCX3FQUIxCZLFIONLKFNN068z+060Vfzb0LNL6xuSSBdBwk1ThqyRX Nw1Tnw7aqtVzG1zCdhaPglX3oGLyy0+TrzsKICZyJtZC80BNJjLMHHZ9uMw1Ixrt8ruEi3ei1CW7/ fvCbaP6n+pMpE6QMibHw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:46474 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cTwyg-000Paf-MQ; Wed, 18 Jan 2017 20:37:07 +0000 From: Guenter Roeck To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Colin Ian King , Jeffrey Lin , Rob Herring Subject: [PATCH 30/33] Input: raydium_i2c_ts - Simplify error return and other changes Date: Wed, 18 Jan 2017 12:36:47 -0800 Message-Id: <1484771819-13761-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484761614-12225-1-git-send-email-linux@roeck-us.net> References: <1484761614-12225-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify error return if the code returns anyway. Other relevant changes: Replace devm_add_action() with devm_add_action_or_reset() This conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Replace devm_add_action() followed by failure action with devm_add_action_or_reset() - Replace 'goto l; ... l: return e;' with 'return e;' - Replace 'if (e) return e; return 0;' with 'return e;' Signed-off-by: Guenter Roeck --- drivers/input/touchscreen/raydium_i2c_ts.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c index 2658afa016c9..84507a882fa1 100644 --- a/drivers/input/touchscreen/raydium_i2c_ts.c +++ b/drivers/input/touchscreen/raydium_i2c_ts.c @@ -741,11 +741,7 @@ static int raydium_i2c_do_update_firmware(struct raydium_data *ts, fw_checksum = raydium_calc_chksum(fw->data, fw->size); - error = raydium_i2c_write_checksum(client, fw->size, fw_checksum); - if (error) - return error; - - return 0; + return raydium_i2c_write_checksum(client, fw->size, fw_checksum); } static int raydium_i2c_fw_update(struct raydium_data *ts) @@ -831,12 +827,12 @@ static irqreturn_t raydium_i2c_irq(int irq, void *_dev) u16 calc_crc; if (ts->boot_mode != RAYDIUM_TS_MAIN) - goto out; + return IRQ_HANDLED; error = raydium_i2c_read_message(ts->client, ts->data_bank_addr, ts->report_data, ts->pkg_size); if (error) - goto out; + return IRQ_HANDLED; fw_crc = get_unaligned_le16(&ts->report_data[ts->report_size]); calc_crc = raydium_calc_chksum(ts->report_data, ts->report_size); @@ -844,12 +840,11 @@ static irqreturn_t raydium_i2c_irq(int irq, void *_dev) dev_warn(&ts->client->dev, "%s: invalid packet crc %#04x vs %#04x\n", __func__, calc_crc, fw_crc); - goto out; + return IRQ_HANDLED; } raydium_mt_event(ts); -out: return IRQ_HANDLED; } @@ -1130,10 +1125,9 @@ static int raydium_i2c_probe(struct i2c_client *client, return error; } - error = devm_add_action(&client->dev, - raydium_i2c_remove_sysfs_group, ts); + error = devm_add_action_or_reset(&client->dev, + raydium_i2c_remove_sysfs_group, ts); if (error) { - raydium_i2c_remove_sysfs_group(ts); dev_err(&client->dev, "Failed to add sysfs cleanup action: %d\n", error); return error;