Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752750AbbH1TLi (ORCPT ); Fri, 28 Aug 2015 15:11:38 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:40616 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752510AbbH1TLh (ORCPT ); Fri, 28 Aug 2015 15:11:37 -0400 From: Mark Brown To: Markus Pargmann , Henry Chen Cc: linux-kernel@vger.kernel.org, Mark Brown Date: Fri, 28 Aug 2015 20:11:04 +0100 Message-Id: <1440789064-11098-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 2.5.0 X-SA-Exim-Connect-IP: 92.40.249.168 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: [PATCH] regmap: Support bulk reads for devices without raw formatting X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2193 Lines: 68 When doing a bulk read from a device which lacks raw I/O support we fall back to doing register at a time reads but we still use the raw formatters in order to render the data into the word size used by the device (since bulk reads still operate on the device word size rather than unsigned ints). This means that devices without raw formatting such as those that provide reg_read() are not supported. Provide handling for them by copying the values read into native endian values of the appropriate size. Signed-off-by: Mark Brown --- This is tested with my "hey, look - it compiles!" test plan. Based on looking at the users and the other ways formatting is used this is the interface that makes most sense to me, we'll need similar handling for the write case. Does this solve the problems you are seeing? drivers/base/regmap/regmap.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index c13b1f2..62e3d7c 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2364,7 +2364,34 @@ 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 { + /* Devices providing read and write + * operations can use the bulk I/O + * functions if they define a val_bytes, + * we assume that the values are native + * endian. + */ + u32 *u32 = val; + u16 *u16 = val; + u8 *u8 = val; + + switch (map->format.val_bytes) { + case 4: + u32[i] = ival; + break; + case 2: + u16[i] = ival; + break; + case 1: + u8[i] = ival; + break; + default: + return -EINVAL; + } + } } } -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/