Commit d4a1a317 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'regmap/topic/atomic', 'regmap/topic/debugfs'...

Merge remote-tracking branches 'regmap/topic/atomic', 'regmap/topic/debugfs' and 'regmap/topic/irq-hdr' into regmap-next
...@@ -59,6 +59,7 @@ struct regmap { ...@@ -59,6 +59,7 @@ struct regmap {
regmap_lock lock; regmap_lock lock;
regmap_unlock unlock; regmap_unlock unlock;
void *lock_arg; /* This is passed to lock/unlock functions */ void *lock_arg; /* This is passed to lock/unlock functions */
gfp_t alloc_flags;
struct device *dev; /* Device we do I/O on */ struct device *dev; /* Device we do I/O on */
void *work_buf; /* Scratch buffer used to format I/O */ void *work_buf; /* Scratch buffer used to format I/O */
......
...@@ -30,7 +30,7 @@ static LIST_HEAD(regmap_debugfs_early_list); ...@@ -30,7 +30,7 @@ static LIST_HEAD(regmap_debugfs_early_list);
static DEFINE_MUTEX(regmap_debugfs_early_lock); static DEFINE_MUTEX(regmap_debugfs_early_lock);
/* Calculate the length of a fixed format */ /* Calculate the length of a fixed format */
static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size) static size_t regmap_calc_reg_len(int max_val)
{ {
return snprintf(NULL, 0, "%x", max_val); return snprintf(NULL, 0, "%x", max_val);
} }
...@@ -173,8 +173,7 @@ static inline void regmap_calc_tot_len(struct regmap *map, ...@@ -173,8 +173,7 @@ static inline void regmap_calc_tot_len(struct regmap *map,
{ {
/* Calculate the length of a fixed format */ /* Calculate the length of a fixed format */
if (!map->debugfs_tot_len) { if (!map->debugfs_tot_len) {
map->debugfs_reg_len = regmap_calc_reg_len(map->max_register, map->debugfs_reg_len = regmap_calc_reg_len(map->max_register),
buf, count);
map->debugfs_val_len = 2 * map->format.val_bytes; map->debugfs_val_len = 2 * map->format.val_bytes;
map->debugfs_tot_len = map->debugfs_reg_len + map->debugfs_tot_len = map->debugfs_reg_len +
map->debugfs_val_len + 3; /* : \n */ map->debugfs_val_len + 3; /* : \n */
...@@ -338,6 +337,7 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file, ...@@ -338,6 +337,7 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
char *buf; char *buf;
char *entry; char *entry;
int ret; int ret;
unsigned entry_len;
if (*ppos < 0 || !count) if (*ppos < 0 || !count)
return -EINVAL; return -EINVAL;
...@@ -365,18 +365,15 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file, ...@@ -365,18 +365,15 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
p = 0; p = 0;
mutex_lock(&map->cache_lock); mutex_lock(&map->cache_lock);
list_for_each_entry(c, &map->debugfs_off_cache, list) { list_for_each_entry(c, &map->debugfs_off_cache, list) {
snprintf(entry, PAGE_SIZE, "%x-%x", entry_len = snprintf(entry, PAGE_SIZE, "%x-%x\n",
c->base_reg, c->max_reg); c->base_reg, c->max_reg);
if (p >= *ppos) { if (p >= *ppos) {
if (buf_pos + 1 + strlen(entry) > count) if (buf_pos + entry_len > count)
break; break;
snprintf(buf + buf_pos, count - buf_pos, memcpy(buf + buf_pos, entry, entry_len);
"%s", entry); buf_pos += entry_len;
buf_pos += strlen(entry);
buf[buf_pos] = '\n';
buf_pos++;
} }
p += strlen(entry) + 1; p += entry_len;
} }
mutex_unlock(&map->cache_lock); mutex_unlock(&map->cache_lock);
...@@ -420,7 +417,7 @@ static ssize_t regmap_access_read_file(struct file *file, ...@@ -420,7 +417,7 @@ static ssize_t regmap_access_read_file(struct file *file,
return -ENOMEM; return -ENOMEM;
/* Calculate the length of a fixed format */ /* Calculate the length of a fixed format */
reg_len = regmap_calc_reg_len(map->max_register, buf, count); reg_len = regmap_calc_reg_len(map->max_register);
tot_len = reg_len + 10; /* ': R W V P\n' */ tot_len = reg_len + 10; /* ': R W V P\n' */
for (i = 0; i <= map->max_register; i += map->reg_stride) { for (i = 0; i <= map->max_register; i += map->reg_stride) {
......
...@@ -561,6 +561,16 @@ struct regmap *__regmap_init(struct device *dev, ...@@ -561,6 +561,16 @@ struct regmap *__regmap_init(struct device *dev,
} }
map->lock_arg = map; map->lock_arg = map;
} }
/*
* When we write in fast-paths with regmap_bulk_write() don't allocate
* scratch buffers with sleeping allocations.
*/
if ((bus && bus->fast_io) || config->fast_io)
map->alloc_flags = GFP_ATOMIC;
else
map->alloc_flags = GFP_KERNEL;
map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8); map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
map->format.pad_bytes = config->pad_bits / 8; map->format.pad_bytes = config->pad_bits / 8;
map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8); map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
...@@ -1787,7 +1797,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, ...@@ -1787,7 +1797,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
if (!val_count) if (!val_count)
return -EINVAL; return -EINVAL;
wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL); wval = kmemdup(val, val_count * val_bytes, map->alloc_flags);
if (!wval) { if (!wval) {
dev_err(map->dev, "Error in memory allocation\n"); dev_err(map->dev, "Error in memory allocation\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -794,6 +794,9 @@ struct regmap_irq { ...@@ -794,6 +794,9 @@ struct regmap_irq {
unsigned int mask; unsigned int mask;
}; };
#define REGMAP_IRQ_REG(_irq, _off, _mask) \
[_irq] = { .reg_offset = (_off), .mask = (_mask) }
/** /**
* Description of a generic regmap irq_chip. This is not intended to * Description of a generic regmap irq_chip. This is not intended to
* handle every possible interrupt controller, but it should handle a * handle every possible interrupt controller, but it should handle a
......
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