Commit 49bbbfa8 authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: default avatarNick Dyer <nick@shmanahar.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 32a62b94
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
* the Free Software Foundation. * the Free Software Foundation.
*/ */
#include <linux/bitops.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/rmi.h> #include <linux/rmi.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <asm/unaligned.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <asm/unaligned.h>
#include "rmi_driver.h" #include "rmi_driver.h"
#include "rmi_f34.h" #include "rmi_f34.h"
...@@ -464,7 +465,7 @@ static int rmi_f34v7_read_queries_bl_version(struct f34_data *f34) ...@@ -464,7 +465,7 @@ static int rmi_f34v7_read_queries_bl_version(struct f34_data *f34)
static int rmi_f34v7_read_queries(struct f34_data *f34) static int rmi_f34v7_read_queries(struct f34_data *f34)
{ {
int ret; int ret;
int i, j; int i;
u8 base; u8 base;
int offset; int offset;
u8 *ptable; u8 *ptable;
...@@ -519,9 +520,6 @@ static int rmi_f34v7_read_queries(struct f34_data *f34) ...@@ -519,9 +520,6 @@ static int rmi_f34v7_read_queries(struct f34_data *f34)
if (query_0 & HAS_CONFIG_ID) { if (query_0 & HAS_CONFIG_ID) {
u8 f34_ctrl[CONFIG_ID_SIZE]; u8 f34_ctrl[CONFIG_ID_SIZE];
int i = 0;
u8 *p = f34->configuration_id;
*p = '\0';
ret = rmi_read_block(f34->fn->rmi_dev, ret = rmi_read_block(f34->fn->rmi_dev,
f34->fn->fd.control_base_addr, f34->fn->fd.control_base_addr,
...@@ -531,13 +529,11 @@ static int rmi_f34v7_read_queries(struct f34_data *f34) ...@@ -531,13 +529,11 @@ static int rmi_f34v7_read_queries(struct f34_data *f34)
return ret; return ret;
/* Eat leading zeros */ /* Eat leading zeros */
while (i < sizeof(f34_ctrl) && !f34_ctrl[i]) for (i = 0; i < sizeof(f34_ctrl) - 1 && !f34_ctrl[i]; i++)
i++; /* Empty */;
for (; i < sizeof(f34_ctrl); i++) snprintf(f34->configuration_id, sizeof(f34->configuration_id),
p += snprintf(p, f34->configuration_id "%*phN", (int)sizeof(f34_ctrl) - i, f34_ctrl + i);
+ sizeof(f34->configuration_id) - p,
"%02X", f34_ctrl[i]);
rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n", rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n",
f34->configuration_id); f34->configuration_id);
...@@ -545,9 +541,7 @@ static int rmi_f34v7_read_queries(struct f34_data *f34) ...@@ -545,9 +541,7 @@ static int rmi_f34v7_read_queries(struct f34_data *f34)
f34->v7.partitions = 0; f34->v7.partitions = 0;
for (i = 0; i < sizeof(query_1_7.partition_support); i++) for (i = 0; i < sizeof(query_1_7.partition_support); i++)
for (j = 0; j < 8; j++) f34->v7.partitions += hweight8(query_1_7.partition_support[i]);
if (query_1_7.partition_support[i] & (1 << j))
f34->v7.partitions++;
rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n", rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n",
__func__, sizeof(query_1_7.partition_support), __func__, sizeof(query_1_7.partition_support),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment