aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Pargmann <mpa@pengutronix.de>2015-08-21 04:26:42 -0400
committerMark Brown <broonie@kernel.org>2015-08-21 12:33:10 -0400
commit67921a1a6660d32cc2770d05d656a1187b6d94d5 (patch)
tree7106e1e16b5a97b7ffa38c20bbd54811b3520390
parentc594b7f21d7d02115e828db46fddbba1da7ed1b8 (diff)
regmap: Split use_single_rw internally into use_single_read/write
use_single_rw currently reflects the capabilities of the connected device. The capabilities of the bus are currently missing for this variable. As there are read only and write only buses we need seperate values for use_single_rw to also reflect tha capabilities of the bus. This patch splits use_single_rw into use_single_read and use_single_write. The initialization is changed to check the configuration for use_single_rw and to check the capabilities of the used bus. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/base/regmap/internal.h6
-rw-r--r--drivers/base/regmap/regcache.c2
-rw-r--r--drivers/base/regmap/regmap-irq.c4
-rw-r--r--drivers/base/regmap/regmap.c9
4 files changed, 12 insertions, 9 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index b2b2849fc6d3..d744ae3926dd 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -139,8 +139,10 @@ struct regmap {
139 struct reg_default *patch; 139 struct reg_default *patch;
140 int patch_regs; 140 int patch_regs;
141 141
142 /* if set, converts bulk rw to single rw */ 142 /* if set, converts bulk read to single read */
143 bool use_single_rw; 143 bool use_single_read;
144 /* if set, converts bulk read to single read */
145 bool use_single_write;
144 /* if set, the device supports multi write mode */ 146 /* if set, the device supports multi write mode */
145 bool can_multi_write; 147 bool can_multi_write;
146 148
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index b9862d741a56..6f8a13ec32a4 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -729,7 +729,7 @@ int regcache_sync_block(struct regmap *map, void *block,
729 unsigned int block_base, unsigned int start, 729 unsigned int block_base, unsigned int start,
730 unsigned int end) 730 unsigned int end)
731{ 731{
732 if (regmap_can_raw_write(map) && !map->use_single_rw) 732 if (regmap_can_raw_write(map) && !map->use_single_write)
733 return regcache_sync_block_raw(map, block, cache_present, 733 return regcache_sync_block_raw(map, block, cache_present,
734 block_base, start, end); 734 block_base, start, end);
735 else 735 else
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 2597600a5d26..38d1f72d869c 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -209,7 +209,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
209 * Read in the statuses, using a single bulk read if possible 209 * Read in the statuses, using a single bulk read if possible
210 * in order to reduce the I/O overheads. 210 * in order to reduce the I/O overheads.
211 */ 211 */
212 if (!map->use_single_rw && map->reg_stride == 1 && 212 if (!map->use_single_read && map->reg_stride == 1 &&
213 data->irq_reg_stride == 1) { 213 data->irq_reg_stride == 1) {
214 u8 *buf8 = data->status_reg_buf; 214 u8 *buf8 = data->status_reg_buf;
215 u16 *buf16 = data->status_reg_buf; 215 u16 *buf16 = data->status_reg_buf;
@@ -398,7 +398,7 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
398 else 398 else
399 d->irq_reg_stride = 1; 399 d->irq_reg_stride = 1;
400 400
401 if (!map->use_single_rw && map->reg_stride == 1 && 401 if (!map->use_single_read && map->reg_stride == 1 &&
402 d->irq_reg_stride == 1) { 402 d->irq_reg_stride == 1) {
403 d->status_reg_buf = kmalloc(map->format.val_bytes * 403 d->status_reg_buf = kmalloc(map->format.val_bytes *
404 chip->num_regs, GFP_KERNEL); 404 chip->num_regs, GFP_KERNEL);
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 90bf5ea34c47..bc82fd34483b 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -576,7 +576,8 @@ struct regmap *regmap_init(struct device *dev,
576 map->reg_stride = config->reg_stride; 576 map->reg_stride = config->reg_stride;
577 else 577 else
578 map->reg_stride = 1; 578 map->reg_stride = 1;
579 map->use_single_rw = config->use_single_rw; 579 map->use_single_read = config->use_single_rw || !bus || !bus->read;
580 map->use_single_write = config->use_single_rw || !bus || !bus->write;
580 map->can_multi_write = config->can_multi_write; 581 map->can_multi_write = config->can_multi_write;
581 map->dev = dev; 582 map->dev = dev;
582 map->bus = bus; 583 map->bus = bus;
@@ -766,7 +767,7 @@ struct regmap *regmap_init(struct device *dev,
766 if ((reg_endian != REGMAP_ENDIAN_BIG) || 767 if ((reg_endian != REGMAP_ENDIAN_BIG) ||
767 (val_endian != REGMAP_ENDIAN_BIG)) 768 (val_endian != REGMAP_ENDIAN_BIG))
768 goto err_map; 769 goto err_map;
769 map->use_single_rw = true; 770 map->use_single_write = true;
770 } 771 }
771 772
772 if (!map->format.format_write && 773 if (!map->format.format_write &&
@@ -1720,7 +1721,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
1720 } 1721 }
1721out: 1722out:
1722 map->unlock(map->lock_arg); 1723 map->unlock(map->lock_arg);
1723 } else if (map->use_single_rw) { 1724 } else if (map->use_single_write) {
1724 map->lock(map->lock_arg); 1725 map->lock(map->lock_arg);
1725 for (i = 0; i < val_count; i++) { 1726 for (i = 0; i < val_count; i++) {
1726 ret = _regmap_raw_write(map, 1727 ret = _regmap_raw_write(map,
@@ -2312,7 +2313,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
2312 * Some devices does not support bulk read, for 2313 * Some devices does not support bulk read, for
2313 * them we have a series of single read operations. 2314 * them we have a series of single read operations.
2314 */ 2315 */
2315 if (map->use_single_rw) { 2316 if (map->use_single_read) {
2316 for (i = 0; i < val_count; i++) { 2317 for (i = 0; i < val_count; i++) {
2317 ret = regmap_raw_read(map, 2318 ret = regmap_raw_read(map,
2318 reg + (i * map->reg_stride), 2319 reg + (i * map->reg_stride),