diff mbox

[v2,4/5] regmap: regmap_raw_read return error on !bus->read

Message ID 1440061956-29064-5-git-send-email-mpa@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Markus Pargmann Aug. 20, 2015, 9:12 a.m. UTC
Return -ENOTSUPP if map->bus->read is not implemented and we do not use
the cache. This code path would directly use bus->read would run into an
NULL pointer for the read function.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/base/regmap/regmap.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Mark Brown Aug. 20, 2015, 6:30 p.m. UTC | #1
On Thu, Aug 20, 2015 at 11:12:35AM +0200, Markus Pargmann wrote:
> Return -ENOTSUPP if map->bus->read is not implemented and we do not use
> the cache. This code path would directly use bus->read would run into an
> NULL pointer for the read function.

Please put fixes like this before coding style changes like patch 3.
diff mbox

Patch

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index bb4e65e7a950..66efe25d64c9 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2201,6 +2201,11 @@  int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
 
 	if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass ||
 	    map->cache_type == REGCACHE_NONE) {
+		if (!map->bus->read) {
+			ret = -ENOTSUPP;
+			goto out;
+		}
+
 		/* Physical block read if there's no cache involved */
 		ret = _regmap_raw_read(map, reg, val, val_len);