diff mbox

[v1,1/3] regmap: add regmap_can_raw_read() api

Message ID 1460569154-25030-2-git-send-email-srinivas.kandagatla@linaro.org
State New
Headers show

Commit Message

Srinivas Kandagatla April 13, 2016, 5:39 p.m. UTC
This patch adds regmap_can_raw_read() api so that users like nvmem can
check if the regmap is capable of doing a raw accessors. This can also
be used by other infrastructures like nvmem which are based on regmap.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

---
 drivers/base/regmap/regmap.c | 13 ++++++++++++-
 include/linux/regmap.h       |  7 +++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

-- 
2.5.0

Comments

Mark Brown April 14, 2016, 5:58 a.m. UTC | #1
On Wed, Apr 13, 2016 at 06:39:12PM +0100, Srinivas Kandagatla wrote:
> This patch adds regmap_can_raw_read() api so that users like nvmem can

> check if the regmap is capable of doing a raw accessors. This can also

> be used by other infrastructures like nvmem which are based on regmap.


This seems tasteless.  If the driver is using raw I/O it needs to know
exactly what device it is working with, it shouldn't need to ask the
core about the properties of the device.  If it does that's a sign that
there's an abstraction problem somewhere along the line.  Most likely
the driver should be using bulk I/O instead.
diff mbox

Patch

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index df2d2ef..23f17fd 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1482,6 +1482,18 @@  int _regmap_raw_write(struct regmap *map, unsigned int reg,
 }
 
 /**
+ * regmap_can_raw_read - Test if regmap_raw_read() is supported
+ *
+ * @map: Map to check.
+ */
+bool regmap_can_raw_read(struct regmap *map)
+{
+	return map->bus && map->bus->read && map->format.format_val &&
+		map->format.format_reg;
+}
+EXPORT_SYMBOL_GPL(regmap_can_raw_read);
+
+/**
  * regmap_can_raw_write - Test if regmap_raw_write() is supported
  *
  * @map: Map to check.
@@ -2492,7 +2504,6 @@  int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 		 * them we have a series of single read operations.
 		 */
 		size_t total_size = val_bytes * val_count;
-
 		if (!map->use_single_read &&
 		    (!map->max_raw_read || map->max_raw_read > total_size)) {
 			ret = regmap_raw_read(map, reg, val,
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 3dc08ce..be3da4c 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -728,6 +728,7 @@  int regmap_get_val_bytes(struct regmap *map);
 int regmap_get_max_register(struct regmap *map);
 int regmap_get_reg_stride(struct regmap *map);
 int regmap_async_complete(struct regmap *map);
+bool regmap_can_raw_read(struct regmap *map);
 bool regmap_can_raw_write(struct regmap *map);
 size_t regmap_get_raw_read_max(struct regmap *map);
 size_t regmap_get_raw_write_max(struct regmap *map);
@@ -1045,6 +1046,12 @@  static inline void regmap_async_complete(struct regmap *map)
 	WARN_ONCE(1, "regmap API is disabled");
 }
 
+static inline bool regmap_can_raw_read(struct regmap *map)
+{
+	WARN_ONCE(1, "regmap API is disabled");
+	return false;
+}
+
 static inline int regmap_register_patch(struct regmap *map,
 					const struct reg_sequence *regs,
 					int num_regs)