Skip to contentSkip to conversation

regmap: mmio: Add regmap_mmio_regbits_check.

PATCH Applied Xiubo Li 2 participants 2 messages Mar 28, 2014

Subsystems (2)
lore
Share & tools
lore

Xiubo Li

author
#0 lore raw

PATCH 1/1 regmap: mmio: Add regmap_mmio_regbits_check.

Fix the support for 1/2/8 bytes wide register address checking.

---

Sorry, this patch has been missed yesterday.

 drivers/base/regmap/regmap-mmio.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/base/regmap/regmap-mmio.c +18 -2
index ed080a4..de45a1e 100644
@@ -47,6 +47,21 @@ static inline void regmap_mmio_regsize_check(size_t reg_size)
 	}
 }
 
+static int regmap_mmio_regbits_check(size_t reg_bits)
+{
+	switch (reg_bits) {
+	case 8:
+	case 16:
+	case 32:
+#ifdef CONFIG_64BIT
+	case 64:
+#endif
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
 static inline void regmap_mmio_count_check(size_t count)
 {
 	BUG_ON(count % 2 != 0);
@@ -191,8 +206,9 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
 	int min_stride;
 	int ret;
 
-	if (config->reg_bits != 32)
-		return ERR_PTR(-EINVAL);
+	ret = regmap_mmio_regbits_check(config->reg_bits);
+	if (ret)
+		return ERR_PTR(ret);
 
 	if (config->pad_bits)
 		return ERR_PTR(-EINVAL);
Signature · 1 line
1.8.4
maintainer Applied
#1 lore raw
Quoted 1 line · Xiubo Li

Fix the support for 1/2/8 bytes wide register address checking.

Applied, thanks.