Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbbLCFgr (ORCPT ); Thu, 3 Dec 2015 00:36:47 -0500 Received: from n9-39.mail.139.com ([221.176.9.39]:39200 "EHLO n9-39.mail.139.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbbLCFgE (ORCPT ); Thu, 3 Dec 2015 00:36:04 -0500 X-Greylist: delayed 544 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Dec 2015 00:36:03 EST X-Richmail-Antispam: sCL2rVi0borhSzeOjpYxWEmrxqxSIjpgsIL2jVqxeZIR0RM= X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2f0f565fd29e0fa-6d9c8 From: Xiubo Li To: broonie@kernel.org Cc: linux-kernel@vger.kernel.org, Xiubo Li Subject: [PATCH 2/2] regmap: mmio: Add regmap_mmio_get_min_stride Date: Thu, 3 Dec 2015 13:27:21 +0800 Message-Id: <1449120441-28287-3-git-send-email-lixiubo@cmss.chinamobile.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449120441-28287-1-git-send-email-lixiubo@cmss.chinamobile.com> References: <1449120441-28287-1-git-send-email-lixiubo@cmss.chinamobile.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1902 Lines: 83 Splite the minimal stride parsing into one signal function. Signed-off-by: Xiubo Li --- drivers/base/regmap/regmap-mmio.c | 49 ++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 38d0dc0..eea5156 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -61,6 +61,33 @@ static int regmap_mmio_regbits_check(size_t reg_bits) } } +static int regmap_mmio_get_min_stride(size_t val_bits) +{ + int min_stride; + + switch (val_bits) { + case 8: + /* The core treats 0 as 1 */ + min_stride = 0; + return 0; + case 16: + min_stride = 2; + break; + case 32: + min_stride = 4; + break; +#ifdef CONFIG_64BIT + case 64: + min_stride = 8; + break; +#endif + default: + return -EINVAL; + } + + return min_stride; +} + static inline void regmap_mmio_count_check(size_t count, u32 offset) { BUG_ON(count <= offset); @@ -231,25 +258,9 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, if (config->pad_bits) return ERR_PTR(-EINVAL); - switch (config->val_bits) { - case 8: - /* The core treats 0 as 1 */ - min_stride = 0; - break; - case 16: - min_stride = 2; - break; - case 32: - min_stride = 4; - break; -#ifdef CONFIG_64BIT - case 64: - min_stride = 8; - break; -#endif - default: - return ERR_PTR(-EINVAL); - } + min_stride = regmap_mmio_get_min_stride(config->val_bits); + if (min_stride < 0) + return ERR_PTR(min_stride); if (config->reg_stride < min_stride) return ERR_PTR(-EINVAL); -- 1.8.3.1 -- 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/