Merge tag 'xtensa-20221213' of https://github.com/jcmvbkbc/linux-xtensa
[linux-2.6-microblaze.git] / include / linux / debugfs.h
index f606746..ea2d919 100644 (file)
@@ -45,7 +45,7 @@ struct debugfs_u32_array {
 
 extern struct dentry *arch_debugfs_dir;
 
-#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt)          \
+#define DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed)     \
 static int __fops ## _open(struct inode *inode, struct file *file)     \
 {                                                                      \
        __simple_attr_check_format(__fmt, 0ull);                        \
@@ -56,10 +56,16 @@ static const struct file_operations __fops = {                              \
        .open    = __fops ## _open,                                     \
        .release = simple_attr_release,                                 \
        .read    = debugfs_attr_read,                                   \
-       .write   = debugfs_attr_write,                                  \
+       .write   = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write,      \
        .llseek  = no_llseek,                                           \
 }
 
+#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt)          \
+       DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
+
+#define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt)   \
+       DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
+
 typedef struct vfsmount *(*debugfs_automount_t)(struct dentry *, void *);
 
 #if defined(CONFIG_DEBUG_FS)
@@ -102,6 +108,8 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf,
                        size_t len, loff_t *ppos);
 ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
                        size_t len, loff_t *ppos);
+ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
+                       size_t len, loff_t *ppos);
 
 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
                 struct dentry *new_dir, const char *new_name);
@@ -254,6 +262,13 @@ static inline ssize_t debugfs_attr_write(struct file *file,
        return -ENODEV;
 }
 
+static inline ssize_t debugfs_attr_write_signed(struct file *file,
+                                       const char __user *buf,
+                                       size_t len, loff_t *ppos)
+{
+       return -ENODEV;
+}
+
 static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
                 struct dentry *new_dir, char *new_name)
 {