diff --git a/[refs] b/[refs] index 9f12ddf5c362..5daa1daf6ecc 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 72b39f6f2b5a6b0beff14b80bed9756f151218a9 +refs/heads/master: 8614419451d88bf99fff7f5e468fe45f8450891e diff --git a/trunk/drivers/base/regmap/Kconfig b/trunk/drivers/base/regmap/Kconfig index 9ef0a5326f17..0f6c7fb418e8 100644 --- a/trunk/drivers/base/regmap/Kconfig +++ b/trunk/drivers/base/regmap/Kconfig @@ -14,8 +14,5 @@ config REGMAP_I2C config REGMAP_SPI tristate -config REGMAP_MMIO - tristate - config REGMAP_IRQ bool diff --git a/trunk/drivers/base/regmap/Makefile b/trunk/drivers/base/regmap/Makefile index 5e75d1b683e2..defd57963c84 100644 --- a/trunk/drivers/base/regmap/Makefile +++ b/trunk/drivers/base/regmap/Makefile @@ -3,5 +3,4 @@ obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o -obj-$(CONFIG_REGMAP_MMIO) += regmap-mmio.o obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o diff --git a/trunk/drivers/base/regmap/internal.h b/trunk/drivers/base/regmap/internal.h index c994bc9bc04f..fcafc5b2e651 100644 --- a/trunk/drivers/base/regmap/internal.h +++ b/trunk/drivers/base/regmap/internal.h @@ -31,21 +31,13 @@ struct regmap_format { unsigned int (*parse_val)(void *buf); }; -typedef void (*regmap_lock)(struct regmap *map); -typedef void (*regmap_unlock)(struct regmap *map); - struct regmap { - struct mutex mutex; - spinlock_t spinlock; - regmap_lock lock; - regmap_unlock unlock; + 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; - void *bus_context; - const char *name; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; diff --git a/trunk/drivers/base/regmap/regcache-rbtree.c b/trunk/drivers/base/regmap/regcache-rbtree.c index cca46007d969..5157fa04c2f0 100644 --- a/trunk/drivers/base/regmap/regcache-rbtree.c +++ b/trunk/drivers/base/regmap/regcache-rbtree.c @@ -139,7 +139,7 @@ static int rbtree_show(struct seq_file *s, void *ignored) int nodes = 0; int registers = 0; - map->lock(map); + mutex_lock(&map->lock); for (node = rb_first(&rbtree_ctx->root); node != NULL; node = rb_next(node)) { @@ -155,7 +155,7 @@ static int rbtree_show(struct seq_file *s, void *ignored) seq_printf(s, "%d nodes, %d registers, average %d registers\n", nodes, registers, registers / nodes); - map->unlock(map); + mutex_unlock(&map->lock); return 0; } diff --git a/trunk/drivers/base/regmap/regcache.c b/trunk/drivers/base/regmap/regcache.c index 4ad18505e9ae..87f54dbf601b 100644 --- a/trunk/drivers/base/regmap/regcache.c +++ b/trunk/drivers/base/regmap/regcache.c @@ -264,7 +264,7 @@ int regcache_sync(struct regmap *map) BUG_ON(!map->cache_ops || !map->cache_ops->sync); - map->lock(map); + mutex_lock(&map->lock); /* Remember the initial bypass state */ bypass = map->cache_bypass; dev_dbg(map->dev, "Syncing %s cache\n", @@ -296,7 +296,7 @@ int regcache_sync(struct regmap *map) trace_regcache_sync(map->dev, name, "stop"); /* Restore the bypass state */ map->cache_bypass = bypass; - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -323,7 +323,7 @@ int regcache_sync_region(struct regmap *map, unsigned int min, BUG_ON(!map->cache_ops || !map->cache_ops->sync); - map->lock(map); + mutex_lock(&map->lock); /* Remember the initial bypass state */ bypass = map->cache_bypass; @@ -342,7 +342,7 @@ int regcache_sync_region(struct regmap *map, unsigned int min, trace_regcache_sync(map->dev, name, "stop region"); /* Restore the bypass state */ map->cache_bypass = bypass; - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -361,11 +361,11 @@ int regcache_sync_region(struct regmap *map, unsigned int min, */ void regcache_cache_only(struct regmap *map, bool enable) { - map->lock(map); + mutex_lock(&map->lock); WARN_ON(map->cache_bypass && enable); map->cache_only = enable; trace_regmap_cache_only(map->dev, enable); - map->unlock(map); + mutex_unlock(&map->lock); } EXPORT_SYMBOL_GPL(regcache_cache_only); @@ -380,9 +380,9 @@ EXPORT_SYMBOL_GPL(regcache_cache_only); */ void regcache_mark_dirty(struct regmap *map) { - map->lock(map); + mutex_lock(&map->lock); map->cache_dirty = true; - map->unlock(map); + mutex_unlock(&map->lock); } EXPORT_SYMBOL_GPL(regcache_mark_dirty); @@ -399,11 +399,11 @@ EXPORT_SYMBOL_GPL(regcache_mark_dirty); */ void regcache_cache_bypass(struct regmap *map, bool enable) { - map->lock(map); + mutex_lock(&map->lock); WARN_ON(map->cache_only && enable); map->cache_bypass = enable; trace_regmap_cache_bypass(map->dev, enable); - map->unlock(map); + mutex_unlock(&map->lock); } EXPORT_SYMBOL_GPL(regcache_cache_bypass); diff --git a/trunk/drivers/base/regmap/regmap-i2c.c b/trunk/drivers/base/regmap/regmap-i2c.c index 5f6b2478bf17..9a3a8c564389 100644 --- a/trunk/drivers/base/regmap/regmap-i2c.c +++ b/trunk/drivers/base/regmap/regmap-i2c.c @@ -15,9 +15,8 @@ #include #include -static int regmap_i2c_write(void *context, const void *data, size_t count) +static int regmap_i2c_write(struct device *dev, const void *data, size_t count) { - struct device *dev = context; struct i2c_client *i2c = to_i2c_client(dev); int ret; @@ -30,11 +29,10 @@ static int regmap_i2c_write(void *context, const void *data, size_t count) return -EIO; } -static int regmap_i2c_gather_write(void *context, +static int regmap_i2c_gather_write(struct device *dev, const void *reg, size_t reg_size, const void *val, size_t val_size) { - struct device *dev = context; struct i2c_client *i2c = to_i2c_client(dev); struct i2c_msg xfer[2]; int ret; @@ -64,11 +62,10 @@ static int regmap_i2c_gather_write(void *context, return -EIO; } -static int regmap_i2c_read(void *context, +static int regmap_i2c_read(struct device *dev, const void *reg, size_t reg_size, void *val, size_t val_size) { - struct device *dev = context; struct i2c_client *i2c = to_i2c_client(dev); struct i2c_msg xfer[2]; int ret; @@ -110,7 +107,7 @@ static struct regmap_bus regmap_i2c = { struct regmap *regmap_init_i2c(struct i2c_client *i2c, const struct regmap_config *config) { - return regmap_init(&i2c->dev, ®map_i2c, &i2c->dev, config); + return regmap_init(&i2c->dev, ®map_i2c, config); } EXPORT_SYMBOL_GPL(regmap_init_i2c); @@ -127,7 +124,7 @@ EXPORT_SYMBOL_GPL(regmap_init_i2c); struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, const struct regmap_config *config) { - return devm_regmap_init(&i2c->dev, ®map_i2c, &i2c->dev, config); + return devm_regmap_init(&i2c->dev, ®map_i2c, config); } EXPORT_SYMBOL_GPL(devm_regmap_init_i2c); diff --git a/trunk/drivers/base/regmap/regmap-mmio.c b/trunk/drivers/base/regmap/regmap-mmio.c deleted file mode 100644 index bdf4dc865293..000000000000 --- a/trunk/drivers/base/regmap/regmap-mmio.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Register map access API - MMIO support - * - * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -struct regmap_mmio_context { - void __iomem *regs; - unsigned val_bytes; -}; - -static int regmap_mmio_gather_write(void *context, - const void *reg, size_t reg_size, - const void *val, size_t val_size) -{ - struct regmap_mmio_context *ctx = context; - u32 offset; - - BUG_ON(reg_size != 4); - - offset = be32_to_cpup(reg); - - while (val_size) { - switch (ctx->val_bytes) { - case 1: - writeb(*(u8 *)val, ctx->regs + offset); - break; - case 2: - writew(be16_to_cpup(val), ctx->regs + offset); - break; - case 4: - writel(be32_to_cpup(val), ctx->regs + offset); - break; -#ifdef CONFIG_64BIT - case 8: - writeq(be64_to_cpup(val), ctx->regs + offset); - break; -#endif - default: - /* Should be caught by regmap_mmio_check_config */ - BUG(); - } - val_size -= ctx->val_bytes; - val += ctx->val_bytes; - offset += ctx->val_bytes; - } - - return 0; -} - -static int regmap_mmio_write(void *context, const void *data, size_t count) -{ - BUG_ON(count < 4); - - return regmap_mmio_gather_write(context, data, 4, data + 4, count - 4); -} - -static int regmap_mmio_read(void *context, - const void *reg, size_t reg_size, - void *val, size_t val_size) -{ - struct regmap_mmio_context *ctx = context; - u32 offset; - - BUG_ON(reg_size != 4); - - offset = be32_to_cpup(reg); - - while (val_size) { - switch (ctx->val_bytes) { - case 1: - *(u8 *)val = readb(ctx->regs + offset); - break; - case 2: - *(u16 *)val = cpu_to_be16(readw(ctx->regs + offset)); - break; - case 4: - *(u32 *)val = cpu_to_be32(readl(ctx->regs + offset)); - break; -#ifdef CONFIG_64BIT - case 8: - *(u64 *)val = cpu_to_be32(readq(ctx->regs + offset)); - break; -#endif - default: - /* Should be caught by regmap_mmio_check_config */ - BUG(); - } - val_size -= ctx->val_bytes; - val += ctx->val_bytes; - offset += ctx->val_bytes; - } - - return 0; -} - -static void regmap_mmio_free_context(void *context) -{ - kfree(context); -} - -static struct regmap_bus regmap_mmio = { - .fast_io = true, - .write = regmap_mmio_write, - .gather_write = regmap_mmio_gather_write, - .read = regmap_mmio_read, - .free_context = regmap_mmio_free_context, -}; - -struct regmap_mmio_context *regmap_mmio_gen_context(void __iomem *regs, - const struct regmap_config *config) -{ - struct regmap_mmio_context *ctx; - - if (config->reg_bits != 32) - return ERR_PTR(-EINVAL); - - if (config->pad_bits) - return ERR_PTR(-EINVAL); - - switch (config->val_bits) { - case 8: - case 16: - case 32: -#ifdef CONFIG_64BIT - case 64: -#endif - break; - default: - return ERR_PTR(-EINVAL); - } - - ctx = kzalloc(GFP_KERNEL, sizeof(*ctx)); - if (!ctx) - return ERR_PTR(-ENOMEM); - - ctx->regs = regs; - ctx->val_bytes = config->val_bits / 8; - - return ctx; -} - -/** - * regmap_init_mmio(): Initialise register map - * - * @dev: Device that will be interacted with - * @regs: Pointer to memory-mapped IO region - * @config: Configuration for register map - * - * The return value will be an ERR_PTR() on error or a valid pointer to - * a struct regmap. - */ -struct regmap *regmap_init_mmio(struct device *dev, - void __iomem *regs, - const struct regmap_config *config) -{ - struct regmap_mmio_context *ctx; - - ctx = regmap_mmio_gen_context(regs, config); - if (IS_ERR(ctx)) - return ERR_CAST(ctx); - - return regmap_init(dev, ®map_mmio, ctx, config); -} -EXPORT_SYMBOL_GPL(regmap_init_mmio); - -/** - * devm_regmap_init_mmio(): Initialise managed register map - * - * @dev: Device that will be interacted with - * @regs: Pointer to memory-mapped IO region - * @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_mmio(struct device *dev, - void __iomem *regs, - const struct regmap_config *config) -{ - struct regmap_mmio_context *ctx; - - ctx = regmap_mmio_gen_context(regs, config); - if (IS_ERR(ctx)) - return ERR_CAST(ctx); - - return devm_regmap_init(dev, ®map_mmio, ctx, config); -} -EXPORT_SYMBOL_GPL(devm_regmap_init_mmio); - -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/base/regmap/regmap-spi.c b/trunk/drivers/base/regmap/regmap-spi.c index ffa46a92ad33..7c0c35a39c33 100644 --- a/trunk/drivers/base/regmap/regmap-spi.c +++ b/trunk/drivers/base/regmap/regmap-spi.c @@ -15,19 +15,17 @@ #include #include -static int regmap_spi_write(void *context, const void *data, size_t count) +static int regmap_spi_write(struct device *dev, const void *data, size_t count) { - struct device *dev = context; struct spi_device *spi = to_spi_device(dev); return spi_write(spi, data, count); } -static int regmap_spi_gather_write(void *context, +static int regmap_spi_gather_write(struct device *dev, const void *reg, size_t reg_len, const void *val, size_t val_len) { - struct device *dev = context; struct spi_device *spi = to_spi_device(dev); struct spi_message m; struct spi_transfer t[2] = { { .tx_buf = reg, .len = reg_len, }, @@ -40,11 +38,10 @@ static int regmap_spi_gather_write(void *context, return spi_sync(spi, &m); } -static int regmap_spi_read(void *context, +static int regmap_spi_read(struct device *dev, const void *reg, size_t reg_size, void *val, size_t val_size) { - struct device *dev = context; struct spi_device *spi = to_spi_device(dev); return spi_write_then_read(spi, reg, reg_size, val, val_size); @@ -69,7 +66,7 @@ static struct regmap_bus regmap_spi = { struct regmap *regmap_init_spi(struct spi_device *spi, const struct regmap_config *config) { - return regmap_init(&spi->dev, ®map_spi, &spi->dev, config); + return regmap_init(&spi->dev, ®map_spi, config); } EXPORT_SYMBOL_GPL(regmap_init_spi); @@ -86,7 +83,7 @@ EXPORT_SYMBOL_GPL(regmap_init_spi); struct regmap *devm_regmap_init_spi(struct spi_device *spi, const struct regmap_config *config) { - return devm_regmap_init(&spi->dev, ®map_spi, &spi->dev, config); + return devm_regmap_init(&spi->dev, ®map_spi, config); } EXPORT_SYMBOL_GPL(devm_regmap_init_spi); diff --git a/trunk/drivers/base/regmap/regmap.c b/trunk/drivers/base/regmap/regmap.c index 618173e4c2b1..7a3f535e481c 100644 --- a/trunk/drivers/base/regmap/regmap.c +++ b/trunk/drivers/base/regmap/regmap.c @@ -158,41 +158,11 @@ static unsigned int regmap_parse_32(void *buf) return b[0]; } -static void regmap_lock_mutex(struct regmap *map) -{ - mutex_lock(&map->mutex); -} - -static void regmap_unlock_mutex(struct regmap *map) -{ - mutex_unlock(&map->mutex); -} - -static void regmap_lock_spinlock(struct regmap *map) -{ - spin_lock(&map->spinlock); -} - -static void regmap_unlock_spinlock(struct regmap *map) -{ - spin_unlock(&map->spinlock); -} - -static void dev_get_regmap_release(struct device *dev, void *res) -{ - /* - * We don't actually have anything to do here; the goal here - * is not to manage the regmap but to provide a simple way to - * get the regmap back given a struct device. - */ -} - /** * regmap_init(): Initialise register map * * @dev: Device that will be interacted with * @bus: Bus-specific callbacks to use with device - * @bus_context: Data passed to bus-specific callbacks * @config: Configuration for register map * * The return value will be an ERR_PTR() on error or a valid pointer to @@ -201,10 +171,9 @@ static void dev_get_regmap_release(struct device *dev, void *res) */ struct regmap *regmap_init(struct device *dev, const struct regmap_bus *bus, - void *bus_context, const struct regmap_config *config) { - struct regmap *map, **m; + struct regmap *map; int ret = -EINVAL; if (!bus || !config) @@ -216,15 +185,7 @@ struct regmap *regmap_init(struct device *dev, goto err; } - if (bus->fast_io) { - spin_lock_init(&map->spinlock); - map->lock = regmap_lock_spinlock; - map->unlock = regmap_unlock_spinlock; - } else { - mutex_init(&map->mutex); - map->lock = regmap_lock_mutex; - map->unlock = regmap_unlock_mutex; - } + mutex_init(&map->lock); map->format.buf_size = (config->reg_bits + config->val_bits) / 8; map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8); map->format.pad_bytes = config->pad_bits / 8; @@ -232,14 +193,12 @@ struct regmap *regmap_init(struct device *dev, map->format.buf_size += map->format.pad_bytes; map->dev = dev; map->bus = bus; - map->bus_context = bus_context; map->max_register = config->max_register; map->writeable_reg = config->writeable_reg; map->readable_reg = config->readable_reg; map->volatile_reg = config->volatile_reg; map->precious_reg = config->precious_reg; map->cache_type = config->cache_type; - map->name = config->name; if (config->read_flag_mask || config->write_flag_mask) { map->read_flag_mask = config->read_flag_mask; @@ -336,19 +295,8 @@ struct regmap *regmap_init(struct device *dev, if (ret < 0) goto err_free_workbuf; - /* Add a devres resource for dev_get_regmap() */ - m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL); - if (!m) { - ret = -ENOMEM; - goto err_cache; - } - *m = map; - devres_add(dev, m); - return map; -err_cache: - regcache_exit(map); err_free_workbuf: kfree(map->work_buf); err_map: @@ -368,7 +316,6 @@ static void devm_regmap_release(struct device *dev, void *res) * * @dev: Device that will be interacted with * @bus: Bus-specific callbacks to use with device - * @bus_context: Data passed to bus-specific callbacks * @config: Configuration for register map * * The return value will be an ERR_PTR() on error or a valid pointer @@ -378,7 +325,6 @@ static void devm_regmap_release(struct device *dev, void *res) */ struct regmap *devm_regmap_init(struct device *dev, const struct regmap_bus *bus, - void *bus_context, const struct regmap_config *config) { struct regmap **ptr, *regmap; @@ -387,7 +333,7 @@ struct regmap *devm_regmap_init(struct device *dev, if (!ptr) return ERR_PTR(-ENOMEM); - regmap = regmap_init(dev, bus, bus_context, config); + regmap = regmap_init(dev, bus, config); if (!IS_ERR(regmap)) { *ptr = regmap; devres_add(dev, ptr); @@ -414,7 +360,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config) { int ret; - map->lock(map); + mutex_lock(&map->lock); regcache_exit(map); regmap_debugfs_exit(map); @@ -433,7 +379,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config) ret = regcache_init(map, config); - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -445,51 +391,11 @@ void regmap_exit(struct regmap *map) { regcache_exit(map); regmap_debugfs_exit(map); - if (map->bus->free_context) - map->bus->free_context(map->bus_context); kfree(map->work_buf); kfree(map); } EXPORT_SYMBOL_GPL(regmap_exit); -static int dev_get_regmap_match(struct device *dev, void *res, void *data) -{ - struct regmap **r = res; - if (!r || !*r) { - WARN_ON(!r || !*r); - return 0; - } - - /* If the user didn't specify a name match any */ - if (data) - return (*r)->name == data; - else - return 1; -} - -/** - * dev_get_regmap(): Obtain the regmap (if any) for a device - * - * @dev: Device to retrieve the map for - * @name: Optional name for the register map, usually NULL. - * - * Returns the regmap for the device if one is present, or NULL. If - * name is specified then it must match the name specified when - * registering the device, if it is NULL then the first regmap found - * will be used. Devices with multiple register maps are very rare, - * generic code should normally not need to specify a name. - */ -struct regmap *dev_get_regmap(struct device *dev, const char *name) -{ - struct regmap **r = devres_find(dev, dev_get_regmap_release, - dev_get_regmap_match, (void *)name); - - if (!r) - return NULL; - return *r; -} -EXPORT_SYMBOL_GPL(dev_get_regmap); - static int _regmap_raw_write(struct regmap *map, unsigned int reg, const void *val, size_t val_len) { @@ -538,12 +444,12 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg, */ if (val == (map->work_buf + map->format.pad_bytes + map->format.reg_bytes)) - ret = map->bus->write(map->bus_context, map->work_buf, + ret = map->bus->write(map->dev, map->work_buf, map->format.reg_bytes + map->format.pad_bytes + val_len); else if (map->bus->gather_write) - ret = map->bus->gather_write(map->bus_context, map->work_buf, + ret = map->bus->gather_write(map->dev, map->work_buf, map->format.reg_bytes + map->format.pad_bytes, val, val_len); @@ -558,7 +464,7 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg, memcpy(buf, map->work_buf, map->format.reg_bytes); memcpy(buf + map->format.reg_bytes + map->format.pad_bytes, val, val_len); - ret = map->bus->write(map->bus_context, buf, len); + ret = map->bus->write(map->dev, buf, len); kfree(buf); } @@ -592,7 +498,7 @@ int _regmap_write(struct regmap *map, unsigned int reg, trace_regmap_hw_write_start(map->dev, reg, 1); - ret = map->bus->write(map->bus_context, map->work_buf, + ret = map->bus->write(map->dev, map->work_buf, map->format.buf_size); trace_regmap_hw_write_done(map->dev, reg, 1); @@ -623,11 +529,11 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val) { int ret; - map->lock(map); + mutex_lock(&map->lock); ret = _regmap_write(map, reg, val); - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -654,14 +560,11 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, { int ret; - if (val_len % map->format.val_bytes) - return -EINVAL; - - map->lock(map); + mutex_lock(&map->lock); ret = _regmap_raw_write(map, reg, val, val_len); - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -691,7 +594,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, if (!map->format.parse_val) return -EINVAL; - map->lock(map); + mutex_lock(&map->lock); /* No formatting is require if val_byte is 1 */ if (val_bytes == 1) { @@ -712,7 +615,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, kfree(wval); out: - map->unlock(map); + mutex_unlock(&map->lock); return ret; } EXPORT_SYMBOL_GPL(regmap_bulk_write); @@ -736,7 +639,7 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val, trace_regmap_hw_read_start(map->dev, reg, val_len / map->format.val_bytes); - ret = map->bus->read(map->bus_context, map->work_buf, + ret = map->bus->read(map->dev, map->work_buf, map->format.reg_bytes + map->format.pad_bytes, val, val_len); @@ -786,11 +689,11 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val) { int ret; - map->lock(map); + mutex_lock(&map->lock); ret = _regmap_read(map, reg, val); - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -815,10 +718,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, unsigned int v; int ret, i; - if (val_len % map->format.val_bytes) - return -EINVAL; - - map->lock(map); + mutex_lock(&map->lock); if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass || map->cache_type == REGCACHE_NONE) { @@ -839,7 +739,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, } out: - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -892,7 +792,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, int ret; unsigned int tmp, orig; - map->lock(map); + mutex_lock(&map->lock); ret = _regmap_read(map, reg, &orig); if (ret != 0) @@ -909,7 +809,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, } out: - map->unlock(map); + mutex_unlock(&map->lock); return ret; } @@ -976,7 +876,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs, if (map->patch) return -EBUSY; - map->lock(map); + mutex_lock(&map->lock); bypass = map->cache_bypass; @@ -1004,7 +904,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs, out: map->cache_bypass = bypass; - map->unlock(map); + mutex_unlock(&map->lock); return ret; } diff --git a/trunk/drivers/mfd/da9052-core.c b/trunk/drivers/mfd/da9052-core.c index 7ff313fe9fb1..7776aff46269 100644 --- a/trunk/drivers/mfd/da9052-core.c +++ b/trunk/drivers/mfd/da9052-core.c @@ -659,12 +659,11 @@ int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id) ret = regmap_add_irq_chip(da9052->regmap, da9052->chip_irq, IRQF_TRIGGER_LOW | IRQF_ONESHOT, da9052->irq_base, &da9052_regmap_irq_chip, - NULL); + &da9052->irq_data); if (ret < 0) goto regmap_err; - desc = irq_to_desc(da9052->chip_irq); - da9052->irq_base = regmap_irq_chip_get_base(desc->action->dev_id); + da9052->irq_base = regmap_irq_chip_get_base(da9052->irq_data); ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info, ARRAY_SIZE(da9052_subdev_info), NULL, 0); @@ -681,8 +680,7 @@ int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id) void da9052_device_exit(struct da9052 *da9052) { - regmap_del_irq_chip(da9052->chip_irq, - irq_get_irq_data(da9052->irq_base)->chip_data); + regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); mfd_remove_devices(da9052->dev); } diff --git a/trunk/include/linux/mfd/da9052/da9052.h b/trunk/include/linux/mfd/da9052/da9052.h index 7ffbd6e9e7fc..8313cd9658e3 100644 --- a/trunk/include/linux/mfd/da9052/da9052.h +++ b/trunk/include/linux/mfd/da9052/da9052.h @@ -80,6 +80,7 @@ struct da9052 { struct regmap *regmap; int irq_base; + struct regmap_irq_chip_data *irq_data; u8 chip_id; int chip_irq; diff --git a/trunk/include/linux/regmap.h b/trunk/include/linux/regmap.h index 90a4652eaaea..a90abb6bfa64 100644 --- a/trunk/include/linux/regmap.h +++ b/trunk/include/linux/regmap.h @@ -97,21 +97,18 @@ struct regmap_config { u8 write_flag_mask; }; -typedef int (*regmap_hw_write)(void *context, const void *data, +typedef int (*regmap_hw_write)(struct device *dev, const void *data, size_t count); -typedef int (*regmap_hw_gather_write)(void *context, +typedef int (*regmap_hw_gather_write)(struct device *dev, const void *reg, size_t reg_len, const void *val, size_t val_len); -typedef int (*regmap_hw_read)(void *context, +typedef int (*regmap_hw_read)(struct device *dev, const void *reg_buf, size_t reg_size, void *val_buf, size_t val_size); -typedef void (*regmap_hw_free_context)(void *context); /** * Description of a hardware bus for the register map infrastructure. * - * @fast_io: Register IO is fast. Use a spinlock instead of a mutex - * to perform locking. * @write: Write operation. * @gather_write: Write operation with split register/value, return -ENOTSUPP * if not implemented on a given device. @@ -121,42 +118,31 @@ typedef void (*regmap_hw_free_context)(void *context); * a read. */ struct regmap_bus { - bool fast_io; regmap_hw_write write; regmap_hw_gather_write gather_write; regmap_hw_read read; - regmap_hw_free_context free_context; u8 read_flag_mask; }; struct regmap *regmap_init(struct device *dev, const struct regmap_bus *bus, - void *bus_context, const struct regmap_config *config); struct regmap *regmap_init_i2c(struct i2c_client *i2c, const struct regmap_config *config); struct regmap *regmap_init_spi(struct spi_device *dev, const struct regmap_config *config); -struct regmap *regmap_init_mmio(struct device *dev, - void __iomem *regs, - const struct regmap_config *config); struct regmap *devm_regmap_init(struct device *dev, const struct regmap_bus *bus, - void *bus_context, const struct regmap_config *config); struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c, const struct regmap_config *config); struct regmap *devm_regmap_init_spi(struct spi_device *dev, const struct regmap_config *config); -struct regmap *devm_regmap_init_mmio(struct device *dev, - void __iomem *regs, - const struct regmap_config *config); void regmap_exit(struct regmap *map); int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config); -struct regmap *dev_get_regmap(struct device *dev, const char *name); int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); int regmap_raw_write(struct regmap *map, unsigned int reg, const void *val, size_t val_len); @@ -341,13 +327,6 @@ static inline int regmap_register_patch(struct regmap *map, return -EINVAL; } -static inline struct regmap *dev_get_regmap(struct device *dev, - const char *name) -{ - WARN_ONCE(1, "regmap API is disabled"); - return NULL; -} - #endif #endif