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

mfd: wm831x: Fix broken wm831x_unique_id_show

wm831x_unique_id_show currently displays an interesting pattern of '0'
and '3' characters which isn't very useful (figuring out why is left
as an exercise for the reader). Presumably "buf[i]" should have been
"id[i] & 0xff".

But while there, it is much simpler to simply use %phN and do all the
formatting at once.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Rasmus Villemoes and committed by
Lee Jones
a5656a70 db2fb60c

+2 -8
+2 -8
drivers/mfd/wm831x-otp.c
··· 47 47 struct device_attribute *attr, char *buf) 48 48 { 49 49 struct wm831x *wm831x = dev_get_drvdata(dev); 50 - int i, rval; 50 + int rval; 51 51 char id[WM831X_UNIQUE_ID_LEN]; 52 - ssize_t ret = 0; 53 52 54 53 rval = wm831x_unique_id_read(wm831x, id); 55 54 if (rval < 0) 56 55 return 0; 57 56 58 - for (i = 0; i < WM831X_UNIQUE_ID_LEN; i++) 59 - ret += sprintf(&buf[ret], "%02x", buf[i]); 60 - 61 - ret += sprintf(&buf[ret], "\n"); 62 - 63 - return ret; 57 + return sprintf(buf, "%*phN\n", WM831X_UNIQUE_ID_LEN, id); 64 58 } 65 59 66 60 static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);