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 {
struct list_head link;
};
static unsigned int dummy_index;
static struct dentry *regmap_debugfs_root;
static LIST_HEAD(regmap_debugfs_early_list);
static DEFINE_MUTEX(regmap_debugfs_early_lock);
......@@ -40,6 +41,7 @@ static ssize_t regmap_name_read_file(struct file *file,
loff_t *ppos)
{
struct regmap *map = file->private_data;
const char *name = "nodev";
int ret;
char *buf;
......@@ -47,7 +49,10 @@ static ssize_t regmap_name_read_file(struct file *file,
if (!buf)
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) {
kfree(buf);
return ret;
......@@ -569,9 +574,20 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
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);
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;
}
......
......@@ -217,8 +217,6 @@ static int regmap_i2c_smbus_i2c_write(void *context, const void *data,
if (count < 1)
return -EINVAL;
if (count >= I2C_SMBUS_BLOCK_MAX)
return -E2BIG;
--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,
if (reg_size != 1 || val_size < 1)
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);
if (ret == val_size)
......
......@@ -28,6 +28,8 @@
struct regmap_mmio_context {
void __iomem *regs;
unsigned val_bytes;
bool attached_clk;
struct clk *clk;
void (*reg_write)(struct regmap_mmio_context *ctx,
......@@ -363,4 +365,26 @@ struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
}
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");
This diff is collapsed.
......@@ -21,6 +21,7 @@
#include <linux/lockdep.h>
struct module;
struct clk;
struct device;
struct i2c_client;
struct irq_domain;
......@@ -905,6 +906,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
__regmap_lockdep_wrapper(__devm_regmap_init_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);
int regmap_reinit_cache(struct regmap *map,
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