Skip to content

Commit fb44f3c

Browse files
charleskeepaxbroonie
authored andcommitted
regmap: Merge redundant handling in regmap_bulk_write
The handling for the first two cases in regmap_bulk_write is essentially identical. The first case is just a better implementation of the second, supporting 8 byte registers and doing the locking manually to avoid bouncing the lock for each register. Drop some redundant code by removing the second of these cases and allowing both situations to be handled by the same code. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 364e378 commit fb44f3c

1 file changed

Lines changed: 3 additions & 36 deletions

File tree

‎drivers/base/regmap/regmap.c‎

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,17 +1965,10 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
19651965
return -EINVAL;
19661966

19671967
/*
1968-
* Some devices don't support bulk write, for
1969-
* them we have a series of single write operations in the first two if
1970-
* blocks.
1971-
*
1972-
* The first if block is used for memory mapped io. It does not allow
1973-
* val_bytes of 3 for example.
1974-
* The second one is for busses that do not provide raw I/O.
1975-
* The third one is used for busses which do not have these limitations
1976-
* and can write arbitrary value lengths.
1968+
* Some devices don't support bulk write, for them we have a series of
1969+
* single write operations.
19771970
*/
1978-
if (!map->bus) {
1971+
if (!map->bus || !map->format.parse_inplace) {
19791972
map->lock(map->lock_arg);
19801973
for (i = 0; i < val_count; i++) {
19811974
unsigned int ival;
@@ -2008,32 +2001,6 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
20082001
}
20092002
out:
20102003
map->unlock(map->lock_arg);
2011-
} else if (map->bus && !map->format.parse_inplace) {
2012-
const u8 *u8 = val;
2013-
const u16 *u16 = val;
2014-
const u32 *u32 = val;
2015-
unsigned int ival;
2016-
2017-
for (i = 0; i < val_count; i++) {
2018-
switch (map->format.val_bytes) {
2019-
case 4:
2020-
ival = u32[i];
2021-
break;
2022-
case 2:
2023-
ival = u16[i];
2024-
break;
2025-
case 1:
2026-
ival = u8[i];
2027-
break;
2028-
default:
2029-
return -EINVAL;
2030-
}
2031-
2032-
ret = regmap_write(map, reg + regmap_get_offset(map, i),
2033-
ival);
2034-
if (ret)
2035-
return ret;
2036-
}
20372004
} else {
20382005
void *wval;
20392006

0 commit comments

Comments
 (0)