Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 266960
b: refs/heads/master
c: 3566cc9
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Aug 9, 2011
1 parent e6c862b commit c2db359
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 379 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: 2efe1642b73e74604498175de032b8a604868fb7
refs/heads/master: 3566cc9d90e3f774cea47de6986c59a09090ce2b
1 change: 0 additions & 1 deletion trunk/drivers/base/regmap/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
obj-$(CONFIG_REGMAP) += regmap.o
obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
61 changes: 0 additions & 61 deletions trunk/drivers/base/regmap/internal.h

This file was deleted.

135 changes: 0 additions & 135 deletions trunk/drivers/base/regmap/regmap-debugfs.c

This file was deleted.

98 changes: 38 additions & 60 deletions trunk/drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,34 @@
#include <linux/mutex.h>
#include <linux/err.h>

#define CREATE_TRACE_POINTS
#include <trace/events/regmap.h>

#include "internal.h"
#include <linux/regmap.h>

struct regmap;

struct regmap_format {
size_t buf_size;
size_t reg_bytes;
size_t val_bytes;
void (*format_write)(struct regmap *map,
unsigned int reg, unsigned int val);
void (*format_reg)(void *buf, unsigned int reg);
void (*format_val)(void *buf, unsigned int val);
unsigned int (*parse_val)(void *buf);
};

struct regmap {
struct mutex lock;

struct device *dev; /* Device we do I/O on */
void *work_buf; /* Scratch buffer used to format I/O */
struct regmap_format format; /* Buffer format */
const struct regmap_bus *bus;

unsigned int max_register;
bool (*writeable_reg)(struct device *dev, unsigned int reg);
bool (*readable_reg)(struct device *dev, unsigned int reg);
bool (*volatile_reg)(struct device *dev, unsigned int reg);
};

static void regmap_format_4_12_write(struct regmap *map,
unsigned int reg, unsigned int val)
Expand Down Expand Up @@ -101,7 +125,6 @@ struct regmap *regmap_init(struct device *dev,
map->writeable_reg = config->writeable_reg;
map->readable_reg = config->readable_reg;
map->volatile_reg = config->volatile_reg;
map->precious_reg = config->precious_reg;

switch (config->reg_bits) {
case 4:
Expand Down Expand Up @@ -157,8 +180,6 @@ struct regmap *regmap_init(struct device *dev,
goto err_bus;
}

regmap_debugfs_init(map);

return map;

err_bus:
Expand All @@ -175,7 +196,6 @@ EXPORT_SYMBOL_GPL(regmap_init);
*/
void regmap_exit(struct regmap *map)
{
regmap_debugfs_exit(map);
kfree(map->work_buf);
module_put(map->bus->owner);
kfree(map);
Expand All @@ -188,32 +208,16 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
void *buf;
int ret = -ENOTSUPP;
size_t len;
int i;

/* Check for unwritable registers before we start */
if (map->writeable_reg)
for (i = 0; i < val_len / map->format.val_bytes; i++)
if (!map->writeable_reg(map->dev, reg + i))
return -EINVAL;

map->format.format_reg(map->work_buf, reg);

trace_regmap_hw_write_start(map->dev, reg,
val_len / map->format.val_bytes);

/* If we're doing a single register write we can probably just
* send the work_buf directly, otherwise try to do a gather
* write.
*/
if (val == map->work_buf + map->format.reg_bytes)
ret = map->bus->write(map->dev, map->work_buf,
map->format.reg_bytes + val_len);
else if (map->bus->gather_write)
/* Try to do a gather write if we can */
if (map->bus->gather_write)
ret = map->bus->gather_write(map->dev, map->work_buf,
map->format.reg_bytes,
val, val_len);

/* If that didn't work fall back on linearising by hand. */
/* Otherwise fall back on linearising by hand. */
if (ret == -ENOTSUPP) {
len = map->format.reg_bytes + val_len;
buf = kmalloc(len, GFP_KERNEL);
Expand All @@ -227,31 +231,19 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
kfree(buf);
}

trace_regmap_hw_write_done(map->dev, reg,
val_len / map->format.val_bytes);

return ret;
}

static int _regmap_write(struct regmap *map, unsigned int reg,
unsigned int val)
{
int ret;
BUG_ON(!map->format.format_write && !map->format.format_val);

trace_regmap_reg_write(map->dev, reg, val);

if (map->format.format_write) {
map->format.format_write(map, reg, val);

trace_regmap_hw_write_start(map->dev, reg, 1);

ret = map->bus->write(map->dev, map->work_buf,
map->format.buf_size);

trace_regmap_hw_write_done(map->dev, reg, 1);

return ret;
return map->bus->write(map->dev, map->work_buf,
map->format.buf_size);
} else {
map->format.format_val(map->work_buf + map->format.reg_bytes,
val);
Expand Down Expand Up @@ -333,16 +325,12 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
if (map->bus->read_flag_mask)
u8[0] |= map->bus->read_flag_mask;

trace_regmap_hw_read_start(map->dev, reg,
val_len / map->format.val_bytes);

ret = map->bus->read(map->dev, map->work_buf, map->format.reg_bytes,
val, val_len);

trace_regmap_hw_read_done(map->dev, reg,
val_len / map->format.val_bytes);
val, map->format.val_bytes);
if (ret != 0)
return ret;

return ret;
return 0;
}

static int _regmap_read(struct regmap *map, unsigned int reg,
Expand All @@ -354,10 +342,8 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
return -EINVAL;

ret = _regmap_raw_read(map, reg, map->work_buf, map->format.val_bytes);
if (ret == 0) {
if (ret == 0)
*val = map->format.parse_val(map->work_buf);
trace_regmap_reg_read(map->dev, reg, *val);
}

return ret;
}
Expand Down Expand Up @@ -476,11 +462,3 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
return ret;
}
EXPORT_SYMBOL_GPL(regmap_update_bits);

static int __init regmap_initcall(void)
{
regmap_debugfs_initcall();

return 0;
}
postcore_initcall(regmap_initcall);
Loading

0 comments on commit c2db359

Please sign in to comment.