aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>2023-01-11 23:23:33 +0000
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>2023-01-25 21:26:54 +0000
commit4fee6659c42c264e17dad7625f8663a45594d46b (patch)
tree6d8d0e81fcf5056c21e77017f94ffc1634f636c9
parent0d4d9ee6f0f9379f3de6e2c684dab19922eda705 (diff)
downloadsrc-4fee6659c42c264e17dad7625f8663a45594d46b.tar.gz
src-4fee6659c42c264e17dad7625f8663a45594d46b.zip
linuxkpi: Add `sysfs_emit()`
Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38086
-rw-r--r--sys/compat/linuxkpi/common/include/linux/sysfs.h19
1 files changed, 19 insertions, 0 deletions
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_ */