diff options
author | Daniel Kurtz <djkurtz@chromium.org> | 2012-06-28 09:08:08 -0400 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2012-06-29 09:58:03 -0400 |
commit | 43a91d51d3750dd9d5a6e5d14e9250a51f01f3c1 (patch) | |
tree | 2f7cc6669eb4ff43f8b2f3dc5488ba1f5f4da6cd /drivers/input | |
parent | 9c67b789e051449d3914d683ba3604c5babc4dd9 (diff) |
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>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 55855b8c2efd..94dd1d156a98 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -479,20 +479,6 @@ static int mxt_read_message(struct mxt_data *data, | |||
479 | sizeof(struct mxt_message), message); | 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 | static int mxt_write_object(struct mxt_data *data, | 482 | static int mxt_write_object(struct mxt_data *data, |
497 | u8 type, u8 offset, u8 val) | 483 | u8 type, u8 offset, u8 val) |
498 | { | 484 | { |
@@ -900,7 +886,14 @@ static ssize_t mxt_object_show(struct device *dev, | |||
900 | int i, j; | 886 | int i, j; |
901 | int error; | 887 | int error; |
902 | u8 val; | 888 | u8 val; |
889 | u8 *obuf; | ||
890 | |||
891 | /* Pre-allocate buffer large enough to hold max sized object. */ | ||
892 | obuf = kmalloc(256, GFP_KERNEL); | ||
893 | if (!obuf) | ||
894 | return -ENOMEM; | ||
903 | 895 | ||
896 | error = 0; | ||
904 | for (i = 0; i < data->info.object_num; i++) { | 897 | for (i = 0; i < data->info.object_num; i++) { |
905 | object = data->object_table + i; | 898 | object = data->object_table + i; |
906 | 899 | ||
@@ -914,20 +907,22 @@ static ssize_t mxt_object_show(struct device *dev, | |||
914 | continue; | 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 | for (j = 0; j < object->size + 1; j++) { | 915 | for (j = 0; j < object->size + 1; j++) { |
918 | error = mxt_read_object(data, | 916 | val = obuf[j]; |
919 | object->type, j, &val); | ||
920 | if (error) | ||
921 | return error; | ||
922 | 917 | ||
923 | count += scnprintf(buf + count, PAGE_SIZE - count, | 918 | count += scnprintf(buf + count, PAGE_SIZE - count, |
924 | "\t[%2d]: %02x (%d)\n", j, val, val); | 919 | "\t[%2d]: %02x (%d)\n", j, val, val); |
925 | } | 920 | } |
926 | |||
927 | count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); | 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 | static int mxt_load_fw(struct device *dev, const char *fn) | 928 | static int mxt_load_fw(struct device *dev, const char *fn) |