All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: melfas_mip4 - ensure that device is present
@ 2017-03-27  5:48 Dmitry Torokhov
  0 siblings, 0 replies; only message in thread
From: Dmitry Torokhov @ 2017-03-27  5:48 UTC (permalink / raw)
  To: linux-input; +Cc: Sangwon Jee, djkurtz, milton.chiang, linux-kernel

Try a quick read from the device in mip4_query_device() to make sure
that the device is there, as we do not consider failures to retrieve
product name or resolution fatal.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/melfas_mip4.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 703d7f983d0a..05108c2fea93 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -253,10 +253,21 @@ static int mip4_get_fw_version(struct mip4_ts *ts)
  */
 static int mip4_query_device(struct mip4_ts *ts)
 {
+	union i2c_smbus_data dummy;
 	int error;
 	u8 cmd[2];
 	u8 buf[14];
 
+	/*
+	 * Make sure there is something at this address as we do not
+	 * consider subsequent failures as fatal.
+	 */
+	if (i2c_smbus_xfer(ts->client->adapter, ts->client->addr,
+			   0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) {
+		dev_err(&ts->client->dev, "nothing at this address\n");
+		return -ENXIO;
+	}
+
 	/* Product name */
 	cmd[0] = MIP4_R0_INFO;
 	cmd[1] = MIP4_R1_INFO_PRODUCT_NAME;
-- 
2.12.1.578.ge9c3154ca4-goog


-- 
Dmitry

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-27  5:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-27  5:48 [PATCH] Input: melfas_mip4 - ensure that device is present Dmitry Torokhov

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.