From patchwork Tue Oct 29 07:20:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 11217387 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 E8CF814E5 for ; Tue, 29 Oct 2019 07:22:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF8582087E for ; Tue, 29 Oct 2019 07:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728800AbfJ2HWc (ORCPT ); Tue, 29 Oct 2019 03:22:32 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:7825 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729677AbfJ2HWc (ORCPT ); Tue, 29 Oct 2019 03:22:32 -0400 IronPort-SDR: ZIJAOe4bkf42ne8sODLsKA/jDZJhThvc8bBtaXehPq5JZ1gy6UsG15l51sv8qbAv/4rWUtXWLU +R5Wt4Pd58WfcwM8coh52SQsfon9ZnH1R33saEd4ZAJEaAg9oKBo4rUF6h0k9ihB/oSfgg4rBv /v5Ynb9vCFRu/EjMxoOwY06kLtNkwVskgJbyoA79+Bbqa8KpAOJGSPnb1OJJiJTPIXFg9bxKru 097/6fiRBDHAdZ8B8IqT1NUMoM2BkkXFZgTTUwuRR991aPu6eeyI/qBu04EOTv7LwL/dz/ZO2f /9Y= X-IronPort-AV: E=Sophos;i="5.68,243,1569312000"; d="scan'208";a="44509438" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 28 Oct 2019 23:22:31 -0800 IronPort-SDR: Cwug88gtiUubjyMGZbM3J1wWJ+h+ecIVQI9AdfiyzjRZjrOT4AtW59JAeSauf4dPh5jkPGYC81 V1MBYwMITduVrmxKGhUcQopbn0MZ7W50vYGFhL0uXeor1BGbCp22sY91vZO/gTBtDtMe+Y9O4z ECz1i0hgwzkGyZAdAM5sqmxUEmORBsOwm3BTQRy8I1UzSlXI8jKGi3IbDkvTsjVxMpmLzv41Qq VSuK77nbsXflKbIkDEeR9qYgOveyB2qMIVuqFH2jROk/zD5PjwtvPEUq4dxzHICvAZtGXWhr8Z UiM= From: Jiada Wang To: , , , CC: , , , , Subject: [PATCH v4 38/48] Input: Atmel: improve error handling in mxt_start() Date: Tue, 29 Oct 2019 16:20:00 +0900 Message-ID: <20191029072010.8492-39-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029072010.8492-1-jiada_wang@mentor.com> References: <20191029072010.8492-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 4a0dce1aa1d5..e6212d384b9d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3974,12 +3974,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: @@ -3993,27 +3994,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) @@ -4333,6 +4333,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; @@ -4340,11 +4341,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);