diff options
author | Anthony Olech <anthony.olech.opensource@diasemi.com> | 2013-10-09 12:44:38 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-09 13:47:27 -0400 |
commit | 4174a7a4f763ed51809a4dbca06de054d31c1d38 (patch) | |
tree | 4a9c3bf3ff7390545e13851bcece13b1f2ea7429 | |
parent | d0e639c9e06d44e713170031fe05fb60ebe680af (diff) |
regmap: Fix regmap_bulk_write single-rw mutex deadlock
When regmap_bulk_write() is called with the map->use_single_rw flag set
an immediate mutex deadlock happens because regmap_raw_write() is called
after obtaining the mutex and regmap_raw_write() itself then tries to
obtain the mutex as well.
It is obvious that no one other than myself tried it with a real device.
I did, but only for the purposes of an experiment and demonstration.
But even if this situation will never ever happen with a real device, it
is a bug and therefore should be fixed.
Signed-off-by: Anthony Olech <anthony.olech.opensource@diasemi.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/base/regmap/regmap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 7d689a15c500..c1245cae0f43 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -1418,10 +1418,11 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | |||
1418 | */ | 1418 | */ |
1419 | if (map->use_single_rw) { | 1419 | if (map->use_single_rw) { |
1420 | for (i = 0; i < val_count; i++) { | 1420 | for (i = 0; i < val_count; i++) { |
1421 | ret = regmap_raw_write(map, | 1421 | ret = _regmap_raw_write(map, |
1422 | reg + (i * map->reg_stride), | 1422 | reg + (i * map->reg_stride), |
1423 | val + (i * val_bytes), | 1423 | val + (i * val_bytes), |
1424 | val_bytes); | 1424 | val_bytes, |
1425 | false); | ||
1425 | if (ret != 0) | 1426 | if (ret != 0) |
1426 | return ret; | 1427 | return ret; |
1427 | } | 1428 | } |