diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-28 16:01:34 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-28 16:01:34 -0400 |
commit | 18f513db93408fdeeba68d5b0931bc26315d28b4 (patch) | |
tree | 111d33e40ac84adea0c625a393d5724a69d0da4b | |
parent | 6cf3d823230794a6e6b3f99541cdb91176614036 (diff) | |
parent | e33fabd365596178e72f62bb4b89f0aaad0509ad (diff) |
Merge remote-tracking branch 'regmap/topic/multi' into regmap-next
-rw-r--r-- | drivers/base/regmap/regmap.c | 41 | ||||
-rw-r--r-- | include/linux/regmap.h | 2 |
2 files changed, 43 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index c7111d0d16fb..9c021d9cace0 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -1564,6 +1564,47 @@ out: | |||
1564 | } | 1564 | } |
1565 | EXPORT_SYMBOL_GPL(regmap_bulk_write); | 1565 | EXPORT_SYMBOL_GPL(regmap_bulk_write); |
1566 | 1566 | ||
1567 | /* | ||
1568 | * regmap_multi_reg_write(): Write multiple registers to the device | ||
1569 | * | ||
1570 | * where the set of register are supplied in any order | ||
1571 | * | ||
1572 | * @map: Register map to write to | ||
1573 | * @regs: Array of structures containing register,value to be written | ||
1574 | * @num_regs: Number of registers to write | ||
1575 | * | ||
1576 | * This function is intended to be used for writing a large block of data | ||
1577 | * atomically to the device in single transfer for those I2C client devices | ||
1578 | * that implement this alternative block write mode. | ||
1579 | * | ||
1580 | * A value of zero will be returned on success, a negative errno will | ||
1581 | * be returned in error cases. | ||
1582 | */ | ||
1583 | int regmap_multi_reg_write(struct regmap *map, struct reg_default *regs, | ||
1584 | int num_regs) | ||
1585 | { | ||
1586 | int ret = 0, i; | ||
1587 | |||
1588 | for (i = 0; i < num_regs; i++) { | ||
1589 | int reg = regs[i].reg; | ||
1590 | if (reg % map->reg_stride) | ||
1591 | return -EINVAL; | ||
1592 | } | ||
1593 | |||
1594 | map->lock(map->lock_arg); | ||
1595 | |||
1596 | for (i = 0; i < num_regs; i++) { | ||
1597 | ret = _regmap_write(map, regs[i].reg, regs[i].def); | ||
1598 | if (ret != 0) | ||
1599 | goto out; | ||
1600 | } | ||
1601 | out: | ||
1602 | map->unlock(map->lock_arg); | ||
1603 | |||
1604 | return ret; | ||
1605 | } | ||
1606 | EXPORT_SYMBOL_GPL(regmap_multi_reg_write); | ||
1607 | |||
1567 | /** | 1608 | /** |
1568 | * regmap_raw_write_async(): Write raw values to one or more registers | 1609 | * regmap_raw_write_async(): Write raw values to one or more registers |
1569 | * asynchronously | 1610 | * asynchronously |
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index dc90b8c134a1..336718382ebb 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
@@ -379,6 +379,8 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, | |||
379 | const void *val, size_t val_len); | 379 | const void *val, size_t val_len); |
380 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | 380 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
381 | size_t val_count); | 381 | size_t val_count); |
382 | int regmap_multi_reg_write(struct regmap *map, struct reg_default *regs, | ||
383 | int num_regs); | ||
382 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, | 384 | int regmap_raw_write_async(struct regmap *map, unsigned int reg, |
383 | const void *val, size_t val_len); | 385 | const void *val, size_t val_len); |
384 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); | 386 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); |