2012-06-15 10:47:56

by Krystian Garbaciak

[permalink] [raw]
Subject: [PATCH 1/2 v2] regmap: Move lock out from internal function _regmap_update_bits().

Locks are moved to regmap_update_bits(), which allows to reenter internal
function _regmap_update_bits() from inside of regmap read/write routines.

Signed-off-by: Krystian Garbaciak <[email protected]>
---
drivers/base/regmap/regmap.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 0bcda48..ce35b8c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -980,11 +980,9 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
int ret;
unsigned int tmp, orig;

- map->lock(map);
-
ret = _regmap_read(map, reg, &orig);
if (ret != 0)
- goto out;
+ return ret;

tmp = orig & ~mask;
tmp |= val & mask;
@@ -996,9 +994,6 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
*change = false;
}

-out:
- map->unlock(map);
-
return ret;
}

@@ -1016,7 +1011,13 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
bool change;
- return _regmap_update_bits(map, reg, mask, val, &change);
+ int ret;
+
+ map->lock(map);
+ ret = _regmap_update_bits(map, reg, mask, val, &change);
+ map->unlock(map);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(regmap_update_bits);

@@ -1036,7 +1037,12 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
- return _regmap_update_bits(map, reg, mask, val, change);
+ int ret;
+
+ map->lock(map);
+ ret = _regmap_update_bits(map, reg, mask, val, change);
+ map->unlock(map);
+ return ret;
}
EXPORT_SYMBOL_GPL(regmap_update_bits_check);

--
1.7.0.4


2012-06-17 20:44:41

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/2 v2] regmap: Move lock out from internal function _regmap_update_bits().

On Fri, Jun 15, 2012 at 11:23:56AM +0100, Krystian Garbaciak wrote:
> Locks are moved to regmap_update_bits(), which allows to reenter internal
> function _regmap_update_bits() from inside of regmap read/write routines.

Applied, thanks.


Attachments:
(No filename) (238.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments