Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965011AbbHLKUB (ORCPT ); Wed, 12 Aug 2015 06:20:01 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:41335 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754082AbbHLKNq (ORCPT ); Wed, 12 Aug 2015 06:13:46 -0400 From: Markus Pargmann To: Mark Brown , Jonathan Cameron Cc: Srinivas Pandruvada , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, Markus Pargmann Subject: [PATCH 10/20] regmap: _regmap_raw_multi_reg_write: Add reg_write() support Date: Wed, 12 Aug 2015 12:12:35 +0200 Message-Id: <1439374365-20623-11-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1439374365-20623-1-git-send-email-mpa@pengutronix.de> References: <1439374365-20623-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1298 Lines: 44 Define a fallback for busses which do not define a write() function. Instead we write one register at a time using reg_write(). Without this patch, _regmap_raw_multi_reg_write would break as it tries to call bus->write() without checking if it exists before. Signed-off-by: Markus Pargmann --- drivers/base/regmap/regmap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 78eb96288a68..87f15fb60bc5 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1778,6 +1778,20 @@ static int _regmap_raw_multi_reg_write(struct regmap *map, if (!len) return -EINVAL; + /* + * If bus->write is not supported we have to use reg_write for each + * register value. + */ + if (!map->bus->write) { + for (i = 0; i < num_regs; i++) { + ret = map->reg_write(map, regs[i].reg, regs[i].def); + if (ret) + return ret; + } + + return 0; + } + buf = kzalloc(len, GFP_KERNEL); if (!buf) return -ENOMEM; -- 2.4.6 -- 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/