Skip to content

Commit

Permalink
regmap: split up regmap_config.use_single_rw
Browse files Browse the repository at this point in the history
Split regmap_config.use_single_rw into use_single_read and
use_single_write. This change enables drivers of devices which only
support bulk operations in one direction to use the regmap_bulk_*()
functions for both directions and have their bulk operation split into
single operations only when necessary.

Update all struct regmap_config instances where use_single_rw==true to
instead set both use_single_read and use_single_write. No attempt was
made to evaluate whether it is possible to set only one of
use_single_read or use_single_write.

Signed-off-by: David Frey <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
dpfrey authored and broonie committed Sep 7, 2018
1 parent 9ad8eb0 commit 1c96a2f
Show file tree
Hide file tree
Showing 34 changed files with 93 additions and 52 deletions.
4 changes: 2 additions & 2 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,8 @@ struct regmap *__regmap_init(struct device *dev,
map->reg_stride_order = ilog2(map->reg_stride);
else
map->reg_stride_order = -1;
map->use_single_read = config->use_single_rw || !bus || !bus->read;
map->use_single_write = config->use_single_rw || !bus || !bus->write;
map->use_single_read = config->use_single_read || !bus || !bus->read;
map->use_single_write = config->use_single_write || !bus || !bus->write;
map->can_multi_write = config->can_multi_write && bus && bus->write;
if (bus) {
map->max_raw_read = bus->max_raw_read;
Expand Down
3 changes: 2 additions & 1 deletion drivers/edac/altera_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ static const struct regmap_config s10_sdram_regmap_cfg = {
.volatile_reg = s10_sdram_volatile_reg,
.reg_read = s10_protected_reg_read,
.reg_write = s10_protected_reg_write,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int altr_s10_sdram_probe(struct platform_device *pdev)
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ static const struct regmap_config lm75_regmap_config = {
.volatile_reg = lm75_is_volatile_reg,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static void lm75_remove(void *data)
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/lm95245.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ static const struct regmap_config lm95245_regmap_config = {
.writeable_reg = lm95245_is_writeable_reg,
.volatile_reg = lm95245_is_volatile_reg,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const u32 lm95245_chip_config[] = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/tmp102.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ static const struct regmap_config tmp102_regmap_config = {
.volatile_reg = tmp102_is_volatile_reg,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int tmp102_probe(struct i2c_client *client,
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/tmp108.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ static const struct regmap_config tmp108_regmap_config = {
.volatile_reg = tmp108_is_volatile_reg,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int tmp108_probe(struct i2c_client *client,
Expand Down
3 changes: 2 additions & 1 deletion drivers/iio/light/apds9960.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ static const struct regmap_config apds9960_regmap_config = {
.name = APDS9960_REGMAP_NAME,
.reg_bits = 8,
.val_bits = 8,
.use_single_rw = 1,
.use_single_read = true,
.use_single_write = true,

.volatile_table = &apds9960_volatile_table,
.precious_table = &apds9960_precious_table,
Expand Down
23 changes: 12 additions & 11 deletions drivers/iio/light/max44000.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,18 @@ static bool max44000_precious_reg(struct device *dev, unsigned int reg)
}

static const struct regmap_config max44000_regmap_config = {
.reg_bits = 8,
.val_bits = 8,

.max_register = MAX44000_REG_PRX_DATA,
.readable_reg = max44000_readable_reg,
.writeable_reg = max44000_writeable_reg,
.volatile_reg = max44000_volatile_reg,
.precious_reg = max44000_precious_reg,

.use_single_rw = 1,
.cache_type = REGCACHE_RBTREE,
.reg_bits = 8,
.val_bits = 8,

.max_register = MAX44000_REG_PRX_DATA,
.readable_reg = max44000_readable_reg,
.writeable_reg = max44000_writeable_reg,
.volatile_reg = max44000_volatile_reg,
.precious_reg = max44000_precious_reg,

.use_single_read = true,
.use_single_write = true,
.cache_type = REGCACHE_RBTREE,
};

static irqreturn_t max44000_trigger_handler(int irq, void *p)
Expand Down
3 changes: 2 additions & 1 deletion drivers/iio/temperature/mlx90632.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ static const struct regmap_config mlx90632_regmap = {
.rd_table = &mlx90632_readable_regs_tbl,
.wr_table = &mlx90632_writeable_regs_tbl,

.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.reg_format_endian = REGMAP_ENDIAN_BIG,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
Expand Down
3 changes: 2 additions & 1 deletion drivers/input/touchscreen/tsc200x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const struct regmap_config tsc200x_regmap_config = {
.read_flag_mask = TSC200X_REG_READ,
.write_flag_mask = TSC200X_REG_PND0,
.wr_table = &tsc200x_writable_table,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};
EXPORT_SYMBOL_GPL(tsc200x_regmap_config);

Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/altera-a10sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ static const struct regmap_config altr_a10sr_regmap_config = {

.cache_type = REGCACHE_NONE,

.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.read_flag_mask = 1,
.write_flag_mask = 0,

Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/da9052-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ static int da9052_spi_probe(struct spi_device *spi)
config.reg_bits = 7;
config.pad_bits = 1;
config.val_bits = 8;
config.use_single_rw = 1;
config.use_single_read = true;
config.use_single_write = true;

da9052->regmap = devm_regmap_init_spi(spi, &config);
if (IS_ERR(da9052->regmap)) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/mc13xxx-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static const struct regmap_config mc13xxx_regmap_spi_config = {
.max_register = MC13XXX_NUMREGS,

.cache_type = REGCACHE_NONE,
.use_single_rw = 1,
.use_single_read = true,
.use_single_write = true,
};

static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/twl6040.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ static const struct regmap_config twl6040_regmap_config = {
.writeable_reg = twl6040_writeable_reg,

.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const struct regmap_irq twl6040_irqs[] = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/ltc3589.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ static const struct regmap_config ltc3589_regmap_config = {
.max_register = LTC3589_L2DTV2,
.reg_defaults = ltc3589_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(ltc3589_reg_defaults),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.cache_type = REGCACHE_RBTREE,
};

Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/ltc3676.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ static const struct regmap_config ltc3676_regmap_config = {
.readable_reg = ltc3676_readable_reg,
.volatile_reg = ltc3676_volatile_reg,
.max_register = LTC3676_CLIRQ,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.cache_type = REGCACHE_RBTREE,
};

Expand Down
12 changes: 8 additions & 4 deletions include/linux/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,12 @@ typedef void (*regmap_unlock)(void *);
* masks are used.
* @zero_flag_mask: If set, read_flag_mask and write_flag_mask are used even
* if they are both empty.
* @use_single_rw: If set, converts the bulk read and write operations into
* a series of single read and write operations. This is useful
* for device that does not support bulk read and write.
* @use_single_read: If set, converts the bulk read operation into a series of
* single read operations. This is useful for a device that
* does not support bulk read.
* @use_single_write: If set, converts the bulk write operation into a series of
* single write operations. This is useful for a device that
* does not support bulk write.
* @can_multi_write: If set, the device supports the multi write mode of bulk
* write operations, if clear multi write requests will be
* split into individual write operations
Expand Down Expand Up @@ -380,7 +383,8 @@ struct regmap_config {
unsigned long write_flag_mask;
bool zero_flag_mask;

bool use_single_rw;
bool use_single_read;
bool use_single_write;
bool can_multi_write;

enum regmap_endian reg_format_endian;
Expand Down
3 changes: 2 additions & 1 deletion sound/hda/hdac_regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ static const struct regmap_config hda_regmap_cfg = {
.cache_type = REGCACHE_RBTREE,
.reg_read = hda_reg_read,
.reg_write = hda_reg_write,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

/**
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/cs35l33.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ static const struct regmap_config cs35l33_regmap = {
.readable_reg = cs35l33_readable_register,
.writeable_reg = cs35l33_writeable_register,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int __maybe_unused cs35l33_runtime_resume(struct device *dev)
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/cs35l35.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,8 @@ static struct regmap_config cs35l35_regmap = {
.readable_reg = cs35l35_readable_register,
.precious_reg = cs35l35_precious_register,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static irqreturn_t cs35l35_irq(int irq, void *data)
Expand Down
4 changes: 3 additions & 1 deletion sound/soc/codecs/cs43130.c
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,9 @@ static const struct regmap_config cs43130_regmap = {
.precious_reg = cs43130_precious_register,
.volatile_reg = cs43130_volatile_register,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true, /* needed for regcache_sync */
/* needed for regcache_sync */
.use_single_read = true,
.use_single_write = true,
};

static u16 const cs43130_dc_threshold[CS43130_DC_THRESHOLD] = {
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/es8328.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ const struct regmap_config es8328_regmap_config = {
.val_bits = 8,
.max_register = ES8328_REG_MAX,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};
EXPORT_SYMBOL_GPL(es8328_regmap_config);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,8 @@ static const struct regmap_config rt1305_regmap = {
.num_reg_defaults = ARRAY_SIZE(rt1305_reg),
.ranges = rt1305_ranges,
.num_ranges = ARRAY_SIZE(rt1305_ranges),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

#if defined(CONFIG_OF)
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5514.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,8 @@ static const struct regmap_config rt5514_regmap = {
.cache_type = REGCACHE_RBTREE,
.reg_defaults = rt5514_reg,
.num_reg_defaults = ARRAY_SIZE(rt5514_reg),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const struct i2c_device_id rt5514_i2c_id[] = {
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5616.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,8 @@ static const struct snd_soc_component_driver soc_component_dev_rt5616 = {
static const struct regmap_config rt5616_regmap = {
.reg_bits = 8,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = RT5616_DEVICE_ID + 1 + (ARRAY_SIZE(rt5616_ranges) *
RT5616_PR_SPACING),
.volatile_reg = rt5616_volatile_register,
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5640.c
Original file line number Diff line number Diff line change
Expand Up @@ -2704,7 +2704,8 @@ static const struct snd_soc_component_driver soc_component_dev_rt5640 = {
static const struct regmap_config rt5640_regmap = {
.reg_bits = 8,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,

.max_register = RT5640_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5640_ranges) *
RT5640_PR_SPACING),
Expand Down
9 changes: 6 additions & 3 deletions sound/soc/codecs/rt5645.c
Original file line number Diff line number Diff line change
Expand Up @@ -3559,7 +3559,8 @@ static const struct snd_soc_component_driver soc_component_dev_rt5645 = {
static const struct regmap_config rt5645_regmap = {
.reg_bits = 8,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) *
RT5645_PR_SPACING),
.volatile_reg = rt5645_volatile_register,
Expand All @@ -3575,7 +3576,8 @@ static const struct regmap_config rt5645_regmap = {
static const struct regmap_config rt5650_regmap = {
.reg_bits = 8,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) *
RT5645_PR_SPACING),
.volatile_reg = rt5645_volatile_register,
Expand All @@ -3592,7 +3594,8 @@ static const struct regmap_config temp_regmap = {
.name="nocache",
.reg_bits = 8,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = RT5645_VENDOR_ID2 + 1,
.cache_type = REGCACHE_NONE,
};
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5651.c
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,8 @@ static const struct regmap_config rt5651_regmap = {
.num_reg_defaults = ARRAY_SIZE(rt5651_reg),
.ranges = rt5651_ranges,
.num_ranges = ARRAY_SIZE(rt5651_ranges),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

#if defined(CONFIG_OF)
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5660.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,8 @@ static const struct snd_soc_component_driver soc_component_dev_rt5660 = {
static const struct regmap_config rt5660_regmap = {
.reg_bits = 8,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,

.max_register = RT5660_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5660_ranges) *
RT5660_PR_SPACING),
Expand Down
9 changes: 6 additions & 3 deletions sound/soc/codecs/rt5663.c
Original file line number Diff line number Diff line change
Expand Up @@ -3252,7 +3252,8 @@ static const struct snd_soc_component_driver soc_component_dev_rt5663 = {
static const struct regmap_config rt5663_v2_regmap = {
.reg_bits = 16,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = 0x07fa,
.volatile_reg = rt5663_v2_volatile_register,
.readable_reg = rt5663_v2_readable_register,
Expand All @@ -3264,7 +3265,8 @@ static const struct regmap_config rt5663_v2_regmap = {
static const struct regmap_config rt5663_regmap = {
.reg_bits = 16,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = 0x03f3,
.volatile_reg = rt5663_volatile_register,
.readable_reg = rt5663_readable_register,
Expand All @@ -3277,7 +3279,8 @@ static const struct regmap_config temp_regmap = {
.name = "nocache",
.reg_bits = 16,
.val_bits = 16,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.max_register = 0x03f3,
.cache_type = REGCACHE_NONE,
};
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5665.c
Original file line number Diff line number Diff line change
Expand Up @@ -4633,7 +4633,8 @@ static const struct regmap_config rt5665_regmap = {
.cache_type = REGCACHE_RBTREE,
.reg_defaults = rt5665_reg,
.num_reg_defaults = ARRAY_SIZE(rt5665_reg),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const struct i2c_device_id rt5665_i2c_id[] = {
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/rt5668.c
Original file line number Diff line number Diff line change
Expand Up @@ -2375,7 +2375,8 @@ static const struct regmap_config rt5668_regmap = {
.cache_type = REGCACHE_RBTREE,
.reg_defaults = rt5668_reg,
.num_reg_defaults = ARRAY_SIZE(rt5668_reg),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const struct i2c_device_id rt5668_i2c_id[] = {
Expand Down
Loading

0 comments on commit 1c96a2f

Please sign in to comment.