Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3367145ybb; Tue, 31 Mar 2020 03:55:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsjtq0wIgEoFRKZTDOip3EsQLm7QH6igQdCU71b6GqtQZ0qCLa32FyzHf/+Essxtxnqc34u X-Received: by 2002:a05:6830:1c7:: with SMTP id r7mr2730454ota.58.1585652145734; Tue, 31 Mar 2020 03:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585652145; cv=none; d=google.com; s=arc-20160816; b=Sup26n7FmMQ30LEbdZQ71kBLk/5A5b8gsV+r00cr3UtvV7NIcKU0GLxyw/fEe6yQMj ZuO7HD+4/uz32oi70qKvmrtSC7w5dAloKFlmRbqTcVqxHiBIsHXMM0s7gsAlA3zDr2yg P+RERZoXDtyO2IAP5F0E+TnZWjIV4BocH098MA24pXKhiGplx288k4ud863pekZzreK9 g7NiQ46Be5A6xvx7Lx4WimSGUdoiPnHotzVYF2LUpdm3MeNls9O+Qwp1yQX3VcWDHHsy cq2PPR0Nrz7usMt0/tCVIJWDmEqRNP6uNLEWWlYZ6WlGW+DpvfNpspfyatktx7hKUFUx Pssg== 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=TBIyEAk+U9cPuztRwgQGXihs49/WlX107Njr1z8GTs8=; b=Gzm0aMHsVJrY5oRsoA6OUF2ILiKLy3R2EF0jQgEoQKwhkC8YLpYVIQ5FSOWZQDq+MO iGYrztUsA5jONfNx08EPnOjWRpkBX8oUr8lIgD0tHlFMo6n+A4VIjFdNq4DPOL56WKjA ashVcP2V9nSq6VZ8XSrR9S7fzjhwRKJRcKAEfWjvS0cRoNBjYhfoqzLocRv9CYX6k2xX g/fIoaLaeDmuVDF1drb3I98nSH+Zgp2+/WocmDRCY/MJy6ux1ZtP/dQwnm96K8t2np50 h/0GxJQQEi8KmdrJW2xPVGE9icE7HwoufNDesS+D24hQKbT4GX9w9mzbenYFrWvHhZUY IfZg== 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 5si6663875oin.43.2020.03.31.03.55.34; Tue, 31 Mar 2020 03:55:45 -0700 (PDT) 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 S1730964AbgCaKxr (ORCPT + 99 others); Tue, 31 Mar 2020 06:53:47 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:43597 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730466AbgCaKxq (ORCPT ); Tue, 31 Mar 2020 06:53:46 -0400 IronPort-SDR: lx6iCNPGOyawy791qi7xl4RwAEx3xlVvWGYXEJLm+YIFm2//Hn6Q9Hw4Y3oLu0augdDKEl2uvs hv2D2yUxbA7+MXw88CyWaaOpeDzk0Sy2eqKNJzF6HkeH+pk16RyISS7azIc1rvLFk/DOyXxy8C fq7uXNSkKi9ZKW3iU65fGXyoDcX5dHvb+YkTk8V7Gcm0xfEAwnRotjQOKD5v5qsN7hM6FCCxf9 WRHN1IXRj6n2u6RxokUVkhsrJG2zT/qO3kLzZH9YXceChIwVJconsaLufVjO7ahA8tfU4xLA/o 7LA= X-IronPort-AV: E=Sophos;i="5.72,327,1580803200"; d="scan'208";a="47330840" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 31 Mar 2020 02:53:46 -0800 IronPort-SDR: kADlqEszrpOL5g0Sm0wizvVBT9qC12O0LcbV+NnNV9nzzynj34rq2ANpg04YrHM3HlB1DedjAv HRtdu0AwEMtSVHjwlmEhy2es1csHKKzTtJ89RBTyHhFPFihkNREejCatACpNY19FRkKXXmY7Vu ArpjuPciadgQ8IfeLN/LAMbTJzG257zzhn36mX3cMBpieFvS5B4dcCPgZYbKZKpRu4GYwU9Hzk yrK4Pdc39U1JZmriHCS7gjzE7g6zqKRXp3UkbqdN0RCLJdok/S1rQO7thEr0sqSS1ijWH8kVsV Ou4= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v10 45/55] Input: Atmel: improve error handling in mxt_start() Date: Tue, 31 Mar 2020 03:50:41 -0700 Message-ID: <20200331105051.58896-46-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331105051.58896-1-jiada_wang@mentor.com> References: <20200331105051.58896-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 bbec5a8e0bb6..0f7ee987a9c5 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3981,12 +3981,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: @@ -4000,27 +4001,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) @@ -4343,6 +4343,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; @@ -4352,11 +4353,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