macintosh/ams: Replace snprintf in show functions with sysfs_emit

show() must not use snprintf() when formatting the value to be returned
to user space.

Fix the following coccicheck warning:
  drivers/macintosh/ams/ams-core.c:53: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Signed-off-by: Qing Wang <wangqing@vivo.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1634280544-4581-1-git-send-email-wangqing@vivo.com
This commit is contained in:
Qing Wang 2021-10-14 23:49:04 -07:00 committed by Michael Ellerman
parent 5749e7c1aa
commit cc4639989e

View File

@ -50,7 +50,7 @@ static ssize_t ams_show_current(struct device *dev,
ams_sensors(&x, &y, &z); ams_sensors(&x, &y, &z);
mutex_unlock(&ams_info.lock); mutex_unlock(&ams_info.lock);
return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z); return sysfs_emit(buf, "%d %d %d\n", x, y, z);
} }
static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL); static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL);