regmap: add regmap_field_update_bits()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 2 Sep 2013 03:24:50 +0000 (20:24 -0700)
committerMark Brown <broonie@linaro.org>
Mon, 16 Sep 2013 23:12:23 +0000 (00:12 +0100)
Current regmap_field is supporting read/write functions.
This patch adds new update_bits function for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/base/regmap/regmap.c
include/linux/regmap.h

index 7d689a15c500bb34ddc3331f33b57512890341aa..285afa7470c07a0ce8183f4951c8ff2696384d0d 100644 (file)
@@ -1369,6 +1369,26 @@ int regmap_field_write(struct regmap_field *field, unsigned int val)
 }
 EXPORT_SYMBOL_GPL(regmap_field_write);
 
+/**
+ * regmap_field_update_bits(): Perform a read/modify/write cycle
+ *                              on the register field
+ *
+ * @field: Register field to write to
+ * @mask: Bitmask to change
+ * @val: Value to be written
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val)
+{
+       mask = (mask << field->shift) & field->mask;
+
+       return regmap_update_bits(field->regmap, field->reg,
+                                 mask, val << field->shift);
+}
+EXPORT_SYMBOL_GPL(regmap_field_update_bits);
+
 /*
  * regmap_bulk_write(): Write multiple registers to the device
  *
index a10380bfbeac9b4c4d018c99a5c914d672833f04..4c8c20a7a75dac66f406a976af8d1825aba81ffa 100644 (file)
@@ -448,6 +448,8 @@ void devm_regmap_field_free(struct device *dev,     struct regmap_field *field);
 
 int regmap_field_read(struct regmap_field *field, unsigned int *val);
 int regmap_field_write(struct regmap_field *field, unsigned int val);
+int regmap_field_update_bits(struct regmap_field *field,
+                            unsigned int mask, unsigned int val);
 
 /**
  * Description of an IRQ for the generic regmap irq_chip.