From: Laxman Dewangan <ldewangan@nvidia.com>
To: broonie@opensource.wolfsonmicro.com, gregkh@linuxfoundation.org,
lrg@ti.com, linux-kernel@vger.kernel.org
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH V1 1/4] regmap: add function for set/clear bits
Date: Mon, 7 May 2012 13:05:36 +0530 [thread overview]
Message-ID: <1336376139-1048-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1336376139-1048-1-git-send-email-ldewangan@nvidia.com>
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@nvidia.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
next prev parent reply other threads:[~2012-05-07 7:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 7:35 [PATCH V1 0/4] regulator: tps62360: add cache support and settling time Laxman Dewangan
2012-05-07 7:35 ` Laxman Dewangan [this message]
2012-05-07 10:55 ` [PATCH V1 1/4] regmap: add function for set/clear bits Mark Brown
2012-05-07 7:35 ` [PATCH V1 2/4] regulator: tps62360: enable register cache Laxman Dewangan
2012-05-07 11:13 ` Mark Brown
2012-05-07 7:35 ` [PATCH V1 3/4] regulator: tps62360: use efficient function Laxman Dewangan
2012-05-07 7:35 ` [PATCH V1 4/4] regulator: tps62360: Provide settling time for voltage change Laxman Dewangan
2012-05-07 11:23 ` Mark Brown
2012-05-07 12:42 ` Laxman Dewangan
2012-05-07 14:22 ` Mark Brown
2012-05-07 14:45 ` Laxman Dewangan
2012-05-07 14:51 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1336376139-1048-2-git-send-email-ldewangan@nvidia.com \
--to=ldewangan@nvidia.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®