linuxkpi: Add sysfs_emit()

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38086
This commit is contained in:
Jean-Sébastien Pédron 2023-01-12 00:23:33 +01:00
parent 0d4d9ee6f0
commit 4fee6659c4
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC

View File

@ -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_ */