linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regmap: Add precious registers to the driver interface
@ 2011-08-08  6:44 Mark Brown
  2011-08-08  6:44 ` [PATCH 2/2] regmap: Skip precious registers when dumping registers via debugfs Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2011-08-08  6:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: patches, Mark Brown

Some devices are sensitive to reads on their registers, especially for
things like clear on read interrupt status registers. Avoid creating
problems with these with things like debugfs by allowing drivers to tell
the core about them. If a register is marked as precious then the core
will not internally generate any reads of it.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 include/linux/regmap.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index aef2b36..c878a4b 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -33,6 +33,9 @@ struct spi_device;
  *                     can be read from.
  * @volatile_register: Optional callback returning true if the register
  *                     value can't be cached.
+ * @precious_register: Optional callback returning true if the rgister
+ *                     should not be read outside of a call from the driver
+ *                     (eg, a clear on read interrupt status register).
  */
 struct regmap_config {
 	int reg_bits;
@@ -42,6 +45,7 @@ struct regmap_config {
 	bool (*writeable_reg)(struct device *dev, unsigned int reg);
 	bool (*readable_reg)(struct device *dev, unsigned int reg);
 	bool (*volatile_reg)(struct device *dev, unsigned int reg);
+	bool (*precious_reg)(struct device *dev, unsigned int reg);
 };
 
 typedef int (*regmap_hw_write)(struct device *dev, const void *data,
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] regmap: Skip precious registers when dumping registers via debugfs
  2011-08-08  6:44 [PATCH 1/2] regmap: Add precious registers to the driver interface Mark Brown
@ 2011-08-08  6:44 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2011-08-08  6:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: patches, Mark Brown

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/base/regmap/internal.h       |    1 +
 drivers/base/regmap/regmap-debugfs.c |    4 ++++
 drivers/base/regmap/regmap.c         |    1 +
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 78f87f3..a67dc68 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -45,6 +45,7 @@ struct regmap {
 	bool (*writeable_reg)(struct device *dev, unsigned int reg);
 	bool (*readable_reg)(struct device *dev, unsigned int reg);
 	bool (*volatile_reg)(struct device *dev, unsigned int reg);
+	bool (*precious_reg)(struct device *dev, unsigned int reg);
 };
 
 #ifdef CONFIG_DEBUG_FS
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 2be8bf8..184b618 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -56,6 +56,10 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
 		    !map->readable_reg(map->dev, i))
 			continue;
 
+		if (map->precious_reg &&
+		    map->precious_reg(map->dev, i))
+			continue;
+
 		/* If we're in the region the user is trying to read */
 		if (p >= *ppos) {
 			/* ...but not beyond it */
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e68556c..c25c13c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -101,6 +101,7 @@ struct regmap *regmap_init(struct device *dev,
 	map->writeable_reg = config->writeable_reg;
 	map->readable_reg = config->readable_reg;
 	map->volatile_reg = config->volatile_reg;
+	map->precious_reg = config->precious_reg;
 
 	switch (config->reg_bits) {
 	case 4:
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-08  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-08  6:44 [PATCH 1/2] regmap: Add precious registers to the driver interface Mark Brown
2011-08-08  6:44 ` [PATCH 2/2] regmap: Skip precious registers when dumping registers via debugfs Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).