diff options
author | Daniel Kurtz <djkurtz@chromium.org> | 2012-06-28 09:08:07 -0400 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2012-06-29 09:58:03 -0400 |
commit | 9c67b789e051449d3914d683ba3604c5babc4dd9 (patch) | |
tree | d1ac672c53479b2d35331df441ea4e20d10602ae /drivers/input/touchscreen | |
parent | 55d6867fe659f4783e57db7b2ae0bb04e4ac816e (diff) |
Input: atmel_mxt_ts - use scnprintf for object sysfs entry
Using scnprintf() is a cleaner way to ensure that we don't overwrite the
PAGE_SIZE sysfs output buffer.
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 9f8dd973e5f5..55855b8c2efd 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -904,17 +904,13 @@ static ssize_t mxt_object_show(struct device *dev, | |||
904 | for (i = 0; i < data->info.object_num; i++) { | 904 | for (i = 0; i < data->info.object_num; i++) { |
905 | object = data->object_table + i; | 905 | object = data->object_table + i; |
906 | 906 | ||
907 | count += snprintf(buf + count, PAGE_SIZE - count, | 907 | count += scnprintf(buf + count, PAGE_SIZE - count, |
908 | "Object[%d] (Type %d)\n", | 908 | "Object[%d] (Type %d)\n", |
909 | i + 1, object->type); | 909 | i + 1, object->type); |
910 | if (count >= PAGE_SIZE) | ||
911 | return PAGE_SIZE - 1; | ||
912 | 910 | ||
913 | if (!mxt_object_readable(object->type)) { | 911 | if (!mxt_object_readable(object->type)) { |
914 | count += snprintf(buf + count, PAGE_SIZE - count, | 912 | count += scnprintf(buf + count, PAGE_SIZE - count, |
915 | "\n"); | 913 | "\n"); |
916 | if (count >= PAGE_SIZE) | ||
917 | return PAGE_SIZE - 1; | ||
918 | continue; | 914 | continue; |
919 | } | 915 | } |
920 | 916 | ||
@@ -924,15 +920,11 @@ static ssize_t mxt_object_show(struct device *dev, | |||
924 | if (error) | 920 | if (error) |
925 | return error; | 921 | return error; |
926 | 922 | ||
927 | count += snprintf(buf + count, PAGE_SIZE - count, | 923 | count += scnprintf(buf + count, PAGE_SIZE - count, |
928 | "\t[%2d]: %02x (%d)\n", j, val, val); | 924 | "\t[%2d]: %02x (%d)\n", j, val, val); |
929 | if (count >= PAGE_SIZE) | ||
930 | return PAGE_SIZE - 1; | ||
931 | } | 925 | } |
932 | 926 | ||
933 | count += snprintf(buf + count, PAGE_SIZE - count, "\n"); | 927 | count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); |
934 | if (count >= PAGE_SIZE) | ||
935 | return PAGE_SIZE - 1; | ||
936 | } | 928 | } |
937 | 929 | ||
938 | return count; | 930 | return count; |