aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorNick Dyer <nick.dyer@itdev.co.uk>2014-05-19 02:15:01 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-05-19 02:27:29 -0400
commitf2ac6cb9201399fa2b2146ea941c0c5ce2aa197a (patch)
treecab7365f543878d3f3358ab0141889e45ace6601 /drivers/input
parentf477c7588bb167191f4162a380680204807316b7 (diff)
Input: atmel_mxt_ts - add check for incorrect firmware file format
Atmel supplies firmware files in ASCII HEX format (.enc) which must be converted before they can be loaded by kernel driver. Try to detect the error and print a friendly error message rather than feeding junk to the bootloader. Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> Acked-by: Benson Leung <bleung@chromium.org> Acked-by: Yufeng Shen <miletus@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 9bf32c3b53aa..7a9197a19f67 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1185,6 +1185,30 @@ done:
1185 return error ?: count; 1185 return error ?: count;
1186} 1186}
1187 1187
1188static int mxt_check_firmware_format(struct device *dev,
1189 const struct firmware *fw)
1190{
1191 unsigned int pos = 0;
1192 char c;
1193
1194 while (pos < fw->size) {
1195 c = *(fw->data + pos);
1196
1197 if (c < '0' || (c > '9' && c < 'A') || c > 'F')
1198 return 0;
1199
1200 pos++;
1201 }
1202
1203 /*
1204 * To convert file try:
1205 * xxd -r -p mXTXXX__APP_VX-X-XX.enc > maxtouch.fw
1206 */
1207 dev_err(dev, "Aborting: firmware file must be in binary format\n");
1208
1209 return -EINVAL;
1210}
1211
1188static int mxt_load_fw(struct device *dev, const char *fn) 1212static int mxt_load_fw(struct device *dev, const char *fn)
1189{ 1213{
1190 struct mxt_data *data = dev_get_drvdata(dev); 1214 struct mxt_data *data = dev_get_drvdata(dev);
@@ -1201,6 +1225,11 @@ static int mxt_load_fw(struct device *dev, const char *fn)
1201 return ret; 1225 return ret;
1202 } 1226 }
1203 1227
1228 /* Check for incorrect enc file */
1229 ret = mxt_check_firmware_format(dev, fw);
1230 if (ret)
1231 goto release_firmware;
1232
1204 ret = mxt_lookup_bootloader_address(data); 1233 ret = mxt_lookup_bootloader_address(data);
1205 if (ret) 1234 if (ret)
1206 goto release_firmware; 1235 goto release_firmware;