diff mbox

[7/7] input: atmel_mxt_ts: check if all config pdata has been written to object table

Message ID 1360246668-2291-8-git-send-email-pmeerw@pmeerw.net (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Meerwald-Stadler Feb. 7, 2013, 2:17 p.m. UTC
From: Peter Meerwald <p.meerwald@bct-electronic.com>

firmware revisions may introduce or alter device objects; error out if there
is an inconsistency (otherwise the device may silently fail)

mxt_platform_data.config is dangerous because the data must match the device object
exactly; if the order or size changes, or if device object disappear, garbage is written
to the device

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
---
 drivers/input/touchscreen/atmel_mxt_ts.c |    5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 7ade272..b85fb30 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -636,6 +636,11 @@  static int mxt_check_reg_init(struct mxt_data *data)
 		index += size;
 	}
 
+	if (index != pdata->config_length) {
+		dev_err(dev, "Config data inconsistent with device objects!\n");
+		return -EINVAL;
+	}
+
 	return 0;
 }