Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294147
b: refs/heads/master
c: 09c6ecd
h: refs/heads/master
i:
  294145: 62fe329
  294143: 518a0c1
v: v3
  • Loading branch information
Dimitris Papastamos authored and Mark Brown committed Feb 22, 2012
1 parent 87ae0fd commit f0c51da
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b8fb5ab156055b745254609f4635fcfd6b7dabc8
refs/heads/master: 09c6ecd394105c4864a0e409e181c9b1578c2a63
42 changes: 42 additions & 0 deletions trunk/drivers/base/regmap/regmap-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,51 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
return ret;
}

#undef REGMAP_ALLOW_WRITE_DEBUGFS
#ifdef REGMAP_ALLOW_WRITE_DEBUGFS
/*
* This can be dangerous especially when we have clients such as
* PMICs, therefore don't provide any real compile time configuration option
* for this feature, people who want to use this will need to modify
* the source code directly.
*/
static ssize_t regmap_map_write_file(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
char buf[32];
size_t buf_size;
char *start = buf;
unsigned long reg, value;
struct regmap *map = file->private_data;

buf_size = min(count, (sizeof(buf)-1));
if (copy_from_user(buf, user_buf, buf_size))
return -EFAULT;
buf[buf_size] = 0;

while (*start == ' ')
start++;
reg = simple_strtoul(start, &start, 16);
while (*start == ' ')
start++;
if (strict_strtoul(start, 16, &value))
return -EINVAL;

/* Userspace has been fiddling around behind the kernel's back */
add_taint(TAINT_USER);

regmap_write(map, reg, value);
return buf_size;
}
#else
#define regmap_map_write_file NULL
#endif

static const struct file_operations regmap_map_fops = {
.open = regmap_open_file,
.read = regmap_map_read_file,
.write = regmap_map_write_file,
.llseek = default_llseek,
};

Expand Down

0 comments on commit f0c51da

Please sign in to comment.