0001
0002
0003
0004
0005
0006 #define MVM_DEBUGFS_READ_FILE_OPS(name) \
0007 static const struct file_operations iwl_dbgfs_##name##_ops = { \
0008 .read = iwl_dbgfs_##name##_read, \
0009 .open = simple_open, \
0010 .llseek = generic_file_llseek, \
0011 }
0012
0013 #define MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype) \
0014 static ssize_t _iwl_dbgfs_##name##_write(struct file *file, \
0015 const char __user *user_buf, \
0016 size_t count, loff_t *ppos) \
0017 { \
0018 argtype *arg = file->private_data; \
0019 char buf[buflen] = {}; \
0020 size_t buf_size = min(count, sizeof(buf) - 1); \
0021 \
0022 if (copy_from_user(buf, user_buf, buf_size)) \
0023 return -EFAULT; \
0024 \
0025 return iwl_dbgfs_##name##_write(arg, buf, buf_size, ppos); \
0026 } \
0027
0028 #define _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, buflen, argtype) \
0029 MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype) \
0030 static const struct file_operations iwl_dbgfs_##name##_ops = { \
0031 .write = _iwl_dbgfs_##name##_write, \
0032 .read = iwl_dbgfs_##name##_read, \
0033 .open = simple_open, \
0034 .llseek = generic_file_llseek, \
0035 };
0036
0037 #define _MVM_DEBUGFS_WRITE_FILE_OPS(name, buflen, argtype) \
0038 MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype) \
0039 static const struct file_operations iwl_dbgfs_##name##_ops = { \
0040 .write = _iwl_dbgfs_##name##_write, \
0041 .open = simple_open, \
0042 .llseek = generic_file_llseek, \
0043 };