linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regmap: Add function check before called format_val
@ 2015-07-20 12:41 Henry Chen
  2015-07-20 15:02 ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Henry Chen @ 2015-07-20 12:41 UTC (permalink / raw)
  To: Mark Brown
  Cc: Matthias Brugger, Sascha Hauer, linux-arm-kernel, linux-kernel,
	linux-mediatek, henryc.chen, eddie.huang

The regmap_format will not be initialize since regmap_bus is not assgined 
on regmap_init(). It should has a function check before using 
format_val() to avoid null function called on regmap_bulk_read().

Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
---
Based on v4.2rc1
---
 drivers/base/regmap/regmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 7111d04..c1e8c32 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2317,7 +2317,10 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 					  &ival);
 			if (ret != 0)
 				return ret;
-			map->format.format_val(val + (i * val_bytes), ival, 0);
+			if (map->format.format_val)
+				map->format.format_val(val + (i * val_bytes), ival, 0);
+			else
+				memcpy(val + (i * val_bytes), &ival, val_bytes);
 		}
 	}
 
-- 
1.8.1.1.dirty


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

end of thread, other threads:[~2015-08-15  2:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 12:41 [PATCH] regmap: Add function check before called format_val Henry Chen
2015-07-20 15:02 ` Mark Brown
2015-07-21  6:07   ` Henry Chen
2015-07-21 17:25     ` Mark Brown
2015-07-22 14:31       ` Henry Chen
2015-07-22 17:00         ` Mark Brown
2015-08-12 14:20     ` Daniel Kurtz
2015-08-13 15:25       ` Henry Chen
2015-08-14 17:56         ` 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).