media: atomisp: Use sysfs_emit() instead of sprintf() where appropriate
authorNguyen Dinh Phi <phind.uet@gmail.com>
Thu, 13 May 2021 03:46:50 +0000 (05:46 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 23 Jul 2021 07:04:02 +0000 (09:04 +0200)
sysfs_emit() is preferred over raw sprintf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.

Link: https://lore.kernel.org/linux-media/20210513034650.252993-1-phind.uet@gmail.com
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_drvfs.c

index f670faf..dcb571f 100644 (file)
@@ -96,7 +96,7 @@ opt_err:
 static ssize_t iunit_dbglvl_show(struct device_driver *drv, char *buf)
 {
        iunit_debug.dbglvl = dbg_level;
-       return sprintf(buf, "dtrace level:%u\n", iunit_debug.dbglvl);
+       return sysfs_emit(buf, "dtrace level:%u\n", iunit_debug.dbglvl);
 }
 
 static ssize_t iunit_dbglvl_store(struct device_driver *drv, const char *buf,
@@ -115,7 +115,7 @@ static ssize_t iunit_dbglvl_store(struct device_driver *drv, const char *buf,
 static ssize_t iunit_dbgfun_show(struct device_driver *drv, char *buf)
 {
        iunit_debug.dbgfun = atomisp_get_css_dbgfunc();
-       return sprintf(buf, "dbgfun opt:%u\n", iunit_debug.dbgfun);
+       return sysfs_emit(buf, "dbgfun opt:%u\n", iunit_debug.dbgfun);
 }
 
 static ssize_t iunit_dbgfun_store(struct device_driver *drv, const char *buf,
@@ -139,7 +139,7 @@ static ssize_t iunit_dbgfun_store(struct device_driver *drv, const char *buf,
 
 static ssize_t iunit_dbgopt_show(struct device_driver *drv, char *buf)
 {
-       return sprintf(buf, "option:0x%x\n", iunit_debug.dbgopt);
+       return sysfs_emit(buf, "option:0x%x\n", iunit_debug.dbgopt);
 }
 
 static ssize_t iunit_dbgopt_store(struct device_driver *drv, const char *buf,