Almost all uses of simple_attr_open() happen via macros that do a
__simple_attr_check_format(__fmt, 0ull). One of the few exceptions
actually does not pass a fmt matching an unsigned long long.

So move the check into the call of simple_attr_open() by wrapping it in
a macro of the same name, and fix the powerpc case while at it.

Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk>
---
 arch/powerpc/platforms/cell/spufs/file.c | 2 +-
 fs/libfs.c                               | 1 +
 include/linux/debugfs.h                  | 1 -
 include/linux/fs.h                       | 6 +++++-
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/file.c 
b/arch/powerpc/platforms/cell/spufs/file.c
index 43e7b93f27c7..b75d70f54f12 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -436,7 +436,7 @@ static int spufs_cntl_open(struct inode *inode, struct file 
*file)
                ctx->cntl = inode->i_mapping;
        mutex_unlock(&ctx->mapping_lock);
        return simple_attr_open(inode, file, spufs_cntl_get,
-                                       spufs_cntl_set, "0x%08lx");
+                                       spufs_cntl_set, "0x%08llx");
 }
 
 static int
diff --git a/fs/libfs.c b/fs/libfs.c
index 0fb590d79f30..327ab701d176 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -792,6 +792,7 @@ struct simple_attr {
 
 /* simple_attr_open is called by an actual attribute open file operation
  * to set the attribute specific access operations. */
+#undef simple_attr_open
 int simple_attr_open(struct inode *inode, struct file *file,
                     int (*get)(void *, u64 *), int (*set)(void *, u64),
                     const char *fmt)
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index 3b0ba54cc4d5..2ddec401343a 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -42,7 +42,6 @@ extern struct dentry *arch_debugfs_dir;
 #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt)          \
 static int __fops ## _open(struct inode *inode, struct file *file)     \
 {                                                                      \
-       __simple_attr_check_format(__fmt, 0ull);                        \
        return simple_attr_open(inode, file, __get, __set, __fmt);      \
 }                                                                      \
 static const struct file_operations __fops = {                         \
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c95c0807471f..cb79b79d2175 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3387,7 +3387,6 @@ void simple_transaction_set(struct file *file, size_t n);
 #define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)           \
 static int __fops ## _open(struct inode *inode, struct file *file)     \
 {                                                                      \
-       __simple_attr_check_format(__fmt, 0ull);                        \
        return simple_attr_open(inode, file, __get, __set, __fmt);      \
 }                                                                      \
 static const struct file_operations __fops = {                         \
@@ -3408,6 +3407,11 @@ void __simple_attr_check_format(const char *fmt, ...)
 int simple_attr_open(struct inode *inode, struct file *file,
                     int (*get)(void *, u64 *), int (*set)(void *, u64),
                     const char *fmt);
+#define simple_attr_open(inode, file, get, set, fmt) ({        \
+       if (0)                                          \
+               __simple_attr_check_format(fmt, 0ull);  \
+       simple_attr_open(inode, file, get, set, fmt);   \
+       })
 int simple_attr_release(struct inode *inode, struct file *file);
 ssize_t simple_attr_read(struct file *file, char __user *buf,
                         size_t len, loff_t *ppos);
-- 
2.19.1.6.gbde171bbf5

Reply via email to