Skip to contentSkip to conversation

mfd: pcf50633: use sprintf directly

PATCH Applied Andy Shevchenko 2 participants 2 messages Sep 4, 2014 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: pcf50633: use sprintf directly

When dump a content of the registers let's use snprintf() directly with %*ph specifier.

---
 drivers/mfd/pcf50633-core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mfd/pcf50633-core.c +1 -4
index c87f7a0..8401552 100644
@@ -106,10 +106,7 @@ static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
 			} else
 				dump[n1] = pcf50633_reg_read(pcf, n + n1);
 
-		hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0);
-		buf1 += strlen(buf1);
-		*buf1++ = '\n';
-		*buf1 = '\0';
+		buf1 += sprintf(buf1, "%*ph\n", (int)sizeof(dump), dump);
 	}
 
 	return buf1 - buf;
Signature · 1 line
2.1.0
Applied
#1 lore raw
Quoted 7 lines · Andy Shevchenko

When dump a content of the registers let's use snprintf() directly with %*ph specifier.

---
 drivers/mfd/pcf50633-core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Applied, thanks.

Quoted 16 lines
drivers/mfd/pcf50633-core.c +1 -4
index c87f7a0..8401552 100644
@@ -106,10 +106,7 @@ static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
 			} else
 				dump[n1] = pcf50633_reg_read(pcf, n + n1);
 
-		hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0);
-		buf1 += strlen(buf1);
-		*buf1++ = '\n';
-		*buf1 = '\0';
+		buf1 += sprintf(buf1, "%*ph\n", (int)sizeof(dump), dump);
 	}
 
 	return buf1 - buf;
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog