[PATCH] video: fbdev: replace snprintf with sysfs_emit

2022-02-09 Thread davidcomponentone
From: Yang Guang 

coccinelle report:
./drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c:
202:8-16: WARNING: use scnprintf or sprintf
./drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c:
172:8-16: WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot 
Signed-off-by: Yang Guang 
Signed-off-by: David Yang 
---
 .../video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c 
b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
index 3db0232c31ab..155b3f8ad158 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
@@ -169,7 +169,7 @@ static ssize_t tpo_td043_vmirror_show(struct device *dev,
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
 
-   return snprintf(buf, PAGE_SIZE, "%d\n", ddata->vmirror);
+   return sysfs_emit(buf, "%d\n", ddata->vmirror);
 }
 
 static ssize_t tpo_td043_vmirror_store(struct device *dev,
@@ -199,7 +199,7 @@ static ssize_t tpo_td043_mode_show(struct device *dev,
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
 
-   return snprintf(buf, PAGE_SIZE, "%d\n", ddata->mode);
+   return sysfs_emit(buf, "%d\n", ddata->mode);
 }
 
 static ssize_t tpo_td043_mode_store(struct device *dev,
-- 
2.30.2



[PATCH] video: fbdev: use swap() to make code cleaner

2021-12-19 Thread davidcomponentone
From: Yang Guang 

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot 
Signed-off-by: David Yang 
Signed-off-by: Yang Guang 
---
 drivers/video/fbdev/sis/sis_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/sis/sis_main.c 
b/drivers/video/fbdev/sis/sis_main.c
index 266a5582f94d..742f62986b80 100644
--- a/drivers/video/fbdev/sis/sis_main.c
+++ b/drivers/video/fbdev/sis/sis_main.c
@@ -213,7 +213,7 @@ static void sisfb_search_mode(char *name, bool quiet)
/* This does some fuzzy mode naming detection */
if(sscanf(strbuf1, "%u %u %u %u", , , , ) 
== 4) {
if((rate <= 32) || (depth > 32)) {
-   j = rate; rate = depth; depth = j;
+   swap(rate, depth);
}
sprintf(strbuf, "%ux%ux%u", xres, yres, depth);
nameptr = strbuf;
-- 
2.30.2



[PATCH] omapfb: replace snprintf with sysfs_emit

2021-11-30 Thread davidcomponentone
From: Yang Guang 

coccinelle report:
./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c:
479:9-17: WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot 
Signed-off-by: Yang Guang 
---
 .../video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c 
b/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c
index 8d8b5ff7d43c..3696eb09b69b 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c
@@ -476,7 +476,7 @@ static ssize_t show_cabc_available_modes(struct device *dev,
int i;
 
if (!ddata->has_cabc)
-   return snprintf(buf, PAGE_SIZE, "%s\n", cabc_modes[0]);
+   return sysfs_emit(buf, "%s\n", cabc_modes[0]);
 
for (i = 0, len = 0;
 len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++)
-- 
2.30.2



[PATCH] fbdev: replace snprintf in show functions with sysfs_emit

2021-11-30 Thread davidcomponentone
From: Yang Guang 

coccinelle report:
./drivers/video/fbdev/core/fbcon.c:2680:8-16:
WARNING: use scnprintf or sprintf
./drivers/video/fbdev/core/fbcon.c:2655:8-16:
WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot 
Signed-off-by: Yang Guang 
---
 drivers/video/fbdev/core/fbcon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 99ecd9a6d844..b4234ec2f047 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2652,7 +2652,7 @@ static ssize_t show_rotate(struct device *device,
rotate = fbcon_get_rotate(info);
 err:
console_unlock();
-   return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
+   return sysfs_emit(buf, "%d\n", rotate);
 }
 
 static ssize_t show_cursor_blink(struct device *device,
@@ -2677,7 +2677,7 @@ static ssize_t show_cursor_blink(struct device *device,
blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
 err:
console_unlock();
-   return snprintf(buf, PAGE_SIZE, "%d\n", blink);
+   return sysfs_emit(buf, "%d\n", blink);
 }
 
 static ssize_t store_cursor_blink(struct device *device,
-- 
2.30.2