regmap: regmap_raw_read return error on !bus->read
authorMarkus Pargmann <mpa@pengutronix.de>
Thu, 20 Aug 2015 09:12:35 +0000 (11:12 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 20 Aug 2015 18:29:38 +0000 (11:29 -0700)
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>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap.c

index 7111d04..fc14a7c 100644 (file)
@@ -2184,6 +2184,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);