CHROMIUM: input: cyapa - 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 18:40:01 +0000 (10:40 -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 Cypress 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: I7d8cc499c5844521fe1b0eb703001f734cc43499
Reviewed-on: https://gerrit.chromium.org/gerrit/43228
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
drivers/input/mouse/cyapa.c

index ee9e0c6..db3c328 100644 (file)
@@ -2057,6 +2057,7 @@ static int __devinit cyapa_probe(struct i2c_client *client,
        u8 adapter_func;
        struct cyapa *cyapa;
        struct device *dev = &client->dev;
+       union i2c_smbus_data dummy;
 
        adapter_func = cyapa_check_adapter_functionality(client);
        if (adapter_func == CYAPA_ADAPTER_FUNC_NONE) {
@@ -2064,6 +2065,11 @@ static int __devinit cyapa_probe(struct i2c_client *client,
                return -EIO;
        }
 
+       /* Make sure there is something at this address */
+       if (dev->of_node && i2c_smbus_xfer(client->adapter, client->addr, 0,
+                        I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0)
+               return -ENODEV;
+
        cyapa = kzalloc(sizeof(struct cyapa), GFP_KERNEL);
        if (!cyapa) {
                dev_err(dev, "allocate memory for cyapa failed\n");