Commit ffd776bf authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regmap-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap updates from Mark Brown:
 "This is a fairly large set of updates for regmap, mainly bugfixes.

  The biggest bit of this is some fixes for the bulk operations code
  which had issues in some use cases, Charles Keepax has sorted them
  out. We also gained the ability to use debugfs with syscon regmaps and
  to specify the clock to be used with MMIO regmaps"

* tag 'regmap-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: (21 commits)
  regmap: debugfs: Improve warning message on debugfs_create_dir() failure
  regmap: debugfs: Free map->debugfs_name when debugfs_create_dir() failed
  regmap: debugfs: Don't leak dummy names
  regmap: debugfs: Disambiguate dummy debugfs file name
  regmap: mmio: Add function to attach a clock
  regmap: Merge redundant handling in regmap_bulk_write
  regmap: Tidy up regmap_raw_write chunking code
  regmap: Move the handling for max_raw_write into regmap_raw_write
  regmap: Remove unnecessary printk for failed allocation
  regmap: Format data for raw write in regmap_bulk_write
  regmap: use debugfs even when no device
  regmap: Allow missing device in regmap_name_read_file()
  regmap: Use _regmap_read in regmap_bulk_read
  regmap: Tidy up regmap_raw_read chunking code
  regmap: Move the handling for max_raw_read into regmap_raw_read
  regmap: Use helper function for register offset
  regmap: Don't use format_val in regmap_bulk_read
  regmap: Correct comparison in regmap_cached
  regmap: Correct offset handling in regmap_volatile_range
  regmap-i2c: Off by one in regmap_i2c_smbus_i2c_read/write()
  ...
parents f2d28566 28893126
...@@ -25,6 +25,7 @@ struct regmap_debugfs_node { ...@@ -25,6 +25,7 @@ struct regmap_debugfs_node {
struct list_head link; struct list_head link;
}; };
static unsigned int dummy_index;
static struct dentry *regmap_debugfs_root; static struct dentry *regmap_debugfs_root;
static LIST_HEAD(regmap_debugfs_early_list); static LIST_HEAD(regmap_debugfs_early_list);
static DEFINE_MUTEX(regmap_debugfs_early_lock); static DEFINE_MUTEX(regmap_debugfs_early_lock);
...@@ -40,6 +41,7 @@ static ssize_t regmap_name_read_file(struct file *file, ...@@ -40,6 +41,7 @@ static ssize_t regmap_name_read_file(struct file *file,
loff_t *ppos) loff_t *ppos)
{ {
struct regmap *map = file->private_data; struct regmap *map = file->private_data;
const char *name = "nodev";
int ret; int ret;
char *buf; char *buf;
...@@ -47,7 +49,10 @@ static ssize_t regmap_name_read_file(struct file *file, ...@@ -47,7 +49,10 @@ static ssize_t regmap_name_read_file(struct file *file,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
ret = snprintf(buf, PAGE_SIZE, "%s\n", map->dev->driver->name); if (map->dev && map->dev->driver)
name = map->dev->driver->name;
ret = snprintf(buf, PAGE_SIZE, "%s\n", name);
if (ret < 0) { if (ret < 0) {
kfree(buf); kfree(buf);
return ret; return ret;
...@@ -569,9 +574,20 @@ void regmap_debugfs_init(struct regmap *map, const char *name) ...@@ -569,9 +574,20 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
name = devname; name = devname;
} }
if (!strcmp(name, "dummy")) {
map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
dummy_index);
name = map->debugfs_name;
dummy_index++;
}
map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
if (!map->debugfs) { if (!map->debugfs) {
dev_warn(map->dev, "Failed to create debugfs directory\n"); dev_warn(map->dev,
"Failed to create %s debugfs directory\n", name);
kfree(map->debugfs_name);
map->debugfs_name = NULL;
return; return;
} }
......
...@@ -217,8 +217,6 @@ static int regmap_i2c_smbus_i2c_write(void *context, const void *data, ...@@ -217,8 +217,6 @@ static int regmap_i2c_smbus_i2c_write(void *context, const void *data,
if (count < 1) if (count < 1)
return -EINVAL; return -EINVAL;
if (count >= I2C_SMBUS_BLOCK_MAX)
return -E2BIG;
--count; --count;
return i2c_smbus_write_i2c_block_data(i2c, ((u8 *)data)[0], count, return i2c_smbus_write_i2c_block_data(i2c, ((u8 *)data)[0], count,
...@@ -235,8 +233,6 @@ static int regmap_i2c_smbus_i2c_read(void *context, const void *reg, ...@@ -235,8 +233,6 @@ static int regmap_i2c_smbus_i2c_read(void *context, const void *reg,
if (reg_size != 1 || val_size < 1) if (reg_size != 1 || val_size < 1)
return -EINVAL; return -EINVAL;
if (val_size >= I2C_SMBUS_BLOCK_MAX)
return -E2BIG;
ret = i2c_smbus_read_i2c_block_data(i2c, ((u8 *)reg)[0], val_size, val); ret = i2c_smbus_read_i2c_block_data(i2c, ((u8 *)reg)[0], val_size, val);
if (ret == val_size) if (ret == val_size)
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
struct regmap_mmio_context { struct regmap_mmio_context {
void __iomem *regs; void __iomem *regs;
unsigned val_bytes; unsigned val_bytes;
bool attached_clk;
struct clk *clk; struct clk *clk;
void (*reg_write)(struct regmap_mmio_context *ctx, void (*reg_write)(struct regmap_mmio_context *ctx,
...@@ -363,4 +365,26 @@ struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, ...@@ -363,4 +365,26 @@ struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
} }
EXPORT_SYMBOL_GPL(__devm_regmap_init_mmio_clk); EXPORT_SYMBOL_GPL(__devm_regmap_init_mmio_clk);
int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk)
{
struct regmap_mmio_context *ctx = map->bus_context;
ctx->clk = clk;
ctx->attached_clk = true;
return clk_prepare(ctx->clk);
}
EXPORT_SYMBOL_GPL(regmap_mmio_attach_clk);
void regmap_mmio_detach_clk(struct regmap *map)
{
struct regmap_mmio_context *ctx = map->bus_context;
clk_unprepare(ctx->clk);
ctx->attached_clk = false;
ctx->clk = NULL;
}
EXPORT_SYMBOL_GPL(regmap_mmio_detach_clk);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/lockdep.h> #include <linux/lockdep.h>
struct module; struct module;
struct clk;
struct device; struct device;
struct i2c_client; struct i2c_client;
struct irq_domain; struct irq_domain;
...@@ -905,6 +906,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); ...@@ -905,6 +906,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
__regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \
sdw, config) sdw, config)
int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk);
void regmap_mmio_detach_clk(struct regmap *map);
void regmap_exit(struct regmap *map); void regmap_exit(struct regmap *map);
int regmap_reinit_cache(struct regmap *map, int regmap_reinit_cache(struct regmap *map,
const struct regmap_config *config); const struct regmap_config *config);
......
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