git: 4fee6659c42c - main - linuxkpi: Add `sysfs_emit()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Jan 2023 21:39:02 UTC
The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=4fee6659c42c264e17dad7625f8663a45594d46b commit 4fee6659c42c264e17dad7625f8663a45594d46b Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2023-01-11 23:23:33 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2023-01-25 21:26:54 +0000 linuxkpi: Add `sysfs_emit()` Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38086 --- sys/compat/linuxkpi/common/include/linux/sysfs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/sysfs.h b/sys/compat/linuxkpi/common/include/linux/sysfs.h index e6b8ad210f16..b9689a367c90 100644 --- a/sys/compat/linuxkpi/common/include/linux/sysfs.h +++ b/sys/compat/linuxkpi/common/include/linux/sysfs.h @@ -37,6 +37,7 @@ #include <linux/kobject.h> #include <linux/stringify.h> +#include <linux/mm.h> struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *, char *); @@ -295,6 +296,24 @@ sysfs_streq(const char *s1, const char *s2) return (l1 == l2 && strncmp(s1, s2, l1) == 0); } +static inline int +sysfs_emit(char *buf, const char *fmt, ...) +{ + va_list args; + int i; + + if (!buf || offset_in_page(buf)) { + pr_warn("invalid sysfs_emit: buf:%p\n", buf); + return (0); + } + + va_start(args, fmt); + i = vscnprintf(buf, PAGE_SIZE, fmt, args); + va_end(args); + + return (i); +} + #define sysfs_attr_init(attr) do {} while(0) #endif /* _LINUXKPI_LINUX_SYSFS_H_ */