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

From: Srinivas Kandagatla
Date: Wed Apr 13 2016 - 13:40:11 EST


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@xxxxxxxxxx>
---
drivers/base/regmap/regmap.c | 13 ++++++++++++-
include/linux/regmap.h | 7 +++++++
2 files changed, 19 insertions(+), 1 deletion(-)

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)
--
2.5.0