Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8019ff6c authored by Nariman Poushin's avatar Nariman Poushin Committed by Mark Brown
Browse files

regmap: Use reg_sequence for multi_reg_write / register_patch



Separate the functionality using sequences of register writes from the
functions that take register defaults. This change renames the arguments
in order to support the extension of reg_sequence to take an optional
delay to be applied after any given register in a sequence is written.
This avoids adding an int to all register defaults, which could
substantially increase memory usage for regmaps with large default tables.

This also updates all the clients of multi_reg_write/register_patch.

Signed-off-by: default avatarNariman Poushin <nariman@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent d770e558
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ struct regmap {
	/* if set, the HW registers are known to match map->reg_defaults */
	bool no_sync_defaults;

	struct reg_default *patch;
	struct reg_sequence *patch;
	int patch_regs;

	/* if set, converts bulk rw to single rw */
+11 −11
Original line number Diff line number Diff line
@@ -1743,7 +1743,7 @@ EXPORT_SYMBOL_GPL(regmap_bulk_write);
 * relative. The page register has been written if that was neccessary.
 */
static int _regmap_raw_multi_reg_write(struct regmap *map,
				       const struct reg_default *regs,
				       const struct reg_sequence *regs,
				       size_t num_regs)
{
	int ret;
@@ -1800,12 +1800,12 @@ static unsigned int _regmap_register_page(struct regmap *map,
}

static int _regmap_range_multi_paged_reg_write(struct regmap *map,
					       struct reg_default *regs,
					       struct reg_sequence *regs,
					       size_t num_regs)
{
	int ret;
	int i, n;
	struct reg_default *base;
	struct reg_sequence *base;
	unsigned int this_page = 0;
	/*
	 * the set of registers are not neccessarily in order, but
@@ -1843,7 +1843,7 @@ static int _regmap_range_multi_paged_reg_write(struct regmap *map,
}

static int _regmap_multi_reg_write(struct regmap *map,
				   const struct reg_default *regs,
				   const struct reg_sequence *regs,
				   size_t num_regs)
{
	int i;
@@ -1895,8 +1895,8 @@ static int _regmap_multi_reg_write(struct regmap *map,
		struct regmap_range_node *range;
		range = _regmap_range_lookup(map, reg);
		if (range) {
			size_t len = sizeof(struct reg_default)*num_regs;
			struct reg_default *base = kmemdup(regs, len,
			size_t len = sizeof(struct reg_sequence)*num_regs;
			struct reg_sequence *base = kmemdup(regs, len,
							   GFP_KERNEL);
			if (!base)
				return -ENOMEM;
@@ -1929,7 +1929,7 @@ static int _regmap_multi_reg_write(struct regmap *map,
 * A value of zero will be returned on success, a negative errno will be
 * returned in error cases.
 */
int regmap_multi_reg_write(struct regmap *map, const struct reg_default *regs,
int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs,
			   int num_regs)
{
	int ret;
@@ -1962,7 +1962,7 @@ EXPORT_SYMBOL_GPL(regmap_multi_reg_write);
 * be returned in error cases.
 */
int regmap_multi_reg_write_bypassed(struct regmap *map,
				    const struct reg_default *regs,
				    const struct reg_sequence *regs,
				    int num_regs)
{
	int ret;
@@ -2552,10 +2552,10 @@ EXPORT_SYMBOL_GPL(regmap_async_complete);
 * The caller must ensure that this function cannot be called
 * concurrently with either itself or regcache_sync().
 */
int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
			  int num_regs)
{
	struct reg_default *p;
	struct reg_sequence *p;
	int ret;
	bool bypass;

@@ -2564,7 +2564,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
		return 0;

	p = krealloc(map->patch,
		     sizeof(struct reg_default) * (map->patch_regs + num_regs),
		     sizeof(struct reg_sequence) * (map->patch_regs + num_regs),
		     GFP_KERNEL);
	if (p) {
		memcpy(p + map->patch_regs, regs, num_regs * sizeof(*regs));
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ static struct adv7511 *encoder_to_adv7511(struct drm_encoder *encoder)
}

/* ADI recommended values for proper operation. */
static const struct reg_default adv7511_fixed_registers[] = {
static const struct reg_sequence adv7511_fixed_registers[] = {
	{ 0x98, 0x03 },
	{ 0x9a, 0xe0 },
	{ 0x9c, 0x30 },
+3 −3
Original line number Diff line number Diff line
@@ -313,14 +313,14 @@ static void drv260x_close(struct input_dev *input)
	gpiod_set_value(haptics->enable_gpio, 0);
}

static const struct reg_default drv260x_lra_cal_regs[] = {
static const struct reg_sequence drv260x_lra_cal_regs[] = {
	{ DRV260X_MODE, DRV260X_AUTO_CAL },
	{ DRV260X_CTRL3, DRV260X_NG_THRESH_2 },
	{ DRV260X_FEEDBACK_CTRL, DRV260X_FB_REG_LRA_MODE |
		DRV260X_BRAKE_FACTOR_4X | DRV260X_LOOP_GAIN_HIGH },
};

static const struct reg_default drv260x_lra_init_regs[] = {
static const struct reg_sequence drv260x_lra_init_regs[] = {
	{ DRV260X_MODE, DRV260X_RT_PLAYBACK },
	{ DRV260X_A_TO_V_CTRL, DRV260X_AUDIO_HAPTICS_PEAK_20MS |
		DRV260X_AUDIO_HAPTICS_FILTER_125HZ },
@@ -337,7 +337,7 @@ static const struct reg_default drv260x_lra_init_regs[] = {
	{ DRV260X_CTRL4, DRV260X_AUTOCAL_TIME_500MS },
};

static const struct reg_default drv260x_erm_cal_regs[] = {
static const struct reg_sequence drv260x_erm_cal_regs[] = {
	{ DRV260X_MODE, DRV260X_AUTO_CAL },
	{ DRV260X_A_TO_V_MIN_INPUT, DRV260X_AUDIO_HAPTICS_MIN_IN_VOLT },
	{ DRV260X_A_TO_V_MAX_INPUT, DRV260X_AUDIO_HAPTICS_MAX_IN_VOLT },
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ static void drv2665_close(struct input_dev *input)
			"Failed to enter standby mode: %d\n", error);
}

static const struct reg_default drv2665_init_regs[] = {
static const struct reg_sequence drv2665_init_regs[] = {
	{ DRV2665_CTRL_2, 0 | DRV2665_10_MS_IDLE_TOUT },
	{ DRV2665_CTRL_1, DRV2665_25_VPP_GAIN },
};
Loading