From patchwork Thu Mar 19 15:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 11447373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 631066CA for ; Thu, 19 Mar 2020 15:03:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CC5F20CC7 for ; Thu, 19 Mar 2020 15:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbgCSPDI (ORCPT ); Thu, 19 Mar 2020 11:03:08 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:32379 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgCSPDH (ORCPT ); Thu, 19 Mar 2020 11:03:07 -0400 IronPort-SDR: yWju7VJK1UJzrmeRb7wvc8ffyUZxOV2qNkj1v0w1k6wVxB3oymiorjPiTXcKsJ6lkw2oCOEBqv 8UUHHZkppCq1ltsCf58Qmr97vTmaAPZwZY0COL8xGOOL+qDKqjj3F3UIQpXcA32gqRrgH+p0Tj bfKefhWQUvssy5xRCKVl0aSiCm4PJi4tNvuVmeiYBM1gLd/sljW/qYUgmbuSqshwkVFcRZxWhD VTBZHTTCEGJSZa6PsVtW/nmmYWSVo5ZxlDbfJKyzdlP82MrKPlDkvo2n+NiWLy/Ax57Jp7uoOM zPs= X-IronPort-AV: E=Sophos;i="5.70,572,1574150400"; d="scan'208";a="46891044" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 19 Mar 2020 07:03:06 -0800 IronPort-SDR: YvMk6tss4/JbxGtRXJZONODjGVMT2dv7dBTsJZ//tGP9SG9BhpJEy2L5DVOA16ix/LSYeP7fkS 7kAj0CUXvz5uYTsZvOa2CVIDxTQE5dq9Nzd9oeyqIVZswcHTEiH2nBkBmG8C29V69iXVy3uq9X GGDuot/DuKjjtR0dBTCit2xsfIziix8//84RRH6T9vQ+hQEsznM9mEH0qQIN6Faw0jc1okZuxH rCvjNRlQUD8n9cYQYZ1892s51WZvZAZZpDz2Yrteod3yRzfkQbolKBLw0y3jJwRS7z5Y2nwI57 uH0= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v8 42/52] Input: Atmel: improve error handling in mxt_start() Date: Thu, 19 Mar 2020 08:00:06 -0700 Message-ID: <20200319150016.61398-43-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319150016.61398-1-jiada_wang@mentor.com> References: <20200319150016.61398-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Deepak Das mxt_start() does not return error in any of the failure cases which will allow input_dev->open() to return success even in case of any failure. This commit modifies mxt_start() to return error in failure cases. Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 6ee83eda7170..2048cfbdc80c 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3973,12 +3973,13 @@ static int mxt_start(struct mxt_data *data) switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: - mxt_soft_reset(data); - + ret = mxt_soft_reset(data); + if (ret) + break; /* Touch enable */ /* 0x83 = SCANEN | RPTEN | ENABLE */ - mxt_write_object(data, - MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); + ret = mxt_write_object(data, + MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); break; case MXT_SUSPEND_REGULATOR: @@ -3992,27 +3993,26 @@ static int mxt_start(struct mxt_data *data) * Discard any touch messages still in message buffer * from before chip went to sleep */ - mxt_process_messages_until_invalid(data); + ret = mxt_process_messages_until_invalid(data); + if (ret) + break; ret = mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); if (ret) - return ret; + break; /* Recalibrate since chip has been in deep sleep */ ret = mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false); if (ret) - return ret; + break; ret = mxt_acquire_irq(data); - if (ret) - return ret; - - break; } - data->suspended = false; + if (!ret) + data->suspended = false; - return 0; + return ret; } static int mxt_stop(struct mxt_data *data) @@ -4335,6 +4335,7 @@ static int __maybe_unused mxt_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct mxt_data *data = i2c_get_clientdata(client); struct input_dev *input_dev = data->input_dev; + int ret = 0; if (!input_dev) return 0; @@ -4344,11 +4345,11 @@ static int __maybe_unused mxt_resume(struct device *dev) mutex_lock(&input_dev->mutex); if (input_dev->users) - mxt_start(data); + ret = mxt_start(data); mutex_unlock(&input_dev->mutex); - return 0; + return ret; } static SIMPLE_DEV_PM_OPS(mxt_pm_ops, mxt_suspend, mxt_resume);