git: 976aa07a885b - main - lindebugfs: Add missing `debugfs_create_u*()` and `debugfs_create_x*()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Jan 2023 21:38:55 UTC
The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=976aa07a885b53e1bc2711082d2f6f113dbdd0bc commit 976aa07a885b53e1bc2711082d2f6f113dbdd0bc Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2023-01-12 23:41:32 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2023-01-25 21:26:52 +0000 lindebugfs: Add missing `debugfs_create_u*()` and `debugfs_create_x*()` The `debugfs_create_x*()` variants are the same as their `debugfs_create_u*()` equivalent, but they work with lowercase hexadecimal. While here, fix a few style(9) issues. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38087 --- sys/compat/lindebugfs/lindebugfs.c | 140 +++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/debugfs.h | 14 +++ 2 files changed, 154 insertions(+) diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c index 11a6dac579ac..8e878b1cd446 100644 --- a/sys/compat/lindebugfs/lindebugfs.c +++ b/sys/compat/lindebugfs/lindebugfs.c @@ -364,6 +364,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_bool_wo, NULL, debugfs_bool_set, "%llu\n"); void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, bool *value) { + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_bool, &fops_bool_ro, &fops_bool_wo); } @@ -392,10 +393,146 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_u8_wo, NULL, debugfs_u8_set, "%u\n"); void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, uint8_t *value) { + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_u8, &fops_u8_ro, &fops_u8_wo); } +DEFINE_DEBUGFS_ATTRIBUTE(fops_x8, debugfs_u8_get, debugfs_u8_set, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x8_ro, debugfs_u8_get, NULL, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x8_wo, NULL, debugfs_u8_set, "0x%016llx\n"); + +void +debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, uint8_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_x8, + &fops_x8_ro, &fops_x8_wo); +} + + +static int +debugfs_u16_get(void *data, uint64_t *value) +{ + uint16_t *u16data = data; + *value = *u16data; + return (0); +} + +static int +debugfs_u16_set(void *data, uint64_t value) +{ + uint16_t *u16data = data; + *u16data = (uint16_t)value; + return (0); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u16_ro, debugfs_u16_get, NULL, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u16_wo, NULL, debugfs_u16_set, "%u\n"); + +void +debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, uint16_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_u16, + &fops_u16_ro, &fops_u16_wo); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_x16, debugfs_u16_get, debugfs_u16_set, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x16_ro, debugfs_u16_get, NULL, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x16_wo, NULL, debugfs_u16_set, "0x%016llx\n"); + +void +debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, uint16_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_x16, + &fops_x16_ro, &fops_x16_wo); +} + + +static int +debugfs_u32_get(void *data, uint64_t *value) +{ + uint32_t *u32data = data; + *value = *u32data; + return (0); +} + +static int +debugfs_u32_set(void *data, uint64_t value) +{ + uint32_t *u32data = data; + *u32data = (uint32_t)value; + return (0); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u32_ro, debugfs_u32_get, NULL, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u32_wo, NULL, debugfs_u32_set, "%u\n"); + +void +debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, uint32_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_u32, + &fops_u32_ro, &fops_u32_wo); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, debugfs_u32_get, debugfs_u32_set, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32_ro, debugfs_u32_get, NULL, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32_wo, NULL, debugfs_u32_set, "0x%016llx\n"); + +void +debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, uint32_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_x32, + &fops_x32_ro, &fops_x32_wo); +} + + +static int +debugfs_u64_get(void *data, uint64_t *value) +{ + uint64_t *u64data = data; + *value = *u64data; + return (0); +} + +static int +debugfs_u64_set(void *data, uint64_t value) +{ + uint64_t *u64data = data; + *u64data = (uint64_t)value; + return (0); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_u64, debugfs_u64_get, debugfs_u64_set, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u64_ro, debugfs_u64_get, NULL, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u64_wo, NULL, debugfs_u64_set, "%u\n"); + +void +debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, uint64_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_u64, + &fops_u64_ro, &fops_u64_wo); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_x64, debugfs_u64_get, debugfs_u64_set, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x64_ro, debugfs_u64_get, NULL, "0x%016llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_x64_wo, NULL, debugfs_u64_set, "0x%016llx\n"); + +void +debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, uint64_t *value) +{ + + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_x64, + &fops_x64_ro, &fops_x64_wo); +} + static int debugfs_ulong_get(void *data, uint64_t *value) @@ -420,6 +557,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ulong_wo, NULL, debugfs_ulong_set, "%llu\n"); void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsigned long *value) { + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_ulong, &fops_ulong_ro, &fops_ulong_wo); } @@ -471,6 +609,7 @@ fops_blob_read(struct file *filp, char __user *ubuf, size_t read_size, loff_t *p static int fops_blob_open(struct inode *inode, struct file *filp) { + return (simple_open(inode, filp)); } @@ -504,6 +643,7 @@ lindebugfs_init(PFS_INIT_ARGS) static int lindebugfs_uninit(PFS_INIT_ARGS) { + return (0); } diff --git a/sys/compat/linuxkpi/common/include/linux/debugfs.h b/sys/compat/linuxkpi/common/include/linux/debugfs.h index 422b96006b04..074f709114eb 100644 --- a/sys/compat/linuxkpi/common/include/linux/debugfs.h +++ b/sys/compat/linuxkpi/common/include/linux/debugfs.h @@ -82,6 +82,20 @@ void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, bool *value); void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, uint8_t *value); +void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, + uint16_t *value); +void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, + uint32_t *value); +void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, + uint64_t *value); +void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, + uint8_t *value); +void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, + uint16_t *value); +void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, + uint32_t *value); +void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, + uint64_t *value); void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsigned long *value); void debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent,