Skip to content

Commit

Permalink
Input: atmel_mxt_ts - Fix bugs in config upgrade
Browse files Browse the repository at this point in the history
Address a couple of bugs in the handling of objects in the config file which
are different lengths to on the chip.

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Signed-off-by: Atul Tiwari <atul.tiwari@atmel.com>
  • Loading branch information
ndyer committed May 24, 2013
1 parent 43e07e2 commit c48e916
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/input/touchscreen/atmel_mxt_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,9 @@ static int mxt_check_reg_init(struct mxt_data *data)
ret = sscanf(cfg->data + data_pos, "%hhx%n",
&val,
&offset);
data_pos += offset;
}
continue;
}

if (instance >= mxt_obj_instances(object)) {
Expand All @@ -1509,10 +1511,8 @@ static int mxt_check_reg_init(struct mxt_data *data)
/* Either we are in fallback mode due to wrong
* config or config from a later fw version,
* or the file is corrupt or hand-edited */
dev_warn(dev, "Discarding %u bytes in T%u!\n",
dev_warn(dev, "Discarding %u byte(s) in T%u\n",
size - mxt_obj_size(object), type);

size = mxt_obj_size(object);
} else if (mxt_obj_size(object) > size) {
/* If firmware is upgraded, new bytes may be added to
* end of objects. It is generally forward compatible
Expand All @@ -1521,7 +1521,7 @@ static int mxt_check_reg_init(struct mxt_data *data)
* will force fallback mode until the configuration is
* updated. We warn here but do nothing else - the
* malloc has zeroed the entire configuration. */
dev_warn(dev, "Zeroing %d byte(s) in T%d\n",
dev_warn(dev, "Zeroing %u byte(s) in T%d\n",
mxt_obj_size(object) - size, type);
}

Expand All @@ -1535,6 +1535,9 @@ static int mxt_check_reg_init(struct mxt_data *data)
goto release_mem;
}

if (i > mxt_obj_size(object))
continue;

byte_offset = reg + i - cfg_start_ofs;

if ((byte_offset >= 0)
Expand Down

0 comments on commit c48e916

Please sign in to comment.