Commit 43a91d51d3750dd9d5a6e5d14e9250a51f01f3c1
Committed by
Henrik Rydberg
1 parent
9c67b789e0
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
Input: atmel_mxt_ts - optimize reading objects in object sysfs entry
Read each object in a single i2c transaction instead of byte-by-byte Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Showing 1 changed file with 15 additions and 20 deletions Side-by-side Diff
drivers/input/touchscreen/atmel_mxt_ts.c
... | ... | @@ -479,20 +479,6 @@ |
479 | 479 | sizeof(struct mxt_message), message); |
480 | 480 | } |
481 | 481 | |
482 | -static int mxt_read_object(struct mxt_data *data, | |
483 | - u8 type, u8 offset, u8 *val) | |
484 | -{ | |
485 | - struct mxt_object *object; | |
486 | - u16 reg; | |
487 | - | |
488 | - object = mxt_get_object(data, type); | |
489 | - if (!object) | |
490 | - return -EINVAL; | |
491 | - | |
492 | - reg = object->start_address; | |
493 | - return __mxt_read_reg(data->client, reg + offset, 1, val); | |
494 | -} | |
495 | - | |
496 | 482 | static int mxt_write_object(struct mxt_data *data, |
497 | 483 | u8 type, u8 offset, u8 val) |
498 | 484 | { |
499 | 485 | |
... | ... | @@ -900,7 +886,14 @@ |
900 | 886 | int i, j; |
901 | 887 | int error; |
902 | 888 | u8 val; |
889 | + u8 *obuf; | |
903 | 890 | |
891 | + /* Pre-allocate buffer large enough to hold max sized object. */ | |
892 | + obuf = kmalloc(256, GFP_KERNEL); | |
893 | + if (!obuf) | |
894 | + return -ENOMEM; | |
895 | + | |
896 | + error = 0; | |
904 | 897 | for (i = 0; i < data->info.object_num; i++) { |
905 | 898 | object = data->object_table + i; |
906 | 899 | |
907 | 900 | |
908 | 901 | |
909 | 902 | |
... | ... | @@ -914,20 +907,22 @@ |
914 | 907 | continue; |
915 | 908 | } |
916 | 909 | |
910 | + error = __mxt_read_reg(data->client, object->start_address, | |
911 | + object->size + 1, obuf); | |
912 | + if (error) | |
913 | + break; | |
914 | + | |
917 | 915 | for (j = 0; j < object->size + 1; j++) { |
918 | - error = mxt_read_object(data, | |
919 | - object->type, j, &val); | |
920 | - if (error) | |
921 | - return error; | |
916 | + val = obuf[j]; | |
922 | 917 | |
923 | 918 | count += scnprintf(buf + count, PAGE_SIZE - count, |
924 | 919 | "\t[%2d]: %02x (%d)\n", j, val, val); |
925 | 920 | } |
926 | - | |
927 | 921 | count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); |
928 | 922 | } |
929 | 923 | |
930 | - return count; | |
924 | + kfree(obuf); | |
925 | + return error ?: count; | |
931 | 926 | } |
932 | 927 | |
933 | 928 | static int mxt_load_fw(struct device *dev, const char *fn) |