diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-05-29 23:22:34 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-06-02 01:11:23 -0400 |
commit | 49bbbfa8d27a227521a9e07cb1612f60e8f0e8ff (patch) | |
tree | 4e765f94333348f6471153a12730c8edd2d4e898 | |
parent | 32a62b9441d840e676d55b45468371c252a4fa01 (diff) |
Input: synaptics-rmi4 - use %phN to form F34 configuration ID
Instead of printing bytes one by one, let's use %phN to print the buffer in
one go.
Also use hweight8 to count number of partitions instead of inspecting it
bit by bit.
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: Nick Dyer <nick@shmanahar.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/rmi4/rmi_f34v7.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c index ae2db1c3aebf..3991d2943660 100644 --- a/drivers/input/rmi4/rmi_f34v7.c +++ b/drivers/input/rmi4/rmi_f34v7.c | |||
@@ -9,13 +9,14 @@ | |||
9 | * the Free Software Foundation. | 9 | * the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/bitops.h> | ||
12 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
13 | #include <linux/rmi.h> | 14 | #include <linux/rmi.h> |
14 | #include <linux/firmware.h> | 15 | #include <linux/firmware.h> |
15 | #include <asm/unaligned.h> | ||
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/jiffies.h> | 18 | #include <linux/jiffies.h> |
19 | #include <asm/unaligned.h> | ||
19 | 20 | ||
20 | #include "rmi_driver.h" | 21 | #include "rmi_driver.h" |
21 | #include "rmi_f34.h" | 22 | #include "rmi_f34.h" |
@@ -464,7 +465,7 @@ static int rmi_f34v7_read_queries_bl_version(struct f34_data *f34) | |||
464 | static int rmi_f34v7_read_queries(struct f34_data *f34) | 465 | static int rmi_f34v7_read_queries(struct f34_data *f34) |
465 | { | 466 | { |
466 | int ret; | 467 | int ret; |
467 | int i, j; | 468 | int i; |
468 | u8 base; | 469 | u8 base; |
469 | int offset; | 470 | int offset; |
470 | u8 *ptable; | 471 | u8 *ptable; |
@@ -519,9 +520,6 @@ static int rmi_f34v7_read_queries(struct f34_data *f34) | |||
519 | 520 | ||
520 | if (query_0 & HAS_CONFIG_ID) { | 521 | if (query_0 & HAS_CONFIG_ID) { |
521 | u8 f34_ctrl[CONFIG_ID_SIZE]; | 522 | u8 f34_ctrl[CONFIG_ID_SIZE]; |
522 | int i = 0; | ||
523 | u8 *p = f34->configuration_id; | ||
524 | *p = '\0'; | ||
525 | 523 | ||
526 | ret = rmi_read_block(f34->fn->rmi_dev, | 524 | ret = rmi_read_block(f34->fn->rmi_dev, |
527 | f34->fn->fd.control_base_addr, | 525 | f34->fn->fd.control_base_addr, |
@@ -531,13 +529,11 @@ static int rmi_f34v7_read_queries(struct f34_data *f34) | |||
531 | return ret; | 529 | return ret; |
532 | 530 | ||
533 | /* Eat leading zeros */ | 531 | /* Eat leading zeros */ |
534 | while (i < sizeof(f34_ctrl) && !f34_ctrl[i]) | 532 | for (i = 0; i < sizeof(f34_ctrl) - 1 && !f34_ctrl[i]; i++) |
535 | i++; | 533 | /* Empty */; |
536 | 534 | ||
537 | for (; i < sizeof(f34_ctrl); i++) | 535 | snprintf(f34->configuration_id, sizeof(f34->configuration_id), |
538 | p += snprintf(p, f34->configuration_id | 536 | "%*phN", (int)sizeof(f34_ctrl) - i, f34_ctrl + i); |
539 | + sizeof(f34->configuration_id) - p, | ||
540 | "%02X", f34_ctrl[i]); | ||
541 | 537 | ||
542 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n", | 538 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n", |
543 | f34->configuration_id); | 539 | f34->configuration_id); |
@@ -545,9 +541,7 @@ static int rmi_f34v7_read_queries(struct f34_data *f34) | |||
545 | 541 | ||
546 | f34->v7.partitions = 0; | 542 | f34->v7.partitions = 0; |
547 | for (i = 0; i < sizeof(query_1_7.partition_support); i++) | 543 | for (i = 0; i < sizeof(query_1_7.partition_support); i++) |
548 | for (j = 0; j < 8; j++) | 544 | f34->v7.partitions += hweight8(query_1_7.partition_support[i]); |
549 | if (query_1_7.partition_support[i] & (1 << j)) | ||
550 | f34->v7.partitions++; | ||
551 | 545 | ||
552 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n", | 546 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n", |
553 | __func__, sizeof(query_1_7.partition_support), | 547 | __func__, sizeof(query_1_7.partition_support), |