linuxkpi: Add sysfs_emit_at() in <linux/sysfs.h>

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38159
This commit is contained in:
Jean-Sébastien Pédron 2023-01-20 20:23:17 +01:00
parent 47877d61af
commit e64afbc215
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC

View File

@ -314,6 +314,24 @@ sysfs_emit(char *buf, const char *fmt, ...)
return (i);
}
static inline int
sysfs_emit_at(char *buf, int at, const char *fmt, ...)
{
va_list args;
int i;
if (!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE) {
pr_warn("invalid sysfs_emit: buf:%p at:%d\n", buf, at);
return (0);
}
va_start(args, fmt);
i = vscnprintf(buf + at, PAGE_SIZE - at, fmt, args);
va_end(args);
return (i);
}
#define sysfs_attr_init(attr) do {} while(0)
#endif /* _LINUXKPI_LINUX_SYSFS_H_ */