Commit 33ae421a authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Helge Deller

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent 5ee70bec
...@@ -466,19 +466,20 @@ static ssize_t show_cabc_available_modes(struct device *dev, ...@@ -466,19 +466,20 @@ static ssize_t show_cabc_available_modes(struct device *dev,
char *buf) char *buf)
{ {
struct panel_drv_data *ddata = dev_get_drvdata(dev); struct panel_drv_data *ddata = dev_get_drvdata(dev);
int len; int len = 0;
int i; int i;
if (!ddata->has_cabc) if (!ddata->has_cabc)
return sysfs_emit(buf, "%s\n", cabc_modes[0]); return sysfs_emit(buf, "%s\n", cabc_modes[0]);
for (i = 0, len = 0; for (i = 0; i < ARRAY_SIZE(cabc_modes); i++)
len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++) len += sysfs_emit_at(buf, len, "%s ", cabc_modes[i]);
len += snprintf(&buf[len], PAGE_SIZE - len, "%s%s%s",
i ? " " : "", cabc_modes[i], /* Remove the trailing space */
i == ARRAY_SIZE(cabc_modes) - 1 ? "\n" : ""); if (len)
buf[len - 1] = '\n';
return len < PAGE_SIZE ? len : PAGE_SIZE - 1; return len;
} }
static DEVICE_ATTR(cabc_mode, S_IRUGO | S_IWUSR, static DEVICE_ATTR(cabc_mode, S_IRUGO | S_IWUSR,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment