提交 a5656a70 编写于 作者: R Rasmus Villemoes 提交者: Lee Jones

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: NRasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: NCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: NLee Jones <lee.jones@linaro.org>
上级 db2fb60c
...@@ -47,20 +47,14 @@ static ssize_t wm831x_unique_id_show(struct device *dev, ...@@ -47,20 +47,14 @@ static ssize_t wm831x_unique_id_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct wm831x *wm831x = dev_get_drvdata(dev); struct wm831x *wm831x = dev_get_drvdata(dev);
int i, rval; int rval;
char id[WM831X_UNIQUE_ID_LEN]; char id[WM831X_UNIQUE_ID_LEN];
ssize_t ret = 0;
rval = wm831x_unique_id_read(wm831x, id); rval = wm831x_unique_id_read(wm831x, id);
if (rval < 0) if (rval < 0)
return 0; return 0;
for (i = 0; i < WM831X_UNIQUE_ID_LEN; i++) return sprintf(buf, "%*phN\n", WM831X_UNIQUE_ID_LEN, id);
ret += sprintf(&buf[ret], "%02x", buf[i]);
ret += sprintf(&buf[ret], "\n");
return ret;
} }
static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL); static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册