regmap: add force_write option on _regmap_update_bits()
Sometimes we want to write data even though it doesn't change value. Then, force_write option on _regmap_update_bits() helps this purpose. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
d770e558e2
commit
7ff0589c7b
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||||
unsigned int mask, unsigned int val,
|
unsigned int mask, unsigned int val,
|
||||||
bool *change);
|
bool *change, bool force_write);
|
||||||
|
|
||||||
static int _regmap_bus_reg_read(void *context, unsigned int reg,
|
static int _regmap_bus_reg_read(void *context, unsigned int reg,
|
||||||
unsigned int *val);
|
unsigned int *val);
|
||||||
@@ -1178,7 +1178,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg,
|
|||||||
ret = _regmap_update_bits(map, range->selector_reg,
|
ret = _regmap_update_bits(map, range->selector_reg,
|
||||||
range->selector_mask,
|
range->selector_mask,
|
||||||
win_page << range->selector_shift,
|
win_page << range->selector_shift,
|
||||||
&page_chg);
|
&page_chg, false);
|
||||||
|
|
||||||
map->work_buf = orig_work_buf;
|
map->work_buf = orig_work_buf;
|
||||||
|
|
||||||
@@ -2327,7 +2327,7 @@ EXPORT_SYMBOL_GPL(regmap_bulk_read);
|
|||||||
|
|
||||||
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||||
unsigned int mask, unsigned int val,
|
unsigned int mask, unsigned int val,
|
||||||
bool *change)
|
bool *change, bool force_write)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int tmp, orig;
|
unsigned int tmp, orig;
|
||||||
@@ -2339,7 +2339,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
|||||||
tmp = orig & ~mask;
|
tmp = orig & ~mask;
|
||||||
tmp |= val & mask;
|
tmp |= val & mask;
|
||||||
|
|
||||||
if (tmp != orig) {
|
if (force_write || (tmp != orig)) {
|
||||||
ret = _regmap_write(map, reg, tmp);
|
ret = _regmap_write(map, reg, tmp);
|
||||||
if (change)
|
if (change)
|
||||||
*change = true;
|
*change = true;
|
||||||
@@ -2367,7 +2367,7 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
map->lock(map->lock_arg);
|
map->lock(map->lock_arg);
|
||||||
ret = _regmap_update_bits(map, reg, mask, val, NULL);
|
ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
|
||||||
map->unlock(map->lock_arg);
|
map->unlock(map->lock_arg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -2398,7 +2398,7 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg,
|
|||||||
|
|
||||||
map->async = true;
|
map->async = true;
|
||||||
|
|
||||||
ret = _regmap_update_bits(map, reg, mask, val, NULL);
|
ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
|
||||||
|
|
||||||
map->async = false;
|
map->async = false;
|
||||||
|
|
||||||
@@ -2427,7 +2427,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
map->lock(map->lock_arg);
|
map->lock(map->lock_arg);
|
||||||
ret = _regmap_update_bits(map, reg, mask, val, change);
|
ret = _regmap_update_bits(map, reg, mask, val, change, false);
|
||||||
map->unlock(map->lock_arg);
|
map->unlock(map->lock_arg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2460,7 +2460,7 @@ int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
|
|||||||
|
|
||||||
map->async = true;
|
map->async = true;
|
||||||
|
|
||||||
ret = _regmap_update_bits(map, reg, mask, val, change);
|
ret = _regmap_update_bits(map, reg, mask, val, change, false);
|
||||||
|
|
||||||
map->async = false;
|
map->async = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user