[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1336376139-1048-2-git-send-email-ldewangan@nvidia.com>
Date: Mon, 7 May 2012 13:05:36 +0530
From: Laxman Dewangan <ldewangan@...dia.com>
To: broonie@...nsource.wolfsonmicro.com, gregkh@...uxfoundation.org,
lrg@...com, linux-kernel@...r.kernel.org
Cc: Laxman Dewangan <ldewangan@...dia.com>
Subject: [PATCH V1 1/4] regmap: add function for set/clear bits
Add regmap_set_bits() and regmap_clear_bits() for
setting/clearing bits.
Although this can be achieve by regmap_update_bits() but
having these functions gives good readability in driver
code which uses regmap apis.
Signed-off-by: Laxman Dewangan <ldewangan@...dia.com>
---
drivers/base/regmap/regmap.c | 32 ++++++++++++++++++++++++++++++++
include/linux/regmap.h | 15 +++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 8a25006..d0c8144 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -942,6 +942,38 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
EXPORT_SYMBOL_GPL(regmap_update_bits_check);
/**
+ * regmap_set_bits: Set bits of register.
+ *
+ * @map: Register map to update
+ * @reg: Register to update
+ * @bits: Bits to set
+ *
+ * Returns zero for success, a negative number on error.
+ */
+int regmap_set_bits(struct regmap *map, unsigned int reg, unsigned int bits)
+{
+ bool change;
+ return _regmap_update_bits(map, reg, bits, bits, &change);
+}
+EXPORT_SYMBOL_GPL(regmap_set_bits);
+
+/**
+ * regmap_clear_bits: Clear bits of register.
+ *
+ * @map: Register map to update
+ * @reg: Register to update
+ * @bits: Bits to clear
+ *
+ * Returns zero for success, a negative number on error.
+ */
+int regmap_clear_bits(struct regmap *map, unsigned int reg, unsigned int bits)
+{
+ bool change;
+ return _regmap_update_bits(map, reg, bits, 0, &change);
+}
+EXPORT_SYMBOL_GPL(regmap_clear_bits);
+
+/**
* regmap_register_patch: Register and apply register updates to be applied
* on device initialistion
*
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index ae797b1..bc859b2 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -185,6 +185,8 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
int regmap_update_bits_check(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change);
+int regmap_set_bits(struct regmap *map, unsigned int reg, unsigned int bits);
+int regmap_clear_bits(struct regmap *map, unsigned int reg, unsigned int bits);
int regmap_get_val_bytes(struct regmap *map);
int regcache_sync(struct regmap *map);
@@ -311,6 +313,19 @@ static inline int regmap_update_bits_check(struct regmap *map,
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
+static inline int regmap_set_bits(struct regmap *map,
+ unsigned int reg, unsigned int bits)
+{
+ WARN_ONCE(1, "regmap API is disabled");
+ return -EINVAL;
+}
+
+static inline int regmap_clear_bits(struct regmap *map,
+ unsigned int reg, unsigned int bits)
+{
+ WARN_ONCE(1, "regmap API is disabled");
+ return -EINVAL;
+}
static inline int regmap_get_val_bytes(struct regmap *map)
{
--
1.7.1.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists