All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@de.bosch.com>
To: linux-input@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Henrik Rydberg <rydberg@bitmath.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Oleksij Rempel <linux@rempel-privat.de>,
	Oleksij Rempel <fixed-term.Oleksij.Rempel@de.bosch.com>,
	Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Subject: [PATCH v3 2/4] Input: zforce_ts: allow open even if initialisation is not completed
Date: Wed, 4 May 2016 12:24:39 +0200	[thread overview]
Message-ID: <1462357481-16258-3-git-send-email-dirk.behme@de.bosch.com> (raw)
In-Reply-To: <1462357481-16258-1-git-send-email-dirk.behme@de.bosch.com>

From: Oleksij Rempel <linux@rempel-privat.de>

Make sure zforce_start() is not called if FW init was not completed.

Signed-off-by: Oleksij Rempel <fixed-term.Oleksij.Rempel@de.bosch.com>
Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
---
 drivers/input/touchscreen/zforce_ts.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 9839d86..c912a0b 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -102,7 +102,6 @@ struct zforce_point {
 enum zforce_state {
 	ZF_STATE_UNINITIALZED = 0,
 	ZF_STATE_PROBE_COMPLETE,
-	ZF_STATE_DEV_OPENED,
 };
 
 /*
@@ -150,6 +149,7 @@ struct zforce_ts {
 	int			notification;
 
 	enum zforce_state	state;
+	atomic_t		opened;
 };
 
 static int zforce_command(struct zforce_ts *ts, u8 cmd)
@@ -647,12 +647,13 @@ static void zforce_boot(struct zforce_ts *ts)
 
 		ts->state = ZF_STATE_PROBE_COMPLETE;
 		break;
-	case ZF_STATE_DEV_OPENED:
-		ret = zforce_start(ts);
-		if (ret)
-			dev_err(dev, "Failed to restart, %d\n", ret);
-		break;
 	}
+
+	if (!atomic_read(&ts->opened))
+		return;
+
+	if (zforce_start(ts))
+		dev_err(dev, "Failed to restart, %d\n", ret);
 }
 
 static void zforce_notification_queue(struct work_struct *work)
@@ -690,11 +691,13 @@ static int zforce_input_open(struct input_dev *dev)
 	struct zforce_ts *ts = input_get_drvdata(dev);
 	int ret;
 
-	ret = zforce_start(ts);
-	if (ret)
-		return ret;
+	if (ts->state == ZF_STATE_PROBE_COMPLETE) {
+		ret = zforce_start(ts);
+		if (ret)
+			return ret;
+	}
 
-	ts->state = ZF_STATE_DEV_OPENED;
+	atomic_inc(&ts->opened);
 
 	return 0;
 }
@@ -709,7 +712,7 @@ static void zforce_input_close(struct input_dev *dev)
 	if (ret)
 		dev_warn(&client->dev, "stopping zforce failed\n");
 
-	ts->state = ZF_STATE_PROBE_COMPLETE;
+	atomic_dec(&ts->opened);
 
 	return;
 }
-- 
1.9.1


  parent reply	other threads:[~2016-05-04 10:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-04 10:24 [PATCH v3 0/4] zForce upstreaming Dirk Behme
2016-05-04 10:24 ` [PATCH v3 1/4] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
2016-05-04 10:24 ` Dirk Behme [this message]
2016-05-04 10:24 ` [PATCH v3 3/4] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
2016-07-06 19:59   ` Dmitry Torokhov
2016-05-04 10:24 ` [PATCH v3 4/4] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
2016-05-19  5:26 ` [PATCH v3 0/4] zForce upstreaming Dirk Behme
2016-06-10  7:43 ` AW: " FIXED-TERM Rempel Oleksij (CM/ESO3)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462357481-16258-3-git-send-email-dirk.behme@de.bosch.com \
    --to=dirk.behme@de.bosch.com \
    --cc=Knut.Wohlrab@de.bosch.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=fixed-term.Oleksij.Rempel@de.bosch.com \
    --cc=javier@osg.samsung.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=rydberg@bitmath.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.