Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294156
b: refs/heads/master
c: c0eb467
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Jan 30, 2012
1 parent 89d4370 commit d6cc9aa
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 360 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f5d6eba74b8aac7d4bf646c5445807aa6a247e6c
refs/heads/master: c0eb46766d395da8d62148bda2e59bad5e6ee2f2
4 changes: 2 additions & 2 deletions trunk/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION = 3
PATCHLEVEL = 3
PATCHLEVEL = 2
SUBLEVEL = 0
EXTRAVERSION = -rc1
EXTRAVERSION =
NAME = Saber-toothed Squirrel

# *DOCUMENTATION*
Expand Down
9 changes: 4 additions & 5 deletions trunk/drivers/base/regmap/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ struct regcache_ops;
struct regmap_format {
size_t buf_size;
size_t reg_bytes;
size_t pad_bytes;
size_t val_bytes;
void (*format_write)(struct regmap *map,
unsigned int reg, unsigned int val);
Expand Down Expand Up @@ -66,16 +65,16 @@ struct regmap {
unsigned int num_reg_defaults_raw;

/* if set, only the cache is modified not the HW */
u32 cache_only;
unsigned int cache_only:1;
/* if set, only the HW is modified not the cache */
u32 cache_bypass;
unsigned int cache_bypass:1;
/* if set, remember to free reg_defaults_raw */
bool cache_free;
unsigned int cache_free:1;

struct reg_default *reg_defaults;
const void *reg_defaults_raw;
void *cache;
u32 cache_dirty;
bool cache_dirty;
};

struct regcache_ops {
Expand Down
6 changes: 0 additions & 6 deletions trunk/drivers/base/regmap/regcache-lzo.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,6 @@ static int regcache_lzo_sync(struct regmap *map)
ret = regcache_read(map, i, &val);
if (ret)
return ret;

/* Is this the hardware default? If so skip. */
ret = regcache_lookup_reg(map, i);
if (ret > 0 && val == map->reg_defaults[ret].def)
continue;

map->cache_bypass = 1;
ret = _regmap_write(map, i, val);
map->cache_bypass = 0;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/base/regmap/regcache-rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static int regcache_rbtree_sync(struct regmap *map)

/* Is this the hardware default? If so skip. */
ret = regcache_lookup_reg(map, i);
if (ret >= 0 && val == map->reg_defaults[ret].def)
if (ret > 0 && val == map->reg_defaults[ret].def)
continue;

map->cache_bypass = 1;
Expand Down
16 changes: 3 additions & 13 deletions trunk/drivers/base/regmap/regcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ int regcache_read(struct regmap *map,

return -EINVAL;
}
EXPORT_SYMBOL_GPL(regcache_read);

/**
* regcache_write: Set the value of a given register in the cache.
Expand All @@ -237,6 +238,7 @@ int regcache_write(struct regmap *map,

return 0;
}
EXPORT_SYMBOL_GPL(regcache_write);

/**
* regcache_sync: Sync the register cache with the hardware.
Expand Down Expand Up @@ -313,7 +315,6 @@ void regcache_cache_only(struct regmap *map, bool enable)
mutex_lock(&map->lock);
WARN_ON(map->cache_bypass && enable);
map->cache_only = enable;
trace_regmap_cache_only(map->dev, enable);
mutex_unlock(&map->lock);
}
EXPORT_SYMBOL_GPL(regcache_cache_only);
Expand Down Expand Up @@ -351,7 +352,6 @@ void regcache_cache_bypass(struct regmap *map, bool enable)
mutex_lock(&map->lock);
WARN_ON(map->cache_only && enable);
map->cache_bypass = enable;
trace_regmap_cache_bypass(map->dev, enable);
mutex_unlock(&map->lock);
}
EXPORT_SYMBOL_GPL(regcache_cache_bypass);
Expand All @@ -374,16 +374,10 @@ bool regcache_set_val(void *base, unsigned int idx,
cache[idx] = val;
break;
}
case 4: {
u32 *cache = base;
if (cache[idx] == val)
return true;
cache[idx] = val;
break;
}
default:
BUG();
}
/* unreachable */
return false;
}

Expand All @@ -402,10 +396,6 @@ unsigned int regcache_get_val(const void *base, unsigned int idx,
const u16 *cache = base;
return cache[idx];
}
case 4: {
const u32 *cache = base;
return cache[idx];
}
default:
BUG();
}
Expand Down
84 changes: 1 addition & 83 deletions trunk/drivers/base/regmap/regmap-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

