aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDaniel Kurtz <djkurtz@chromium.org>2012-06-28 09:08:10 -0400
committerHenrik Rydberg <rydberg@euromail.se>2012-06-29 09:58:03 -0400
commit794eb67e76118108af5280ace2be8ae4983a6a81 (patch)
tree6c322c47a240cb3e1d60c61dce755d2bcbb74a5d /drivers/input
parent91630955cb4c9899aa4521d1459837c66c5e9c7a (diff)
Input: atmel_mxt_ts - print all instances when dumping objects
For objects with multiple instances, dump them all, prepending each with its "Instance #". [rydberg@euromail.se: break out mxt_show_instance()] 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.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index c8cfd7b3dc9e..ee37b0b0e0e4 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -877,6 +877,24 @@ static void mxt_calc_resolution(struct mxt_data *data)
877 } 877 }
878} 878}
879 879
880static ssize_t mxt_show_instance(char *buf, int count,
881 struct mxt_object *object, int instance,
882 const u8 *val)
883{
884 int i;
885
886 if (object->instances > 0)
887 count += scnprintf(buf + count, PAGE_SIZE - count,
888 "Instance %u\n", instance);
889
890 for (i = 0; i < object->size + 1; i++)
891 count += scnprintf(buf + count, PAGE_SIZE - count,
892 "\t[%2u]: %02x (%d)\n", i, val[i], val[i]);
893 count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
894
895 return count;
896}
897
880static ssize_t mxt_object_show(struct device *dev, 898static ssize_t mxt_object_show(struct device *dev,
881 struct device_attribute *attr, char *buf) 899 struct device_attribute *attr, char *buf)
882{ 900{
@@ -885,7 +903,6 @@ static ssize_t mxt_object_show(struct device *dev,
885 int count = 0; 903 int count = 0;
886 int i, j; 904 int i, j;
887 int error; 905 int error;
888 u8 val;
889 u8 *obuf; 906 u8 *obuf;
890 907
891 /* Pre-allocate buffer large enough to hold max sized object. */ 908 /* Pre-allocate buffer large enough to hold max sized object. */
@@ -903,20 +920,19 @@ static ssize_t mxt_object_show(struct device *dev,
903 count += scnprintf(buf + count, PAGE_SIZE - count, 920 count += scnprintf(buf + count, PAGE_SIZE - count,
904 "T%u:\n", object->type); 921 "T%u:\n", object->type);
905 922
906 error = __mxt_read_reg(data->client, object->start_address, 923 for (j = 0; j < object->instances + 1; j++) {
907 object->size + 1, obuf); 924 u16 size = object->size + 1;
908 if (error) 925 u16 addr = object->start_address + j * size;
909 break;
910 926
911 for (j = 0; j < object->size + 1; j++) { 927 error = __mxt_read_reg(data->client, addr, size, obuf);
912 val = obuf[j]; 928 if (error)
929 goto done;
913 930
914 count += scnprintf(buf + count, PAGE_SIZE - count, 931 count = mxt_show_instance(buf, count, object, j, obuf);
915 "\t[%2d]: %02x (%d)\n", j, val, val);
916 } 932 }
917 count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
918 } 933 }
919 934
935done:
920 kfree(obuf); 936 kfree(obuf);
921 return error ?: count; 937 return error ?: count;
922} 938}