hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/include/linux/debugfs.h
....@@ -45,7 +45,7 @@
4545
4646 extern struct dentry *arch_debugfs_dir;
4747
48
-#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
48
+#define DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed) \
4949 static int __fops ## _open(struct inode *inode, struct file *file) \
5050 { \
5151 __simple_attr_check_format(__fmt, 0ull); \
....@@ -56,9 +56,15 @@
5656 .open = __fops ## _open, \
5757 .release = simple_attr_release, \
5858 .read = debugfs_attr_read, \
59
- .write = debugfs_attr_write, \
59
+ .write = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write, \
6060 .llseek = no_llseek, \
6161 }
62
+
63
+#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
64
+ DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
65
+
66
+#define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \
67
+ DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
6268
6369 typedef struct vfsmount *(*debugfs_automount_t)(struct dentry *, void *);
6470
....@@ -101,6 +107,8 @@
101107 ssize_t debugfs_attr_read(struct file *file, char __user *buf,
102108 size_t len, loff_t *ppos);
103109 ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
110
+ size_t len, loff_t *ppos);
111
+ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
104112 size_t len, loff_t *ppos);
105113
106114 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
....@@ -249,6 +257,13 @@
249257 return -ENODEV;
250258 }
251259
260
+static inline ssize_t debugfs_attr_write_signed(struct file *file,
261
+ const char __user *buf,
262
+ size_t len, loff_t *ppos)
263
+{
264
+ return -ENODEV;
265
+}
266
+
252267 static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
253268 struct dentry *new_dir, char *new_name)
254269 {