From patchwork Tue Aug 27 06:30:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 11116185 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 1F36614D5 for ; Tue, 27 Aug 2019 06:31:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06D3E20828 for ; Tue, 27 Aug 2019 06:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbfH0Ga4 (ORCPT ); Tue, 27 Aug 2019 02:30:56 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:48270 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbfH0Ga4 (ORCPT ); Tue, 27 Aug 2019 02:30:56 -0400 IronPort-SDR: RWaRv887OGd4N7Bx1ydYwH29Anzm0vj6i+1Pf8ypITC4BpJJkFNb56pip4BulBjOFOGPnaacZZ MT2Gzgpj+nQs+Rj0VvUimb6uFbNI6L/QR+Why5wFkwaWfQ5VPRtEchkqJrKcq1TXjSNMukVOxL zCs6pcKKboUPpsfTSU5+ufJpMTSZ2mHyuinJTeWijJcJBdpYR7AwQCA35rAFERh4e+3WFxRJ3A 3IpbPJN7BTpXnWqG+03C7+nkRB/h4U0eDQhdRqNrVk4s83WU9cGUGgjyIzGDvZGR/1BL8oWWWH QhI= X-IronPort-AV: E=Sophos;i="5.64,436,1559548800"; d="scan'208";a="40784633" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 26 Aug 2019 22:30:55 -0800 IronPort-SDR: udTi8abBojH8yoHsR9OzkH4HGD5+LXST8xhaI7UXSI9uWbC3UBXMRpGFtfzfr2jAyJCB5tYHeZ c/GKNe+pmI142jlA85dquSb/P43ByF0DSB7ohC7aek3W23V5lKeTRsGQaf14kGiwtkUzn6DGgb 6x4nhISgO1E2rqjC87IlzDv7rVEfX7duwFa4FLoyBgVS+HM3ebwqAMqSiDYAEz8MusY4y6M+lW /ia+s+2Q2cSug3lkMSAE3t2acncr6ModFrd8URqGi4YOM9LUZmbxupyLfWhIwFjBxmymqmUZO4 IaY= From: Jiada Wang To: , CC: , , , Subject: [PATCH v2 39/49] Input: Atmel: improve error handling in mxt_start() Date: Tue, 27 Aug 2019 15:30:44 +0900 Message-ID: <20190827063054.20883-5-jiada_wang@mentor.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190827063054.20883-1-jiada_wang@mentor.com> References: <20190827063054.20883-1-jiada_wang@mentor.com> MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) 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 e9a895473ed8..dd70f3b9678f 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3971,12 +3971,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: @@ -3990,27 +3991,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) @@ -4331,6 +4331,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; @@ -4338,11 +4339,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);