#include <linux/slab.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/debugfs.h>
#include <linux/uaccess.h>
Expand All @@ -32,35 +33,6 @@ static int regmap_open_file(struct inode *inode, struct file *file)
return 0;
}

static ssize_t regmap_name_read_file(struct file *file,
char __user *user_buf, size_t count,
loff_t *ppos)
{
struct regmap *map = file->private_data;
int ret;
char *buf;

buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;

ret = snprintf(buf, PAGE_SIZE, "%s\n", map->dev->driver->name);
if (ret < 0) {
kfree(buf);
return ret;
}

ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
kfree(buf);
return ret;
}

static const struct file_operations regmap_name_fops = {
.open = regmap_open_file,
.read = regmap_name_read_file,
.llseek = default_llseek,
};

static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
Expand Down Expand Up @@ -131,51 +103,9 @@ 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 Expand Up @@ -256,24 +186,12 @@ void regmap_debugfs_init(struct regmap *map)
return;
}

debugfs_create_file("name", 0400, map->debugfs,
map, &regmap_name_fops);

if (map->max_register) {
debugfs_create_file("registers", 0400, map->debugfs,
map, &regmap_map_fops);
debugfs_create_file("access", 0400, map->debugfs,
map, &regmap_access_fops);
}

if (map->cache_type) {
debugfs_create_bool("cache_only", 0400, map->debugfs,
&map->cache_only);
debugfs_create_bool("cache_dirty", 0400, map->debugfs,
&map->cache_dirty);
debugfs_create_bool("cache_bypass", 0400, map->debugfs,
&map->cache_bypass);
}
}

void regmap_debugfs_exit(struct regmap *map)
Expand Down
17 changes: 17 additions & 0 deletions trunk/drivers/base/regmap/regmap-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,21 @@ struct regmap *regmap_init_i2c(struct i2c_client *i2c,
}
EXPORT_SYMBOL_GPL(regmap_init_i2c);

/**
* devm_regmap_init_i2c(): Initialise managed register map
*
* @i2c: Device that will be interacted with
* @config: Configuration for register map
*
* The return value will be an ERR_PTR() on error or a valid pointer
* to a struct regmap. The regmap will be automatically freed by the
* device management code.
*/
struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
const struct regmap_config *config)
{
return devm_regmap_init(&i2c->dev, &regmap_i2c, config);
}
EXPORT_SYMBOL_GPL(devm_regmap_init_i2c);

MODULE_LICENSE("GPL");
17 changes: 17 additions & 0 deletions trunk/drivers/base/regmap/regmap-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,21 @@ struct regmap *regmap_init_spi(struct spi_device *spi,
}
EXPORT_SYMBOL_GPL(regmap_init_spi);

/**
* devm_regmap_init_spi(): Initialise register map
*
* @spi: Device that will be interacted with
* @config: Configuration for register map
*
* The return value will be an ERR_PTR() on error or a valid pointer
* to a struct regmap. The map will be automatically freed by the
* device management code.
*/
struct regmap *devm_regmap_init_spi(struct spi_device *spi,
const struct regmap_config *config)
{
return devm_regmap_init(&spi->dev, &regmap_spi, config);
}
EXPORT_SYMBOL_GPL(devm_regmap_init_spi);

MODULE_LICENSE("GPL");
Loading

0 comments on commit d6cc9aa

Please sign in to comment.