From patchwork Wed Jan 18 17:46:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9524425 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 6EA6760113 for ; Wed, 18 Jan 2017 17:50:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FE0126E8A for ; Wed, 18 Jan 2017 17:50:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54E2F2860E; Wed, 18 Jan 2017 17:50:06 +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=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 0997526E8A for ; Wed, 18 Jan 2017 17:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753501AbdARRtt (ORCPT ); Wed, 18 Jan 2017 12:49:49 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:59093 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753382AbdARRs7 (ORCPT ); Wed, 18 Jan 2017 12:48:59 -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=E+FbjEcax9t9DeGm2+wLWsS3aYGiAE3sLA6kMkKbFeU=; b=w0wEP/fbD6+P/a 4lDniQODXb0rwBnDKiWKrHt5mIgcpjUpCD9YSlpd6Q89SnDc+AGUq/5UOHH2LAhoVRMldbn3zQrEy zHb718SefzhN6Frr5en54eARm+rcOW31xpYt3ACSufLGBDD74jp2S6Y+4VXnVjLANAsBrtw3Dxkq9 wLlzMtpu3Absu/cBzoSLAFqWRjLyvo0hvapzdswvErtMr1j1h+bIJvBPD/+XYTCzkFgg9/lnvjC3i 6MdvhUpN7mTK2cIStj1uIBUpgTGtyBoRg38R8Zggt2WxwWZghjoGv28GbrLeXukZGH4ZCRrNJVLsV y+iPR69+rjWd3CHw+YJw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:45212 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cTuLr-001mbx-Qv; Wed, 18 Jan 2017 17:48:54 +0000 From: Guenter Roeck To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 28/33] Input: egalax_ts - Drop unnecessary call to i2c_set_clientdata and other changes Date: Wed, 18 Jan 2017 09:46:49 -0800 Message-Id: <1484761614-12225-29-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 There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Other relevant changes: Simplify error return Drop error messages after memory allocation failures 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 - Drop unused variables - Drop unnecessary braces around conditional return statements - Drop error message after devm_kzalloc() failure - Replace 'if (e) return e; return 0;' with 'return e;' - Drop i2c_set_clientdata() Signed-off-by: Guenter Roeck --- drivers/input/touchscreen/egalax_ts.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 1afc08b08155..05ba1a6dc7fc 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c @@ -82,10 +82,9 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) if (ret < 0) return IRQ_HANDLED; - if (buf[0] != REPORT_MODE_MTTOUCH) { + if (buf[0] != REPORT_MODE_MTTOUCH) /* ignore mouse events and vendor events */ return IRQ_HANDLED; - } state = buf[1]; x = (buf[3] << 8) | buf[2]; @@ -155,13 +154,8 @@ static int egalax_wake_up_device(struct i2c_client *client) static int egalax_firmware_version(struct i2c_client *client) { static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 }; - int ret; - - ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN); - if (ret < 0) - return ret; - return 0; + return i2c_master_send(client, cmd, MAX_I2C_DATA_LEN); } static int egalax_ts_probe(struct i2c_client *client, @@ -172,10 +166,8 @@ static int egalax_ts_probe(struct i2c_client *client, int error; ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL); - if (!ts) { - dev_err(&client->dev, "Failed to allocate memory\n"); + if (!ts) return -ENOMEM; - } input_dev = devm_input_allocate_device(&client->dev); if (!input_dev) { @@ -225,12 +217,7 @@ static int egalax_ts_probe(struct i2c_client *client, return error; } - error = input_register_device(ts->input_dev); - if (error) - return error; - - i2c_set_clientdata(client, ts); - return 0; + return input_register_device(ts->input_dev); } static const struct i2c_device_id egalax_ts_id[] = {