diff options
author | Sven Van Asbroeck <svenv@arcx.com> | 2012-10-01 12:16:38 -0400 |
---|---|---|
committer | Eric Nelson <eric.nelson@boundarydevices.com> | 2013-02-12 10:46:51 -0700 |
commit | 4eb6f49453af284e31be76c2d0fdce99957e0ef7 (patch) | |
tree | 0381b4ed0181cb7724df3a1742a951342e72f356 | |
parent | ece5aa7de11df34d89215415938408832ccf8773 (diff) |
Fix detect of focaltech-ft5x06 5-finger multi-touch device.
Signed-off-by: Sven Van Asbroeck <info@arcx.com>
-rw-r--r-- | drivers/input/touchscreen/ft5x06_ts.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/drivers/input/touchscreen/ft5x06_ts.c b/drivers/input/touchscreen/ft5x06_ts.c index 24cfe3fab381..89b57265f7e8 100644 --- a/drivers/input/touchscreen/ft5x06_ts.c +++ b/drivers/input/touchscreen/ft5x06_ts.c @@ -444,16 +444,33 @@ static void ts_shutdown(struct ft5x06_ts *ts) /*-----------------------------------------------------------------------*/ /* Return 0 if detection is successful, -ENODEV otherwise */ -static int ts_detect(struct i2c_client *client, - struct i2c_board_info *info) +static int detect_ft5x06(struct i2c_client *client) { struct i2c_adapter *adapter = client->adapter; + char buffer; + struct i2c_msg pkt = { + client->addr, + I2C_M_RD, + sizeof(buffer), + &buffer + }; if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) return -ENODEV; - strlcpy(info->type, "ft5x06-ts", I2C_NAME_SIZE); + if (i2c_transfer(adapter, &pkt, 1) != 1) + return -ENODEV; return 0; } +/* Return 0 if detection is successful, -ENODEV otherwise */ +static int ts_detect(struct i2c_client *client, + struct i2c_board_info *info) +{ + int err = detect_ft5x06(client); + if (!err) + strlcpy(info->type, "ft5x06-ts", I2C_NAME_SIZE); + return err; +} + static int ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = 0; @@ -464,6 +481,11 @@ static int ts_probe(struct i2c_client *client, const struct i2c_device_id *id) client_name); return -ENOMEM; } + if (detect_ft5x06(client) != 0) { + dev_err(dev, "%s: Could not detect touch screen.\n", + client_name); + return -ENODEV; + } ts = kzalloc(sizeof(struct ft5x06_ts), GFP_KERNEL); if (!ts) { dev_err(dev, "Couldn't allocate memory for %s\n", client_name); |