mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Murphy <dmurphy@ti.com>
To: <broonie@kernel.org>, <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org>,
	Dan Murphy <dmurphy@ti.com>
Subject: [PATCH] regmap: Allow read_reg_mask to be 0
Date: Tue, 30 Sep 2014 11:07:00 -0500	[thread overview]
Message-ID: <1412093220-24690-1-git-send-email-dmurphy@ti.com> (raw)

There may be spi devices that do not require a
register read mask to read the registers.

Currently the code sets the read mask based on
a non-zero value passed in from the driver or if that
value is 0 sets the read mask to 0x80.

A mask of 0 is a valid mask as well.  Create a define
to indicate that the read mask can be zero and separate
out the read flag mask and the write flag mask.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/base/regmap/regmap.c |   11 +++++++----
 include/linux/regmap.h       |    2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 78f43fb..8c0a9b8 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -528,12 +528,15 @@ struct regmap *regmap_init(struct device *dev,
 	INIT_LIST_HEAD(&map->async_free);
 	init_waitqueue_head(&map->async_waitq);
 
-	if (config->read_flag_mask || config->write_flag_mask) {
+	if (config->read_flag_mask == REGMAP_NO_READ_MASK)
+		map->read_flag_mask = 0x00;
+	else if (config->read_flag_mask)
 		map->read_flag_mask = config->read_flag_mask;
-		map->write_flag_mask = config->write_flag_mask;
-	} else if (bus) {
+	else if (bus)
 		map->read_flag_mask = bus->read_flag_mask;
-	}
+
+	if (config->write_flag_mask)
+		map->write_flag_mask = config->write_flag_mask;
 
 	if (!bus) {
 		map->reg_read  = config->reg_read;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index c5ed83f..f1cdfe5 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -18,6 +18,8 @@
 #include <linux/err.h>
 #include <linux/bug.h>
 
+#define REGMAP_NO_READ_MASK		0xff
+
 struct module;
 struct device;
 struct i2c_client;
-- 
1.7.9.5


             reply	other threads:[~2014-09-30 16:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30 16:07 Dan Murphy [this message]
2014-09-30 17:25 ` Mark Brown
2014-09-30 20:19   ` Dan Murphy
2014-09-30 20:20   ` Dan Murphy
2014-09-30 20:39   ` Dan Murphy
2014-09-30 21:03 ` Lars-Peter Clausen
2014-09-30 21:18   ` Dan Murphy
2014-09-30 21:29     ` Lars-Peter Clausen
2014-10-01 11:15       ` Mark Brown
2014-10-01 11:39       ` Dan Murphy
2014-10-01 16:30         ` Lars-Peter Clausen

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=1412093220-24690-1-git-send-email-dmurphy@ti.com \
    --to=dmurphy@ti.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    /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®