[alsa-devel] [PATCH 1/4] regmap: add regmap_field_update_bits()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Fri Aug 30 06:33:01 CEST 2013
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 at renesas.com>
---
drivers/base/regmap/regmap.c | 20 ++++++++++++++++++++
include/linux/regmap.h | 2 ++
2 files changed, 22 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e0d0c7d..7ae90d8 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1360,6 +1360,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_write);
+
/*
* regmap_bulk_write(): Write multiple registers to the device
*
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 75981d0..1425c91 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -446,6 +446,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.
--
1.7.9.5
More information about the Alsa-devel
mailing list