Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5827632ybv; Wed, 12 Feb 2020 00:47:39 -0800 (PST) X-Google-Smtp-Source: APXvYqwtEruxIB4qIoZ3wue5R5SryJQ8N47tA0rn5n5zY5Boy2XGXeO4bxeyxnAQpX5lzF09bY8H X-Received: by 2002:aca:2210:: with SMTP id b16mr5299954oic.32.1581497259321; Wed, 12 Feb 2020 00:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581497259; cv=none; d=google.com; s=arc-20160816; b=O1kWVCw+Fqh2L89jQVTSGSTpR8IPKyOblU3Yf16KdhZOncAhJ3zEW/m5/81G0AQOtw GEe6xXyvOTN1cY7F+HKxl4V9FIKIXsIKGqTGPMDseY9TAY8pcs/7+272ESdBKBykHoZk 2gb2hfg60+MrsrsLtuYkjMbJJpj4RXjYlaRIR0WrT1F4/G7fio6OmAGH9acmT7TAeSq2 FXLppKNbxH5Z3T0UVF2Vtl2LykjwIQ1yUw8sPPwvEeVNxRE1loCZ7IrjfeJEpFS81g8z NiXJcVsXVrEQzEZx1RAHnWVSVFu5kq4xn8jueYuwwiNO8NZIwplQIVz/TIq3SSS1+PRG su5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=87aQYgMtPTC02abL4WmtkJG7SBlVKetoabQozQHjBPQ=; b=h+AGXPcllPdzcXu/LBlTgT1jCFuu4ks0SIbbWIkWjurZHJ4vEddVQc0pGlhIwXgAhO yfHGC48Vn5tcX/F8yCVyV5K5kE3UnQyVjECrkTgkPPKSvVm+fsW3P6Z5MVWZt/rOFrnu gx9hPclT7OBmfJAdIwtQ9jjC5kMllcLYnwz19BUfhe+ldd0capgfxag6PfTBtO1SIpIr Qrq32C5HiHs8QrO4WTHZiwJ1m6tT7hbA0zTNPdW/Kf4K2MYVCaJ+eSsvcz355kpge6vG KhaZHydAk8+vYCkmJpyUTDqyo8edmRNj1tBFJQfoAgw9r26bklrOiUD9hJ91UvNnSVVN Pwxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si3229151oti.269.2020.02.12.00.47.27; Wed, 12 Feb 2020 00:47:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728690AbgBLIq6 (ORCPT + 99 others); Wed, 12 Feb 2020 03:46:58 -0500 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:5128 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728603AbgBLIq5 (ORCPT ); Wed, 12 Feb 2020 03:46:57 -0500 IronPort-SDR: D1pvV3rSJ97Tl4cFDxuZSwNQtnoYxot3Eq5AWJYSIVEDTrHXZyVys2yqKTP6vfxUKK1oYFdBZp /HqOKkwly3Px4CDNfDuYxKLQ4vJu6KpcNVH00nEqIQCIFkFq/zXNHDoH7QwdE66o0h45p/PxGU iGMvvvk1Tf+mx/M3ORJK/c0h5Kn4HDkze3e8Ft+JnXXUnIwwKsEqRjuB/gyYEBmmVJ+P4jHm+4 hYtVFpKxmR7Fy/O7maD6SSVO8QwjGhKLoYXANnaXA0djjp45aLCi5vekrlx81QJRYSjP0Tgq9Z /M8= X-IronPort-AV: E=Sophos;i="5.70,428,1574150400"; d="scan'208";a="45686290" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 12 Feb 2020 00:46:56 -0800 IronPort-SDR: G4iHbSb6oqGDlu3bACNLznyOqVs3wcG8JIf9L1DP7+2i4tycR+A3Plafinj8zd5dl0O09Ah1xs L8C8t/LRYHV2PDX/O3nCIO7U5kyI30SDnynS5Fp/8CjQFFldmBm5clzyAj8vUOJNUdwOhg7N1x MvPfgiZ96D/Lb1Aj5R3MhjoPrJRvBWCi+fv//+WMhvH2ypTEyx714NVnHaZqwupnhrj7elH7BS xFB94gpYsRAaNbrBim8KXrLHbH9lsJQlHaWVIMzw/hiUYD6x6gk17LJoGB1P7jZIc6W+kOAwEb FYE= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v7 38/48] Input: Atmel: improve error handling in mxt_start() Date: Wed, 12 Feb 2020 00:42:08 -0800 Message-ID: <20200212084218.32344-39-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200212084218.32344-1-jiada_wang@mentor.com> References: <20200212084218.32344-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 2a5a5a362a13..d96726fa00c5 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) @@ -4332,6 +4332,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; @@ -4341,11 +4342,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); -- 2.17.1