Skip to contentSkip to conversation

OLPC: use %*ph specifier instead of passing direct values

PATCH In review Andy Shevchenko 3 participants 4 messages Dec 29, 2014 – Oct 6, 2015 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OLPC: use %*ph specifier instead of passing direct values

The %*ph specifier allows to dump small buffers in hex format. Let's use it instead of passing direct values via stack.

---
 drivers/platform/olpc/olpc-ec.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/platform/olpc/olpc-ec.c +5 -8
index f911952..f99b183 100644
@@ -192,18 +192,15 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 	for (i = 0; i <= ec_cmd_bytes; i++)
 		ec_cmd[i] = ec_cmd_int[i];
 
-	pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %02x %02x %02x %02x %02x, want %d returns\n",
-			ec_cmd[0], ec_cmd_bytes, ec_cmd[1], ec_cmd[2],
-			ec_cmd[3], ec_cmd[4], ec_cmd[5], ec_dbgfs_resp_bytes);
+	pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %5ph, want %d returns\n",
+			ec_cmd[0], ec_cmd_bytes, ec_cmd + 1,
+			ec_dbgfs_resp_bytes);
 
 	olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : &ec_cmd[1],
 			ec_cmd_bytes, ec_dbgfs_resp, ec_dbgfs_resp_bytes);
 
-	pr_debug("olpc-ec: response %02x %02x %02x %02x %02x %02x %02x %02x (%d bytes expected)\n",
-			ec_dbgfs_resp[0], ec_dbgfs_resp[1], ec_dbgfs_resp[2],
-			ec_dbgfs_resp[3], ec_dbgfs_resp[4], ec_dbgfs_resp[5],
-			ec_dbgfs_resp[6], ec_dbgfs_resp[7],
-			ec_dbgfs_resp_bytes);
+	pr_debug("olpc-ec: response %8ph (%d bytes expected)\n",
+			ec_dbgfs_resp, ec_dbgfs_resp_bytes);
 
 out:
 	mutex_unlock(&ec_dbgfs_lock);
Signature · 1 line
2.1.3
Acked-by on v1 1/1
#1 lore raw

change looks okay to me.

paul

Quoted 38 lines · andy

The %*ph specifier allows to dump small buffers in hex format. Let's use it instead of passing direct values via stack.

---
 drivers/platform/olpc/olpc-ec.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/platform/olpc/olpc-ec.c +5 -8
index f911952..f99b183 100644
@@ -192,18 +192,15 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 	for (i = 0; i <= ec_cmd_bytes; i++)
 		ec_cmd[i] = ec_cmd_int[i];
 
-	pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %02x %02x %02x %02x %02x, want %d returns\n",
-			ec_cmd[0], ec_cmd_bytes, ec_cmd[1], ec_cmd[2],
-			ec_cmd[3], ec_cmd[4], ec_cmd[5], ec_dbgfs_resp_bytes);
+	pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %5ph, want %d returns\n",
+			ec_cmd[0], ec_cmd_bytes, ec_cmd + 1,
+			ec_dbgfs_resp_bytes);
 
 	olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : &ec_cmd[1],
 			ec_cmd_bytes, ec_dbgfs_resp, ec_dbgfs_resp_bytes);
 
-	pr_debug("olpc-ec: response %02x %02x %02x %02x %02x %02x %02x %02x (%d bytes expected)\n",
-			ec_dbgfs_resp[0], ec_dbgfs_resp[1], ec_dbgfs_resp[2],
-			ec_dbgfs_resp[3], ec_dbgfs_resp[4], ec_dbgfs_resp[5],
-			ec_dbgfs_resp[6], ec_dbgfs_resp[7],
-			ec_dbgfs_resp_bytes);
+	pr_debug("olpc-ec: response %8ph (%d bytes expected)\n",
+			ec_dbgfs_resp, ec_dbgfs_resp_bytes);
 
 out:
 	mutex_unlock(&ec_dbgfs_lock);
Signature · 1 line
2.1.3

=---------------------
paul fox, [email protected]

#2 lore raw
Quoted 3 lines · Paul Fox

change looks okay to me.

Darren, maybe you can apply this one? Seems OLPC is x86-based.

Quoted 56 lines

paul

Quoted 1 line · andy

The %*ph specifier allows to dump small buffers in hex format.

Let's use it

Review

Quoted 8 lines

instead of passing direct values via stack.

---
 drivers/platform/olpc/olpc-ec.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/platform/olpc/olpc-ec.c

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct

Quoted 4 lines

index f911952..f99b183 100644

drivers/platform/olpc/olpc-ec.c +0 -0
@@ -192,18 +192,15 @@ static ssize_t ec_dbgfs_cmd_write(struct 

file *file, const char __user *buf,

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,

Quoted 4 lines
drivers/platform/olpc/olpc-ec.c +0 -1
 	for (i = 0; i <= ec_cmd_bytes; i++)
 		ec_cmd[i] = ec_cmd_int[i];
 
-	pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %02x %02x 

%02x %02x %02x, want %d returns\n",

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 196

Quoted 1 line
drivers/platform/olpc/olpc-ec.c +0 -1
-			ec_cmd[0], ec_cmd_bytes, ec_cmd[1], 

ec_cmd[2],

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 197

Quoted 1 line
drivers/platform/olpc/olpc-ec.c +0 -1
-			ec_cmd[3], ec_cmd[4], ec_cmd[5], 

ec_dbgfs_resp_bytes);

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 195

Quoted 1 line
drivers/platform/olpc/olpc-ec.c +1 -0
+	pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %5ph, 

want %d returns\n",

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,

Quoted 4 lines
drivers/platform/olpc/olpc-ec.c +2 -0
+			ec_cmd[0], ec_cmd_bytes, ec_cmd + 1,
+			ec_dbgfs_resp_bytes);
 
 	olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : 

&ec_cmd[1],

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 200

Quoted 1 line
drivers/platform/olpc/olpc-ec.c +0 -0
 			ec_cmd_bytes, ec_dbgfs_resp, 

ec_dbgfs_resp_bytes);

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 201

Quoted 2 lines
drivers/platform/olpc/olpc-ec.c +0 -1
-	pr_debug("olpc-ec: response %02x %02x %02x %02x %02x %02x 

%02x %02x (%d bytes expected)\n",

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 202

Quoted 1 line
drivers/platform/olpc/olpc-ec.c +0 -1
-			ec_dbgfs_resp[0], ec_dbgfs_resp[1], 

ec_dbgfs_resp[2],

drivers/platform/olpc/olpc-ec.c static ssize_t ec_dbgfs_cmd_write(struct · line 203

Quoted 1 line
drivers/platform/olpc/olpc-ec.c +0 -1
-			ec_dbgfs_resp[3], ec_dbgfs_resp[4], 

ec_dbgfs_resp[5],

Quoted 9 lines
drivers/platform/olpc/olpc-ec.c +2 -2
-			ec_dbgfs_resp[6], ec_dbgfs_resp[7],
-			ec_dbgfs_resp_bytes);
+	pr_debug("olpc-ec: response %8ph (%d bytes expected)\n",
+			ec_dbgfs_resp, ec_dbgfs_resp_bytes);
 
 out:
 	mutex_unlock(&ec_dbgfs_lock);
Signature · 1 line
2.1.3

=---------------------
paul fox, [email protected]

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#3 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Paul Fox

change looks okay to me.

Darren, maybe you can apply this one? Seems OLPC is x86-based.

Change is good, and olpc appears to be orphaned per MAINTAINERS. I'm OK including it in my pull request along with an update to MAINTAINERS.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center