mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
fbdev: omapfb: Use sysfs_emit_at() to simplify code
This file already uses sysfs_emit(). So be consistent and also use sysfs_emit_at(). Moreover, size is always < PAGE_SIZE because scnprintf() (and now sysfs_emit_at()) returns the number of characters written not including the trailing '\0'. So some tests can be removed. This slightly simplifies the code and makes it more readable. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
parent
33ae421ad2
commit
2451a285ee
@ -1241,14 +1241,13 @@ static ssize_t omapfb_show_caps_num(struct device *dev,
|
||||
{
|
||||
struct omapfb_device *fbdev = dev_get_drvdata(dev);
|
||||
int plane;
|
||||
size_t size;
|
||||
size_t size = 0;
|
||||
struct omapfb_caps caps;
|
||||
|
||||
plane = 0;
|
||||
size = 0;
|
||||
while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) {
|
||||
while (plane < OMAPFB_PLANE_NUM) {
|
||||
omapfb_get_caps(fbdev, plane, &caps);
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
size += sysfs_emit_at(buf, size,
|
||||
"plane#%d %#010x %#010x %#010x\n",
|
||||
plane, caps.ctrl, caps.plane_color, caps.wnd_color);
|
||||
plane++;
|
||||
@ -1263,34 +1262,27 @@ static ssize_t omapfb_show_caps_text(struct device *dev,
|
||||
int i;
|
||||
struct omapfb_caps caps;
|
||||
int plane;
|
||||
size_t size;
|
||||
size_t size = 0;
|
||||
|
||||
plane = 0;
|
||||
size = 0;
|
||||
while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) {
|
||||
while (plane < OMAPFB_PLANE_NUM) {
|
||||
omapfb_get_caps(fbdev, plane, &caps);
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
"plane#%d:\n", plane);
|
||||
for (i = 0; i < ARRAY_SIZE(ctrl_caps) &&
|
||||
size < PAGE_SIZE; i++) {
|
||||
size += sysfs_emit_at(buf, size, "plane#%d:\n", plane);
|
||||
for (i = 0; i < ARRAY_SIZE(ctrl_caps); i++) {
|
||||
if (ctrl_caps[i].flag & caps.ctrl)
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
size += sysfs_emit_at(buf, size,
|
||||
" %s\n", ctrl_caps[i].name);
|
||||
}
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
" plane colors:\n");
|
||||
for (i = 0; i < ARRAY_SIZE(color_caps) &&
|
||||
size < PAGE_SIZE; i++) {
|
||||
size += sysfs_emit_at(buf, size, " plane colors:\n");
|
||||
for (i = 0; i < ARRAY_SIZE(color_caps); i++) {
|
||||
if (color_caps[i].flag & caps.plane_color)
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
size += sysfs_emit_at(buf, size,
|
||||
" %s\n", color_caps[i].name);
|
||||
}
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
" window colors:\n");
|
||||
for (i = 0; i < ARRAY_SIZE(color_caps) &&
|
||||
size < PAGE_SIZE; i++) {
|
||||
size += sysfs_emit_at(buf, size, " window colors:\n");
|
||||
for (i = 0; i < ARRAY_SIZE(color_caps); i++) {
|
||||
if (color_caps[i].flag & caps.wnd_color)
|
||||
size += scnprintf(&buf[size], PAGE_SIZE - size,
|
||||
size += sysfs_emit_at(buf, size,
|
||||
" %s\n", color_caps[i].name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user