From patchwork Wed Nov 6 07:01:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 11229459 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 6B2D01986 for ; Wed, 6 Nov 2019 07:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48D48218AE for ; Wed, 6 Nov 2019 07:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731265AbfKFHET (ORCPT ); Wed, 6 Nov 2019 02:04:19 -0500 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:8793 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731733AbfKFHES (ORCPT ); Wed, 6 Nov 2019 02:04:18 -0500 IronPort-SDR: IZCegv9M42kilb2C4KzY0bXx4BQG+qv8gg/oMWvxMw5EJ9z1j/htvH84d1y0vcPII7POxVz60s /PJp2cLKXuLTIIbPzC9mwZdVeWAfPowsztKwqjD+FacJVQQ4ekvRBK5tXMpAgnfCGPpS2Jdm/y 0m+zE5YUWYxjyJKKh9KbTTovzPk40bKtVlQJKhinvPuJsExAvSY16pVbVLH3hFyIC/MSNK2b9L 19tv6m3tEZuPvrImJhDAhUQ3rcaE05OIPN8tlP4z+XGn6qMxGzivtjIVL3FOtg4ajIWHHjJr8N fhw= X-IronPort-AV: E=Sophos;i="5.68,272,1569312000"; d="scan'208";a="42908672" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 05 Nov 2019 23:04:17 -0800 IronPort-SDR: Q8ZhhjXEZb8MjTmSs0X0JDBYeoTgPv3x1E3wmsKY3UwQKqUbqT/fYSRs+4zfmWWrmAP8dv+sJ3 twS+2Er1ioy5JEDp775qXl/pi+8las8FFRtOt4aXNK/4Xv/C+KVuYdS48hlPyN6ZTLAyCYSFZl 3ZWRUcRlkGzXrtEjumV0/Rcdjqi3tkmcXtjChTifqBWFMQ7vPwiAtCqfKyEXovGeY6yKyuKdQJ 7wCERdDc34vY2bbANaP5J4s2+lpnwO0cOcY1FaqZMB2f/RlzNrMs5yoGdWVkskK9U+Kifsp443 jiY= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v5 38/48] Input: Atmel: improve error handling in mxt_start() Date: Wed, 6 Nov 2019 16:01:36 +0900 Message-ID: <20191106070146.18759-39-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191106070146.18759-1-jiada_wang@mentor.com> References: <20191106070146.18759-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 a5af1f91d704..1ebdca1ed815 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);