Skip to content

Commit 2451a28

Browse files
tititiou36hdeller
authored andcommitted
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 <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 33ae421 commit 2451a28

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

drivers/video/fbdev/omap/omapfb_main.c

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,14 +1241,13 @@ static ssize_t omapfb_show_caps_num(struct device *dev,
12411241
{
12421242
struct omapfb_device *fbdev = dev_get_drvdata(dev);
12431243
int plane;
1244-
size_t size;
1244+
size_t size = 0;
12451245
struct omapfb_caps caps;
12461246

12471247
plane = 0;
1248-
size = 0;
1249-
while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) {
1248+
while (plane < OMAPFB_PLANE_NUM) {
12501249
omapfb_get_caps(fbdev, plane, &caps);
1251-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1250+
size += sysfs_emit_at(buf, size,
12521251
"plane#%d %#010x %#010x %#010x\n",
12531252
plane, caps.ctrl, caps.plane_color, caps.wnd_color);
12541253
plane++;
@@ -1263,34 +1262,27 @@ static ssize_t omapfb_show_caps_text(struct device *dev,
12631262
int i;
12641263
struct omapfb_caps caps;
12651264
int plane;
1266-
size_t size;
1265+
size_t size = 0;
12671266

12681267
plane = 0;
1269-
size = 0;
1270-
while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) {
1268+
while (plane < OMAPFB_PLANE_NUM) {
12711269
omapfb_get_caps(fbdev, plane, &caps);
1272-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1273-
"plane#%d:\n", plane);
1274-
for (i = 0; i < ARRAY_SIZE(ctrl_caps) &&
1275-
size < PAGE_SIZE; i++) {
1270+
size += sysfs_emit_at(buf, size, "plane#%d:\n", plane);
1271+
for (i = 0; i < ARRAY_SIZE(ctrl_caps); i++) {
12761272
if (ctrl_caps[i].flag & caps.ctrl)
1277-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1273+
size += sysfs_emit_at(buf, size,
12781274
" %s\n", ctrl_caps[i].name);
12791275
}
1280-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1281-
" plane colors:\n");
1282-
for (i = 0; i < ARRAY_SIZE(color_caps) &&
1283-
size < PAGE_SIZE; i++) {
1276+
size += sysfs_emit_at(buf, size, " plane colors:\n");
1277+
for (i = 0; i < ARRAY_SIZE(color_caps); i++) {
12841278
if (color_caps[i].flag & caps.plane_color)
1285-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1279+
size += sysfs_emit_at(buf, size,
12861280
" %s\n", color_caps[i].name);
12871281
}
1288-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1289-
" window colors:\n");
1290-
for (i = 0; i < ARRAY_SIZE(color_caps) &&
1291-
size < PAGE_SIZE; i++) {
1282+
size += sysfs_emit_at(buf, size, " window colors:\n");
1283+
for (i = 0; i < ARRAY_SIZE(color_caps); i++) {
12921284
if (color_caps[i].flag & caps.wnd_color)
1293-
size += scnprintf(&buf[size], PAGE_SIZE - size,
1285+
size += sysfs_emit_at(buf, size,
12941286
" %s\n", color_caps[i].name);
12951287
}
12961288

0 commit comments

Comments
 (0)