Input: atmel_mxt_ts - handle objects with multiple instances correctly
authorIiro Valkonen <iiro.valkonen@atmel.com>
Mon, 4 Jul 2011 10:16:25 +0000 (03:16 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 4 Jul 2011 10:19:20 +0000 (03:19 -0700)
Handle the objects with multiple instances correctly when the configuration
data is loaded.

Signed-off-by: Iiro Valkonen <iiro.valkonen@atmel.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/touchscreen/atmel_mxt_ts.c

index 5d71e4475934511aeddb40f00ce7e2c6303131b9..ae00604a6a81d8c1cf37d65823d14eb728e36e3a 100644 (file)
@@ -655,7 +655,9 @@ static int mxt_check_reg_init(struct mxt_data *data)
                if (!mxt_object_writable(object->type))
                        continue;
 
-               for (j = 0; j < object->size + 1; j++) {
+               for (j = 0;
+                    j < (object->size + 1) * (object->instances + 1);
+                    j++) {
                        config_offset = index + j;
                        if (config_offset > pdata->config_length) {
                                dev_err(dev, "Not enough config data!\n");
@@ -664,7 +666,7 @@ static int mxt_check_reg_init(struct mxt_data *data)
                        mxt_write_object(data, object->type, j,
                                         pdata->config[config_offset]);
                }
-               index += object->size + 1;
+               index += (object->size + 1) * (object->instances + 1);
        }
 
        return 0;