Skip to content

Commit 33ae421

Browse files
tititiou36hdeller
authored andcommitted
fbdev: omapfb: panel-sony-acx565akm: Simplify show_cabc_available_modes()
Use sysfs_emit_at() instead of snprintf() + custom logic. Using sysfs_emit_at() is much more simple. Also, sysfs_emit() is already used in this function, so using sysfs_emit_at() is more consistent. Also simplify the logic: - always add a space after an entry - change the last space into a '\n' Finally it is easy to see that, given the size of cabc_modes, PAGE_SIZE can not be reached. So better keep everything simple (and correct). Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 5ee70be commit 33ae421

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,19 +466,20 @@ static ssize_t show_cabc_available_modes(struct device *dev,
466466
char *buf)
467467
{
468468
struct panel_drv_data *ddata = dev_get_drvdata(dev);
469-
int len;
469+
int len = 0;
470470
int i;
471471

472472
if (!ddata->has_cabc)
473473
return sysfs_emit(buf, "%s\n", cabc_modes[0]);
474474

475-
for (i = 0, len = 0;
476-
len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++)
477-
len += snprintf(&buf[len], PAGE_SIZE - len, "%s%s%s",
478-
i ? " " : "", cabc_modes[i],
479-
i == ARRAY_SIZE(cabc_modes) - 1 ? "\n" : "");
475+
for (i = 0; i < ARRAY_SIZE(cabc_modes); i++)
476+
len += sysfs_emit_at(buf, len, "%s ", cabc_modes[i]);
477+
478+
/* Remove the trailing space */
479+
if (len)
480+
buf[len - 1] = '\n';
480481

481-
return len < PAGE_SIZE ? len : PAGE_SIZE - 1;
482+
return len;
482483
}
483484

484485
static DEVICE_ATTR(cabc_mode, S_IRUGO | S_IWUSR,

0 commit comments

Comments
 (0)