Commit 0642ef6f authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

debugfs: Export bool read/write functions

The file read/write functions for bools have no special dependencies
on debugfs internals and are sufficiently non-trivial to be worth
exporting so clients can re-use the implementation.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bc0195aa
...@@ -435,7 +435,7 @@ struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, ...@@ -435,7 +435,7 @@ struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
} }
EXPORT_SYMBOL_GPL(debugfs_create_atomic_t); EXPORT_SYMBOL_GPL(debugfs_create_atomic_t);
static ssize_t read_file_bool(struct file *file, char __user *user_buf, ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[3]; char buf[3];
...@@ -449,8 +449,9 @@ static ssize_t read_file_bool(struct file *file, char __user *user_buf, ...@@ -449,8 +449,9 @@ static ssize_t read_file_bool(struct file *file, char __user *user_buf,
buf[2] = 0x00; buf[2] = 0x00;
return simple_read_from_buffer(user_buf, count, ppos, buf, 2); return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
} }
EXPORT_SYMBOL_GPL(debugfs_read_file_bool);
static ssize_t write_file_bool(struct file *file, const char __user *user_buf, ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[32]; char buf[32];
...@@ -468,10 +469,11 @@ static ssize_t write_file_bool(struct file *file, const char __user *user_buf, ...@@ -468,10 +469,11 @@ static ssize_t write_file_bool(struct file *file, const char __user *user_buf,
return count; return count;
} }
EXPORT_SYMBOL_GPL(debugfs_write_file_bool);
static const struct file_operations fops_bool = { static const struct file_operations fops_bool = {
.read = read_file_bool, .read = debugfs_read_file_bool,
.write = write_file_bool, .write = debugfs_write_file_bool,
.open = simple_open, .open = simple_open,
.llseek = default_llseek, .llseek = default_llseek,
}; };
......
...@@ -116,6 +116,12 @@ struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name, ...@@ -116,6 +116,12 @@ struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
bool debugfs_initialized(void); bool debugfs_initialized(void);
ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos);
ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos);
#else #else
#include <linux/err.h> #include <linux/err.h>
...@@ -282,6 +288,20 @@ static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev, ...@@ -282,6 +288,20 @@ static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
static inline ssize_t debugfs_read_file_bool(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
{
return -ENODEV;
}
static inline ssize_t debugfs_write_file_bool(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
return -ENODEV;
}
#endif #endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment