Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -14
+8 -14
drivers/input/rmi4/rmi_f34v7.c
··· 9 9 * the Free Software Foundation. 10 10 */ 11 11 12 + #include <linux/bitops.h> 12 13 #include <linux/kernel.h> 13 14 #include <linux/rmi.h> 14 15 #include <linux/firmware.h> 15 - #include <asm/unaligned.h> 16 16 #include <linux/delay.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/jiffies.h> 19 + #include <asm/unaligned.h> 19 20 20 21 #include "rmi_driver.h" 21 22 #include "rmi_f34.h" ··· 465 464 static int rmi_f34v7_read_queries(struct f34_data *f34) 466 465 { 467 466 int ret; 468 - int i, j; 467 + int i; 469 468 u8 base; 470 469 int offset; 471 470 u8 *ptable; ··· 520 519 521 520 if (query_0 & HAS_CONFIG_ID) { 522 521 u8 f34_ctrl[CONFIG_ID_SIZE]; 523 - int i = 0; 524 - u8 *p = f34->configuration_id; 525 - *p = '\0'; 526 522 527 523 ret = rmi_read_block(f34->fn->rmi_dev, 528 524 f34->fn->fd.control_base_addr, ··· 529 531 return ret; 530 532 531 533 /* Eat leading zeros */ 532 - while (i < sizeof(f34_ctrl) && !f34_ctrl[i]) 533 - i++; 534 + for (i = 0; i < sizeof(f34_ctrl) - 1 && !f34_ctrl[i]; i++) 535 + /* Empty */; 534 536 535 - for (; i < sizeof(f34_ctrl); i++) 536 - p += snprintf(p, f34->configuration_id 537 - + sizeof(f34->configuration_id) - p, 538 - "%02X", f34_ctrl[i]); 537 + snprintf(f34->configuration_id, sizeof(f34->configuration_id), 538 + "%*phN", (int)sizeof(f34_ctrl) - i, f34_ctrl + i); 539 539 540 540 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n", 541 541 f34->configuration_id); ··· 541 545 542 546 f34->v7.partitions = 0; 543 547 for (i = 0; i < sizeof(query_1_7.partition_support); i++) 544 - for (j = 0; j < 8; j++) 545 - if (query_1_7.partition_support[i] & (1 << j)) 546 - f34->v7.partitions++; 548 + f34->v7.partitions += hweight8(query_1_7.partition_support[i]); 547 549 548 550 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n", 549 551 __func__, sizeof(query_1_7.partition_support),