CHROMIUM: input: atmel_mxt_ts - bail out early if we have no hardware
authorVincent Palatin <vpalatin@chromium.org>
Wed, 13 Feb 2013 23:29:49 +0000 (15:29 -0800)
committerChromeBot <chrome-bot@google.com>
Fri, 15 Feb 2013 19:03:57 +0000 (11:03 -0800)
When using the device tree to configure the kernel I2C devices,
the devices are not probed. So if we want to support multiple optional
peripherals, we might end up executing their probe callback.
In that case, just probe early the Atmel chip on the i2c and bail out
early if it is not present.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=chrome-os-partner:17825
TEST=boot a machine with an Atmel trackpad attached and one with Cypress
trackpad and have a working pointer on both of them.

Change-Id: I0c948cac2a38f587cc5f1efa5ba424715f25804d
Reviewed-on: https://gerrit.chromium.org/gerrit/43229
Reviewed-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
drivers/input/touchscreen/atmel_mxt_ts.c

index 8142d4f..5e40f6d 100644 (file)
@@ -2695,6 +2695,12 @@ static int __devinit mxt_probe(struct i2c_client *client,
        const struct mxt_platform_data *pdata = client->dev.platform_data;
        struct mxt_data *data;
        int error;
+       union i2c_smbus_data dummy;
+
+       /* Make sure there is something at this address */
+       if (client->dev.of_node && i2c_smbus_xfer(client->adapter, client->addr,
+                        0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0)
+               return -ENODEV;
 
        data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL);
        if (!data) {